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
39 changes: 39 additions & 0 deletions packages/clients/src/api/secret/v1beta1/api.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ import type {
ListTagsRequest,
ListTagsResponse,
ProtectSecretRequest,
RestoreSecretRequest,
RestoreSecretVersionRequest,
Secret,
SecretVersion,
UnprotectSecretRequest,
Expand Down Expand Up @@ -158,6 +160,7 @@ export class API extends ParentAPI {
],
['path', request.path],
['project_id', request.projectId],
['scheduled_for_deletion', request.scheduledForDeletion],
['tags', request.tags],
['type', request.type],
),
Expand Down Expand Up @@ -496,4 +499,40 @@ export class API extends ParentAPI {
*/
listSecretTypes = (request: Readonly<ListSecretTypesRequest> = {}) =>
enrichForPagination('types', this.pageOfListSecretTypes, request)

/**
* Restore a version.. Restore a secret's version specified by the `region`,
* `secret_id` and `revision` parameters.
*
* @param request - The request {@link RestoreSecretVersionRequest}
* @returns A Promise of SecretVersion
*/
restoreSecretVersion = (request: Readonly<RestoreSecretVersionRequest>) =>
this.client.fetch<SecretVersion>(
{
body: '{}',
headers: jsonContentHeaders,
method: 'POST',
path: `/secret-manager/v1beta1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/secrets/${validatePathParam('secretId', request.secretId)}/versions/${validatePathParam('revision', request.revision)}/restore`,
},
unmarshalSecretVersion,
)

/**
* Restore a secret.. Restore a secret and all its versions scheduled for
* deletion specified by the `region` and `secret_id` parameters.
*
* @param request - The request {@link RestoreSecretRequest}
* @returns A Promise of Secret
*/
restoreSecret = (request: Readonly<RestoreSecretRequest>) =>
this.client.fetch<Secret>(
{
body: '{}',
headers: jsonContentHeaders,
method: 'POST',
path: `/secret-manager/v1beta1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/secrets/${validatePathParam('secretId', request.secretId)}/restore`,
},
unmarshalSecret,
)
}
2 changes: 2 additions & 0 deletions packages/clients/src/api/secret/v1beta1/index.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ export type {
ListTagsResponse,
Product,
ProtectSecretRequest,
RestoreSecretRequest,
RestoreSecretVersionRequest,
SSHKey,
Secret,
SecretStatus,
Expand Down
2 changes: 2 additions & 0 deletions packages/clients/src/api/secret/v1beta1/marshalling.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ export const unmarshalSecretVersion = (data: unknown): SecretVersion => {
return {
createdAt: unmarshalDate(data.created_at),
deletedAt: unmarshalDate(data.deleted_at),
deletionRequestedAt: unmarshalDate(data.deletion_requested_at),
description: data.description,
ephemeralProperties: data.ephemeral_properties
? unmarshalEphemeralProperties(data.ephemeral_properties)
Expand Down Expand Up @@ -86,6 +87,7 @@ export const unmarshalSecret = (data: unknown): Secret => {

return {
createdAt: unmarshalDate(data.created_at),
deletionRequestedAt: unmarshalDate(data.deletion_requested_at),
description: data.description,
ephemeralPolicy: data.ephemeral_policy
? unmarshalEphemeralPolicy(data.ephemeral_policy)
Expand Down
34 changes: 32 additions & 2 deletions packages/clients/src/api/secret/v1beta1/types.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export type SecretVersionStatus =
| 'enabled'
| 'disabled'
| 'deleted'
| 'scheduled_for_deletion'

export interface EphemeralPolicy {
/**
Expand Down Expand Up @@ -95,8 +96,9 @@ export interface SecretVersion {
/**
* - `unknown_status`: the version is in an invalid state. `enabled`: the
* version is accessible. `disabled`: the version is not accessible but can
* be enabled. `deleted`: the version is permanently deleted. It is not
* possible to recover it.
* be enabled. `scheduled_for_deletion`: the version is scheduled for
* deletion. It will be deleted in 7 days. `deleted`: the version is
* permanently deleted. It is not possible to recover it.
*/
status: SecretVersionStatus
/** Date and time of the version's creation. */
Expand All @@ -115,6 +117,8 @@ export interface SecretVersion {
* version expires.
*/
ephemeralProperties?: EphemeralProperties
/** Returns the time at which deletion was requested. */
deletionRequestedAt?: Date
}

export interface Secret {
Expand Down Expand Up @@ -155,6 +159,8 @@ export interface Secret {
ephemeralPolicy?: EphemeralPolicy
/** List of Scaleway resources that can access and manage the secret. */
usedBy: Product[]
/** Returns the time at which deletion was requested. */
deletionRequestedAt?: Date
/** Region of the secret. */
region: ScwRegion
}
Expand Down Expand Up @@ -500,6 +506,11 @@ export type ListSecretsRequest = {
ephemeral?: boolean
/** Filter by secret type (optional). */
type?: SecretType
/**
* Filter by whether the secret was scheduled for deletion / not scheduled for
* deletion (optional).
*/
scheduledForDeletion?: boolean
}

export interface ListSecretsResponse {
Expand Down Expand Up @@ -538,6 +549,25 @@ export type ProtectSecretRequest = {
secretId: string
}

export type RestoreSecretRequest = {
/**
* Region to target. If none is passed will use default region from the
* config.
*/
region?: ScwRegion
secretId: string
}

export type RestoreSecretVersionRequest = {
/**
* Region to target. If none is passed will use default region from the
* config.
*/
region?: ScwRegion
secretId: string
revision: string
}

export interface SSHKey {
/** The private SSH key. */
sshPrivateKey: string
Expand Down
Loading