From ffcac499df7763051cfe7f6a1501bde187a18b66 Mon Sep 17 00:00:00 2001 From: scaleway-bot Date: Mon, 21 Nov 2022 15:56:12 +0000 Subject: [PATCH] feat: update generated APIs --- .../clients/src/api/account/v2/api.gen.ts | 94 ------------------- .../src/api/account/v2/marshalling.gen.ts | 52 ---------- .../clients/src/api/account/v2/types.gen.ts | 50 ---------- 3 files changed, 196 deletions(-) diff --git a/packages/clients/src/api/account/v2/api.gen.ts b/packages/clients/src/api/account/v2/api.gen.ts index 2f11a7641..fc70fdb50 100644 --- a/packages/clients/src/api/account/v2/api.gen.ts +++ b/packages/clients/src/api/account/v2/api.gen.ts @@ -7,31 +7,19 @@ import { validatePathParam, } from '../../../bridge' import { - marshalCreateMFAOTPRequest, marshalCreateProjectRequest, marshalUpdateProjectRequest, - marshalValidateMFAOTPRequest, - unmarshalListMFAOTPsResponse, unmarshalListProjectsResponse, - unmarshalMFAOTP, unmarshalProject, - unmarshalValidateMFAOTPResponse, } from './marshalling.gen' import type { - CreateMFAOTPRequest, CreateProjectRequest, - DeleteMFAOTPRequest, DeleteProjectRequest, GetProjectRequest, - ListMFAOTPsRequest, - ListMFAOTPsResponse, ListProjectsRequest, ListProjectsResponse, - MFAOTP, Project, UpdateProjectRequest, - ValidateMFAOTPRequest, - ValidateMFAOTPResponse, } from './types.gen' const jsonContentHeaders = { @@ -151,86 +139,4 @@ export class AccountV2GenAPI extends API { }, unmarshalProject, ) - - protected pageOfListMFAOTPs = (request: Readonly) => - this.client.fetch( - { - method: 'GET', - path: `/account/v2/mfa/otps`, - urlParams: urlParams( - ['account_root_user_id', request.accountRootUserId], - ['order_by', request.orderBy ?? 'created_at_asc'], - ['page', request.page], - [ - 'page_size', - request.pageSize ?? this.client.settings.defaultPageSize, - ], - ), - }, - unmarshalListMFAOTPsResponse, - ) - - /** - * List MFA OTPs - * - * @param request - The request {@link ListMFAOTPsRequest} - * @returns A Promise of ListMFAOTPsResponse - */ - listMFAOTPs = (request: Readonly) => - enrichForPagination('mfaOtps', this.pageOfListMFAOTPs, request) - - /** - * Create MFA OTP - * - * @param request - The request {@link CreateMFAOTPRequest} - * @returns A Promise of MFAOTP - */ - createMFAOTP = (request: Readonly) => - this.client.fetch( - { - body: JSON.stringify( - marshalCreateMFAOTPRequest(request, this.client.settings), - ), - headers: jsonContentHeaders, - method: 'POST', - path: `/account/v2/mfa/otps`, - }, - unmarshalMFAOTP, - ) - - /** - * Validate MFA OTP - * - * @param request - The request {@link ValidateMFAOTPRequest} - * @returns A Promise of ValidateMFAOTPResponse - */ - validateMFAOTP = (request: Readonly) => - this.client.fetch( - { - body: JSON.stringify( - marshalValidateMFAOTPRequest(request, this.client.settings), - ), - headers: jsonContentHeaders, - method: 'POST', - path: `/account/v2/mfa/otps/${validatePathParam( - 'mfaOtpId', - request.mfaOtpId, - )}/validate`, - }, - unmarshalValidateMFAOTPResponse, - ) - - /** - * Delete MFA OTP - * - * @param request - The request {@link DeleteMFAOTPRequest} - */ - deleteMFAOTP = (request: Readonly) => - this.client.fetch({ - method: 'DELETE', - path: `/account/v2/mfa/otps/${validatePathParam( - 'mfaOtpId', - request.mfaOtpId, - )}`, - }) } diff --git a/packages/clients/src/api/account/v2/marshalling.gen.ts b/packages/clients/src/api/account/v2/marshalling.gen.ts index 770b142b8..d62873b86 100644 --- a/packages/clients/src/api/account/v2/marshalling.gen.ts +++ b/packages/clients/src/api/account/v2/marshalling.gen.ts @@ -7,27 +7,12 @@ import { } from '../../../bridge' import type { DefaultValues } from '../../../bridge' import type { - CreateMFAOTPRequest, CreateProjectRequest, - ListMFAOTPsResponse, ListProjectsResponse, - MFAOTP, Project, UpdateProjectRequest, - ValidateMFAOTPRequest, - ValidateMFAOTPResponse, } from './types.gen' -export const unmarshalMFAOTP = (data: unknown) => { - if (!isJSONObject(data)) { - throw new TypeError( - `Unmarshalling the type 'MFAOTP' failed as data isn't a dictionary.`, - ) - } - - return { id: data.id } as MFAOTP -} - export const unmarshalProject = (data: unknown) => { if (!isJSONObject(data)) { throw new TypeError( @@ -45,19 +30,6 @@ export const unmarshalProject = (data: unknown) => { } as Project } -export const unmarshalListMFAOTPsResponse = (data: unknown) => { - if (!isJSONObject(data)) { - throw new TypeError( - `Unmarshalling the type 'ListMFAOTPsResponse' failed as data isn't a dictionary.`, - ) - } - - return { - mfaOtps: unmarshalArrayOfObject(data.mfa_otps, unmarshalMFAOTP), - totalCount: data.total_count, - } as ListMFAOTPsResponse -} - export const unmarshalListProjectsResponse = (data: unknown) => { if (!isJSONObject(data)) { throw new TypeError( @@ -71,23 +43,6 @@ export const unmarshalListProjectsResponse = (data: unknown) => { } as ListProjectsResponse } -export const unmarshalValidateMFAOTPResponse = (data: unknown) => { - if (!isJSONObject(data)) { - throw new TypeError( - `Unmarshalling the type 'ValidateMFAOTPResponse' failed as data isn't a dictionary.`, - ) - } - - return { backupCodes: data.backup_codes } as ValidateMFAOTPResponse -} - -export const marshalCreateMFAOTPRequest = ( - request: CreateMFAOTPRequest, - defaults: DefaultValues, -): Record => ({ - account_root_user_id: request.accountRootUserId, -}) - export const marshalCreateProjectRequest = ( request: CreateProjectRequest, defaults: DefaultValues, @@ -104,10 +59,3 @@ export const marshalUpdateProjectRequest = ( description: request.description, name: request.name, }) - -export const marshalValidateMFAOTPRequest = ( - request: ValidateMFAOTPRequest, - defaults: DefaultValues, -): Record => ({ - otp: request.otp, -}) diff --git a/packages/clients/src/api/account/v2/types.gen.ts b/packages/clients/src/api/account/v2/types.gen.ts index 728be576d..af61fb1d8 100644 --- a/packages/clients/src/api/account/v2/types.gen.ts +++ b/packages/clients/src/api/account/v2/types.gen.ts @@ -1,22 +1,12 @@ // This file was automatically generated. DO NOT EDIT. // If you have any remark or suggestion do not hesitate to open an issue. -export type ListMFAOTPsRequestOrderBy = 'created_at_asc' | 'created_at_desc' - export type ListProjectsRequestOrderBy = | 'created_at_asc' | 'created_at_desc' | 'name_asc' | 'name_desc' -/** List mfaot ps response */ -export interface ListMFAOTPsResponse { - /** The total number of MFA OTPs */ - totalCount: number - /** The paginated returned MFA OTPs */ - mfaOtps: Array -} - /** List projects response */ export interface ListProjectsResponse { /** The total number of projects */ @@ -25,12 +15,6 @@ export interface ListProjectsResponse { projects: Array } -/** Mfaotp */ -export interface MFAOTP { - /** The ID of the MFA OTP */ - id: string -} - /** Project */ export interface Project { /** The ID of the project */ @@ -47,12 +31,6 @@ export interface Project { description: string } -/** Validate mfaotp response */ -export interface ValidateMFAOTPResponse { - /** The backup codes of the MFA OTP */ - backupCodes: Array -} - export type CreateProjectRequest = { /** The name of the project */ name: string @@ -95,31 +73,3 @@ export type UpdateProjectRequest = { /** The description of the project */ description?: string } - -export type ListMFAOTPsRequest = { - /** The page number for the returned MFA OTPs */ - page?: number - /** The maximum number of MFA OTP per page */ - pageSize?: number - /** The sort order of the returned MFA OTPs */ - orderBy?: ListMFAOTPsRequestOrderBy - /** Filter out by a account root user ID */ - accountRootUserId: string -} - -export type CreateMFAOTPRequest = { - /** The account root user ID of the MFA OTP */ - accountRootUserId: string -} - -export type ValidateMFAOTPRequest = { - /** The MFA OTP ID */ - mfaOtpId: string - /** The code of the MFA OTP */ - otp: string -} - -export type DeleteMFAOTPRequest = { - /** The MFA OTP ID */ - mfaOtpId: string -}