Skip to content

Commit

Permalink
feat: update generated APIs
Browse files Browse the repository at this point in the history
  • Loading branch information
scaleway-bot committed Aug 29, 2024
1 parent 43cf8b0 commit bffe841
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 0 deletions.
38 changes: 38 additions & 0 deletions packages/clients/src/api/key_manager/v1alpha1/api.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
marshalDecryptRequest,
marshalEncryptRequest,
marshalGenerateDataKeyRequest,
marshalImportKeyMaterialRequest,
marshalUpdateKeyRequest,
unmarshalDataKey,
unmarshalDecryptResponse,
Expand All @@ -24,13 +25,15 @@ import type {
DataKey,
DecryptRequest,
DecryptResponse,
DeleteKeyMaterialRequest,
DeleteKeyRequest,
DisableKeyRequest,
EnableKeyRequest,
EncryptRequest,
EncryptResponse,
GenerateDataKeyRequest,
GetKeyRequest,
ImportKeyMaterialRequest,
Key,
ListKeysRequest,
ListKeysResponse,
Expand Down Expand Up @@ -324,4 +327,39 @@ export class API extends ParentAPI {
},
unmarshalDecryptResponse,
)

/**
* Import key material. Import key material to use to derive a new
* cryptographic key. The key's origin must be `external`.
*
* @param request - The request {@link ImportKeyMaterialRequest}
* @returns A Promise of Key
*/
importKeyMaterial = (request: Readonly<ImportKeyMaterialRequest>) =>
this.client.fetch<Key>(
{
body: JSON.stringify(
marshalImportKeyMaterialRequest(request, this.client.settings),
),
headers: jsonContentHeaders,
method: 'POST',
path: `/key-manager/v1alpha1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/keys/${validatePathParam('keyId', request.keyId)}/import-key-material`,
},
unmarshalKey,
)

/**
* Delete key material. Delete previously imported key material. This renders
* the associated cryptographic key unusable for any operation. The key's
* origin must be `external`.
*
* @param request - The request {@link DeleteKeyMaterialRequest}
*/
deleteKeyMaterial = (request: Readonly<DeleteKeyMaterialRequest>) =>
this.client.fetch<void>({
body: '{}',
headers: jsonContentHeaders,
method: 'POST',
path: `/key-manager/v1alpha1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/keys/${validatePathParam('keyId', request.keyId)}/delete-key-material`,
})
}
3 changes: 3 additions & 0 deletions packages/clients/src/api/key_manager/v1alpha1/index.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,18 @@ export type {
DataKeyAlgorithmSymmetricEncryption,
DecryptRequest,
DecryptResponse,
DeleteKeyMaterialRequest,
DeleteKeyRequest,
DisableKeyRequest,
EnableKeyRequest,
EncryptRequest,
EncryptResponse,
GenerateDataKeyRequest,
GetKeyRequest,
ImportKeyMaterialRequest,
Key,
KeyAlgorithmSymmetricEncryption,
KeyOrigin,
KeyRotationPolicy,
KeyState,
KeyUsage,
Expand Down
11 changes: 11 additions & 0 deletions packages/clients/src/api/key_manager/v1alpha1/marshalling.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import type {
EncryptRequest,
EncryptResponse,
GenerateDataKeyRequest,
ImportKeyMaterialRequest,
Key,
KeyRotationPolicy,
KeyUsage,
Expand Down Expand Up @@ -62,6 +63,7 @@ export const unmarshalKey = (data: unknown): Key => {
id: data.id,
locked: data.locked,
name: data.name,
origin: data.origin,
projectId: data.project_id,
protected: data.protected,
region: data.region,
Expand Down Expand Up @@ -156,6 +158,7 @@ export const marshalCreateKeyRequest = (
): Record<string, unknown> => ({
description: request.description,
name: request.name,
origin: request.origin,
project_id: request.projectId ?? defaults.defaultProjectId,
rotation_policy:
request.rotationPolicy !== undefined
Expand Down Expand Up @@ -193,6 +196,14 @@ export const marshalGenerateDataKeyRequest = (
without_plaintext: request.withoutPlaintext,
})

export const marshalImportKeyMaterialRequest = (
request: ImportKeyMaterialRequest,
defaults: DefaultValues,
): Record<string, unknown> => ({
key_material: request.keyMaterial,
salt: request.salt,
})

export const marshalUpdateKeyRequest = (
request: UpdateKeyRequest,
defaults: DefaultValues,
Expand Down
36 changes: 36 additions & 0 deletions packages/clients/src/api/key_manager/v1alpha1/types.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ export type KeyAlgorithmSymmetricEncryption =
| 'unknown_symmetric_encryption'
| 'aes_256_gcm'

export type KeyOrigin = 'unknown_origin' | 'scaleway_kms' | 'external'

export type KeyState =
| 'unknown_state'
| 'enabled'
Expand Down Expand Up @@ -77,6 +79,8 @@ export interface Key {
rotatedAt?: Date
/** Key rotation policy. */
rotationPolicy?: KeyRotationPolicy
/** Refer to the `Key.Origin` enum for a description of values. */
origin: KeyOrigin
/** Region of the key. */
region: Region
}
Expand Down Expand Up @@ -104,6 +108,8 @@ export type CreateKeyRequest = {
rotationPolicy?: KeyRotationPolicy
/** Default value is `false`. */
unprotected: boolean
/** Refer to the `Key.Origin` enum for a description of values. */
origin?: KeyOrigin
}

export interface DataKey {
Expand Down Expand Up @@ -152,6 +158,16 @@ export interface DecryptResponse {
ciphertext?: string
}

export type DeleteKeyMaterialRequest = {
/**
* Region to target. If none is passed will use default region from the
* config.
*/
region?: Region
/** ID of the key of which to delete the key material. */
keyId: string
}

export type DeleteKeyRequest = {
/**
* Region to target. If none is passed will use default region from the
Expand Down Expand Up @@ -237,6 +253,26 @@ export type GetKeyRequest = {
keyId: string
}

export type ImportKeyMaterialRequest = {
/**
* Region to target. If none is passed will use default region from the
* config.
*/
region?: Region
/** The key's origin must be 'external'. */
keyId: string
/**
* The key material The key material is a random sequence of bytes used to
* derive a cryptographic key.
*/
keyMaterial: string
/**
* A salt can be used to improve the quality of randomness when the key
* material is generated from a low entropy source.
*/
salt?: string
}

export type ListKeysRequest = {
/**
* Region to target. If none is passed will use default region from the
Expand Down

0 comments on commit bffe841

Please sign in to comment.