Skip to content

Commit ded7597

Browse files
authored
feat(secret_manager): add AccessSecretVersionByPath endpoint (#1232)
1 parent 7c9a9b3 commit ded7597

File tree

3 files changed

+52
-0
lines changed

3 files changed

+52
-0
lines changed

packages/clients/src/api/secret/v1beta1/api.gen.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import {
2222
unmarshalSecretVersion,
2323
} from './marshalling.gen'
2424
import type {
25+
AccessSecretVersionByPathRequest,
2526
AccessSecretVersionRequest,
2627
AccessSecretVersionResponse,
2728
AddSecretOwnerRequest,
@@ -364,6 +365,33 @@ export class API extends ParentAPI {
364365
unmarshalAccessSecretVersionResponse,
365366
)
366367

368+
/**
369+
* Access a secret's version using the secret's name and path. Access
370+
* sensitive data in a secret's version specified by the `region`,
371+
* `secret_name`, `secret_path` and `revision` parameters.
372+
*
373+
* @param request - The request {@link AccessSecretVersionByPathRequest}
374+
* @returns A Promise of AccessSecretVersionResponse
375+
*/
376+
accessSecretVersionByPath = (
377+
request: Readonly<AccessSecretVersionByPathRequest>,
378+
) =>
379+
this.client.fetch<AccessSecretVersionResponse>(
380+
{
381+
method: 'GET',
382+
path: `/secret-manager/v1beta1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/secrets-by-path/versions/${validatePathParam('revision', request.revision)}/access`,
383+
urlParams: urlParams(
384+
[
385+
'project_id',
386+
request.projectId ?? this.client.settings.defaultProjectId,
387+
],
388+
['secret_name', request.secretName],
389+
['secret_path', request.secretPath],
390+
),
391+
},
392+
unmarshalAccessSecretVersionResponse,
393+
)
394+
367395
/**
368396
* Enable a version. Make a specific version accessible. You must specify the
369397
* `region`, `secret_id` and `revision` parameters.

packages/clients/src/api/secret/v1beta1/index.gen.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// If you have any remark or suggestion do not hesitate to open an issue.
33
export { API } from './api.gen'
44
export type {
5+
AccessSecretVersionByPathRequest,
56
AccessSecretVersionRequest,
67
AccessSecretVersionResponse,
78
AddSecretOwnerRequest,

packages/clients/src/api/secret/v1beta1/types.gen.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,29 @@ export interface Secret {
154154
region: Region
155155
}
156156

157+
export type AccessSecretVersionByPathRequest = {
158+
/**
159+
* Region to target. If none is passed will use default region from the
160+
* config.
161+
*/
162+
region?: Region
163+
/**
164+
* The first version of the secret is numbered 1, and all subsequent revisions
165+
* augment by 1. Value can be either:
166+
*
167+
* - An integer (the revision number)
168+
* - "latest" (the latest revision)
169+
* - "latest_enabled" (the latest enabled revision).
170+
*/
171+
revision: string
172+
/** Secret's path. */
173+
secretPath: string
174+
/** Secret's name. */
175+
secretName: string
176+
/** ID of the Project to target. */
177+
projectId?: string
178+
}
179+
157180
export type AccessSecretVersionRequest = {
158181
/**
159182
* Region to target. If none is passed will use default region from the

0 commit comments

Comments
 (0)