diff --git a/packages_generated/key_manager/src/v1alpha1/api.gen.ts b/packages_generated/key_manager/src/v1alpha1/api.gen.ts index fc4597614..2c2f3be8b 100644 --- a/packages_generated/key_manager/src/v1alpha1/api.gen.ts +++ b/packages_generated/key_manager/src/v1alpha1/api.gen.ts @@ -22,6 +22,7 @@ import { unmarshalDecryptResponse, unmarshalEncryptResponse, unmarshalKey, + unmarshalListAlgorithmsResponse, unmarshalListKeysResponse, unmarshalPublicKey, unmarshalSignResponse, @@ -43,6 +44,8 @@ import type { GetPublicKeyRequest, ImportKeyMaterialRequest, Key, + ListAlgorithmsRequest, + ListAlgorithmsResponse, ListKeysRequest, ListKeysResponse, ProtectKeyRequest, @@ -414,4 +417,20 @@ The data encryption key is returned in plaintext and ciphertext but it should on }, unmarshalKey, ) + + /** + * List all available algorithms. Lists all cryptographic algorithms supported by the Key Manager service. + * + * @param request - The request {@link ListAlgorithmsRequest} + * @returns A Promise of ListAlgorithmsResponse + */ + listAlgorithms = (request: Readonly = {}) => + this.client.fetch( + { + method: 'GET', + path: `/key-manager/v1alpha1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/algorithms`, + urlParams: urlParams(['usages', request.usages]), + }, + unmarshalListAlgorithmsResponse, + ) } diff --git a/packages_generated/key_manager/src/v1alpha1/index.gen.ts b/packages_generated/key_manager/src/v1alpha1/index.gen.ts index 86ba77426..90e2bbc52 100644 --- a/packages_generated/key_manager/src/v1alpha1/index.gen.ts +++ b/packages_generated/key_manager/src/v1alpha1/index.gen.ts @@ -26,6 +26,10 @@ export type { KeyRotationPolicy, KeyState, KeyUsage, + ListAlgorithmsRequest, + ListAlgorithmsRequestUsage, + ListAlgorithmsResponse, + ListAlgorithmsResponseAlgorithm, ListKeysRequest, ListKeysRequestOrderBy, ListKeysRequestUsage, diff --git a/packages_generated/key_manager/src/v1alpha1/marshalling.gen.ts b/packages_generated/key_manager/src/v1alpha1/marshalling.gen.ts index a008527ed..95f756aea 100644 --- a/packages_generated/key_manager/src/v1alpha1/marshalling.gen.ts +++ b/packages_generated/key_manager/src/v1alpha1/marshalling.gen.ts @@ -20,6 +20,8 @@ import type { Key, KeyRotationPolicy, KeyUsage, + ListAlgorithmsResponse, + ListAlgorithmsResponseAlgorithm, ListKeysResponse, PublicKey, SignRequest, @@ -135,6 +137,39 @@ export const unmarshalEncryptResponse = (data: unknown): EncryptResponse => { } as EncryptResponse } +const unmarshalListAlgorithmsResponseAlgorithm = ( + data: unknown, +): ListAlgorithmsResponseAlgorithm => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'ListAlgorithmsResponseAlgorithm' failed as data isn't a dictionary.`, + ) + } + + return { + name: data.name, + recommended: data.recommended, + usage: data.usage, + } as ListAlgorithmsResponseAlgorithm +} + +export const unmarshalListAlgorithmsResponse = ( + data: unknown, +): ListAlgorithmsResponse => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'ListAlgorithmsResponse' failed as data isn't a dictionary.`, + ) + } + + return { + algorithms: unmarshalArrayOfObject( + data.algorithms, + unmarshalListAlgorithmsResponseAlgorithm, + ), + } as ListAlgorithmsResponse +} + export const unmarshalListKeysResponse = (data: unknown): ListKeysResponse => { if (!isJSONObject(data)) { throw new TypeError( diff --git a/packages_generated/key_manager/src/v1alpha1/types.gen.ts b/packages_generated/key_manager/src/v1alpha1/types.gen.ts index 520261b73..d070c9a35 100644 --- a/packages_generated/key_manager/src/v1alpha1/types.gen.ts +++ b/packages_generated/key_manager/src/v1alpha1/types.gen.ts @@ -36,6 +36,12 @@ export type KeyState = | 'pending_key_material' | 'scheduled_for_deletion' +export type ListAlgorithmsRequestUsage = + | 'unknown_usage' + | 'symmetric_encryption' + | 'asymmetric_encryption' + | 'asymmetric_signing' + export type ListKeysRequestOrderBy = | 'name_asc' | 'name_desc' @@ -80,6 +86,12 @@ export interface KeyUsage { asymmetricSigning?: KeyAlgorithmAsymmetricSigning } +export interface ListAlgorithmsResponseAlgorithm { + usage: string + name: string + recommended: boolean +} + export interface Key { /** * ID of the key. @@ -382,6 +394,24 @@ export type ImportKeyMaterialRequest = { salt?: string } +export type ListAlgorithmsRequest = { + /** + * Region to target. If none is passed will use default region from the config. + */ + region?: ScwRegion + /** + * Filter by key usage. + */ + usages?: ListAlgorithmsRequestUsage[] +} + +export interface ListAlgorithmsResponse { + /** + * Returns a list of algorithms matching the requested criteria. + */ + algorithms: ListAlgorithmsResponseAlgorithm[] +} + export type ListKeysRequest = { /** * Region to target. If none is passed will use default region from the config.