@stedi/sdk-client-exchange-credentials
Advanced tools
Comparing version 0.3.0 to 0.3.1
@@ -93,3 +93,3 @@ { | ||
}, | ||
"version": "0.3.0" | ||
"version": "0.3.1" | ||
} |
@@ -12,3 +12,3 @@ <!-- generated file, do not edit directly --> | ||
Stedi SDK for JavaScript that includes ExchangeCredentials Client for Node.js, Browser and React Native. | ||
Stedi ExchangeCredentials SDK for JavaScript. | ||
@@ -28,16 +28,13 @@ Service to exchange Stedi credentials for Web Identity to access AWS account. | ||
### Import | ||
### Initialize the client | ||
The Stedi SDK is modulized by clients and commands. | ||
To send a request, you only need to import the `ExchangeCredentialsClient` and | ||
the commands you need, for example `GetAwsAccessCommand`: | ||
First, create a new `ExchangeCredentialsClient`. | ||
```js | ||
// ES5 example | ||
const { ExchangeCredentialsClient, GetAwsAccessCommand } = require("@stedi/sdk-client-exchange-credentials"); | ||
``` | ||
```ts | ||
// ES6+ example | ||
import { ExchangeCredentialsClient, GetAwsAccessCommand } from "@stedi/sdk-client-exchange-credentials"; | ||
const client = new ExchangeCredentialsClient({ | ||
region: "us", | ||
apiKey: "my-api-key", | ||
}); | ||
``` | ||
@@ -47,26 +44,21 @@ | ||
To send a request, you: | ||
Once the client is initiated, you may use it to send multiple commands. | ||
If you are using a custom http handler, you may call `destroy()` to close open connections. | ||
- Initiate client with configuration (e.g. credentials, region). | ||
- Initiate command with input parameters. | ||
- Call `send` operation on client with command object as input. | ||
- If you are using a custom http handler, you may call `destroy()` to close open connections. | ||
Create a command by creating a new `GetAwsAccessCommand`. | ||
```js | ||
// a client can be shared by different commands. | ||
const client = new ExchangeCredentialsClient({ region: "REGION" }); | ||
```ts | ||
import { ExchangeCredentialsClient, GetAwsAccessCommand } from "@stedi/sdk-client-exchange-credentials"; | ||
const client = new ExchangeCredentialsClient({ | ||
region: "us", | ||
apiKey: "my-api-key", | ||
}); | ||
const params = { | ||
/** input parameters */ | ||
}; | ||
const command = new GetAwsAccessCommand(params); | ||
``` | ||
#### Async/await | ||
We recommend using [await](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/await) | ||
operator to wait for the promise returned by send operation as follows: | ||
```js | ||
// async/await. | ||
try { | ||
@@ -82,49 +74,2 @@ const data = await client.send(command); | ||
Async-await is clean, concise, intuitive, easy to debug and has better error handling | ||
as compared to using Promise chains or callbacks. | ||
#### Promises | ||
You can also use [Promise chaining](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Using_promises#chaining) | ||
to execute send operation. | ||
```js | ||
client.send(command).then( | ||
(data) => { | ||
// process data. | ||
}, | ||
(error) => { | ||
// error handling. | ||
} | ||
); | ||
``` | ||
Promises can also be called using `.catch()` and `.finally()` as follows: | ||
```js | ||
client | ||
.send(command) | ||
.then((data) => { | ||
// process data. | ||
}) | ||
.catch((error) => { | ||
// error handling. | ||
}) | ||
.finally(() => { | ||
// finally. | ||
}); | ||
``` | ||
#### Callbacks | ||
We do not recommend using callbacks because of [callback hell](http://callbackhell.com/), | ||
but they are supported by the send operation. | ||
```js | ||
// callbacks. | ||
client.send(command, (err, data) => { | ||
// process err and data. | ||
}); | ||
``` | ||
### Troubleshooting | ||
@@ -165,4 +110,4 @@ | ||
[Command API Reference](https://stedi.github.io/stedi-sdk-javascript/clients/exchange-credentials/docs/classes/GetAwsAccessCommand.html) / [Input](https://stedi.github.io/stedi-sdk-javascript/clients/exchange-credentials/docs/interfaces/GetAwsAccessCommandInput.html) / [Output](https://stedi.github.io/stedi-sdk-javascript/clients/exchange-credentials/docs/interfaces/GetAwsAccessCommandOutput.html) | ||
[Command API Reference](https://stedi-sdk-javascript.vercel.app/clients/exchange-credentials/docs/classes/GetAwsAccessCommand.html) / [Input](https://stedi-sdk-javascript.vercel.app/clients/exchange-credentials/docs/interfaces/GetAwsAccessCommandInput.html) / [Output](https://stedi-sdk-javascript.vercel.app/clients/exchange-credentials/docs/interfaces/GetAwsAccessCommandOutput.html) | ||
</details> |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
234433
109