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
18 changes: 18 additions & 0 deletions packages_generated/key_manager/src/v1alpha1/api.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
unmarshalEncryptResponse,
unmarshalKey,
unmarshalListKeysResponse,
unmarshalPublicKey,
} from './marshalling.gen'
import type {
CreateKeyRequest,
Expand All @@ -33,11 +34,13 @@ import type {
EncryptResponse,
GenerateDataKeyRequest,
GetKeyRequest,
GetPublicKeyRequest,
ImportKeyMaterialRequest,
Key,
ListKeysRequest,
ListKeysResponse,
ProtectKeyRequest,
PublicKey,
RotateKeyRequest,
UnprotectKeyRequest,
UpdateKeyRequest,
Expand Down Expand Up @@ -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<GetPublicKeyRequest>) =>
this.client.fetch<PublicKey>(
{
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.
*
Expand Down
2 changes: 2 additions & 0 deletions packages_generated/key_manager/src/v1alpha1/index.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export type {
EncryptResponse,
GenerateDataKeyRequest,
GetKeyRequest,
GetPublicKeyRequest,
ImportKeyMaterialRequest,
Key,
KeyAlgorithmSymmetricEncryption,
Expand All @@ -27,6 +28,7 @@ export type {
ListKeysRequestOrderBy,
ListKeysResponse,
ProtectKeyRequest,
PublicKey,
RotateKeyRequest,
UnprotectKeyRequest,
UpdateKeyRequest,
Expand Down
13 changes: 13 additions & 0 deletions packages_generated/key_manager/src/v1alpha1/marshalling.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import type {
KeyRotationPolicy,
KeyUsage,
ListKeysResponse,
PublicKey,
UpdateKeyRequest,
} from './types.gen'

Expand Down Expand Up @@ -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,
Expand Down
15 changes: 15 additions & 0 deletions packages_generated/key_manager/src/v1alpha1/types.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down
Loading