From 65d38e19b53ce0812fc3d33bd4cab39fb8659ebf Mon Sep 17 00:00:00 2001 From: scaleway-bot Date: Thu, 16 Jan 2025 17:15:46 +0000 Subject: [PATCH] feat: update generated APIs --- .../clients/src/api/account/v3/index.gen.ts | 13 +++- .../clients/src/api/iam/v1alpha1/api.gen.ts | 60 +++++++++++++++++++ .../clients/src/api/iam/v1alpha1/index.gen.ts | 5 ++ .../src/api/iam/v1alpha1/marshalling.gen.ts | 37 +++++++++++- .../clients/src/api/iam/v1alpha1/types.gen.ts | 31 ++++++++-- .../api/iam/v1alpha1/validation-rules.gen.ts | 6 ++ 6 files changed, 145 insertions(+), 7 deletions(-) diff --git a/packages/clients/src/api/account/v3/index.gen.ts b/packages/clients/src/api/account/v3/index.gen.ts index 2760d6891..4ece97ed7 100644 --- a/packages/clients/src/api/account/v3/index.gen.ts +++ b/packages/clients/src/api/account/v3/index.gen.ts @@ -1,7 +1,18 @@ // This file was automatically generated. DO NOT EDIT. // If you have any remark or suggestion do not hesitate to open an issue. -export { ProjectAPI } from './api.gen' +export { ContractAPI, ProjectAPI } from './api.gen' export type { + CheckContractSignatureResponse, + Contract, + ContractApiCheckContractSignatureRequest, + ContractApiCreateContractSignatureRequest, + ContractApiDownloadContractSignatureRequest, + ContractApiListContractSignaturesRequest, + ContractApiValidateContractSignatureRequest, + ContractSignature, + ContractType, + ListContractSignaturesRequestOrderBy, + ListContractSignaturesResponse, ListProjectsRequestOrderBy, ListProjectsResponse, Project, diff --git a/packages/clients/src/api/iam/v1alpha1/api.gen.ts b/packages/clients/src/api/iam/v1alpha1/api.gen.ts index 6963a6e9d..c87d7debf 100644 --- a/packages/clients/src/api/iam/v1alpha1/api.gen.ts +++ b/packages/clients/src/api/iam/v1alpha1/api.gen.ts @@ -29,6 +29,7 @@ import { marshalUpdateUserPasswordRequest, marshalUpdateUserRequest, marshalUpdateUserUsernameRequest, + marshalValidateUserMFAOTPRequest, unmarshalAPIKey, unmarshalApplication, unmarshalEncodedJWT, @@ -47,12 +48,14 @@ import { unmarshalListSSHKeysResponse, unmarshalListUsersResponse, unmarshalLog, + unmarshalMFAOTP, unmarshalOrganizationSecuritySettings, unmarshalPolicy, unmarshalQuotum, unmarshalSSHKey, unmarshalSetRulesResponse, unmarshalUser, + unmarshalValidateUserMFAOTPResponse, } from './marshalling.gen' import type { APIKey, @@ -66,6 +69,7 @@ import type { CreateJWTRequest, CreatePolicyRequest, CreateSSHKeyRequest, + CreateUserMFAOTPRequest, CreateUserRequest, DeleteAPIKeyRequest, DeleteApplicationRequest, @@ -73,6 +77,7 @@ import type { DeleteJWTRequest, DeletePolicyRequest, DeleteSSHKeyRequest, + DeleteUserMFAOTPRequest, DeleteUserRequest, EncodedJWT, GetAPIKeyRequest, @@ -113,6 +118,7 @@ import type { ListUsersResponse, LockUserRequest, Log, + MFAOTP, OrganizationSecuritySettings, Policy, Quotum, @@ -132,6 +138,8 @@ import type { UpdateUserRequest, UpdateUserUsernameRequest, User, + ValidateUserMFAOTPRequest, + ValidateUserMFAOTPResponse, } from './types.gen' const jsonContentHeaders = { @@ -397,6 +405,58 @@ export class API extends ParentAPI { unmarshalUser, ) + /** + * Create a MFA OTP. Private Beta feature.. Create a MFA OTP. Private Beta + * feature. + * + * @param request - The request {@link CreateUserMFAOTPRequest} + * @returns A Promise of MFAOTP + */ + createUserMFAOTP = (request: Readonly) => + this.client.fetch( + { + body: '{}', + headers: jsonContentHeaders, + method: 'POST', + path: `/iam/v1alpha1/users/${validatePathParam('userId', request.userId)}/mfa-otp`, + }, + unmarshalMFAOTP, + ) + + /** + * Validate a MFA OTP. Private Beta feature.. Validate a MFA OTP. Private Beta + * feature. + * + * @param request - The request {@link ValidateUserMFAOTPRequest} + * @returns A Promise of ValidateUserMFAOTPResponse + */ + validateUserMFAOTP = (request: Readonly) => + this.client.fetch( + { + body: JSON.stringify( + marshalValidateUserMFAOTPRequest(request, this.client.settings), + ), + headers: jsonContentHeaders, + method: 'POST', + path: `/iam/v1alpha1/users/${validatePathParam('userId', request.userId)}/validate-mfa-otp`, + }, + unmarshalValidateUserMFAOTPResponse, + ) + + /** + * Delete a MFA OTP. Private Beta feature.. Delete a MFA OTP. Private Beta + * feature. + * + * @param request - The request {@link DeleteUserMFAOTPRequest} + */ + deleteUserMFAOTP = (request: Readonly) => + this.client.fetch({ + body: '{}', + headers: jsonContentHeaders, + method: 'DELETE', + path: `/iam/v1alpha1/users/${validatePathParam('userId', request.userId)}/mfa-otp`, + }) + /** * Lock a member. Lock a member. A locked member cannot log in or use API keys * until the locked status is removed. Private Beta feature. diff --git a/packages/clients/src/api/iam/v1alpha1/index.gen.ts b/packages/clients/src/api/iam/v1alpha1/index.gen.ts index d25177e5d..0e1b20a7f 100644 --- a/packages/clients/src/api/iam/v1alpha1/index.gen.ts +++ b/packages/clients/src/api/iam/v1alpha1/index.gen.ts @@ -14,6 +14,7 @@ export type { CreateJWTRequest, CreatePolicyRequest, CreateSSHKeyRequest, + CreateUserMFAOTPRequest, CreateUserRequest, CreateUserRequestMember, DeleteAPIKeyRequest, @@ -22,6 +23,7 @@ export type { DeleteJWTRequest, DeletePolicyRequest, DeleteSSHKeyRequest, + DeleteUserMFAOTPRequest, DeleteUserRequest, EncodedJWT, GetAPIKeyRequest, @@ -76,6 +78,7 @@ export type { Log, LogAction, LogResourceType, + MFAOTP, OrganizationSecuritySettings, PermissionSet, PermissionSetScopeType, @@ -101,5 +104,7 @@ export type { User, UserStatus, UserType, + ValidateUserMFAOTPRequest, + ValidateUserMFAOTPResponse, } from './types.gen' export * as ValidationRules from './validation-rules.gen' diff --git a/packages/clients/src/api/iam/v1alpha1/marshalling.gen.ts b/packages/clients/src/api/iam/v1alpha1/marshalling.gen.ts index 1a1daba91..b3929d943 100644 --- a/packages/clients/src/api/iam/v1alpha1/marshalling.gen.ts +++ b/packages/clients/src/api/iam/v1alpha1/marshalling.gen.ts @@ -38,6 +38,7 @@ import type { ListSSHKeysResponse, ListUsersResponse, Log, + MFAOTP, OrganizationSecuritySettings, PermissionSet, Policy, @@ -59,6 +60,8 @@ import type { UpdateUserRequest, UpdateUserUsernameRequest, User, + ValidateUserMFAOTPRequest, + ValidateUserMFAOTPResponse, } from './types.gen' export const unmarshalJWT = (data: unknown): JWT => { @@ -506,6 +509,18 @@ export const unmarshalListUsersResponse = ( } as ListUsersResponse } +export const unmarshalMFAOTP = (data: unknown): MFAOTP => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'MFAOTP' failed as data isn't a dictionary.`, + ) + } + + return { + secret: data.secret, + } as MFAOTP +} + export const unmarshalOrganizationSecuritySettings = ( data: unknown, ): OrganizationSecuritySettings => { @@ -534,6 +549,20 @@ export const unmarshalSetRulesResponse = (data: unknown): SetRulesResponse => { } as SetRulesResponse } +export const unmarshalValidateUserMFAOTPResponse = ( + data: unknown, +): ValidateUserMFAOTPResponse => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'ValidateUserMFAOTPResponse' failed as data isn't a dictionary.`, + ) + } + + return { + recoveryCodes: data.recovery_codes, + } as ValidateUserMFAOTPResponse +} + export const marshalAddGroupMemberRequest = ( request: AddGroupMemberRequest, defaults: DefaultValues, @@ -752,7 +781,6 @@ export const marshalUpdateUserPasswordRequest = ( defaults: DefaultValues, ): Record => ({ password: request.password, - send_email: request.sendEmail, }) export const marshalUpdateUserRequest = ( @@ -769,3 +797,10 @@ export const marshalUpdateUserUsernameRequest = ( ): Record => ({ username: request.username, }) + +export const marshalValidateUserMFAOTPRequest = ( + request: ValidateUserMFAOTPRequest, + defaults: DefaultValues, +): Record => ({ + one_time_password: request.oneTimePassword, +}) diff --git a/packages/clients/src/api/iam/v1alpha1/types.gen.ts b/packages/clients/src/api/iam/v1alpha1/types.gen.ts index 0aff51123..0ac5b1267 100644 --- a/packages/clients/src/api/iam/v1alpha1/types.gen.ts +++ b/packages/clients/src/api/iam/v1alpha1/types.gen.ts @@ -586,6 +586,11 @@ export type CreateSSHKeyRequest = { projectId?: string } +export type CreateUserMFAOTPRequest = { + /** User ID of the MFA OTP. */ + userId: string +} + export type CreateUserRequest = { /** ID of the Organization. */ organizationId?: string @@ -634,6 +639,11 @@ export type DeleteSSHKeyRequest = { sshKeyId: string } +export type DeleteUserMFAOTPRequest = { + /** User ID of the MFA OTP. */ + userId: string +} + export type DeleteUserRequest = { /** ID of the user to delete. */ userId: string @@ -995,6 +1005,10 @@ export type LockUserRequest = { userId: string } +export interface MFAOTP { + secret: string +} + export interface OrganizationSecuritySettings { /** Defines whether password renewal is enforced during first login. */ enforcePasswordRenewal: boolean @@ -1141,11 +1155,6 @@ export type UpdateUserPasswordRequest = { userId: string /** The new password. */ password: string - /** - * Whether or not to send an email alerting the user their password has - * changed. - */ - sendEmail: boolean } export type UpdateUserRequest = { @@ -1163,3 +1172,15 @@ export type UpdateUserUsernameRequest = { /** The new username. */ username: string } + +export type ValidateUserMFAOTPRequest = { + /** User ID of the MFA OTP. */ + userId: string + /** A password generated using the OTP. */ + oneTimePassword: string +} + +export interface ValidateUserMFAOTPResponse { + /** List of recovery codes usable for this OTP method. */ + recoveryCodes: string[] +} diff --git a/packages/clients/src/api/iam/v1alpha1/validation-rules.gen.ts b/packages/clients/src/api/iam/v1alpha1/validation-rules.gen.ts index 057845334..d05e1db5e 100644 --- a/packages/clients/src/api/iam/v1alpha1/validation-rules.gen.ts +++ b/packages/clients/src/api/iam/v1alpha1/validation-rules.gen.ts @@ -269,3 +269,9 @@ export const UpdateUserUsernameRequest = { pattern: /^[a-zA-Z0-9._-]+$/, }, } + +export const ValidateUserMFAOTPRequest = { + oneTimePassword: { + pattern: /^[0-9]{6}$/, + }, +}