diff --git a/packages/clients/src/api/secret/v1alpha1/api.gen.ts b/packages/clients/src/api/secret/v1alpha1/api.gen.ts index c1028467a..0e53473e2 100644 --- a/packages/clients/src/api/secret/v1alpha1/api.gen.ts +++ b/packages/clients/src/api/secret/v1alpha1/api.gen.ts @@ -17,6 +17,7 @@ import { unmarshalAccessSecretVersionResponse, unmarshalListSecretVersionsResponse, unmarshalListSecretsResponse, + unmarshalListTagsResponse, unmarshalSecret, unmarshalSecretVersion, } from './marshalling.gen' @@ -41,6 +42,8 @@ import type { ListSecretVersionsResponse, ListSecretsRequest, ListSecretsResponse, + ListTagsRequest, + ListTagsResponse, Secret, SecretVersion, UpdateSecretRequest, @@ -537,4 +540,33 @@ export class API extends ParentAPI { }, unmarshalSecretVersion, ) + + protected pageOfListTags = (request: Readonly = {}) => + this.client.fetch( + { + method: 'GET', + path: `/secret-manager/v1alpha1/regions/${validatePathParam( + 'region', + request.region ?? this.client.settings.defaultRegion, + )}/tags`, + urlParams: urlParams( + ['page', request.page], + [ + 'page_size', + request.pageSize ?? this.client.settings.defaultPageSize, + ], + ['project_id', request.projectId], + ), + }, + unmarshalListTagsResponse, + ) + + /** + * List tags. List all tags associated to secrets in one or several Projects. + * + * @param request - The request {@link ListTagsRequest} + * @returns A Promise of ListTagsResponse + */ + listTags = (request: Readonly = {}) => + enrichForPagination('tags', this.pageOfListTags, request) } diff --git a/packages/clients/src/api/secret/v1alpha1/index.gen.ts b/packages/clients/src/api/secret/v1alpha1/index.gen.ts index 432e665b2..513ebd348 100644 --- a/packages/clients/src/api/secret/v1alpha1/index.gen.ts +++ b/packages/clients/src/api/secret/v1alpha1/index.gen.ts @@ -23,6 +23,8 @@ export type { ListSecretsRequest, ListSecretsRequestOrderBy, ListSecretsResponse, + ListTagsRequest, + ListTagsResponse, PasswordGenerationParams, Product, Secret, diff --git a/packages/clients/src/api/secret/v1alpha1/marshalling.gen.ts b/packages/clients/src/api/secret/v1alpha1/marshalling.gen.ts index d89079873..ac4245c24 100644 --- a/packages/clients/src/api/secret/v1alpha1/marshalling.gen.ts +++ b/packages/clients/src/api/secret/v1alpha1/marshalling.gen.ts @@ -15,6 +15,7 @@ import type { GeneratePasswordRequest, ListSecretVersionsResponse, ListSecretsResponse, + ListTagsResponse, PasswordGenerationParams, Secret, SecretVersion, @@ -103,6 +104,16 @@ export const unmarshalListSecretsResponse = (data: unknown) => { } as ListSecretsResponse } +export const unmarshalListTagsResponse = (data: unknown) => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'ListTagsResponse' failed as data isn't a dictionary.`, + ) + } + + return { tags: data.tags, totalCount: data.total_count } as ListTagsResponse +} + const marshalPasswordGenerationParams = ( request: PasswordGenerationParams, defaults: DefaultValues, diff --git a/packages/clients/src/api/secret/v1alpha1/types.gen.ts b/packages/clients/src/api/secret/v1alpha1/types.gen.ts index 4962ebd97..eb86e0331 100644 --- a/packages/clients/src/api/secret/v1alpha1/types.gen.ts +++ b/packages/clients/src/api/secret/v1alpha1/types.gen.ts @@ -54,6 +54,14 @@ export interface ListSecretsResponse { totalCount: number } +/** List tags response. */ +export interface ListTagsResponse { + /** List of tags. */ + tags: string[] + /** Count of all tags matching the requested criteria. */ + totalCount: number +} + /** Password generation params. */ export interface PasswordGenerationParams { /** Length of the password to generate (between 1 and 1024). */ @@ -467,3 +475,18 @@ export type DestroySecretVersionRequest = { */ revision: string } + +export type ListTagsRequest = { + /** + * Region to target. If none is passed will use default region from the + * config. + */ + region?: Region + /** + * ID of the Project to target. (Optional.) If not specified, Secret Manager + * will look for tags in all Projects. + */ + projectId?: string + page?: number + pageSize?: number +}