From 11136b8ea71bac5b60547a26f057c4e3ef3858af Mon Sep 17 00:00:00 2001 From: scaleway-bot Date: Mon, 4 Mar 2024 10:09:05 +0000 Subject: [PATCH] feat: update generated APIs --- .../clients/src/api/iam/v1alpha1/api.gen.ts | 23 ++++++++++++++++++ .../clients/src/api/iam/v1alpha1/index.gen.ts | 2 ++ .../src/api/iam/v1alpha1/marshalling.gen.ts | 24 +++++++++++++++++++ .../clients/src/api/iam/v1alpha1/types.gen.ts | 16 +++++++++++++ 4 files changed, 65 insertions(+) diff --git a/packages/clients/src/api/iam/v1alpha1/api.gen.ts b/packages/clients/src/api/iam/v1alpha1/api.gen.ts index 39706ff17..52d5dc870 100644 --- a/packages/clients/src/api/iam/v1alpha1/api.gen.ts +++ b/packages/clients/src/api/iam/v1alpha1/api.gen.ts @@ -13,6 +13,7 @@ import { marshalCreateAPIKeyRequest, marshalCreateApplicationRequest, marshalCreateGroupRequest, + marshalCreateJWTRequest, marshalCreatePolicyRequest, marshalCreateSSHKeyRequest, marshalCreateUserRequest, @@ -27,6 +28,7 @@ import { marshalUpdateUserRequest, unmarshalAPIKey, unmarshalApplication, + unmarshalEncodedJWT, unmarshalGroup, unmarshalJWT, unmarshalListAPIKeysResponse, @@ -56,6 +58,7 @@ import type { CreateAPIKeyRequest, CreateApplicationRequest, CreateGroupRequest, + CreateJWTRequest, CreatePolicyRequest, CreateSSHKeyRequest, CreateUserRequest, @@ -66,6 +69,7 @@ import type { DeletePolicyRequest, DeleteSSHKeyRequest, DeleteUserRequest, + EncodedJWT, GetAPIKeyRequest, GetApplicationRequest, GetGroupRequest, @@ -1088,6 +1092,25 @@ export class API extends ParentAPI { listJWTs = (request: Readonly = {}) => enrichForPagination('jwts', this.pageOfListJWTs, request) + /** + * Create a JWT. + * + * @param request - The request {@link CreateJWTRequest} + * @returns A Promise of EncodedJWT + */ + createJWT = (request: Readonly) => + this.client.fetch( + { + body: JSON.stringify( + marshalCreateJWTRequest(request, this.client.settings), + ), + headers: jsonContentHeaders, + method: 'POST', + path: `/iam/v1alpha1/jwts`, + }, + unmarshalEncodedJWT, + ) + /** * Get a JWT. * diff --git a/packages/clients/src/api/iam/v1alpha1/index.gen.ts b/packages/clients/src/api/iam/v1alpha1/index.gen.ts index d1d1c062c..20cde5922 100644 --- a/packages/clients/src/api/iam/v1alpha1/index.gen.ts +++ b/packages/clients/src/api/iam/v1alpha1/index.gen.ts @@ -11,6 +11,7 @@ export type { CreateAPIKeyRequest, CreateApplicationRequest, CreateGroupRequest, + CreateJWTRequest, CreatePolicyRequest, CreateSSHKeyRequest, CreateUserRequest, @@ -21,6 +22,7 @@ export type { DeletePolicyRequest, DeleteSSHKeyRequest, DeleteUserRequest, + EncodedJWT, GetAPIKeyRequest, GetApplicationRequest, GetGroupRequest, diff --git a/packages/clients/src/api/iam/v1alpha1/marshalling.gen.ts b/packages/clients/src/api/iam/v1alpha1/marshalling.gen.ts index e9f334ba6..fccc77f03 100644 --- a/packages/clients/src/api/iam/v1alpha1/marshalling.gen.ts +++ b/packages/clients/src/api/iam/v1alpha1/marshalling.gen.ts @@ -16,9 +16,11 @@ import type { CreateAPIKeyRequest, CreateApplicationRequest, CreateGroupRequest, + CreateJWTRequest, CreatePolicyRequest, CreateSSHKeyRequest, CreateUserRequest, + EncodedJWT, Group, JWT, ListAPIKeysResponse, @@ -237,6 +239,20 @@ export const unmarshalUser = (data: unknown): User => { } as User } +export const unmarshalEncodedJWT = (data: unknown): EncodedJWT => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'EncodedJWT' failed as data isn't a dictionary.`, + ) + } + + return { + jwt: data.jwt ? unmarshalJWT(data.jwt) : undefined, + renewToken: data.renew_token, + token: data.token, + } as EncodedJWT +} + export const unmarshalListAPIKeysResponse = ( data: unknown, ): ListAPIKeysResponse => { @@ -500,6 +516,14 @@ export const marshalCreateGroupRequest = ( tags: request.tags, }) +export const marshalCreateJWTRequest = ( + request: CreateJWTRequest, + defaults: DefaultValues, +): Record => ({ + referrer: request.referrer, + user_id: request.userId, +}) + const marshalRuleSpecs = ( request: RuleSpecs, defaults: DefaultValues, diff --git a/packages/clients/src/api/iam/v1alpha1/types.gen.ts b/packages/clients/src/api/iam/v1alpha1/types.gen.ts index f9d3c4b62..2780794db 100644 --- a/packages/clients/src/api/iam/v1alpha1/types.gen.ts +++ b/packages/clients/src/api/iam/v1alpha1/types.gen.ts @@ -462,6 +462,13 @@ export type CreateGroupRequest = { tags?: string[] } +export type CreateJWTRequest = { + /** ID of the user the JWT will be created for. */ + userId: string + /** Referrer of the JWT. */ + referrer: string +} + export type CreatePolicyRequest = { /** Name of the policy to create (max length is 64 characters). */ name?: string @@ -558,6 +565,15 @@ export type DeleteUserRequest = { userId: string } +export interface EncodedJWT { + /** The renewed JWT. */ + jwt?: JWT + /** The encoded token of the renewed JWT. */ + token: string + /** The encoded renew token. This token is necessary to renew the JWT. */ + renewToken: string +} + export type GetAPIKeyRequest = { /** Access key to search for. */ accessKey: string