diff --git a/packages_generated/key_manager/src/v1alpha1/api.gen.ts b/packages_generated/key_manager/src/v1alpha1/api.gen.ts index da40495e6..dcc15be90 100644 --- a/packages_generated/key_manager/src/v1alpha1/api.gen.ts +++ b/packages_generated/key_manager/src/v1alpha1/api.gen.ts @@ -19,6 +19,7 @@ import { unmarshalEncryptResponse, unmarshalKey, unmarshalListKeysResponse, + unmarshalPublicKey, } from './marshalling.gen' import type { CreateKeyRequest, @@ -33,11 +34,13 @@ import type { EncryptResponse, GenerateDataKeyRequest, GetKeyRequest, + GetPublicKeyRequest, ImportKeyMaterialRequest, Key, ListKeysRequest, ListKeysResponse, ProtectKeyRequest, + PublicKey, RotateKeyRequest, UnprotectKeyRequest, UpdateKeyRequest, @@ -94,6 +97,21 @@ export class API extends ParentAPI { unmarshalKey, ) + /** + * Get the public key in PEM format.. Retrieves the public portion of an asymmetric cryptographic key in PEM format. + * + * @param request - The request {@link GetPublicKeyRequest} + * @returns A Promise of PublicKey + */ + getPublicKey = (request: Readonly) => + this.client.fetch( + { + method: 'GET', + path: `/key-manager/v1alpha1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/keys/${validatePathParam('keyId', request.keyId)}/public-key`, + }, + unmarshalPublicKey, + ) + /** * Update a key. Modify a key's metadata including name, description and tags, specified by the `key_id` and `region` parameters. * diff --git a/packages_generated/key_manager/src/v1alpha1/index.gen.ts b/packages_generated/key_manager/src/v1alpha1/index.gen.ts index cda61f724..18c5a8eb2 100644 --- a/packages_generated/key_manager/src/v1alpha1/index.gen.ts +++ b/packages_generated/key_manager/src/v1alpha1/index.gen.ts @@ -16,6 +16,7 @@ export type { EncryptResponse, GenerateDataKeyRequest, GetKeyRequest, + GetPublicKeyRequest, ImportKeyMaterialRequest, Key, KeyAlgorithmSymmetricEncryption, @@ -27,6 +28,7 @@ export type { ListKeysRequestOrderBy, ListKeysResponse, ProtectKeyRequest, + PublicKey, RotateKeyRequest, UnprotectKeyRequest, UpdateKeyRequest, diff --git a/packages_generated/key_manager/src/v1alpha1/marshalling.gen.ts b/packages_generated/key_manager/src/v1alpha1/marshalling.gen.ts index 423ff8257..9b97616d4 100644 --- a/packages_generated/key_manager/src/v1alpha1/marshalling.gen.ts +++ b/packages_generated/key_manager/src/v1alpha1/marshalling.gen.ts @@ -20,6 +20,7 @@ import type { KeyRotationPolicy, KeyUsage, ListKeysResponse, + PublicKey, UpdateKeyRequest, } from './types.gen' @@ -135,6 +136,18 @@ export const unmarshalListKeysResponse = (data: unknown): ListKeysResponse => { } as ListKeysResponse } +export const unmarshalPublicKey = (data: unknown): PublicKey => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'PublicKey' failed as data isn't a dictionary.`, + ) + } + + return { + pem: data.pem, + } as PublicKey +} + const marshalKeyRotationPolicy = ( request: KeyRotationPolicy, defaults: DefaultValues, diff --git a/packages_generated/key_manager/src/v1alpha1/types.gen.ts b/packages_generated/key_manager/src/v1alpha1/types.gen.ts index 3cdacb7a8..e6caeffb3 100644 --- a/packages_generated/key_manager/src/v1alpha1/types.gen.ts +++ b/packages_generated/key_manager/src/v1alpha1/types.gen.ts @@ -314,6 +314,17 @@ export type GetKeyRequest = { keyId: string } +export type GetPublicKeyRequest = { + /** + * Region to target. If none is passed will use default region from the config. + */ + region?: ScwRegion + /** + * ID of the key. + */ + keyId: string +} + export type ImportKeyMaterialRequest = { /** * Region to target. If none is passed will use default region from the config. @@ -381,6 +392,10 @@ export type ProtectKeyRequest = { keyId: string } +export interface PublicKey { + pem: string +} + export type RotateKeyRequest = { /** * Region to target. If none is passed will use default region from the config.