Skip to content

Commit 34bbc3e

Browse files
authored
feat(secret): use optional type for some request fields (#610)
1 parent e18f76c commit 34bbc3e

File tree

2 files changed

+92
-92
lines changed

2 files changed

+92
-92
lines changed

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

Lines changed: 42 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -146,24 +146,6 @@ export class API extends ParentAPI {
146146
unmarshalSecret,
147147
)
148148

149-
/**
150-
* Allow another product to use the secret.
151-
*
152-
* @param request - The request {@link AddSecretOwnerRequest}
153-
*/
154-
addSecretOwner = (request: Readonly<AddSecretOwnerRequest>) =>
155-
this.client.fetch<void>({
156-
body: JSON.stringify(
157-
marshalAddSecretOwnerRequest(request, this.client.settings),
158-
),
159-
headers: jsonContentHeaders,
160-
method: 'POST',
161-
path: `/secret-manager/v1alpha1/regions/${validatePathParam(
162-
'region',
163-
request.region ?? this.client.settings.defaultRegion,
164-
)}/secrets/${validatePathParam('secretId', request.secretId)}/add-owner`,
165-
})
166-
167149
protected pageOfListSecrets = (request: Readonly<ListSecretsRequest> = {}) =>
168150
this.client.fetch<ListSecretsResponse>(
169151
{
@@ -215,6 +197,24 @@ export class API extends ParentAPI {
215197
)}/secrets/${validatePathParam('secretId', request.secretId)}`,
216198
})
217199

200+
/**
201+
* Allow a product to use the secret.
202+
*
203+
* @param request - The request {@link AddSecretOwnerRequest}
204+
*/
205+
addSecretOwner = (request: Readonly<AddSecretOwnerRequest>) =>
206+
this.client.fetch<void>({
207+
body: JSON.stringify(
208+
marshalAddSecretOwnerRequest(request, this.client.settings),
209+
),
210+
headers: jsonContentHeaders,
211+
method: 'POST',
212+
path: `/secret-manager/v1alpha1/regions/${validatePathParam(
213+
'region',
214+
request.region ?? this.client.settings.defaultRegion,
215+
)}/secrets/${validatePathParam('secretId', request.secretId)}/add-owner`,
216+
})
217+
218218
/**
219219
* Create a version. Create a version of a given secret specified by the
220220
* `region` and `secret_id` parameters.
@@ -385,30 +385,6 @@ export class API extends ParentAPI {
385385
request,
386386
)
387387

388-
/**
389-
* Delete a version. Delete a secret's version and the sensitive data
390-
* contained in it. Deleting a version is permanent and cannot be undone.
391-
*
392-
* @param request - The request {@link DestroySecretVersionRequest}
393-
* @returns A Promise of SecretVersion
394-
*/
395-
destroySecretVersion = (request: Readonly<DestroySecretVersionRequest>) =>
396-
this.client.fetch<SecretVersion>(
397-
{
398-
body: '{}',
399-
headers: jsonContentHeaders,
400-
method: 'POST',
401-
path: `/secret-manager/v1alpha1/regions/${validatePathParam(
402-
'region',
403-
request.region ?? this.client.settings.defaultRegion,
404-
)}/secrets/${validatePathParam(
405-
'secretId',
406-
request.secretId,
407-
)}/versions/${validatePathParam('revision', request.revision)}/destroy`,
408-
},
409-
unmarshalSecretVersion,
410-
)
411-
412388
/**
413389
* Enable a version. Make a specific version accessible. You must specify the
414390
* `region`, `secret_id` and `revision` parameters.
@@ -504,4 +480,28 @@ export class API extends ParentAPI {
504480
},
505481
unmarshalAccessSecretVersionResponse,
506482
)
483+
484+
/**
485+
* Delete a version. Delete a secret's version and the sensitive data
486+
* contained in it. Deleting a version is permanent and cannot be undone.
487+
*
488+
* @param request - The request {@link DestroySecretVersionRequest}
489+
* @returns A Promise of SecretVersion
490+
*/
491+
destroySecretVersion = (request: Readonly<DestroySecretVersionRequest>) =>
492+
this.client.fetch<SecretVersion>(
493+
{
494+
body: '{}',
495+
headers: jsonContentHeaders,
496+
method: 'POST',
497+
path: `/secret-manager/v1alpha1/regions/${validatePathParam(
498+
'region',
499+
request.region ?? this.client.settings.defaultRegion,
500+
)}/secrets/${validatePathParam(
501+
'secretId',
502+
request.secretId,
503+
)}/versions/${validatePathParam('revision', request.revision)}/destroy`,
504+
},
505+
unmarshalSecretVersion,
506+
)
507507
}

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

Lines changed: 50 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -33,23 +33,23 @@ export interface AccessSecretVersionResponse {
3333
* The CRC32 checksum of the data as a base-10 integer. This field is present
3434
* only if a CRC32 was supplied during the creation of the version.
3535
*/
36-
dataCrc32: number
36+
dataCrc32?: number
3737
}
3838

3939
/** List secret versions response. */
4040
export interface ListSecretVersionsResponse {
41-
/** Number of versions. */
42-
totalCount: number
4341
/** Single page of versions. */
4442
versions: SecretVersion[]
43+
/** Number of versions. */
44+
totalCount: number
4545
}
4646

4747
/** List secrets response. */
4848
export interface ListSecretsResponse {
49-
/** Count of all secrets matching the requested criteria. */
50-
totalCount: number
5149
/** Single page of secrets matching the requested criteria. */
5250
secrets: Secret[]
51+
/** Count of all secrets matching the requested criteria. */
52+
totalCount: number
5353
}
5454

5555
/** Password generation params. */
@@ -85,40 +85,40 @@ export interface Secret {
8585
updatedAt?: Date
8686
/** List of the secret's tags. */
8787
tags: string[]
88-
/** Region of the secret. */
89-
region: Region
9088
/** Number of versions for this secret. */
9189
versionCount: number
9290
/** Updated description of the secret. */
9391
description?: string
9492
/** True for secrets that are managed by another product. */
9593
isManaged: boolean
94+
/** Region of the secret. */
95+
region: Region
9696
}
9797

9898
/** Secret version. */
9999
export interface SecretVersion {
100-
/** ID of the secret. */
101-
secretId: string
102100
/**
103101
* Version number. The first version of the secret is numbered 1, and all
104102
* subsequent revisions augment by 1.
105103
*/
106104
revision: number
105+
/** ID of the secret. */
106+
secretId: string
107107
/**
108108
* Current status of the version. `unknown`: the version is in an invalid
109109
* state. `enabled`: the version is accessible. `disabled`: the version is not
110110
* accessible but can be enabled. `destroyed`: the version is permanently
111111
* deleted. It is not possible to recover it.
112112
*/
113113
status: SecretVersionStatus
114-
/** True if the version is the latest one. */
115-
isLatest: boolean
116114
/** Date and time of the version's creation. */
117115
createdAt?: Date
118116
/** Last update of the version. */
119117
updatedAt?: Date
120118
/** Description of the version. */
121119
description?: string
120+
/** True if the version is the latest one. */
121+
isLatest: boolean
122122
}
123123

124124
export type CreateSecretRequest = {
@@ -173,18 +173,6 @@ export type UpdateSecretRequest = {
173173
description?: string
174174
}
175175

176-
export type AddSecretOwnerRequest = {
177-
/**
178-
* Region to target. If none is passed will use default region from the
179-
* config.
180-
*/
181-
region?: Region
182-
/** ID of the secret. */
183-
secretId: string
184-
/** Name of the product to add. */
185-
productName: string
186-
}
187-
188176
export type ListSecretsRequest = {
189177
/**
190178
* Region to target. If none is passed will use default region from the
@@ -195,15 +183,15 @@ export type ListSecretsRequest = {
195183
organizationId?: string
196184
/** Filter by Project ID (optional). */
197185
projectId?: string
198-
/** Filter by secret name (optional). */
199-
name?: string
186+
orderBy?: ListSecretsRequestOrderBy
187+
page?: number
188+
pageSize?: number
200189
/** List of tags to filter on (optional). */
201190
tags?: string[]
191+
/** Filter by secret name (optional). */
192+
name?: string
202193
/** Filter by managed / not managed (optional). */
203194
isManaged?: boolean
204-
orderBy?: ListSecretsRequestOrderBy
205-
page?: number
206-
pageSize?: number
207195
}
208196

209197
export type DeleteSecretRequest = {
@@ -216,6 +204,18 @@ export type DeleteSecretRequest = {
216204
secretId: string
217205
}
218206

207+
export type AddSecretOwnerRequest = {
208+
/**
209+
* Region to target. If none is passed will use default region from the
210+
* config.
211+
*/
212+
region?: Region
213+
/** ID of the secret. */
214+
secretId: string
215+
/** Name of the product to add. */
216+
productName: string
217+
}
218+
219219
export type CreateSecretVersionRequest = {
220220
/**
221221
* Region to target. If none is passed will use default region from the
@@ -229,28 +229,28 @@ export type CreateSecretVersionRequest = {
229229
/** Description of the version. */
230230
description?: string
231231
/**
232-
* Disable the previous secret version. If there is no previous version or if
233-
* the previous version was already disabled, does nothing.
232+
* Disable the previous secret version. Optional. If there is no previous
233+
* version or if the previous version was already disabled, does nothing.
234234
*/
235-
disablePrevious: boolean
235+
disablePrevious?: boolean
236236
/**
237-
* Options to generate a password. If specified, a random password will be
238-
* generated. The data field must be empty. By default, the generator will use
239-
* upper and lower case letters, and digits. This behavior can be tuned using
240-
* the generation parameters.
237+
* Options to generate a password. Optional. If specified, a random password
238+
* will be generated. The data and data_crc32 fields must be empty. By
239+
* default, the generator will use upper and lower case letters, and digits.
240+
* This behavior can be tuned using the generation parameters.
241241
*
242242
* One-of ('PasswordGeneration'): at most one of 'passwordGeneration' could be
243243
* set.
244244
*/
245245
passwordGeneration?: PasswordGenerationParams
246246
/**
247-
* The CRC32 checksum of the data as a base-10 integer. This field is optional
248-
* and can be set to 0. If greater than 0, the Secret Manager will verify the
249-
* integrity of the data received against the given CRC32. An error is
250-
* returned if the CRC32 does not match. Otherwise, the CRC32 will be stored
251-
* and returned along with the SecretVersion on futur accesses.
247+
* The CRC32 checksum of the data as a base-10 integer. Optional. If
248+
* specified, the Secret Manager will verify the integrity of the data
249+
* received against the given CRC32. An error is returned if the CRC32 does
250+
* not match. Otherwise, the CRC32 will be stored and returned along with the
251+
* SecretVersion on futur accesses.
252252
*/
253-
dataCrc32: number
253+
dataCrc32?: number
254254
}
255255

256256
export type GetSecretVersionRequest = {
@@ -328,7 +328,7 @@ export type ListSecretVersionsByNameRequest = {
328328
status?: SecretVersionStatus[]
329329
}
330330

331-
export type DestroySecretVersionRequest = {
331+
export type EnableSecretVersionRequest = {
332332
/**
333333
* Region to target. If none is passed will use default region from the
334334
* config.
@@ -343,7 +343,7 @@ export type DestroySecretVersionRequest = {
343343
revision: string
344344
}
345345

346-
export type EnableSecretVersionRequest = {
346+
export type DisableSecretVersionRequest = {
347347
/**
348348
* Region to target. If none is passed will use default region from the
349349
* config.
@@ -358,7 +358,7 @@ export type EnableSecretVersionRequest = {
358358
revision: string
359359
}
360360

361-
export type DisableSecretVersionRequest = {
361+
export type AccessSecretVersionRequest = {
362362
/**
363363
* Region to target. If none is passed will use default region from the
364364
* config.
@@ -373,29 +373,29 @@ export type DisableSecretVersionRequest = {
373373
revision: string
374374
}
375375

376-
export type AccessSecretVersionRequest = {
376+
export type AccessSecretVersionByNameRequest = {
377377
/**
378378
* Region to target. If none is passed will use default region from the
379379
* config.
380380
*/
381381
region?: Region
382-
/** ID of the secret. */
383-
secretId: string
382+
/** Name of the secret. */
383+
secretName: string
384384
/**
385385
* Version number. The first version of the secret is numbered 1, and all
386386
* subsequent revisions augment by 1. Value can be a number or "latest".
387387
*/
388388
revision: string
389389
}
390390

391-
export type AccessSecretVersionByNameRequest = {
391+
export type DestroySecretVersionRequest = {
392392
/**
393393
* Region to target. If none is passed will use default region from the
394394
* config.
395395
*/
396396
region?: Region
397-
/** Name of the secret. */
398-
secretName: string
397+
/** ID of the secret. */
398+
secretId: string
399399
/**
400400
* Version number. The first version of the secret is numbered 1, and all
401401
* subsequent revisions augment by 1. Value can be a number or "latest".

0 commit comments

Comments
 (0)