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
53 changes: 53 additions & 0 deletions packages/clients/src/api/edge_services/v1alpha1/api.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {
marshalCreatePipelineRequest,
marshalCreatePurgeRequestRequest,
marshalCreateTLSStageRequest,
marshalSelectPlanRequest,
marshalUpdateBackendStageRequest,
marshalUpdateCacheStageRequest,
marshalUpdateDNSStageRequest,
Expand All @@ -37,9 +38,11 @@ import {
unmarshalListCacheStagesResponse,
unmarshalListDNSStagesResponse,
unmarshalListPipelinesResponse,
unmarshalListPlansResponse,
unmarshalListPurgeRequestsResponse,
unmarshalListTLSStagesResponse,
unmarshalPipeline,
unmarshalPlan,
unmarshalPurgeRequest,
unmarshalTLSStage,
} from './marshalling.gen'
Expand All @@ -61,11 +64,13 @@ import type {
DNSStage,
DeleteBackendStageRequest,
DeleteCacheStageRequest,
DeleteCurrentPlanRequest,
DeleteDNSStageRequest,
DeletePipelineRequest,
DeleteTLSStageRequest,
GetBackendStageRequest,
GetCacheStageRequest,
GetCurrentPlanRequest,
GetDNSStageRequest,
GetPipelineRequest,
GetPurgeRequestRequest,
Expand All @@ -78,12 +83,15 @@ import type {
ListDNSStagesResponse,
ListPipelinesRequest,
ListPipelinesResponse,
ListPlansResponse,
ListPurgeRequestsRequest,
ListPurgeRequestsResponse,
ListTLSStagesRequest,
ListTLSStagesResponse,
Pipeline,
Plan,
PurgeRequest,
SelectPlanRequest,
TLSStage,
UpdateBackendStageRequest,
UpdateCacheStageRequest,
Expand Down Expand Up @@ -781,4 +789,49 @@ export class API extends ParentAPI {
},
unmarshalCheckLbOriginResponse,
)

listPlans = () =>
this.client.fetch<ListPlansResponse>(
{
method: 'GET',
path: `/edge-services/v1alpha1/plans`,
},
unmarshalListPlansResponse,
)

selectPlan = (request: Readonly<SelectPlanRequest> = {}) =>
this.client.fetch<Plan>(
{
body: JSON.stringify(
marshalSelectPlanRequest(request, this.client.settings),
),
headers: jsonContentHeaders,
method: 'PATCH',
path: `/edge-services/v1alpha1/current-plan`,
},
unmarshalPlan,
)

getCurrentPlan = (request: Readonly<GetCurrentPlanRequest> = {}) =>
this.client.fetch<Plan>(
{
method: 'GET',
path: `/edge-services/v1alpha1/current-plan`,
urlParams: urlParams([
'project_id',
request.projectId ?? this.client.settings.defaultProjectId,
]),
},
unmarshalPlan,
)

deleteCurrentPlan = (request: Readonly<DeleteCurrentPlanRequest> = {}) =>
this.client.fetch<void>({
method: 'DELETE',
path: `/edge-services/v1alpha1/current-plan`,
urlParams: urlParams([
'project_id',
request.projectId ?? this.client.settings.defaultProjectId,
]),
})
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,13 @@ export type {
DNSStageType,
DeleteBackendStageRequest,
DeleteCacheStageRequest,
DeleteCurrentPlanRequest,
DeleteDNSStageRequest,
DeletePipelineRequest,
DeleteTLSStageRequest,
GetBackendStageRequest,
GetCacheStageRequest,
GetCurrentPlanRequest,
GetDNSStageRequest,
GetPipelineRequest,
GetPurgeRequestRequest,
Expand All @@ -44,6 +46,7 @@ export type {
ListPipelinesRequest,
ListPipelinesRequestOrderBy,
ListPipelinesResponse,
ListPlansResponse,
ListPurgeRequestsRequest,
ListPurgeRequestsRequestOrderBy,
ListPurgeRequestsResponse,
Expand All @@ -57,11 +60,15 @@ export type {
PipelineErrorStage,
PipelineErrorType,
PipelineStatus,
Plan,
PlanDetails,
PlanName,
PurgeRequest,
PurgeRequestStatus,
ScalewayLb,
ScalewayLbBackendConfig,
ScalewayS3BackendConfig,
SelectPlanRequest,
TLSSecret,
TLSSecretsConfig,
TLSStage,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,18 @@ import type {
ListCacheStagesResponse,
ListDNSStagesResponse,
ListPipelinesResponse,
ListPlansResponse,
ListPurgeRequestsResponse,
ListTLSStagesResponse,
Pipeline,
PipelineError,
Plan,
PlanDetails,
PurgeRequest,
ScalewayLb,
ScalewayLbBackendConfig,
ScalewayS3BackendConfig,
SelectPlanRequest,
TLSSecret,
TLSSecretsConfig,
TLSStage,
Expand Down Expand Up @@ -344,6 +348,35 @@ export const unmarshalListPipelinesResponse = (
} as ListPipelinesResponse
}

const unmarshalPlanDetails = (data: unknown): PlanDetails => {
if (!isJSONObject(data)) {
throw new TypeError(
`Unmarshalling the type 'PlanDetails' failed as data isn't a dictionary.`,
)
}

return {
packageGb: data.package_gb,
pipelineLimit: data.pipeline_limit,
planName: data.plan_name,
} as PlanDetails
}

export const unmarshalListPlansResponse = (
data: unknown,
): ListPlansResponse => {
if (!isJSONObject(data)) {
throw new TypeError(
`Unmarshalling the type 'ListPlansResponse' failed as data isn't a dictionary.`,
)
}

return {
plans: unmarshalArrayOfObject(data.plans, unmarshalPlanDetails),
totalCount: data.total_count,
} as ListPlansResponse
}

export const unmarshalListPurgeRequestsResponse = (
data: unknown,
): ListPurgeRequestsResponse => {
Expand Down Expand Up @@ -377,6 +410,18 @@ export const unmarshalListTLSStagesResponse = (
} as ListTLSStagesResponse
}

export const unmarshalPlan = (data: unknown): Plan => {
if (!isJSONObject(data)) {
throw new TypeError(
`Unmarshalling the type 'Plan' failed as data isn't a dictionary.`,
)
}

return {
planName: data.plan_name,
} as Plan
}

export const marshalCheckDomainRequest = (
request: CheckDomainRequest,
defaults: DefaultValues,
Expand Down Expand Up @@ -541,6 +586,14 @@ export const marshalCreateTLSStageRequest = (
]),
})

export const marshalSelectPlanRequest = (
request: SelectPlanRequest,
defaults: DefaultValues,
): Record<string, unknown> => ({
plan_name: request.planName,
project_id: request.projectId ?? defaults.defaultProjectId,
})

export const marshalUpdateBackendStageRequest = (
request: UpdateBackendStageRequest,
defaults: DefaultValues,
Expand Down
30 changes: 30 additions & 0 deletions packages/clients/src/api/edge_services/v1alpha1/types.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ export type PipelineStatus =
| 'pending'
| 'warning'

export type PlanName = 'unknown_name' | 'starter' | 'professional' | 'advanced'

export type PurgeRequestStatus = 'unknown_status' | 'done' | 'error' | 'pending'

export interface ScalewayLb {
Expand Down Expand Up @@ -240,6 +242,12 @@ export interface Pipeline {
dnsStageId?: string
}

export interface PlanDetails {
planName: PlanName
packageGb: number
pipelineLimit: number
}

export interface PurgeRequest {
/** ID of the purge request. */
id: string
Expand Down Expand Up @@ -469,6 +477,10 @@ export type DeleteCacheStageRequest = {
cacheStageId: string
}

export type DeleteCurrentPlanRequest = {
projectId?: string
}

export type DeleteDNSStageRequest = {
/** ID of the DNS stage to delete. */
dnsStageId: string
Expand All @@ -494,6 +506,10 @@ export type GetCacheStageRequest = {
cacheStageId: string
}

export type GetCurrentPlanRequest = {
projectId?: string
}

export type GetDNSStageRequest = {
/** ID of the requested DNS stage. */
dnsStageId: string
Expand Down Expand Up @@ -648,6 +664,11 @@ export interface ListPipelinesResponse {
totalCount: number
}

export interface ListPlansResponse {
totalCount: number
plans: PlanDetails[]
}

export type ListPurgeRequestsRequest = {
/** Sort order of purge requests in the response. */
orderBy?: ListPurgeRequestsRequestOrderBy
Expand Down Expand Up @@ -715,6 +736,15 @@ export interface ListTLSStagesResponse {
totalCount: number
}

export interface Plan {
planName: PlanName
}

export type SelectPlanRequest = {
projectId?: string
planName?: PlanName
}

export type UpdateBackendStageRequest = {
/** ID of the backend stage to update. */
backendStageId: string
Expand Down