Skip to content

Commit b3a9ed9

Browse files
authored
feat(secret_manager): add ListTags to v1beta1 (#1167)
1 parent 3e0d380 commit b3a9ed9

File tree

4 files changed

+67
-0
lines changed

4 files changed

+67
-0
lines changed

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

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import {
1717
unmarshalBrowseSecretsResponse,
1818
unmarshalListSecretVersionsResponse,
1919
unmarshalListSecretsResponse,
20+
unmarshalListTagsResponse,
2021
unmarshalSecret,
2122
unmarshalSecretVersion,
2223
} from './marshalling.gen'
@@ -38,6 +39,8 @@ import type {
3839
ListSecretVersionsResponse,
3940
ListSecretsRequest,
4041
ListSecretsResponse,
42+
ListTagsRequest,
43+
ListTagsResponse,
4144
ProtectSecretRequest,
4245
Secret,
4346
SecretVersion,
@@ -393,4 +396,33 @@ export class API extends ParentAPI {
393396
},
394397
unmarshalSecretVersion,
395398
)
399+
400+
protected pageOfListTags = (request: Readonly<ListTagsRequest> = {}) =>
401+
this.client.fetch<ListTagsResponse>(
402+
{
403+
method: 'GET',
404+
path: `/secret-manager/v1beta1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/tags`,
405+
urlParams: urlParams(
406+
['page', request.page],
407+
[
408+
'page_size',
409+
request.pageSize ?? this.client.settings.defaultPageSize,
410+
],
411+
[
412+
'project_id',
413+
request.projectId ?? this.client.settings.defaultProjectId,
414+
],
415+
),
416+
},
417+
unmarshalListTagsResponse,
418+
)
419+
420+
/**
421+
* List tags. List all tags associated with secrets within a given Project.
422+
*
423+
* @param request - The request {@link ListTagsRequest}
424+
* @returns A Promise of ListTagsResponse
425+
*/
426+
listTags = (request: Readonly<ListTagsRequest> = {}) =>
427+
enrichForPagination('tags', this.pageOfListTags, request)
396428
}

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ export type {
2727
ListSecretsRequest,
2828
ListSecretsRequestOrderBy,
2929
ListSecretsResponse,
30+
ListTagsRequest,
31+
ListTagsResponse,
3032
Product,
3133
ProtectSecretRequest,
3234
Secret,

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import type {
1919
EphemeralProperties,
2020
ListSecretVersionsResponse,
2121
ListSecretsResponse,
22+
ListTagsResponse,
2223
Secret,
2324
SecretVersion,
2425
UpdateSecretRequest,
@@ -222,6 +223,19 @@ export const unmarshalListSecretsResponse = (
222223
} as ListSecretsResponse
223224
}
224225

226+
export const unmarshalListTagsResponse = (data: unknown): ListTagsResponse => {
227+
if (!isJSONObject(data)) {
228+
throw new TypeError(
229+
`Unmarshalling the type 'ListTagsResponse' failed as data isn't a dictionary.`,
230+
)
231+
}
232+
233+
return {
234+
tags: data.tags,
235+
totalCount: data.total_count,
236+
} as ListTagsResponse
237+
}
238+
225239
export const marshalAddSecretOwnerRequest = (
226240
request: AddSecretOwnerRequest,
227241
defaults: DefaultValues,

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

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,25 @@ export interface ListSecretsResponse {
425425
totalCount: number
426426
}
427427

428+
export type ListTagsRequest = {
429+
/**
430+
* Region to target. If none is passed will use default region from the
431+
* config.
432+
*/
433+
region?: Region
434+
/** ID of the Project to target. */
435+
projectId?: string
436+
page?: number
437+
pageSize?: number
438+
}
439+
440+
export interface ListTagsResponse {
441+
/** List of tags. */
442+
tags: string[]
443+
/** Count of all tags matching the requested criteria. */
444+
totalCount: number
445+
}
446+
428447
export type ProtectSecretRequest = {
429448
/**
430449
* Region to target. If none is passed will use default region from the

0 commit comments

Comments
 (0)