Skip to content

Commit e980d36

Browse files
scaleway-botyfodil
andauthored
feat(key_manager): add getpublickey endpoint (#2102)
Co-authored-by: Yacine FODIL <[email protected]>
1 parent a138582 commit e980d36

File tree

4 files changed

+48
-0
lines changed

4 files changed

+48
-0
lines changed

packages_generated/key_manager/src/v1alpha1/api.gen.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import {
1919
unmarshalEncryptResponse,
2020
unmarshalKey,
2121
unmarshalListKeysResponse,
22+
unmarshalPublicKey,
2223
} from './marshalling.gen'
2324
import type {
2425
CreateKeyRequest,
@@ -33,11 +34,13 @@ import type {
3334
EncryptResponse,
3435
GenerateDataKeyRequest,
3536
GetKeyRequest,
37+
GetPublicKeyRequest,
3638
ImportKeyMaterialRequest,
3739
Key,
3840
ListKeysRequest,
3941
ListKeysResponse,
4042
ProtectKeyRequest,
43+
PublicKey,
4144
RotateKeyRequest,
4245
UnprotectKeyRequest,
4346
UpdateKeyRequest,
@@ -94,6 +97,21 @@ export class API extends ParentAPI {
9497
unmarshalKey,
9598
)
9699

100+
/**
101+
* Get the public key in PEM format.. Retrieves the public portion of an asymmetric cryptographic key in PEM format.
102+
*
103+
* @param request - The request {@link GetPublicKeyRequest}
104+
* @returns A Promise of PublicKey
105+
*/
106+
getPublicKey = (request: Readonly<GetPublicKeyRequest>) =>
107+
this.client.fetch<PublicKey>(
108+
{
109+
method: 'GET',
110+
path: `/key-manager/v1alpha1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/keys/${validatePathParam('keyId', request.keyId)}/public-key`,
111+
},
112+
unmarshalPublicKey,
113+
)
114+
97115
/**
98116
* Update a key. Modify a key's metadata including name, description and tags, specified by the `key_id` and `region` parameters.
99117
*

packages_generated/key_manager/src/v1alpha1/index.gen.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ export type {
1616
EncryptResponse,
1717
GenerateDataKeyRequest,
1818
GetKeyRequest,
19+
GetPublicKeyRequest,
1920
ImportKeyMaterialRequest,
2021
Key,
2122
KeyAlgorithmSymmetricEncryption,
@@ -27,6 +28,7 @@ export type {
2728
ListKeysRequestOrderBy,
2829
ListKeysResponse,
2930
ProtectKeyRequest,
31+
PublicKey,
3032
RotateKeyRequest,
3133
UnprotectKeyRequest,
3234
UpdateKeyRequest,

packages_generated/key_manager/src/v1alpha1/marshalling.gen.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import type {
2020
KeyRotationPolicy,
2121
KeyUsage,
2222
ListKeysResponse,
23+
PublicKey,
2324
UpdateKeyRequest,
2425
} from './types.gen'
2526

@@ -135,6 +136,18 @@ export const unmarshalListKeysResponse = (data: unknown): ListKeysResponse => {
135136
} as ListKeysResponse
136137
}
137138

139+
export const unmarshalPublicKey = (data: unknown): PublicKey => {
140+
if (!isJSONObject(data)) {
141+
throw new TypeError(
142+
`Unmarshalling the type 'PublicKey' failed as data isn't a dictionary.`,
143+
)
144+
}
145+
146+
return {
147+
pem: data.pem,
148+
} as PublicKey
149+
}
150+
138151
const marshalKeyRotationPolicy = (
139152
request: KeyRotationPolicy,
140153
defaults: DefaultValues,

packages_generated/key_manager/src/v1alpha1/types.gen.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,17 @@ export type GetKeyRequest = {
314314
keyId: string
315315
}
316316

317+
export type GetPublicKeyRequest = {
318+
/**
319+
* Region to target. If none is passed will use default region from the config.
320+
*/
321+
region?: ScwRegion
322+
/**
323+
* ID of the key.
324+
*/
325+
keyId: string
326+
}
327+
317328
export type ImportKeyMaterialRequest = {
318329
/**
319330
* Region to target. If none is passed will use default region from the config.
@@ -381,6 +392,10 @@ export type ProtectKeyRequest = {
381392
keyId: string
382393
}
383394

395+
export interface PublicKey {
396+
pem: string
397+
}
398+
384399
export type RotateKeyRequest = {
385400
/**
386401
* Region to target. If none is passed will use default region from the config.

0 commit comments

Comments
 (0)