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
94 changes: 0 additions & 94 deletions packages/clients/src/api/account/v2/api.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -151,86 +139,4 @@ export class AccountV2GenAPI extends API {
},
unmarshalProject,
)

protected pageOfListMFAOTPs = (request: Readonly<ListMFAOTPsRequest>) =>
this.client.fetch<ListMFAOTPsResponse>(
{
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<ListMFAOTPsRequest>) =>
enrichForPagination('mfaOtps', this.pageOfListMFAOTPs, request)

/**
* Create MFA OTP
*
* @param request - The request {@link CreateMFAOTPRequest}
* @returns A Promise of MFAOTP
*/
createMFAOTP = (request: Readonly<CreateMFAOTPRequest>) =>
this.client.fetch<MFAOTP>(
{
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<ValidateMFAOTPRequest>) =>
this.client.fetch<ValidateMFAOTPResponse>(
{
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<DeleteMFAOTPRequest>) =>
this.client.fetch<void>({
method: 'DELETE',
path: `/account/v2/mfa/otps/${validatePathParam(
'mfaOtpId',
request.mfaOtpId,
)}`,
})
}
52 changes: 0 additions & 52 deletions packages/clients/src/api/account/v2/marshalling.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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(
Expand All @@ -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<string, unknown> => ({
account_root_user_id: request.accountRootUserId,
})

export const marshalCreateProjectRequest = (
request: CreateProjectRequest,
defaults: DefaultValues,
Expand All @@ -104,10 +59,3 @@ export const marshalUpdateProjectRequest = (
description: request.description,
name: request.name,
})

export const marshalValidateMFAOTPRequest = (
request: ValidateMFAOTPRequest,
defaults: DefaultValues,
): Record<string, unknown> => ({
otp: request.otp,
})
50 changes: 0 additions & 50 deletions packages/clients/src/api/account/v2/types.gen.ts
Original file line number Diff line number Diff line change
@@ -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<MFAOTP>
}

/** List projects response */
export interface ListProjectsResponse {
/** The total number of projects */
Expand All @@ -25,12 +15,6 @@ export interface ListProjectsResponse {
projects: Array<Project>
}

/** Mfaotp */
export interface MFAOTP {
/** The ID of the MFA OTP */
id: string
}

/** Project */
export interface Project {
/** The ID of the project */
Expand All @@ -47,12 +31,6 @@ export interface Project {
description: string
}

/** Validate mfaotp response */
export interface ValidateMFAOTPResponse {
/** The backup codes of the MFA OTP */
backupCodes: Array<string>
}

export type CreateProjectRequest = {
/** The name of the project */
name: string
Expand Down Expand Up @@ -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
}