Skip to content

Commit 10f5810

Browse files
committed
docs: updates api docs for SecretsProvider
1 parent 6ef1985 commit 10f5810

File tree

2 files changed

+32
-17
lines changed

2 files changed

+32
-17
lines changed

packages/parameters/src/secrets/SecretsProvider.ts

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ import type {
3333
* const secretsProvider = new SecretsProvider();
3434
*
3535
* export const handler = async (): Promise<void> => {
36-
* // Retrieve a single secret
36+
* // Retrieve a secret
3737
* const secret = await secretsProvider.get('my-secret');
3838
* };
3939
* ```
@@ -54,8 +54,8 @@ import type {
5454
* const secretsProvider = new SecretsProvider();
5555
*
5656
* export const handler = async (): Promise<void> => {
57-
* // Retrieve a single secret and cache it for 10 seconds
58-
* const secret = await secretsProvider.get('my-secret', { maxAge: 10 });
57+
* // Retrieve a secret and cache it for 10 seconds
58+
* const secret = await secretsProvider.get('my-secret', { maxAge: 10 });
5959
* };
6060
* ```
6161
*
@@ -68,7 +68,7 @@ import type {
6868
* const secretsProvider = new SecretsProvider();
6969
*
7070
* export const handler = async (): Promise<void> => {
71-
* // Retrieve a single secret and always fetch the latest value
71+
* // Retrieve a secret and always fetch the latest value
7272
* const secret = await secretsProvider.get('my-secret', { forceFetch: true });
7373
* };
7474
* ```
@@ -84,8 +84,8 @@ import type {
8484
* const secretsProvider = new SecretsProvider();
8585
*
8686
* export const handler = async (): Promise<void> => {
87-
* // Retrieve a single secret and deserialize it as JSON
88-
* const secret = await secretsProvider.get('my-secret', { transform: 'json' });
87+
* // Retrieve a secret and parse it as JSON
88+
* const secret = await secretsProvider.get('my-secret', { transform: 'json' });
8989
* };
9090
* ```
9191
*
@@ -100,7 +100,7 @@ import type {
100100
* const secretsProvider = new SecretsProvider();
101101
*
102102
* export const handler = async (): Promise<void> => {
103-
* // Retrieve a single secret and pass extra options to the AWS SDK v3 for JavaScript client
103+
* // Retrieve a secret and pass extra options to the AWS SDK v3 for JavaScript client
104104
* const secret = await secretsProvider.get('my-secret', {
105105
* sdkOptions: {
106106
* VersionId: 1,
@@ -152,6 +152,11 @@ import type {
152152
class SecretsProvider extends BaseProvider {
153153
public client: SecretsManagerClient;
154154

155+
/**
156+
* It initializes the SecretsProvider class.
157+
*
158+
* @param {SecretsProviderOptions} config - The configuration object.
159+
*/
155160
public constructor (config?: SecretsProviderOptions) {
156161
super();
157162

@@ -178,21 +183,22 @@ class SecretsProvider extends BaseProvider {
178183
* const secretsProvider = new SecretsProvider();
179184
*
180185
* export const handler = async (): Promise<void> => {
181-
* // Retrieve a single secret
186+
* // Retrieve a secret
182187
* const secret = await secretsProvider.get('my-secret');
183188
* };
184189
* ```
185190
*
186191
* You can customize the retrieval of the secret by passing options to the function:
187192
* * `maxAge` - The maximum age of the value in cache before fetching a new one (in seconds) (default: 5)
188193
* * `forceFetch` - Whether to always fetch a new value from the store regardless if already available in cache
189-
* * `transform` - Whether to transform the value before returning it. Supported values: `json`, `base64`
194+
* * `transform` - Whether to transform the value before returning it. Supported values: `json`, `binary`
190195
* * `sdkOptions` - Extra options to pass to the AWS SDK v3 for JavaScript client
191196
*
192197
* For usage examples check {@link SecretsProvider}.
193198
*
194199
* @param {string} name - The name of the secret
195200
* @param {SecretsGetOptionsInterface} options - Options to customize the retrieval of the secret
201+
* @see https://awslabs.github.io/aws-lambda-powertools-typescript/latest/utilities/parameters/
196202
*/
197203
public async get(
198204
name: string,
@@ -211,6 +217,12 @@ class SecretsProvider extends BaseProvider {
211217
return super.getMultiple(path);
212218
}
213219

220+
/**
221+
* Retrieve a configuration from AWS AppConfig.
222+
*
223+
* @param {string} name - Name of the configuration or its ID
224+
* @param {SecretsGetOptionsInterface} options - SDK options to propagate to the AWS SDK v3 for JavaScript client
225+
*/
214226
protected async _get(
215227
name: string,
216228
options?: SecretsGetOptionsInterface
@@ -229,6 +241,8 @@ class SecretsProvider extends BaseProvider {
229241

230242
/**
231243
* Retrieving multiple parameter values is not supported with AWS Secrets Manager.
244+
*
245+
* @throws Not Implemented Error.
232246
*/
233247
protected async _getMultiple(
234248
_path: string,

packages/parameters/src/secrets/getSecret.ts

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import type { SecretsGetOptionsInterface } from '../types/SecretsProvider';
2424
* import { getSecret } from '@aws-lambda-powertools/parameters/secrets';
2525
*
2626
* export const handler = async (): Promise<void> => {
27-
* // Retrieve a single secret
27+
* // Retrieve a secret
2828
* const secret = await getSecret('my-secret');
2929
* };
3030
* ```
@@ -41,8 +41,8 @@ import type { SecretsGetOptionsInterface } from '../types/SecretsProvider';
4141
* import { getSecret } from '@aws-lambda-powertools/parameters/secrets';
4242
*
4343
* export const handler = async (): Promise<void> => {
44-
* // Retrieve a single secret and cache it for 10 seconds
45-
* const secret = await getSecret('my-secret', { maxAge: 10 });
44+
* // Retrieve a secret and cache it for 10 seconds
45+
* const secret = await getSecret('my-secret', { maxAge: 10 });
4646
* };
4747
* ```
4848
*
@@ -53,22 +53,23 @@ import type { SecretsGetOptionsInterface } from '../types/SecretsProvider';
5353
* import { getSecret } from '@aws-lambda-powertools/parameters/secrets';
5454
*
5555
* export const handler = async (): Promise<void> => {
56-
* // Retrieve a single secret and always fetch the latest value
56+
* // Retrieve a secret and always fetch the latest value
5757
* const secret = await getSecret('my-secret', { forceFetch: true });
5858
* };
5959
* ```
6060
*
6161
* ### Transformations
6262
*
63-
* For parameters stored in JSON or Base64 format, you can use the transform argument for deserialization.
63+
* For parameters stored as JSON or base64-encoded strings, you can use the transform argument set to `json` or `binary` for deserialization.
6464
*
6565
* @example
6666
* ```typescript
6767
* import { getSecret } from '@aws-lambda-powertools/parameters/secrets';
6868
*
6969
* export const handler = async (): Promise<void> => {
70-
* // Retrieve a single secret and deserialize it as JSON
71-
* const secret = await getSecret('my-secret', { transform: 'json' });
70+
* // Retrieve a secret and parse it as JSON
71+
* const secret = await getSecret('my-secret', { transform: 'json' });
72+
* };
7273
* ```
7374
*
7475
* ### Extra SDK options
@@ -80,7 +81,7 @@ import type { SecretsGetOptionsInterface } from '../types/SecretsProvider';
8081
* import { getSecret } from '@aws-lambda-powertools/parameters/secrets';
8182
*
8283
* export const handler = async (): Promise<void> => {
83-
* // Retrieve a single secret and pass extra options to the AWS SDK v3 for JavaScript client
84+
* // Retrieve a secret and pass extra options to the AWS SDK v3 for JavaScript client
8485
* const secret = await getSecret('my-secret', {
8586
* sdkOptions: {
8687
* VersionId: 1,

0 commit comments

Comments
 (0)