Skip to content

Commit

Permalink
Javascript: Add documentation for service binding to destination API (#…
Browse files Browse the repository at this point in the history
…1883)

* add docs for new APIs

* including info admonition

* final details
  • Loading branch information
shibeshduw authored Aug 12, 2024
1 parent 426fb46 commit 3614c86
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions docs-js/features/connectivity/destination.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,34 @@ const destination = getDestinationFromServiceBinding({
});
```

:::info Creating destinations from service bindings

The SAP Cloud SDK provides the `getServiceBinding()` function to retrieve the first service binding from `VCAP_SERVICES` for a given service type.
It also provides the `transformServiceBindingToDestination()` function to transform known service bindings to destinations.

<details>
<summary>Example Usage</summary>

```ts
import {
getServiceBinding,
transformServiceBindingToDestination
} from '@sap-cloud-sdk/connectivity';

const service = getServiceBinding('aicore');

await transformServiceBindingToDestination(service);
```

</details>

`transformServiceBindingToDestination()` supports the [default service types](#service-binding-environment-variables) as listed above.

The transformation includes auth token flows for destinations with type `OAuth2ClientCredentials` and adds retrieved tokens to the destination.
If the provided service binding is not supported, an error is thrown.

:::

### Destination Service

In a productive environment, in most cases you will use the [destination service](https://help.sap.com/viewer/cca91383641e40ffbe03bdc78f00f681/Cloud/en-US/7e306250e08340f89d6c103e28840f30.html) to retrieve destinations.
Expand Down

0 comments on commit 3614c86

Please sign in to comment.