@sap-cloud-sdk/core
Version:
SAP Cloud SDK for JavaScript core
48 lines • 1.82 kB
TypeScript
import { Destination } from './destination-service-types';
/**
* Tries to build a destination from a service binding with the given name.
* Throws an error if no services are bound at all, no service with the given name can be found, or the service type is not supported.
* The last error can be circumvent by using the second parameter to provide a custom function that transforms a service binding to a destination.
* @param serviceInstanceName - The name of the service.
* @param options - Options to customize the behavior of this function.
* @returns A destination.
*/
export declare function destinationForServiceBinding(serviceInstanceName: string, options?: DestinationForServiceBindingsOptions): Destination;
/**
* Options to customize the behavior of [[destinationForServiceBinding]].
*/
export interface DestinationForServiceBindingsOptions {
/**
* Custom transformation function to control how a [[Destination]] is built from the given [[ServiceBinding]].
*/
transformationFn?: (serviceBinding: ServiceBinding) => Destination;
}
/**
* Represents the JSON object for a given service binding as obtained from the VCAP_SERVICE environment variable.
* To see service bindings, run `cf env <app-name>` in the terminal. This will produce output like this:
*
* ```
* {
* ...
* "VCAP_SERVICES": {
* "s4-hana-cloud": [
* {
* "name": "...",
* "type": "...".
* ...
* }
* ]
* }
* }
*
* ```
*
* In this example, the key "s4-hana-cloud" refers to an array of service bindings.
*/
export interface ServiceBinding {
[key: string]: any;
name: string;
type: string;
}
export declare function searchServiceBindingForDestination(name: string): Destination | undefined;
//# sourceMappingURL=destination-from-vcap.d.ts.map