Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions packages/clients/src/api/secret/v1alpha1/api.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
unmarshalAccessSecretVersionResponse,
unmarshalListSecretVersionsResponse,
unmarshalListSecretsResponse,
unmarshalListTagsResponse,
unmarshalSecret,
unmarshalSecretVersion,
} from './marshalling.gen'
Expand All @@ -41,6 +42,8 @@ import type {
ListSecretVersionsResponse,
ListSecretsRequest,
ListSecretsResponse,
ListTagsRequest,
ListTagsResponse,
Secret,
SecretVersion,
UpdateSecretRequest,
Expand Down Expand Up @@ -537,4 +540,33 @@ export class API extends ParentAPI {
},
unmarshalSecretVersion,
)

protected pageOfListTags = (request: Readonly<ListTagsRequest> = {}) =>
this.client.fetch<ListTagsResponse>(
{
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<ListTagsRequest> = {}) =>
enrichForPagination('tags', this.pageOfListTags, request)
}
2 changes: 2 additions & 0 deletions packages/clients/src/api/secret/v1alpha1/index.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ export type {
ListSecretsRequest,
ListSecretsRequestOrderBy,
ListSecretsResponse,
ListTagsRequest,
ListTagsResponse,
PasswordGenerationParams,
Product,
Secret,
Expand Down
11 changes: 11 additions & 0 deletions packages/clients/src/api/secret/v1alpha1/marshalling.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import type {
GeneratePasswordRequest,
ListSecretVersionsResponse,
ListSecretsResponse,
ListTagsResponse,
PasswordGenerationParams,
Secret,
SecretVersion,
Expand Down Expand Up @@ -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,
Expand Down
23 changes: 23 additions & 0 deletions packages/clients/src/api/secret/v1alpha1/types.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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). */
Expand Down Expand Up @@ -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
}