diff --git a/packages/clients/src/api/edge_services/index.gen.ts b/packages/clients/src/api/edge_services/index.gen.ts index 6dec29b44..72d281d6b 100644 --- a/packages/clients/src/api/edge_services/index.gen.ts +++ b/packages/clients/src/api/edge_services/index.gen.ts @@ -4,3 +4,4 @@ */ export * as v1alpha1 from './v1alpha1/index.gen' +export * as v1beta1 from './v1beta1/index.gen' diff --git a/packages/clients/src/api/edge_services/v1beta1/api.gen.ts b/packages/clients/src/api/edge_services/v1beta1/api.gen.ts new file mode 100644 index 000000000..353e85121 --- /dev/null +++ b/packages/clients/src/api/edge_services/v1beta1/api.gen.ts @@ -0,0 +1,1235 @@ +// This file was automatically generated. DO NOT EDIT. +// If you have any remark or suggestion do not hesitate to open an issue. +import { + API as ParentAPI, + enrichForPagination, + urlParams, + validatePathParam, + waitForResource, +} from '../../../bridge' +import type { WaitForOptions } from '../../../bridge' +import { + PIPELINE_TRANSIENT_STATUSES, + PURGE_REQUEST_TRANSIENT_STATUSES, +} from './content.gen' +import { + marshalAddRouteRulesRequest, + marshalCheckDomainRequest, + marshalCheckLbOriginRequest, + marshalCheckPEMChainRequest, + marshalCreateBackendStageRequest, + marshalCreateCacheStageRequest, + marshalCreateDNSStageRequest, + marshalCreatePipelineRequest, + marshalCreatePurgeRequestRequest, + marshalCreateRouteStageRequest, + marshalCreateTLSStageRequest, + marshalCreateWafStageRequest, + marshalSelectPlanRequest, + marshalSetHeadStageRequest, + marshalSetRouteRulesRequest, + marshalUpdateBackendStageRequest, + marshalUpdateCacheStageRequest, + marshalUpdateDNSStageRequest, + marshalUpdatePipelineRequest, + marshalUpdateRouteStageRequest, + marshalUpdateTLSStageRequest, + marshalUpdateWafStageRequest, + unmarshalAddRouteRulesResponse, + unmarshalBackendStage, + unmarshalCacheStage, + unmarshalCheckDomainResponse, + unmarshalCheckLbOriginResponse, + unmarshalCheckPEMChainResponse, + unmarshalDNSStage, + unmarshalGetBillingResponse, + unmarshalHeadStageResponse, + unmarshalListBackendStagesResponse, + unmarshalListCacheStagesResponse, + unmarshalListDNSStagesResponse, + unmarshalListHeadStagesResponse, + unmarshalListPipelinesResponse, + unmarshalListPipelinesWithStagesResponse, + unmarshalListPlansResponse, + unmarshalListPurgeRequestsResponse, + unmarshalListRouteRulesResponse, + unmarshalListRouteStagesResponse, + unmarshalListTLSStagesResponse, + unmarshalListWafStagesResponse, + unmarshalPipeline, + unmarshalPlan, + unmarshalPurgeRequest, + unmarshalRouteStage, + unmarshalSetRouteRulesResponse, + unmarshalTLSStage, + unmarshalWafStage, +} from './marshalling.gen' +import type { + AddRouteRulesRequest, + AddRouteRulesResponse, + BackendStage, + CacheStage, + CheckDomainRequest, + CheckDomainResponse, + CheckLbOriginRequest, + CheckLbOriginResponse, + CheckPEMChainRequest, + CheckPEMChainResponse, + CreateBackendStageRequest, + CreateCacheStageRequest, + CreateDNSStageRequest, + CreatePipelineRequest, + CreatePurgeRequestRequest, + CreateRouteStageRequest, + CreateTLSStageRequest, + CreateWafStageRequest, + DNSStage, + DeleteBackendStageRequest, + DeleteCacheStageRequest, + DeleteCurrentPlanRequest, + DeleteDNSStageRequest, + DeletePipelineRequest, + DeleteRouteStageRequest, + DeleteTLSStageRequest, + DeleteWafStageRequest, + GetBackendStageRequest, + GetBillingRequest, + GetBillingResponse, + GetCacheStageRequest, + GetCurrentPlanRequest, + GetDNSStageRequest, + GetPipelineRequest, + GetPurgeRequestRequest, + GetRouteStageRequest, + GetTLSStageRequest, + GetWafStageRequest, + HeadStageResponse, + ListBackendStagesRequest, + ListBackendStagesResponse, + ListCacheStagesRequest, + ListCacheStagesResponse, + ListDNSStagesRequest, + ListDNSStagesResponse, + ListHeadStagesRequest, + ListHeadStagesResponse, + ListPipelinesRequest, + ListPipelinesResponse, + ListPipelinesWithStagesRequest, + ListPipelinesWithStagesResponse, + ListPlansResponse, + ListPurgeRequestsRequest, + ListPurgeRequestsResponse, + ListRouteRulesRequest, + ListRouteRulesResponse, + ListRouteStagesRequest, + ListRouteStagesResponse, + ListTLSStagesRequest, + ListTLSStagesResponse, + ListWafStagesRequest, + ListWafStagesResponse, + Pipeline, + Plan, + PurgeRequest, + RouteStage, + SearchBackendStagesRequest, + SelectPlanRequest, + SetHeadStageRequest, + SetRouteRulesRequest, + SetRouteRulesResponse, + TLSStage, + UpdateBackendStageRequest, + UpdateCacheStageRequest, + UpdateDNSStageRequest, + UpdatePipelineRequest, + UpdateRouteStageRequest, + UpdateTLSStageRequest, + UpdateWafStageRequest, + WafStage, +} from './types.gen' + +const jsonContentHeaders = { + 'Content-Type': 'application/json; charset=utf-8', +} + +/** Edge Services API. */ +export class API extends ParentAPI { + protected pageOfListPipelines = ( + request: Readonly = {}, + ) => + this.client.fetch( + { + method: 'GET', + path: `/edge-services/v1beta1/pipelines`, + urlParams: urlParams( + ['has_backend_stage_lb', request.hasBackendStageLb], + ['name', request.name], + ['order_by', request.orderBy], + ['organization_id', request.organizationId], + ['page', request.page], + [ + 'page_size', + request.pageSize ?? this.client.settings.defaultPageSize, + ], + ['project_id', request.projectId], + ), + }, + unmarshalListPipelinesResponse, + ) + + /** + * List pipelines. List all pipelines, for a Scaleway Organization or Scaleway + * Project. By default, the pipelines returned in the list are ordered by + * creation date in ascending order, though this can be modified via the + * `order_by` field. + * + * @param request - The request {@link ListPipelinesRequest} + * @returns A Promise of ListPipelinesResponse + */ + listPipelines = (request: Readonly = {}) => + enrichForPagination('pipelines', this.pageOfListPipelines, request) + + /** + * Create pipeline. Create a new pipeline. You must specify a `dns_stage_id` + * to form a stage-chain that goes all the way to the backend stage (origin), + * so the HTTP request will be processed according to the stages you created. + * + * @param request - The request {@link CreatePipelineRequest} + * @returns A Promise of Pipeline + */ + createPipeline = (request: Readonly) => + this.client.fetch( + { + body: JSON.stringify( + marshalCreatePipelineRequest(request, this.client.settings), + ), + headers: jsonContentHeaders, + method: 'POST', + path: `/edge-services/v1beta1/pipelines`, + }, + unmarshalPipeline, + ) + + /** + * Get pipeline. Retrieve information about an existing pipeline, specified by + * its `pipeline_id`. Its full details, including errors, are returned in the + * response object. + * + * @param request - The request {@link GetPipelineRequest} + * @returns A Promise of Pipeline + */ + getPipeline = (request: Readonly) => + this.client.fetch( + { + method: 'GET', + path: `/edge-services/v1beta1/pipelines/${validatePathParam('pipelineId', request.pipelineId)}`, + }, + unmarshalPipeline, + ) + + /** + * Waits for {@link Pipeline} to be in a final state. + * + * @param request - The request {@link GetPipelineRequest} + * @param options - The waiting options + * @returns A Promise of Pipeline + */ + waitForPipeline = ( + request: Readonly, + options?: Readonly>, + ) => + waitForResource( + options?.stop ?? + (res => + Promise.resolve(!PIPELINE_TRANSIENT_STATUSES.includes(res.status))), + this.getPipeline, + request, + options, + ) + + protected pageOfListPipelinesWithStages = ( + request: Readonly = {}, + ) => + this.client.fetch( + { + method: 'GET', + path: `/edge-services/v1beta1/pipelines-stages`, + urlParams: urlParams( + ['name', request.name], + ['order_by', request.orderBy], + ['organization_id', request.organizationId], + ['page', request.page], + [ + 'page_size', + request.pageSize ?? this.client.settings.defaultPageSize, + ], + ['project_id', request.projectId], + ), + }, + unmarshalListPipelinesWithStagesResponse, + ) + + listPipelinesWithStages = ( + request: Readonly = {}, + ) => + enrichForPagination( + 'pipelines', + this.pageOfListPipelinesWithStages, + request, + ) + + /** + * Update pipeline. Update the parameters of an existing pipeline, specified + * by its `pipeline_id`. Parameters which can be updated include the `name`, + * `description` and `dns_stage_id`. + * + * @param request - The request {@link UpdatePipelineRequest} + * @returns A Promise of Pipeline + */ + updatePipeline = (request: Readonly) => + this.client.fetch( + { + body: JSON.stringify( + marshalUpdatePipelineRequest(request, this.client.settings), + ), + headers: jsonContentHeaders, + method: 'PATCH', + path: `/edge-services/v1beta1/pipelines/${validatePathParam('pipelineId', request.pipelineId)}`, + }, + unmarshalPipeline, + ) + + /** + * Delete pipeline. Delete an existing pipeline, specified by its + * `pipeline_id`. Deleting a pipeline is permanent, and cannot be undone. Note + * that all stages linked to the pipeline are also deleted. + * + * @param request - The request {@link DeletePipelineRequest} + */ + deletePipeline = (request: Readonly) => + this.client.fetch({ + method: 'DELETE', + path: `/edge-services/v1beta1/pipelines/${validatePathParam('pipelineId', request.pipelineId)}`, + }) + + protected pageOfListHeadStages = (request: Readonly) => + this.client.fetch( + { + method: 'GET', + path: `/edge-services/v1beta1/pipelines/${validatePathParam('pipelineId', request.pipelineId)}/head-stages`, + urlParams: urlParams( + ['page', request.page], + [ + 'page_size', + request.pageSize ?? this.client.settings.defaultPageSize, + ], + ), + }, + unmarshalListHeadStagesResponse, + ) + + listHeadStages = (request: Readonly) => + enrichForPagination('headStages', this.pageOfListHeadStages, request) + + /** + * Configure a entry point to your pipeline. You must specify a `head stage` + * to form a stage-chain that goes all the way to the backend stage (origin), + * so the HTTP request will be processed according to the stages you created.. + * You must specify either a `add_new_head_stage` (to add a new head stage), + * `remove_head_stage` (to remove a head stage) or `swap_head_stage` (to + * replace a head stage). + * + * @param request - The request {@link SetHeadStageRequest} + * @returns A Promise of HeadStageResponse + */ + setHeadStage = (request: Readonly) => + this.client.fetch( + { + body: JSON.stringify( + marshalSetHeadStageRequest(request, this.client.settings), + ), + headers: jsonContentHeaders, + method: 'POST', + path: `/edge-services/v1beta1/pipelines/${validatePathParam('pipelineId', request.pipelineId)}/set-head-stage`, + }, + unmarshalHeadStageResponse, + ) + + protected pageOfListDNSStages = (request: Readonly) => + this.client.fetch( + { + method: 'GET', + path: `/edge-services/v1beta1/pipelines/${validatePathParam('pipelineId', request.pipelineId)}/dns-stages`, + urlParams: urlParams( + ['fqdn', request.fqdn], + ['order_by', request.orderBy], + ['page', request.page], + [ + 'page_size', + request.pageSize ?? this.client.settings.defaultPageSize, + ], + ), + }, + unmarshalListDNSStagesResponse, + ) + + /** + * List DNS stages. List all DNS stages, for a Scaleway Organization or + * Scaleway Project. By default, the DNS stages returned in the list are + * ordered by creation date in ascending order, though this can be modified + * via the `order_by` field. + * + * @param request - The request {@link ListDNSStagesRequest} + * @returns A Promise of ListDNSStagesResponse + */ + listDNSStages = (request: Readonly) => + enrichForPagination('stages', this.pageOfListDNSStages, request) + + /** + * Create DNS stage. Create a new DNS stage. You must specify the `fqdns` + * field to customize the domain endpoint, using a domain you already own. + * + * @param request - The request {@link CreateDNSStageRequest} + * @returns A Promise of DNSStage + */ + createDNSStage = (request: Readonly) => + this.client.fetch( + { + body: JSON.stringify( + marshalCreateDNSStageRequest(request, this.client.settings), + ), + headers: jsonContentHeaders, + method: 'POST', + path: `/edge-services/v1beta1/pipelines/${validatePathParam('pipelineId', request.pipelineId)}/dns-stages`, + }, + unmarshalDNSStage, + ) + + /** + * Get DNS stage. Retrieve information about an existing DNS stage, specified + * by its `dns_stage_id`. Its full details, including FQDNs, are returned in + * the response object. + * + * @param request - The request {@link GetDNSStageRequest} + * @returns A Promise of DNSStage + */ + getDNSStage = (request: Readonly) => + this.client.fetch( + { + method: 'GET', + path: `/edge-services/v1beta1/dns-stages/${validatePathParam('dnsStageId', request.dnsStageId)}`, + }, + unmarshalDNSStage, + ) + + /** + * Update DNS stage. Update the parameters of an existing DNS stage, specified + * by its `dns_stage_id`. + * + * @param request - The request {@link UpdateDNSStageRequest} + * @returns A Promise of DNSStage + */ + updateDNSStage = (request: Readonly) => + this.client.fetch( + { + body: JSON.stringify( + marshalUpdateDNSStageRequest(request, this.client.settings), + ), + headers: jsonContentHeaders, + method: 'PATCH', + path: `/edge-services/v1beta1/dns-stages/${validatePathParam('dnsStageId', request.dnsStageId)}`, + }, + unmarshalDNSStage, + ) + + /** + * Delete DNS stage. Delete an existing DNS stage, specified by its + * `dns_stage_id`. Deleting a DNS stage is permanent, and cannot be undone. + * + * @param request - The request {@link DeleteDNSStageRequest} + */ + deleteDNSStage = (request: Readonly) => + this.client.fetch({ + method: 'DELETE', + path: `/edge-services/v1beta1/dns-stages/${validatePathParam('dnsStageId', request.dnsStageId)}`, + }) + + protected pageOfListTLSStages = (request: Readonly) => + this.client.fetch( + { + method: 'GET', + path: `/edge-services/v1beta1/pipelines/${validatePathParam('pipelineId', request.pipelineId)}/tls-stages`, + urlParams: urlParams( + ['order_by', request.orderBy], + ['page', request.page], + [ + 'page_size', + request.pageSize ?? this.client.settings.defaultPageSize, + ], + ['secret_id', request.secretId], + ['secret_region', request.secretRegion], + ), + }, + unmarshalListTLSStagesResponse, + ) + + /** + * List TLS stages. List all TLS stages, for a Scaleway Organization or + * Scaleway Project. By default, the TLS stages returned in the list are + * ordered by creation date in ascending order, though this can be modified + * via the `order_by` field. + * + * @param request - The request {@link ListTLSStagesRequest} + * @returns A Promise of ListTLSStagesResponse + */ + listTLSStages = (request: Readonly) => + enrichForPagination('stages', this.pageOfListTLSStages, request) + + /** + * Create TLS stage. Create a new TLS stage. You must specify either the + * `secrets` or `managed_certificate` fields to customize the SSL/TLS + * certificate of your endpoint. Choose `secrets` if you are using a + * pre-existing certificate held in Scaleway Secret Manager, or + * `managed_certificate` to let Scaleway generate and manage a Let's Encrypt + * certificate for your customized endpoint. + * + * @param request - The request {@link CreateTLSStageRequest} + * @returns A Promise of TLSStage + */ + createTLSStage = (request: Readonly) => + this.client.fetch( + { + body: JSON.stringify( + marshalCreateTLSStageRequest(request, this.client.settings), + ), + headers: jsonContentHeaders, + method: 'POST', + path: `/edge-services/v1beta1/pipelines/${validatePathParam('pipelineId', request.pipelineId)}/tls-stages`, + }, + unmarshalTLSStage, + ) + + /** + * Get TLS stage. Retrieve information about an existing TLS stage, specified + * by its `tls_stage_id`. Its full details, including secrets and certificate + * expiration date are returned in the response object. + * + * @param request - The request {@link GetTLSStageRequest} + * @returns A Promise of TLSStage + */ + getTLSStage = (request: Readonly) => + this.client.fetch( + { + method: 'GET', + path: `/edge-services/v1beta1/tls-stages/${validatePathParam('tlsStageId', request.tlsStageId)}`, + }, + unmarshalTLSStage, + ) + + /** + * Update TLS stage. Update the parameters of an existing TLS stage, specified + * by its `tls_stage_id`. Both `tls_secrets_config` and `managed_certificate` + * parameters can be updated. + * + * @param request - The request {@link UpdateTLSStageRequest} + * @returns A Promise of TLSStage + */ + updateTLSStage = (request: Readonly) => + this.client.fetch( + { + body: JSON.stringify( + marshalUpdateTLSStageRequest(request, this.client.settings), + ), + headers: jsonContentHeaders, + method: 'PATCH', + path: `/edge-services/v1beta1/tls-stages/${validatePathParam('tlsStageId', request.tlsStageId)}`, + }, + unmarshalTLSStage, + ) + + /** + * Delete TLS stage. Delete an existing TLS stage, specified by its + * `tls_stage_id`. Deleting a TLS stage is permanent, and cannot be undone. + * + * @param request - The request {@link DeleteTLSStageRequest} + */ + deleteTLSStage = (request: Readonly) => + this.client.fetch({ + method: 'DELETE', + path: `/edge-services/v1beta1/tls-stages/${validatePathParam('tlsStageId', request.tlsStageId)}`, + }) + + protected pageOfListCacheStages = ( + request: Readonly, + ) => + this.client.fetch( + { + method: 'GET', + path: `/edge-services/v1beta1/pipelines/${validatePathParam('pipelineId', request.pipelineId)}/cache-stages`, + urlParams: urlParams( + ['order_by', request.orderBy], + ['page', request.page], + [ + 'page_size', + request.pageSize ?? this.client.settings.defaultPageSize, + ], + ), + }, + unmarshalListCacheStagesResponse, + ) + + /** + * List cache stages. List all cache stages, for a Scaleway Organization or + * Scaleway Project. By default, the cache stages returned in the list are + * ordered by creation date in ascending order, though this can be modified + * via the `order_by` field. + * + * @param request - The request {@link ListCacheStagesRequest} + * @returns A Promise of ListCacheStagesResponse + */ + listCacheStages = (request: Readonly) => + enrichForPagination('stages', this.pageOfListCacheStages, request) + + /** + * Create cache stage. Create a new cache stage. You must specify the + * `fallback_ttl` field to customize the TTL of the cache. + * + * @param request - The request {@link CreateCacheStageRequest} + * @returns A Promise of CacheStage + */ + createCacheStage = (request: Readonly) => + this.client.fetch( + { + body: JSON.stringify( + marshalCreateCacheStageRequest(request, this.client.settings), + ), + headers: jsonContentHeaders, + method: 'POST', + path: `/edge-services/v1beta1/pipelines/${validatePathParam('pipelineId', request.pipelineId)}/cache-stages`, + }, + unmarshalCacheStage, + ) + + /** + * Get cache stage. Retrieve information about an existing cache stage, + * specified by its `cache_stage_id`. Its full details, including Time To Live + * (TTL), are returned in the response object. + * + * @param request - The request {@link GetCacheStageRequest} + * @returns A Promise of CacheStage + */ + getCacheStage = (request: Readonly) => + this.client.fetch( + { + method: 'GET', + path: `/edge-services/v1beta1/cache-stages/${validatePathParam('cacheStageId', request.cacheStageId)}`, + }, + unmarshalCacheStage, + ) + + /** + * Update cache stage. Update the parameters of an existing cache stage, + * specified by its `cache_stage_id`. Parameters which can be updated include + * the `fallback_ttl` and `backend_stage_id`. + * + * @param request - The request {@link UpdateCacheStageRequest} + * @returns A Promise of CacheStage + */ + updateCacheStage = (request: Readonly) => + this.client.fetch( + { + body: JSON.stringify( + marshalUpdateCacheStageRequest(request, this.client.settings), + ), + headers: jsonContentHeaders, + method: 'PATCH', + path: `/edge-services/v1beta1/cache-stages/${validatePathParam('cacheStageId', request.cacheStageId)}`, + }, + unmarshalCacheStage, + ) + + /** + * Delete cache stage. Delete an existing cache stage, specified by its + * `cache_stage_id`. Deleting a cache stage is permanent, and cannot be + * undone. + * + * @param request - The request {@link DeleteCacheStageRequest} + */ + deleteCacheStage = (request: Readonly) => + this.client.fetch({ + method: 'DELETE', + path: `/edge-services/v1beta1/cache-stages/${validatePathParam('cacheStageId', request.cacheStageId)}`, + }) + + protected pageOfListBackendStages = ( + request: Readonly, + ) => + this.client.fetch( + { + method: 'GET', + path: `/edge-services/v1beta1/pipelines/${validatePathParam('pipelineId', request.pipelineId)}/backend-stages`, + urlParams: urlParams( + ['bucket_name', request.bucketName], + ['bucket_region', request.bucketRegion], + ['lb_id', request.lbId], + ['order_by', request.orderBy], + ['page', request.page], + [ + 'page_size', + request.pageSize ?? this.client.settings.defaultPageSize, + ], + ), + }, + unmarshalListBackendStagesResponse, + ) + + /** + * List backend stages. List all backend stages, for a Scaleway Organization + * or Scaleway Project. By default, the backend stages returned in the list + * are ordered by creation date in ascending order, though this can be + * modified via the `order_by` field. + * + * @param request - The request {@link ListBackendStagesRequest} + * @returns A Promise of ListBackendStagesResponse + */ + listBackendStages = (request: Readonly) => + enrichForPagination('stages', this.pageOfListBackendStages, request) + + /** + * Create backend stage. Create a new backend stage. You must specify either a + * `scaleway_s3` (for a Scaleway Object Storage bucket) or `scaleway_lb` (for + * a Scaleway Load Balancer) field to configure the origin. + * + * @param request - The request {@link CreateBackendStageRequest} + * @returns A Promise of BackendStage + */ + createBackendStage = (request: Readonly) => + this.client.fetch( + { + body: JSON.stringify( + marshalCreateBackendStageRequest(request, this.client.settings), + ), + headers: jsonContentHeaders, + method: 'POST', + path: `/edge-services/v1beta1/pipelines/${validatePathParam('pipelineId', request.pipelineId)}/backend-stages`, + }, + unmarshalBackendStage, + ) + + /** + * Get backend stage. Retrieve information about an existing backend stage, + * specified by its `backend_stage_id`. Its full details, including + * `scaleway_s3` or `scaleway_lb`, are returned in the response object. + * + * @param request - The request {@link GetBackendStageRequest} + * @returns A Promise of BackendStage + */ + getBackendStage = (request: Readonly) => + this.client.fetch( + { + method: 'GET', + path: `/edge-services/v1beta1/backend-stages/${validatePathParam('backendStageId', request.backendStageId)}`, + }, + unmarshalBackendStage, + ) + + /** + * Update backend stage. Update the parameters of an existing backend stage, + * specified by its `backend_stage_id`. + * + * @param request - The request {@link UpdateBackendStageRequest} + * @returns A Promise of BackendStage + */ + updateBackendStage = (request: Readonly) => + this.client.fetch( + { + body: JSON.stringify( + marshalUpdateBackendStageRequest(request, this.client.settings), + ), + headers: jsonContentHeaders, + method: 'PATCH', + path: `/edge-services/v1beta1/backend-stages/${validatePathParam('backendStageId', request.backendStageId)}`, + }, + unmarshalBackendStage, + ) + + /** + * Delete backend stage. Delete an existing backend stage, specified by its + * `backend_stage_id`. Deleting a backend stage is permanent, and cannot be + * undone. + * + * @param request - The request {@link DeleteBackendStageRequest} + */ + deleteBackendStage = (request: Readonly) => + this.client.fetch({ + method: 'DELETE', + path: `/edge-services/v1beta1/backend-stages/${validatePathParam('backendStageId', request.backendStageId)}`, + }) + + protected pageOfListWafStages = (request: Readonly) => + this.client.fetch( + { + method: 'GET', + path: `/edge-services/v1beta1/pipelines/${validatePathParam('pipelineId', request.pipelineId)}/waf-stages`, + urlParams: urlParams( + ['order_by', request.orderBy], + ['page', request.page], + [ + 'page_size', + request.pageSize ?? this.client.settings.defaultPageSize, + ], + ), + }, + unmarshalListWafStagesResponse, + ) + + /** + * List WAF stages. List all WAF stages, for a Scaleway Organization or + * Scaleway Project. By default, the WAF stages returned in the list are + * ordered by creation date in ascending order, though this can be modified + * via the `order_by` field. + * + * @param request - The request {@link ListWafStagesRequest} + * @returns A Promise of ListWafStagesResponse + */ + listWafStages = (request: Readonly) => + enrichForPagination('stages', this.pageOfListWafStages, request) + + /** + * Create WAF stage. Create a new WAF stage. You must specify the `mode` and + * `paranoia_level` fields to customize the WAF. + * + * @param request - The request {@link CreateWafStageRequest} + * @returns A Promise of WafStage + */ + createWafStage = (request: Readonly) => + this.client.fetch( + { + body: JSON.stringify( + marshalCreateWafStageRequest(request, this.client.settings), + ), + headers: jsonContentHeaders, + method: 'POST', + path: `/edge-services/v1beta1/pipelines/${validatePathParam('pipelineId', request.pipelineId)}/waf-stages`, + }, + unmarshalWafStage, + ) + + /** + * Get WAF stage. Retrieve information about an existing WAF stage, specified + * by its `waf_stage_id`. Its full details are returned in the response + * object. + * + * @param request - The request {@link GetWafStageRequest} + * @returns A Promise of WafStage + */ + getWafStage = (request: Readonly) => + this.client.fetch( + { + method: 'GET', + path: `/edge-services/v1beta1/waf-stages/${validatePathParam('wafStageId', request.wafStageId)}`, + }, + unmarshalWafStage, + ) + + /** + * Update WAF stage. Update the parameters of an existing WAF stage, specified + * by its `waf_stage_id`. Both `mode` and `paranoia_level` parameters can be + * updated. + * + * @param request - The request {@link UpdateWafStageRequest} + * @returns A Promise of WafStage + */ + updateWafStage = (request: Readonly) => + this.client.fetch( + { + body: JSON.stringify( + marshalUpdateWafStageRequest(request, this.client.settings), + ), + headers: jsonContentHeaders, + method: 'PATCH', + path: `/edge-services/v1beta1/waf-stages/${validatePathParam('wafStageId', request.wafStageId)}`, + }, + unmarshalWafStage, + ) + + /** + * Delete WAF stage. Delete an existing WAF stage, specified by its + * `waf_stage_id`. Deleting a WAF stage is permanent, and cannot be undone. + * + * @param request - The request {@link DeleteWafStageRequest} + */ + deleteWafStage = (request: Readonly) => + this.client.fetch({ + method: 'DELETE', + path: `/edge-services/v1beta1/waf-stages/${validatePathParam('wafStageId', request.wafStageId)}`, + }) + + protected pageOfListRouteStages = ( + request: Readonly, + ) => + this.client.fetch( + { + method: 'GET', + path: `/edge-services/v1beta1/pipelines/${validatePathParam('pipelineId', request.pipelineId)}/route-stages`, + urlParams: urlParams( + ['order_by', request.orderBy], + ['page', request.page], + [ + 'page_size', + request.pageSize ?? this.client.settings.defaultPageSize, + ], + ), + }, + unmarshalListRouteStagesResponse, + ) + + /** + * List route stages. List all route stages, for a given pipeline. By default, + * the route stages returned in the list are ordered by creation date in + * ascending order, though this can be modified via the `order_by` field. + * + * @param request - The request {@link ListRouteStagesRequest} + * @returns A Promise of ListRouteStagesResponse + */ + listRouteStages = (request: Readonly) => + enrichForPagination('stages', this.pageOfListRouteStages, request) + + /** + * Create route stage. Create a new route stage. You must specify the + * `waf_stage_id` field to customize the route. + * + * @param request - The request {@link CreateRouteStageRequest} + * @returns A Promise of RouteStage + */ + createRouteStage = (request: Readonly) => + this.client.fetch( + { + body: JSON.stringify( + marshalCreateRouteStageRequest(request, this.client.settings), + ), + headers: jsonContentHeaders, + method: 'POST', + path: `/edge-services/v1beta1/pipelines/${validatePathParam('pipelineId', request.pipelineId)}/route-stages`, + }, + unmarshalRouteStage, + ) + + /** + * Get route stage. Retrieve information about an existing route stage, + * specified by its `route_stage_id`. The summary of the route stage (without + * route rules) is returned in the response object. + * + * @param request - The request {@link GetRouteStageRequest} + * @returns A Promise of RouteStage + */ + getRouteStage = (request: Readonly) => + this.client.fetch( + { + method: 'GET', + path: `/edge-services/v1beta1/route-stages/${validatePathParam('routeStageId', request.routeStageId)}`, + }, + unmarshalRouteStage, + ) + + /** + * Update route stage. Update the parameters of an existing route stage, + * specified by its `route_stage_id`. + * + * @param request - The request {@link UpdateRouteStageRequest} + * @returns A Promise of RouteStage + */ + updateRouteStage = (request: Readonly) => + this.client.fetch( + { + body: JSON.stringify( + marshalUpdateRouteStageRequest(request, this.client.settings), + ), + headers: jsonContentHeaders, + method: 'PATCH', + path: `/edge-services/v1beta1/route-stages/${validatePathParam('routeStageId', request.routeStageId)}`, + }, + unmarshalRouteStage, + ) + + /** + * Delete route stage. Delete an existing route stage, specified by its + * `route_stage_id`. Deleting a route stage is permanent, and cannot be + * undone. + * + * @param request - The request {@link DeleteRouteStageRequest} + */ + deleteRouteStage = (request: Readonly) => + this.client.fetch({ + method: 'DELETE', + path: `/edge-services/v1beta1/route-stages/${validatePathParam('routeStageId', request.routeStageId)}`, + }) + + /** + * List route rules. List all route rules of an existing route stage, + * specified by its `route_stage_id`. + * + * @param request - The request {@link ListRouteRulesRequest} + * @returns A Promise of ListRouteRulesResponse + */ + listRouteRules = (request: Readonly) => + this.client.fetch( + { + method: 'GET', + path: `/edge-services/v1beta1/${validatePathParam('routeStageId', request.routeStageId)}/route-rules`, + }, + unmarshalListRouteRulesResponse, + ) + + /** + * Set route rules. Set the rules of an existing route stage, specified by its + * `route_stage_id`. + * + * @param request - The request {@link SetRouteRulesRequest} + * @returns A Promise of SetRouteRulesResponse + */ + setRouteRules = (request: Readonly) => + this.client.fetch( + { + body: JSON.stringify( + marshalSetRouteRulesRequest(request, this.client.settings), + ), + headers: jsonContentHeaders, + method: 'PUT', + path: `/edge-services/v1beta1/route-stages/${validatePathParam('routeStageId', request.routeStageId)}/route-rules`, + }, + unmarshalSetRouteRulesResponse, + ) + + /** + * Add route rules. Add route rules to an existing route stage, specified by + * its `route_stage_id`. + * + * @param request - The request {@link AddRouteRulesRequest} + * @returns A Promise of AddRouteRulesResponse + */ + addRouteRules = (request: Readonly) => + this.client.fetch( + { + body: JSON.stringify( + marshalAddRouteRulesRequest(request, this.client.settings), + ), + headers: jsonContentHeaders, + method: 'POST', + path: `/edge-services/v1beta1/route-stages/${validatePathParam('routeStageId', request.routeStageId)}/route-rules`, + }, + unmarshalAddRouteRulesResponse, + ) + + checkDomain = (request: Readonly) => + this.client.fetch( + { + body: JSON.stringify( + marshalCheckDomainRequest(request, this.client.settings), + ), + headers: jsonContentHeaders, + method: 'POST', + path: `/edge-services/v1beta1/check-domain`, + }, + unmarshalCheckDomainResponse, + ) + + checkPEMChain = (request: Readonly) => + this.client.fetch( + { + body: JSON.stringify( + marshalCheckPEMChainRequest(request, this.client.settings), + ), + headers: jsonContentHeaders, + method: 'POST', + path: `/edge-services/v1beta1/check-pem-chain`, + }, + unmarshalCheckPEMChainResponse, + ) + + searchBackendStages = (request: Readonly = {}) => + this.client.fetch( + { + method: 'GET', + path: `/edge-services/v1beta1/search-backend-stages`, + urlParams: urlParams( + ['bucket_name', request.bucketName], + ['bucket_region', request.bucketRegion], + ['lb_id', request.lbId], + ['order_by', request.orderBy], + ['page', request.page], + [ + 'page_size', + request.pageSize ?? this.client.settings.defaultPageSize, + ], + [ + 'project_id', + request.projectId ?? this.client.settings.defaultProjectId, + ], + ), + }, + unmarshalListBackendStagesResponse, + ) + + protected pageOfListPurgeRequests = ( + request: Readonly = {}, + ) => + this.client.fetch( + { + method: 'GET', + path: `/edge-services/v1beta1/purge-requests`, + urlParams: urlParams( + ['order_by', request.orderBy], + ['organization_id', request.organizationId], + ['page', request.page], + [ + 'page_size', + request.pageSize ?? this.client.settings.defaultPageSize, + ], + ['pipeline_id', request.pipelineId], + ['project_id', request.projectId], + ), + }, + unmarshalListPurgeRequestsResponse, + ) + + /** + * List purge requests. List all purge requests, for a Scaleway Organization + * or Scaleway Project. This enables you to retrieve a history of all + * previously-made purge requests. By default, the purge requests returned in + * the list are ordered by creation date in ascending order, though this can + * be modified via the `order_by` field. + * + * @param request - The request {@link ListPurgeRequestsRequest} + * @returns A Promise of ListPurgeRequestsResponse + */ + listPurgeRequests = (request: Readonly = {}) => + enrichForPagination('purgeRequests', this.pageOfListPurgeRequests, request) + + /** + * Create purge request. Create a new purge request. You must specify either + * the `all` field (to purge all content) or a list of `assets` (to define the + * precise assets to purge). + * + * @param request - The request {@link CreatePurgeRequestRequest} + * @returns A Promise of PurgeRequest + */ + createPurgeRequest = (request: Readonly) => + this.client.fetch( + { + body: JSON.stringify( + marshalCreatePurgeRequestRequest(request, this.client.settings), + ), + headers: jsonContentHeaders, + method: 'POST', + path: `/edge-services/v1beta1/purge-requests`, + }, + unmarshalPurgeRequest, + ) + + /** + * Get purge request. Retrieve information about a purge request, specified by + * its `purge_request_id`. Its full details, including `status` and `target`, + * are returned in the response object. + * + * @param request - The request {@link GetPurgeRequestRequest} + * @returns A Promise of PurgeRequest + */ + getPurgeRequest = (request: Readonly) => + this.client.fetch( + { + method: 'GET', + path: `/edge-services/v1beta1/purge-requests/${validatePathParam('purgeRequestId', request.purgeRequestId)}`, + }, + unmarshalPurgeRequest, + ) + + /** + * Waits for {@link PurgeRequest} to be in a final state. + * + * @param request - The request {@link GetPurgeRequestRequest} + * @param options - The waiting options + * @returns A Promise of PurgeRequest + */ + waitForPurgeRequest = ( + request: Readonly, + options?: Readonly>, + ) => + waitForResource( + options?.stop ?? + (res => + Promise.resolve( + !PURGE_REQUEST_TRANSIENT_STATUSES.includes(res.status), + )), + this.getPurgeRequest, + request, + options, + ) + + checkLbOrigin = (request: Readonly = {}) => + this.client.fetch( + { + body: JSON.stringify( + marshalCheckLbOriginRequest(request, this.client.settings), + ), + headers: jsonContentHeaders, + method: 'POST', + path: `/edge-services/v1beta1/check-lb-origin`, + }, + unmarshalCheckLbOriginResponse, + ) + + listPlans = () => + this.client.fetch( + { + method: 'GET', + path: `/edge-services/v1beta1/plans`, + }, + unmarshalListPlansResponse, + ) + + selectPlan = (request: Readonly = {}) => + this.client.fetch( + { + body: JSON.stringify( + marshalSelectPlanRequest(request, this.client.settings), + ), + headers: jsonContentHeaders, + method: 'PATCH', + path: `/edge-services/v1beta1/current-plan`, + }, + unmarshalPlan, + ) + + getCurrentPlan = (request: Readonly = {}) => + this.client.fetch( + { + method: 'GET', + path: `/edge-services/v1beta1/current-plan/${validatePathParam('projectId', request.projectId ?? this.client.settings.defaultProjectId)}`, + }, + unmarshalPlan, + ) + + deleteCurrentPlan = (request: Readonly = {}) => + this.client.fetch({ + method: 'DELETE', + path: `/edge-services/v1beta1/current-plan/${validatePathParam('projectId', request.projectId ?? this.client.settings.defaultProjectId)}`, + }) + + /** + * Gives information on the currently selected Edge Services subscription + * plan, resource usage and associated billing information for this calendar + * month (including whether consumption falls within or exceeds the currently + * selected subscription plan.). + * + * @param request - The request {@link GetBillingRequest} + * @returns A Promise of GetBillingResponse + */ + getBilling = (request: Readonly = {}) => + this.client.fetch( + { + method: 'GET', + path: `/edge-services/v1beta1/billing/${validatePathParam('projectId', request.projectId ?? this.client.settings.defaultProjectId)}`, + }, + unmarshalGetBillingResponse, + ) +} diff --git a/packages/clients/src/api/edge_services/v1beta1/content.gen.ts b/packages/clients/src/api/edge_services/v1beta1/content.gen.ts new file mode 100644 index 000000000..fc2747c15 --- /dev/null +++ b/packages/clients/src/api/edge_services/v1beta1/content.gen.ts @@ -0,0 +1,11 @@ +// This file was automatically generated. DO NOT EDIT. +// If you have any remark or suggestion do not hesitate to open an issue. +import type { PipelineStatus, PurgeRequestStatus } from './types.gen' + +/** Lists transient statutes of the enum {@link PipelineStatus}. */ +export const PIPELINE_TRANSIENT_STATUSES: PipelineStatus[] = ['pending'] + +/** Lists transient statutes of the enum {@link PurgeRequestStatus}. */ +export const PURGE_REQUEST_TRANSIENT_STATUSES: PurgeRequestStatus[] = [ + 'pending', +] diff --git a/packages/clients/src/api/edge_services/v1beta1/index.gen.ts b/packages/clients/src/api/edge_services/v1beta1/index.gen.ts new file mode 100644 index 000000000..526f90544 --- /dev/null +++ b/packages/clients/src/api/edge_services/v1beta1/index.gen.ts @@ -0,0 +1,128 @@ +// This file was automatically generated. DO NOT EDIT. +// If you have any remark or suggestion do not hesitate to open an issue. +export { API } from './api.gen' +export * from './content.gen' +export type { + AddRouteRulesRequest, + AddRouteRulesResponse, + BackendStage, + CacheStage, + CheckDomainRequest, + CheckDomainResponse, + CheckLbOriginRequest, + CheckLbOriginResponse, + CheckPEMChainRequest, + CheckPEMChainRequestSecretChain, + CheckPEMChainResponse, + CreateBackendStageRequest, + CreateCacheStageRequest, + CreateDNSStageRequest, + CreatePipelineRequest, + CreatePurgeRequestRequest, + CreateRouteStageRequest, + CreateTLSStageRequest, + CreateWafStageRequest, + DNSStage, + DNSStageType, + DeleteBackendStageRequest, + DeleteCacheStageRequest, + DeleteCurrentPlanRequest, + DeleteDNSStageRequest, + DeletePipelineRequest, + DeleteRouteStageRequest, + DeleteTLSStageRequest, + DeleteWafStageRequest, + GetBackendStageRequest, + GetBillingRequest, + GetBillingResponse, + GetCacheStageRequest, + GetCurrentPlanRequest, + GetDNSStageRequest, + GetPipelineRequest, + GetPurgeRequestRequest, + GetRouteStageRequest, + GetTLSStageRequest, + GetWafStageRequest, + HeadStageResponse, + HeadStageResponseHeadStage, + LbOriginError, + ListBackendStagesRequest, + ListBackendStagesRequestOrderBy, + ListBackendStagesResponse, + ListCacheStagesRequest, + ListCacheStagesRequestOrderBy, + ListCacheStagesResponse, + ListDNSStagesRequest, + ListDNSStagesRequestOrderBy, + ListDNSStagesResponse, + ListHeadStagesRequest, + ListHeadStagesResponse, + ListHeadStagesResponseHeadStage, + ListPipelinesRequest, + ListPipelinesRequestOrderBy, + ListPipelinesResponse, + ListPipelinesWithStagesRequest, + ListPipelinesWithStagesRequestOrderBy, + ListPipelinesWithStagesResponse, + ListPlansResponse, + ListPurgeRequestsRequest, + ListPurgeRequestsRequestOrderBy, + ListPurgeRequestsResponse, + ListRouteRulesRequest, + ListRouteRulesResponse, + ListRouteStagesRequest, + ListRouteStagesRequestOrderBy, + ListRouteStagesResponse, + ListTLSStagesRequest, + ListTLSStagesRequestOrderBy, + ListTLSStagesResponse, + ListWafStagesRequest, + ListWafStagesRequestOrderBy, + ListWafStagesResponse, + Pipeline, + PipelineError, + PipelineErrorCode, + PipelineErrorSeverity, + PipelineErrorStage, + PipelineErrorType, + PipelineStages, + PipelineStatus, + Plan, + PlanDetails, + PlanName, + PlanUsageDetails, + PurgeRequest, + PurgeRequestStatus, + RouteRule, + RouteStage, + RuleHttpMatch, + RuleHttpMatchMethodFilter, + RuleHttpMatchPathFilter, + RuleHttpMatchPathFilterPathFilterType, + ScalewayLb, + ScalewayLbBackendConfig, + ScalewayS3BackendConfig, + SearchBackendStagesRequest, + SearchBackendStagesRequestOrderBy, + SelectPlanRequest, + SetHeadStageRequest, + SetHeadStageRequestAddNewHeadStage, + SetHeadStageRequestRemoveHeadStage, + SetHeadStageRequestSwapHeadStage, + SetRouteRulesRequest, + SetRouteRulesRequestRouteRule, + SetRouteRulesResponse, + TLSSecret, + TLSSecretsConfig, + TLSStage, + UpdateBackendStageRequest, + UpdateCacheStageRequest, + UpdateDNSStageRequest, + UpdatePipelineRequest, + UpdateRouteStageRequest, + UpdateTLSStageRequest, + UpdateWafStageRequest, + WafStage, + WafStageMode, +} from './types.gen' +export * as ValidationRules from './validation-rules.gen' diff --git a/packages/clients/src/api/edge_services/v1beta1/marshalling.gen.ts b/packages/clients/src/api/edge_services/v1beta1/marshalling.gen.ts new file mode 100644 index 000000000..dcc6e4979 --- /dev/null +++ b/packages/clients/src/api/edge_services/v1beta1/marshalling.gen.ts @@ -0,0 +1,1166 @@ +// This file was automatically generated. DO NOT EDIT. +// If you have any remark or suggestion do not hesitate to open an issue. +import { + isJSONObject, + resolveOneOf, + unmarshalArrayOfObject, + unmarshalDate, + unmarshalMapOfObject, + unmarshalMoney, +} from '../../../bridge' +import type { DefaultValues } from '../../../bridge' +import type { + AddRouteRulesRequest, + AddRouteRulesResponse, + BackendStage, + CacheStage, + CheckDomainRequest, + CheckDomainResponse, + CheckLbOriginRequest, + CheckLbOriginResponse, + CheckPEMChainRequest, + CheckPEMChainRequestSecretChain, + CheckPEMChainResponse, + CreateBackendStageRequest, + CreateCacheStageRequest, + CreateDNSStageRequest, + CreatePipelineRequest, + CreatePurgeRequestRequest, + CreateRouteStageRequest, + CreateTLSStageRequest, + CreateWafStageRequest, + DNSStage, + GetBillingResponse, + HeadStageResponse, + HeadStageResponseHeadStage, + ListBackendStagesResponse, + ListCacheStagesResponse, + ListDNSStagesResponse, + ListHeadStagesResponse, + ListHeadStagesResponseHeadStage, + ListPipelinesResponse, + ListPipelinesWithStagesResponse, + ListPlansResponse, + ListPurgeRequestsResponse, + ListRouteRulesResponse, + ListRouteStagesResponse, + ListTLSStagesResponse, + ListWafStagesResponse, + Pipeline, + PipelineError, + PipelineStages, + Plan, + PlanDetails, + PlanUsageDetails, + PurgeRequest, + RouteRule, + RouteStage, + RuleHttpMatch, + RuleHttpMatchPathFilter, + ScalewayLb, + ScalewayLbBackendConfig, + ScalewayS3BackendConfig, + SelectPlanRequest, + SetHeadStageRequest, + SetHeadStageRequestAddNewHeadStage, + SetHeadStageRequestRemoveHeadStage, + SetHeadStageRequestSwapHeadStage, + SetRouteRulesRequest, + SetRouteRulesRequestRouteRule, + SetRouteRulesResponse, + TLSSecret, + TLSSecretsConfig, + TLSStage, + UpdateBackendStageRequest, + UpdateCacheStageRequest, + UpdateDNSStageRequest, + UpdatePipelineRequest, + UpdateRouteStageRequest, + UpdateTLSStageRequest, + UpdateWafStageRequest, + WafStage, +} from './types.gen' + +const unmarshalScalewayLb = (data: unknown): ScalewayLb => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'ScalewayLb' failed as data isn't a dictionary.`, + ) + } + + return { + domainName: data.domain_name, + frontendId: data.frontend_id, + id: data.id, + isSsl: data.is_ssl, + zone: data.zone, + } as ScalewayLb +} + +const unmarshalScalewayLbBackendConfig = ( + data: unknown, +): ScalewayLbBackendConfig => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'ScalewayLbBackendConfig' failed as data isn't a dictionary.`, + ) + } + + return { + lbs: unmarshalArrayOfObject(data.lbs, unmarshalScalewayLb), + } as ScalewayLbBackendConfig +} + +const unmarshalScalewayS3BackendConfig = ( + data: unknown, +): ScalewayS3BackendConfig => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'ScalewayS3BackendConfig' failed as data isn't a dictionary.`, + ) + } + + return { + bucketName: data.bucket_name, + bucketRegion: data.bucket_region, + isWebsite: data.is_website, + } as ScalewayS3BackendConfig +} + +export const unmarshalBackendStage = (data: unknown): BackendStage => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'BackendStage' failed as data isn't a dictionary.`, + ) + } + + return { + createdAt: unmarshalDate(data.created_at), + id: data.id, + pipelineId: data.pipeline_id, + scalewayLb: data.scaleway_lb + ? unmarshalScalewayLbBackendConfig(data.scaleway_lb) + : undefined, + scalewayS3: data.scaleway_s3 + ? unmarshalScalewayS3BackendConfig(data.scaleway_s3) + : undefined, + updatedAt: unmarshalDate(data.updated_at), + } as BackendStage +} + +export const unmarshalCacheStage = (data: unknown): CacheStage => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'CacheStage' failed as data isn't a dictionary.`, + ) + } + + return { + backendStageId: data.backend_stage_id, + createdAt: unmarshalDate(data.created_at), + fallbackTtl: data.fallback_ttl, + id: data.id, + pipelineId: data.pipeline_id, + routeStageId: data.route_stage_id, + updatedAt: unmarshalDate(data.updated_at), + wafStageId: data.waf_stage_id, + } as CacheStage +} + +export const unmarshalDNSStage = (data: unknown): DNSStage => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'DNSStage' failed as data isn't a dictionary.`, + ) + } + + return { + backendStageId: data.backend_stage_id, + cacheStageId: data.cache_stage_id, + createdAt: unmarshalDate(data.created_at), + fqdns: data.fqdns, + id: data.id, + pipelineId: data.pipeline_id, + tlsStageId: data.tls_stage_id, + type: data.type, + updatedAt: unmarshalDate(data.updated_at), + } as DNSStage +} + +const unmarshalPipelineError = (data: unknown): PipelineError => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'PipelineError' failed as data isn't a dictionary.`, + ) + } + + return { + code: data.code, + message: data.message, + severity: data.severity, + stage: data.stage, + type: data.type, + } as PipelineError +} + +export const unmarshalPipeline = (data: unknown): Pipeline => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'Pipeline' failed as data isn't a dictionary.`, + ) + } + + return { + createdAt: unmarshalDate(data.created_at), + description: data.description, + errors: unmarshalArrayOfObject(data.errors, unmarshalPipelineError), + id: data.id, + name: data.name, + organizationId: data.organization_id, + projectId: data.project_id, + status: data.status, + updatedAt: unmarshalDate(data.updated_at), + } as Pipeline +} + +export const unmarshalRouteStage = (data: unknown): RouteStage => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'RouteStage' failed as data isn't a dictionary.`, + ) + } + + return { + createdAt: unmarshalDate(data.created_at), + id: data.id, + pipelineId: data.pipeline_id, + updatedAt: unmarshalDate(data.updated_at), + wafStageId: data.waf_stage_id, + } as RouteStage +} + +const unmarshalTLSSecret = (data: unknown): TLSSecret => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'TLSSecret' failed as data isn't a dictionary.`, + ) + } + + return { + region: data.region, + secretId: data.secret_id, + } as TLSSecret +} + +export const unmarshalTLSStage = (data: unknown): TLSStage => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'TLSStage' failed as data isn't a dictionary.`, + ) + } + + return { + backendStageId: data.backend_stage_id, + cacheStageId: data.cache_stage_id, + certificateExpiresAt: unmarshalDate(data.certificate_expires_at), + createdAt: unmarshalDate(data.created_at), + id: data.id, + managedCertificate: data.managed_certificate, + pipelineId: data.pipeline_id, + routeStageId: data.route_stage_id, + secrets: unmarshalArrayOfObject(data.secrets, unmarshalTLSSecret), + updatedAt: unmarshalDate(data.updated_at), + wafStageId: data.waf_stage_id, + } as TLSStage +} + +export const unmarshalWafStage = (data: unknown): WafStage => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'WafStage' failed as data isn't a dictionary.`, + ) + } + + return { + backendStageId: data.backend_stage_id, + createdAt: unmarshalDate(data.created_at), + id: data.id, + mode: data.mode, + paranoiaLevel: data.paranoia_level, + pipelineId: data.pipeline_id, + updatedAt: unmarshalDate(data.updated_at), + } as WafStage +} + +export const unmarshalPipelineStages = (data: unknown): PipelineStages => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'PipelineStages' failed as data isn't a dictionary.`, + ) + } + + return { + backendStages: unmarshalArrayOfObject( + data.backend_stages, + unmarshalBackendStage, + ), + cacheStages: unmarshalArrayOfObject(data.cache_stages, unmarshalCacheStage), + dnsStages: unmarshalArrayOfObject(data.dns_stages, unmarshalDNSStage), + pipeline: data.pipeline ? unmarshalPipeline(data.pipeline) : undefined, + routeStages: unmarshalArrayOfObject(data.route_stages, unmarshalRouteStage), + tlsStages: unmarshalArrayOfObject(data.tls_stages, unmarshalTLSStage), + wafStages: unmarshalArrayOfObject(data.waf_stages, unmarshalWafStage), + } as PipelineStages +} + +export const unmarshalPurgeRequest = (data: unknown): PurgeRequest => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'PurgeRequest' failed as data isn't a dictionary.`, + ) + } + + return { + all: data.all, + assets: data.assets, + createdAt: unmarshalDate(data.created_at), + id: data.id, + pipelineId: data.pipeline_id, + status: data.status, + updatedAt: unmarshalDate(data.updated_at), + } as PurgeRequest +} + +const unmarshalRuleHttpMatchPathFilter = ( + data: unknown, +): RuleHttpMatchPathFilter => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'RuleHttpMatchPathFilter' failed as data isn't a dictionary.`, + ) + } + + return { + pathFilterType: data.path_filter_type, + value: data.value, + } as RuleHttpMatchPathFilter +} + +const unmarshalRuleHttpMatch = (data: unknown): RuleHttpMatch => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'RuleHttpMatch' failed as data isn't a dictionary.`, + ) + } + + return { + methodFilters: data.method_filters, + pathFilter: data.path_filter + ? unmarshalRuleHttpMatchPathFilter(data.path_filter) + : undefined, + } as RuleHttpMatch +} + +const unmarshalRouteRule = (data: unknown): RouteRule => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'RouteRule' failed as data isn't a dictionary.`, + ) + } + + return { + backendStageId: data.backend_stage_id, + position: data.position, + routeStageId: data.route_stage_id, + ruleHttpMatch: data.rule_http_match + ? unmarshalRuleHttpMatch(data.rule_http_match) + : undefined, + } as RouteRule +} + +export const unmarshalAddRouteRulesResponse = ( + data: unknown, +): AddRouteRulesResponse => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'AddRouteRulesResponse' failed as data isn't a dictionary.`, + ) + } + + return { + routeRules: unmarshalArrayOfObject(data.route_rules, unmarshalRouteRule), + } as AddRouteRulesResponse +} + +export const unmarshalCheckDomainResponse = ( + data: unknown, +): CheckDomainResponse => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'CheckDomainResponse' failed as data isn't a dictionary.`, + ) + } + + return { + isValid: data.is_valid, + } as CheckDomainResponse +} + +export const unmarshalCheckLbOriginResponse = ( + data: unknown, +): CheckLbOriginResponse => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'CheckLbOriginResponse' failed as data isn't a dictionary.`, + ) + } + + return { + errorType: data.error_type, + isValid: data.is_valid, + } as CheckLbOriginResponse +} + +export const unmarshalCheckPEMChainResponse = ( + data: unknown, +): CheckPEMChainResponse => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'CheckPEMChainResponse' failed as data isn't a dictionary.`, + ) + } + + return { + isValid: data.is_valid, + } as CheckPEMChainResponse +} + +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, + wafRequests: data.waf_requests, + } as PlanDetails +} + +const unmarshalPlanUsageDetails = (data: unknown): PlanUsageDetails => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'PlanUsageDetails' failed as data isn't a dictionary.`, + ) + } + + return { + planCost: data.plan_cost ? unmarshalMoney(data.plan_cost) : undefined, + } as PlanUsageDetails +} + +export const unmarshalGetBillingResponse = ( + data: unknown, +): GetBillingResponse => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'GetBillingResponse' failed as data isn't a dictionary.`, + ) + } + + return { + currentPlan: data.current_plan + ? unmarshalPlanDetails(data.current_plan) + : undefined, + currentPlanCacheUsage: data.current_plan_cache_usage, + currentPlanWafUsage: data.current_plan_waf_usage, + extraCacheCost: data.extra_cache_cost + ? unmarshalMoney(data.extra_cache_cost) + : undefined, + extraCacheUsage: data.extra_cache_usage, + extraPipelinesCost: data.extra_pipelines_cost + ? unmarshalMoney(data.extra_pipelines_cost) + : undefined, + extraWafCost: data.extra_waf_cost + ? unmarshalMoney(data.extra_waf_cost) + : undefined, + extraWafUsage: data.extra_waf_usage, + pipelineNumber: data.pipeline_number, + planCost: data.plan_cost ? unmarshalMoney(data.plan_cost) : undefined, + plansUsageDetails: unmarshalMapOfObject( + data.plans_usage_details, + unmarshalPlanUsageDetails, + ), + totalCost: data.total_cost ? unmarshalMoney(data.total_cost) : undefined, + wafAddOn: data.waf_add_on ? unmarshalMoney(data.waf_add_on) : undefined, + } as GetBillingResponse +} + +const unmarshalHeadStageResponseHeadStage = ( + data: unknown, +): HeadStageResponseHeadStage => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'HeadStageResponseHeadStage' failed as data isn't a dictionary.`, + ) + } + + return { + dnsStageId: data.dns_stage_id, + } as HeadStageResponseHeadStage +} + +export const unmarshalHeadStageResponse = ( + data: unknown, +): HeadStageResponse => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'HeadStageResponse' failed as data isn't a dictionary.`, + ) + } + + return { + headStage: data.head_stage + ? unmarshalHeadStageResponseHeadStage(data.head_stage) + : undefined, + } as HeadStageResponse +} + +export const unmarshalListBackendStagesResponse = ( + data: unknown, +): ListBackendStagesResponse => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'ListBackendStagesResponse' failed as data isn't a dictionary.`, + ) + } + + return { + stages: unmarshalArrayOfObject(data.stages, unmarshalBackendStage), + totalCount: data.total_count, + } as ListBackendStagesResponse +} + +export const unmarshalListCacheStagesResponse = ( + data: unknown, +): ListCacheStagesResponse => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'ListCacheStagesResponse' failed as data isn't a dictionary.`, + ) + } + + return { + stages: unmarshalArrayOfObject(data.stages, unmarshalCacheStage), + totalCount: data.total_count, + } as ListCacheStagesResponse +} + +export const unmarshalListDNSStagesResponse = ( + data: unknown, +): ListDNSStagesResponse => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'ListDNSStagesResponse' failed as data isn't a dictionary.`, + ) + } + + return { + stages: unmarshalArrayOfObject(data.stages, unmarshalDNSStage), + totalCount: data.total_count, + } as ListDNSStagesResponse +} + +const unmarshalListHeadStagesResponseHeadStage = ( + data: unknown, +): ListHeadStagesResponseHeadStage => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'ListHeadStagesResponseHeadStage' failed as data isn't a dictionary.`, + ) + } + + return { + dnsStageId: data.dns_stage_id, + } as ListHeadStagesResponseHeadStage +} + +export const unmarshalListHeadStagesResponse = ( + data: unknown, +): ListHeadStagesResponse => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'ListHeadStagesResponse' failed as data isn't a dictionary.`, + ) + } + + return { + headStages: unmarshalArrayOfObject( + data.head_stages, + unmarshalListHeadStagesResponseHeadStage, + ), + totalCount: data.total_count, + } as ListHeadStagesResponse +} + +export const unmarshalListPipelinesResponse = ( + data: unknown, +): ListPipelinesResponse => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'ListPipelinesResponse' failed as data isn't a dictionary.`, + ) + } + + return { + pipelines: unmarshalArrayOfObject(data.pipelines, unmarshalPipeline), + totalCount: data.total_count, + } as ListPipelinesResponse +} + +export const unmarshalListPipelinesWithStagesResponse = ( + data: unknown, +): ListPipelinesWithStagesResponse => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'ListPipelinesWithStagesResponse' failed as data isn't a dictionary.`, + ) + } + + return { + pipelines: unmarshalArrayOfObject(data.pipelines, unmarshalPipelineStages), + totalCount: data.total_count, + } as ListPipelinesWithStagesResponse +} + +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 => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'ListPurgeRequestsResponse' failed as data isn't a dictionary.`, + ) + } + + return { + purgeRequests: unmarshalArrayOfObject( + data.purge_requests, + unmarshalPurgeRequest, + ), + totalCount: data.total_count, + } as ListPurgeRequestsResponse +} + +export const unmarshalListRouteRulesResponse = ( + data: unknown, +): ListRouteRulesResponse => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'ListRouteRulesResponse' failed as data isn't a dictionary.`, + ) + } + + return { + routeRules: unmarshalArrayOfObject(data.route_rules, unmarshalRouteRule), + } as ListRouteRulesResponse +} + +export const unmarshalListRouteStagesResponse = ( + data: unknown, +): ListRouteStagesResponse => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'ListRouteStagesResponse' failed as data isn't a dictionary.`, + ) + } + + return { + stages: unmarshalArrayOfObject(data.stages, unmarshalRouteStage), + totalCount: data.total_count, + } as ListRouteStagesResponse +} + +export const unmarshalListTLSStagesResponse = ( + data: unknown, +): ListTLSStagesResponse => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'ListTLSStagesResponse' failed as data isn't a dictionary.`, + ) + } + + return { + stages: unmarshalArrayOfObject(data.stages, unmarshalTLSStage), + totalCount: data.total_count, + } as ListTLSStagesResponse +} + +export const unmarshalListWafStagesResponse = ( + data: unknown, +): ListWafStagesResponse => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'ListWafStagesResponse' failed as data isn't a dictionary.`, + ) + } + + return { + stages: unmarshalArrayOfObject(data.stages, unmarshalWafStage), + totalCount: data.total_count, + } as ListWafStagesResponse +} + +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 unmarshalSetRouteRulesResponse = ( + data: unknown, +): SetRouteRulesResponse => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'SetRouteRulesResponse' failed as data isn't a dictionary.`, + ) + } + + return { + routeRules: unmarshalArrayOfObject(data.route_rules, unmarshalRouteRule), + } as SetRouteRulesResponse +} + +const marshalRuleHttpMatchPathFilter = ( + request: RuleHttpMatchPathFilter, + defaults: DefaultValues, +): Record => ({ + path_filter_type: request.pathFilterType, + value: request.value, +}) + +const marshalRuleHttpMatch = ( + request: RuleHttpMatch, + defaults: DefaultValues, +): Record => ({ + method_filters: request.methodFilters, + path_filter: + request.pathFilter !== undefined + ? marshalRuleHttpMatchPathFilter(request.pathFilter, defaults) + : undefined, +}) + +const marshalSetRouteRulesRequestRouteRule = ( + request: SetRouteRulesRequestRouteRule, + defaults: DefaultValues, +): Record => ({ + ...resolveOneOf([ + { + param: 'rule_http_match', + value: + request.ruleHttpMatch !== undefined + ? marshalRuleHttpMatch(request.ruleHttpMatch, defaults) + : undefined, + }, + ]), + ...resolveOneOf([ + { param: 'backend_stage_id', value: request.backendStageId }, + ]), +}) + +export const marshalAddRouteRulesRequest = ( + request: AddRouteRulesRequest, + defaults: DefaultValues, +): Record => ({ + route_rules: + request.routeRules !== undefined + ? request.routeRules.map(elt => + marshalSetRouteRulesRequestRouteRule(elt, defaults), + ) + : undefined, + ...resolveOneOf([ + { param: 'after_position', value: request.afterPosition }, + { param: 'before_position', value: request.beforePosition }, + ]), +}) + +export const marshalCheckDomainRequest = ( + request: CheckDomainRequest, + defaults: DefaultValues, +): Record => ({ + cname: request.cname, + fqdn: request.fqdn, + project_id: request.projectId ?? defaults.defaultProjectId, +}) + +const marshalScalewayLb = ( + request: ScalewayLb, + defaults: DefaultValues, +): Record => ({ + domain_name: request.domainName, + frontend_id: request.frontendId, + id: request.id, + is_ssl: request.isSsl, + zone: request.zone, +}) + +export const marshalCheckLbOriginRequest = ( + request: CheckLbOriginRequest, + defaults: DefaultValues, +): Record => ({ + lb: + request.lb !== undefined + ? marshalScalewayLb(request.lb, defaults) + : undefined, +}) + +const marshalCheckPEMChainRequestSecretChain = ( + request: CheckPEMChainRequestSecretChain, + defaults: DefaultValues, +): Record => ({ + secret_id: request.secretId, + secret_region: request.secretRegion, +}) + +export const marshalCheckPEMChainRequest = ( + request: CheckPEMChainRequest, + defaults: DefaultValues, +): Record => ({ + fqdn: request.fqdn, + project_id: request.projectId ?? defaults.defaultProjectId, + ...resolveOneOf | string>([ + { + param: 'secret', + value: + request.secret !== undefined + ? marshalCheckPEMChainRequestSecretChain(request.secret, defaults) + : undefined, + }, + { param: 'raw', value: request.raw }, + ]), +}) + +const marshalScalewayLbBackendConfig = ( + request: ScalewayLbBackendConfig, + defaults: DefaultValues, +): Record => ({ + lbs: request.lbs.map(elt => marshalScalewayLb(elt, defaults)), +}) + +const marshalScalewayS3BackendConfig = ( + request: ScalewayS3BackendConfig, + defaults: DefaultValues, +): Record => ({ + bucket_name: request.bucketName, + bucket_region: request.bucketRegion, + is_website: request.isWebsite, +}) + +export const marshalCreateBackendStageRequest = ( + request: CreateBackendStageRequest, + defaults: DefaultValues, +): Record => ({ + ...resolveOneOf([ + { + param: 'scaleway_s3', + value: + request.scalewayS3 !== undefined + ? marshalScalewayS3BackendConfig(request.scalewayS3, defaults) + : undefined, + }, + { + param: 'scaleway_lb', + value: + request.scalewayLb !== undefined + ? marshalScalewayLbBackendConfig(request.scalewayLb, defaults) + : undefined, + }, + ]), +}) + +export const marshalCreateCacheStageRequest = ( + request: CreateCacheStageRequest, + defaults: DefaultValues, +): Record => ({ + fallback_ttl: request.fallbackTtl, + ...resolveOneOf([ + { param: 'backend_stage_id', value: request.backendStageId }, + { param: 'waf_stage_id', value: request.wafStageId }, + { param: 'route_stage_id', value: request.routeStageId }, + ]), +}) + +export const marshalCreateDNSStageRequest = ( + request: CreateDNSStageRequest, + defaults: DefaultValues, +): Record => ({ + fqdns: request.fqdns, + ...resolveOneOf([ + { param: 'tls_stage_id', value: request.tlsStageId }, + { param: 'cache_stage_id', value: request.cacheStageId }, + { param: 'backend_stage_id', value: request.backendStageId }, + ]), +}) + +export const marshalCreatePipelineRequest = ( + request: CreatePipelineRequest, + defaults: DefaultValues, +): Record => ({ + description: request.description, + name: request.name, + project_id: request.projectId ?? defaults.defaultProjectId, +}) + +export const marshalCreatePurgeRequestRequest = ( + request: CreatePurgeRequestRequest, + defaults: DefaultValues, +): Record => ({ + pipeline_id: request.pipelineId, + ...resolveOneOf([ + { param: 'assets', value: request.assets }, + { param: 'all', value: request.all }, + ]), +}) + +export const marshalCreateRouteStageRequest = ( + request: CreateRouteStageRequest, + defaults: DefaultValues, +): Record => ({ + ...resolveOneOf([{ param: 'waf_stage_id', value: request.wafStageId }]), +}) + +const marshalTLSSecret = ( + request: TLSSecret, + defaults: DefaultValues, +): Record => ({ + region: request.region, + secret_id: request.secretId, +}) + +export const marshalCreateTLSStageRequest = ( + request: CreateTLSStageRequest, + defaults: DefaultValues, +): Record => ({ + managed_certificate: request.managedCertificate, + secrets: + request.secrets !== undefined + ? request.secrets.map(elt => marshalTLSSecret(elt, defaults)) + : undefined, + ...resolveOneOf([ + { param: 'cache_stage_id', value: request.cacheStageId }, + { param: 'backend_stage_id', value: request.backendStageId }, + { param: 'route_stage_id', value: request.routeStageId }, + { param: 'waf_stage_id', value: request.wafStageId }, + ]), +}) + +export const marshalCreateWafStageRequest = ( + request: CreateWafStageRequest, + defaults: DefaultValues, +): Record => ({ + mode: request.mode, + paranoia_level: request.paranoiaLevel, + ...resolveOneOf([ + { param: 'backend_stage_id', value: request.backendStageId }, + ]), +}) + +export const marshalSelectPlanRequest = ( + request: SelectPlanRequest, + defaults: DefaultValues, +): Record => ({ + plan_name: request.planName, + project_id: request.projectId ?? defaults.defaultProjectId, +}) + +const marshalSetHeadStageRequestAddNewHeadStage = ( + request: SetHeadStageRequestAddNewHeadStage, + defaults: DefaultValues, +): Record => ({ + new_stage_id: request.newStageId, +}) + +const marshalSetHeadStageRequestRemoveHeadStage = ( + request: SetHeadStageRequestRemoveHeadStage, + defaults: DefaultValues, +): Record => ({ + remove_stage_id: request.removeStageId, +}) + +const marshalSetHeadStageRequestSwapHeadStage = ( + request: SetHeadStageRequestSwapHeadStage, + defaults: DefaultValues, +): Record => ({ + current_stage_id: request.currentStageId, + new_stage_id: request.newStageId, +}) + +export const marshalSetHeadStageRequest = ( + request: SetHeadStageRequest, + defaults: DefaultValues, +): Record => ({ + ...resolveOneOf([ + { + param: 'add_new_head_stage', + value: + request.addNewHeadStage !== undefined + ? marshalSetHeadStageRequestAddNewHeadStage( + request.addNewHeadStage, + defaults, + ) + : undefined, + }, + { + param: 'remove_head_stage', + value: + request.removeHeadStage !== undefined + ? marshalSetHeadStageRequestRemoveHeadStage( + request.removeHeadStage, + defaults, + ) + : undefined, + }, + { + param: 'swap_head_stage', + value: + request.swapHeadStage !== undefined + ? marshalSetHeadStageRequestSwapHeadStage( + request.swapHeadStage, + defaults, + ) + : undefined, + }, + ]), +}) + +export const marshalSetRouteRulesRequest = ( + request: SetRouteRulesRequest, + defaults: DefaultValues, +): Record => ({ + route_rules: + request.routeRules !== undefined + ? request.routeRules.map(elt => + marshalSetRouteRulesRequestRouteRule(elt, defaults), + ) + : undefined, +}) + +export const marshalUpdateBackendStageRequest = ( + request: UpdateBackendStageRequest, + defaults: DefaultValues, +): Record => ({ + pipeline_id: request.pipelineId, + ...resolveOneOf([ + { + param: 'scaleway_s3', + value: + request.scalewayS3 !== undefined + ? marshalScalewayS3BackendConfig(request.scalewayS3, defaults) + : undefined, + }, + { + param: 'scaleway_lb', + value: + request.scalewayLb !== undefined + ? marshalScalewayLbBackendConfig(request.scalewayLb, defaults) + : undefined, + }, + ]), +}) + +export const marshalUpdateCacheStageRequest = ( + request: UpdateCacheStageRequest, + defaults: DefaultValues, +): Record => ({ + fallback_ttl: request.fallbackTtl, + ...resolveOneOf([ + { param: 'backend_stage_id', value: request.backendStageId }, + { param: 'waf_stage_id', value: request.wafStageId }, + { param: 'route_stage_id', value: request.routeStageId }, + ]), +}) + +export const marshalUpdateDNSStageRequest = ( + request: UpdateDNSStageRequest, + defaults: DefaultValues, +): Record => ({ + fqdns: request.fqdns, + ...resolveOneOf([ + { param: 'tls_stage_id', value: request.tlsStageId }, + { param: 'cache_stage_id', value: request.cacheStageId }, + { param: 'backend_stage_id', value: request.backendStageId }, + ]), +}) + +export const marshalUpdatePipelineRequest = ( + request: UpdatePipelineRequest, + defaults: DefaultValues, +): Record => ({ + description: request.description, + name: request.name, +}) + +export const marshalUpdateRouteStageRequest = ( + request: UpdateRouteStageRequest, + defaults: DefaultValues, +): Record => ({ + ...resolveOneOf([{ param: 'waf_stage_id', value: request.wafStageId }]), +}) + +const marshalTLSSecretsConfig = ( + request: TLSSecretsConfig, + defaults: DefaultValues, +): Record => ({ + tls_secrets: request.tlsSecrets.map(elt => marshalTLSSecret(elt, defaults)), +}) + +export const marshalUpdateTLSStageRequest = ( + request: UpdateTLSStageRequest, + defaults: DefaultValues, +): Record => ({ + managed_certificate: request.managedCertificate, + tls_secrets_config: + request.tlsSecretsConfig !== undefined + ? marshalTLSSecretsConfig(request.tlsSecretsConfig, defaults) + : undefined, + ...resolveOneOf([ + { param: 'cache_stage_id', value: request.cacheStageId }, + { param: 'backend_stage_id', value: request.backendStageId }, + { param: 'route_stage_id', value: request.routeStageId }, + { param: 'waf_stage_id', value: request.wafStageId }, + ]), +}) + +export const marshalUpdateWafStageRequest = ( + request: UpdateWafStageRequest, + defaults: DefaultValues, +): Record => ({ + mode: request.mode, + paranoia_level: request.paranoiaLevel, + ...resolveOneOf([ + { param: 'backend_stage_id', value: request.backendStageId }, + ]), +}) diff --git a/packages/clients/src/api/edge_services/v1beta1/types.gen.ts b/packages/clients/src/api/edge_services/v1beta1/types.gen.ts new file mode 100644 index 000000000..b85b803c6 --- /dev/null +++ b/packages/clients/src/api/edge_services/v1beta1/types.gen.ts @@ -0,0 +1,1412 @@ +// This file was automatically generated. DO NOT EDIT. +// If you have any remark or suggestion do not hesitate to open an issue. +import type { + Money, + Region as ScwRegion, + Zone as ScwZone, +} from '../../../bridge' + +export type DNSStageType = 'unknown_type' | 'auto' | 'managed' | 'custom' + +export type LbOriginError = + | 'unknown' + | 'timeout' + | 'connection_refused' + | 'tls_error' + +export type ListBackendStagesRequestOrderBy = + | 'created_at_asc' + | 'created_at_desc' + +export type ListCacheStagesRequestOrderBy = 'created_at_asc' | 'created_at_desc' + +export type ListDNSStagesRequestOrderBy = 'created_at_asc' | 'created_at_desc' + +export type ListPipelinesRequestOrderBy = + | 'created_at_asc' + | 'created_at_desc' + | 'name_asc' + | 'name_desc' + +export type ListPipelinesWithStagesRequestOrderBy = + | 'created_at_asc' + | 'created_at_desc' + | 'name_asc' + | 'name_desc' + +export type ListPurgeRequestsRequestOrderBy = + | 'created_at_asc' + | 'created_at_desc' + +export type ListRouteStagesRequestOrderBy = 'created_at_asc' | 'created_at_desc' + +export type ListTLSStagesRequestOrderBy = 'created_at_asc' | 'created_at_desc' + +export type ListWafStagesRequestOrderBy = 'created_at_asc' | 'created_at_desc' + +export type PipelineErrorCode = + | 'unknown_code' + | 'dns_invalid_format' + | 'dns_invalid_tld' + | 'dns_forbidden_root_domain' + | 'dns_forbidden_scw_cloud' + | 'dns_domain_dont_exist' + | 'dns_cname_dont_exist' + | 'dns_cname_resolve' + | 'dns_fqdn_already_exists' + | 'dns_fqdn_already_in_use' + | 'tls_cert_deleted' + | 'tls_cert_disabled' + | 'tls_cert_expired' + | 'tls_cert_invalid_format' + | 'tls_cert_missing' + | 'tls_chain_order' + | 'tls_key_invalid_format' + | 'tls_key_missing' + | 'tls_key_too_many' + | 'tls_managed_domain_rate_limit' + | 'tls_managed_internal' + | 'tls_pair_mismatch' + | 'tls_root_inconsistent' + | 'tls_root_incorrect' + | 'tls_root_missing' + | 'tls_san_mismatch' + | 'tls_self_signed' + | 'pipeline_invalid_workflow' + | 'pipeline_missing_head_stage' + +export type PipelineErrorSeverity = 'unknown_severity' | 'warning' | 'critical' + +export type PipelineErrorStage = + | 'unknown_stage' + | 'dns' + | 'tls' + | 'cache' + | 'backend' + +export type PipelineErrorType = 'unknown_type' | 'runtime' | 'config' + +export type PipelineStatus = + | 'unknown_status' + | 'ready' + | 'error' + | 'pending' + | 'warning' + +export type PlanName = 'unknown_name' | 'starter' | 'professional' | 'advanced' + +export type PurgeRequestStatus = 'unknown_status' | 'done' | 'error' | 'pending' + +export type RuleHttpMatchMethodFilter = + | 'unknown_method_filter' + | 'get' + | 'post' + | 'put' + | 'patch' + | 'delete' + | 'head' + | 'options' + +export type RuleHttpMatchPathFilterPathFilterType = + | 'unknown_path_filter' + | 'regex' + +export type SearchBackendStagesRequestOrderBy = + | 'created_at_asc' + | 'created_at_desc' + +export type WafStageMode = 'unknown_mode' | 'disable' | 'log_only' | 'enable' + +export interface ScalewayLb { + /** ID of the Load Balancer. */ + id: string + /** Zone of the Load Balancer. */ + zone: ScwZone + /** ID of the frontend linked to the Load Balancer. */ + frontendId: string + /** Defines whether the Load Balancer's frontend handles SSL connections. */ + isSsl?: boolean + /** + * Fully Qualified Domain Name (in the format subdomain.example.com) to use in + * HTTP requests sent towards your Load Balancer. + */ + domainName?: string +} + +export interface RuleHttpMatchPathFilter { + /** + * Type of filter to match for the HTTP URL path. For now, all path filters + * must be written in regex and use the `regex` type. + */ + pathFilterType: RuleHttpMatchPathFilterPathFilterType + /** Value to be matched for the HTTP URL path. */ + value: string +} + +export interface ScalewayLbBackendConfig { + /** Load Balancer information. */ + lbs: ScalewayLb[] +} + +export interface ScalewayS3BackendConfig { + /** Name of the Bucket. */ + bucketName?: string + /** Region of the Bucket. */ + bucketRegion?: string + /** Defines whether the bucket website feature is enabled. */ + isWebsite?: boolean +} + +export interface PipelineError { + stage: PipelineErrorStage + code: PipelineErrorCode + severity: PipelineErrorSeverity + message: string + type: PipelineErrorType +} + +export interface TLSSecret { + /** ID of the Secret. */ + secretId: string + /** Region of the Secret. */ + region: ScwRegion +} + +export interface RuleHttpMatch { + /** + * HTTP methods to filter for. A request using any of these methods will be + * considered to match the rule. Possible values are `get`, `post`, `put`, + * `patch`, `delete`, `head`, `options`. All methods will match if none is + * provided. + */ + methodFilters: RuleHttpMatchMethodFilter[] + /** + * HTTP URL path to filter for. A request whose path matches the given filter + * will be considered to match the rule. All paths will match if none is + * provided. + */ + pathFilter?: RuleHttpMatchPathFilter +} + +export interface BackendStage { + /** ID of the backend stage. */ + id: string + /** Pipeline ID the backend stage belongs to. */ + pipelineId: string + /** Date the backend stage was created. */ + createdAt?: Date + /** Date the backend stage was last updated. */ + updatedAt?: Date + /** + * Scaleway Object Storage origin bucket (S3) linked to the backend stage. + * + * One-of ('backendConfig'): at most one of 'scalewayS3', 'scalewayLb' could + * be set. + */ + scalewayS3?: ScalewayS3BackendConfig + /** + * Scaleway Load Balancer origin linked to the backend stage. + * + * One-of ('backendConfig'): at most one of 'scalewayS3', 'scalewayLb' could + * be set. + */ + scalewayLb?: ScalewayLbBackendConfig +} + +export interface CacheStage { + /** ID of the cache stage. */ + id: string + /** Pipeline ID the cache stage belongs to. */ + pipelineId: string + /** Time To Live (TTL) in seconds. Defines how long content is cached. */ + fallbackTtl?: string + /** Date the cache stage was created. */ + createdAt?: Date + /** Date the cache stage was last updated. */ + updatedAt?: Date + /** + * Backend stage ID the cache stage is linked to. + * + * One-of ('next'): at most one of 'backendStageId', 'wafStageId', + * 'routeStageId' could be set. + */ + backendStageId?: string + /** + * One-of ('next'): at most one of 'backendStageId', 'wafStageId', + * 'routeStageId' could be set. + */ + wafStageId?: string + /** + * One-of ('next'): at most one of 'backendStageId', 'wafStageId', + * 'routeStageId' could be set. + */ + routeStageId?: string +} + +export interface DNSStage { + /** ID of the DNS stage. */ + id: string + /** List of Fully Qualified Domain Names attached to the stage. */ + fqdns: string[] + /** Type of the stage. */ + type: DNSStageType + /** Pipeline ID the DNS stage belongs to. */ + pipelineId: string + /** Date the DNS stage was created. */ + createdAt?: Date + /** Date the DNS stage was last updated. */ + updatedAt?: Date + /** + * TLS stage ID the DNS stage is linked to. + * + * One-of ('next'): at most one of 'tlsStageId', 'cacheStageId', + * 'backendStageId' could be set. + */ + tlsStageId?: string + /** + * Cache stage ID the DNS stage is linked to. + * + * One-of ('next'): at most one of 'tlsStageId', 'cacheStageId', + * 'backendStageId' could be set. + */ + cacheStageId?: string + /** + * Backend stage ID the DNS stage is linked to. + * + * One-of ('next'): at most one of 'tlsStageId', 'cacheStageId', + * 'backendStageId' could be set. + */ + backendStageId?: string +} + +export interface Pipeline { + /** ID of the pipeline. */ + id: string + /** Name of the pipeline. */ + name: string + /** Description of the pipeline. */ + description: string + /** Status of the pipeline. */ + status: PipelineStatus + /** Errors of the pipeline. */ + errors: PipelineError[] + /** Project ID of the pipeline. */ + projectId: string + /** Organization ID of the pipeline. */ + organizationId: string + /** Date the pipeline was created. */ + createdAt?: Date + /** Date the pipeline was last updated. */ + updatedAt?: Date +} + +export interface RouteStage { + /** ID of the route stage. */ + id: string + /** Pipeline ID the route stage belongs to. */ + pipelineId: string + /** + * ID of the WAF stage HTTP requests should be forwarded to when no rules are + * matched. + * + * One-of ('next'): at most one of 'wafStageId' could be set. + */ + wafStageId?: string + /** Date the route stage was created. */ + createdAt?: Date + /** Date the route stage was last updated. */ + updatedAt?: Date +} + +export interface TLSStage { + /** ID of the TLS stage. */ + id: string + /** Secret (from Scaleway Secret Manager) containing your custom certificate. */ + secrets: TLSSecret[] + /** + * True when Scaleway generates and manages a Let's Encrypt certificate for + * the TLS stage/custom endpoint. + */ + managedCertificate: boolean + /** Pipeline ID the TLS stage belongs to. */ + pipelineId: string + /** Expiration date of the certificate. */ + certificateExpiresAt?: Date + /** Date the TLS stage was created. */ + createdAt?: Date + /** Date the TLS stage was last updated. */ + updatedAt?: Date + /** + * Cache stage ID the TLS stage is linked to. + * + * One-of ('next'): at most one of 'cacheStageId', 'backendStageId', + * 'wafStageId', 'routeStageId' could be set. + */ + cacheStageId?: string + /** + * Backend stage ID the TLS stage is linked to. + * + * One-of ('next'): at most one of 'cacheStageId', 'backendStageId', + * 'wafStageId', 'routeStageId' could be set. + */ + backendStageId?: string + /** + * One-of ('next'): at most one of 'cacheStageId', 'backendStageId', + * 'wafStageId', 'routeStageId' could be set. + */ + wafStageId?: string + /** + * One-of ('next'): at most one of 'cacheStageId', 'backendStageId', + * 'wafStageId', 'routeStageId' could be set. + */ + routeStageId?: string +} + +export interface WafStage { + /** ID of the WAF stage. */ + id: string + /** Pipeline ID the WAF stage belongs to. */ + pipelineId: string + /** Mode defining WAF behavior (`disable`/`log_only`/`enable`). */ + mode: WafStageMode + /** + * Sensitivity level (`1`,`2`,`3`,`4`) to use when classifying requests as + * malicious. With a high level, requests are more likely to be classed as + * malicious, and false positives are expected. With a lower level, requests + * are more likely to be classed as benign. + */ + paranoiaLevel: number + /** Date the WAF stage was created. */ + createdAt?: Date + /** Date the WAF stage was last updated. */ + updatedAt?: Date + /** + * ID of the backend stage to forward requests to after the WAF stage. + * + * One-of ('next'): at most one of 'backendStageId' could be set. + */ + backendStageId?: string +} + +export interface SetRouteRulesRequestRouteRule { + /** + * Rule condition to be matched. Requests matching the condition defined here + * will be directly forwarded to the backend specified by the + * `backend_stage_id` field. Requests that do not match will be checked by the + * next rule's condition. + * + * One-of ('match'): at most one of 'ruleHttpMatch' could be set. + */ + ruleHttpMatch?: RuleHttpMatch + /** + * ID of the backend stage that requests matching the rule should be forwarded + * to. + * + * One-of ('next'): at most one of 'backendStageId' could be set. + */ + backendStageId?: string +} + +export interface RouteRule { + /** + * Rule condition to be matched. Requests matching the condition defined here + * will be directly forwarded to the backend specified by the + * `backend_stage_id` field. Requests that do not match will be checked by the + * next rule's condition. + * + * One-of ('match'): at most one of 'ruleHttpMatch' could be set. + */ + ruleHttpMatch?: RuleHttpMatch + /** + * ID of the backend stage that requests matching the rule should be forwarded + * to. + * + * One-of ('next'): at most one of 'backendStageId' could be set. + */ + backendStageId?: string + /** + * Position of the rule which determines the order of processing within the + * route stage. + */ + position: number + /** Route stage ID the route rule belongs to. */ + routeStageId: string +} + +export interface CheckPEMChainRequestSecretChain { + secretId: string + secretRegion: string +} + +export interface PlanDetails { + /** Subscription plan name. */ + planName: PlanName + /** Amount of egress data from cache included in subscription plan. */ + packageGb: number + /** Number of pipelines included in subscription plan. */ + pipelineLimit: number + /** Number of WAF requests included in subscription plan. */ + wafRequests: number +} + +export interface PlanUsageDetails { + /** + * Cost to date (this month) for the corresponding Edge Services subscription + * plan. + */ + planCost?: Money +} + +export interface HeadStageResponseHeadStage { + /** One-of ('head'): at most one of 'dnsStageId' could be set. */ + dnsStageId?: string +} + +export interface ListHeadStagesResponseHeadStage { + /** One-of ('head'): at most one of 'dnsStageId' could be set. */ + dnsStageId?: string +} + +export interface PipelineStages { + pipeline?: Pipeline + dnsStages: DNSStage[] + tlsStages: TLSStage[] + cacheStages: CacheStage[] + backendStages: BackendStage[] + wafStages: WafStage[] + routeStages: RouteStage[] +} + +export interface PurgeRequest { + /** ID of the purge request. */ + id: string + /** Pipeline ID the purge request belongs to. */ + pipelineId: string + /** Status of the purge request. */ + status: PurgeRequestStatus + /** + * List of asserts to purge. + * + * One-of ('target'): at most one of 'assets', 'all' could be set. + */ + assets?: string[] + /** + * Defines whether to purge all content. + * + * One-of ('target'): at most one of 'assets', 'all' could be set. + */ + all?: boolean + /** Date the purge request was created. */ + createdAt?: Date + /** Date the purge request was last updated. */ + updatedAt?: Date +} + +export interface SetHeadStageRequestAddNewHeadStage { + newStageId: string +} + +export interface SetHeadStageRequestRemoveHeadStage { + removeStageId: string +} + +export interface SetHeadStageRequestSwapHeadStage { + newStageId: string + currentStageId: string +} + +export interface TLSSecretsConfig { + /** Secret information (from Secret Manager). */ + tlsSecrets: TLSSecret[] +} + +export interface AddRouteRulesRequest { + /** ID of the route stage to update. */ + routeStageId: string + /** + * List of rules to be checked against every HTTP request. The first matching + * rule will forward the request to its specified backend stage. If no rules + * are matched, the request is forwarded to the WAF stage defined by + * `waf_stage_id`. + */ + routeRules?: SetRouteRulesRequestRouteRule[] + /** + * Add rules after the given position. + * + * One-of ('position'): at most one of 'afterPosition', 'beforePosition' could + * be set. + */ + afterPosition?: number + /** + * Add rules before the given position. + * + * One-of ('position'): at most one of 'afterPosition', 'beforePosition' could + * be set. + */ + beforePosition?: number +} + +export interface AddRouteRulesResponse { + /** + * List of rules to be checked against every HTTP request. The first matching + * rule will forward the request to its specified backend stage. If no rules + * are matched, the request is forwarded to the WAF stage defined by + * `waf_stage_id`. + */ + routeRules: RouteRule[] +} + +export interface CheckDomainRequest { + projectId?: string + fqdn: string + cname: string +} + +export interface CheckDomainResponse { + isValid: boolean +} + +export interface CheckLbOriginRequest { + lb?: ScalewayLb +} + +export interface CheckLbOriginResponse { + isValid: boolean + errorType: LbOriginError +} + +export interface CheckPEMChainRequest { + projectId?: string + fqdn: string + /** One-of ('chain'): at most one of 'secret', 'raw' could be set. */ + secret?: CheckPEMChainRequestSecretChain + /** One-of ('chain'): at most one of 'secret', 'raw' could be set. */ + raw?: string +} + +export interface CheckPEMChainResponse { + isValid: boolean +} + +export interface CreateBackendStageRequest { + /** Pipeline ID the Backend stage belongs to. */ + pipelineId: string + /** + * Scaleway Object Storage origin bucket (S3) linked to the backend stage. + * + * One-of ('backendConfig'): at most one of 'scalewayS3', 'scalewayLb' could + * be set. + */ + scalewayS3?: ScalewayS3BackendConfig + /** + * Scaleway Load Balancer origin linked to the backend stage. + * + * One-of ('backendConfig'): at most one of 'scalewayS3', 'scalewayLb' could + * be set. + */ + scalewayLb?: ScalewayLbBackendConfig +} + +export interface CreateCacheStageRequest { + /** Pipeline ID the Cache stage belongs to. */ + pipelineId: string + /** Time To Live (TTL) in seconds. Defines how long content is cached. */ + fallbackTtl?: string + /** + * Backend stage ID the cache stage will be linked to. + * + * One-of ('next'): at most one of 'backendStageId', 'wafStageId', + * 'routeStageId' could be set. + */ + backendStageId?: string + /** + * One-of ('next'): at most one of 'backendStageId', 'wafStageId', + * 'routeStageId' could be set. + */ + wafStageId?: string + /** + * One-of ('next'): at most one of 'backendStageId', 'wafStageId', + * 'routeStageId' could be set. + */ + routeStageId?: string +} + +export interface CreateDNSStageRequest { + /** Pipeline ID the DNS stage belongs to. */ + pipelineId: string + /** + * Fully Qualified Domain Name (in the format subdomain.example.com) to attach + * to the stage. + */ + fqdns?: string[] + /** + * TLS stage ID the DNS stage will be linked to. + * + * One-of ('next'): at most one of 'tlsStageId', 'cacheStageId', + * 'backendStageId' could be set. + */ + tlsStageId?: string + /** + * Cache stage ID the DNS stage will be linked to. + * + * One-of ('next'): at most one of 'tlsStageId', 'cacheStageId', + * 'backendStageId' could be set. + */ + cacheStageId?: string + /** + * Backend stage ID the DNS stage will be linked to. + * + * One-of ('next'): at most one of 'tlsStageId', 'cacheStageId', + * 'backendStageId' could be set. + */ + backendStageId?: string +} + +export interface CreatePipelineRequest { + /** Project ID in which the pipeline will be created. */ + projectId?: string + /** Name of the pipeline. */ + name: string + /** Description of the pipeline. */ + description: string +} + +export interface CreatePurgeRequestRequest { + /** Pipeline ID in which the purge request will be created. */ + pipelineId: string + /** + * List of asserts to purge. + * + * One-of ('target'): at most one of 'assets', 'all' could be set. + */ + assets?: string[] + /** + * Defines whether to purge all content. + * + * One-of ('target'): at most one of 'assets', 'all' could be set. + */ + all?: boolean +} + +export interface CreateRouteStageRequest { + /** Pipeline ID the route stage belongs to. */ + pipelineId: string + /** + * ID of the WAF stage HTTP requests should be forwarded to when no rules are + * matched. + * + * One-of ('next'): at most one of 'wafStageId' could be set. + */ + wafStageId?: string +} + +export interface CreateTLSStageRequest { + /** Pipeline ID the TLS stage belongs to. */ + pipelineId: string + /** Secret (from Scaleway Secret Manager) containing your custom certificate. */ + secrets?: TLSSecret[] + /** + * True when Scaleway generates and manages a Let's Encrypt certificate for + * the TLS stage/custom endpoint. + */ + managedCertificate?: boolean + /** + * Cache stage ID the TLS stage will be linked to. + * + * One-of ('next'): at most one of 'cacheStageId', 'backendStageId', + * 'routeStageId', 'wafStageId' could be set. + */ + cacheStageId?: string + /** + * Backend stage ID the TLS stage will be linked to. + * + * One-of ('next'): at most one of 'cacheStageId', 'backendStageId', + * 'routeStageId', 'wafStageId' could be set. + */ + backendStageId?: string + /** + * One-of ('next'): at most one of 'cacheStageId', 'backendStageId', + * 'routeStageId', 'wafStageId' could be set. + */ + routeStageId?: string + /** + * One-of ('next'): at most one of 'cacheStageId', 'backendStageId', + * 'routeStageId', 'wafStageId' could be set. + */ + wafStageId?: string +} + +export interface CreateWafStageRequest { + /** Pipeline ID the WAF stage belongs to. */ + pipelineId: string + /** Mode defining WAF behavior (`disable`/`log_only`/`enable`). */ + mode?: WafStageMode + /** + * Sensitivity level (`1`,`2`,`3`,`4`) to use when classifying requests as + * malicious. With a high level, requests are more likely to be classed as + * malicious, and false positives are expected. With a lower level, requests + * are more likely to be classed as benign. + */ + paranoiaLevel: number + /** + * ID of the backend stage to forward requests to after the WAF stage. + * + * One-of ('next'): at most one of 'backendStageId' could be set. + */ + backendStageId?: string +} + +export interface DeleteBackendStageRequest { + /** ID of the backend stage to delete. */ + backendStageId: string +} + +export interface DeleteCacheStageRequest { + /** ID of the cache stage to delete. */ + cacheStageId: string +} + +export interface DeleteCurrentPlanRequest { + projectId?: string +} + +export interface DeleteDNSStageRequest { + /** ID of the DNS stage to delete. */ + dnsStageId: string +} + +export interface DeletePipelineRequest { + /** ID of the pipeline to delete. */ + pipelineId: string +} + +export interface DeleteRouteStageRequest { + /** ID of the route stage to delete. */ + routeStageId: string +} + +export interface DeleteTLSStageRequest { + /** ID of the TLS stage to delete. */ + tlsStageId: string +} + +export interface DeleteWafStageRequest { + /** ID of the WAF stage to delete. */ + wafStageId: string +} + +export interface GetBackendStageRequest { + /** ID of the requested backend stage. */ + backendStageId: string +} + +export interface GetBillingRequest { + projectId?: string +} + +export interface GetBillingResponse { + /** + * Information on the currently-selected, active Edge Services subscription + * plan. + */ + currentPlan?: PlanDetails + /** + * Cost to date (this month) for Edge Service subscription plans. This + * comprises the pro-rata cost of the current subscription plan, and any + * previous subscription plans that were active earlier in the month. + */ + planCost?: Money + /** Total number of pipelines currently configured. */ + pipelineNumber: number + /** + * Cost to date (this month) of pipelines not included in the subscription + * plans. + */ + extraPipelinesCost?: Money + /** + * Total amount of data egressed from the cache in gigabytes from the + * beginning of the month, for the active subscription plan. + */ + currentPlanCacheUsage: number + /** + * Total amount of extra data egressed from cache in gigabytes from the + * beginning of the month, not included in the subscription plans. + */ + extraCacheUsage: number + /** + * Cost to date (this month) of the data egressed from the cache that is not + * included in the subscription plans. + */ + extraCacheCost?: Money + /** + * Total number of requests processed by the WAF since the beginning of the + * current month, for the active subscription plan. + */ + currentPlanWafUsage: number + /** + * Total number of extra requests processed by the WAF from the beginning of + * the month, not included in the subscription plans. + */ + extraWafUsage: number + /** + * Cost to date (this month) of the extra requests processed by the WAF that + * were not included in the subscription plans. + */ + extraWafCost?: Money + /** + * Cost of activating WAF add-on (where subscription plan does not include + * WAF). + */ + wafAddOn?: Money + /** + * Detailed costs and usage for all Edge Services subscription plans that were + * activated during the month. + */ + plansUsageDetails: Record + /** + * Total cost to date (this month) of all Edge Services resources including + * active subscription plan, previously active plans, extra pipelines and + * extra egress cache data. + */ + totalCost?: Money +} + +export interface GetCacheStageRequest { + /** ID of the requested cache stage. */ + cacheStageId: string +} + +export interface GetCurrentPlanRequest { + projectId?: string +} + +export interface GetDNSStageRequest { + /** ID of the requested DNS stage. */ + dnsStageId: string +} + +export interface GetPipelineRequest { + /** ID of the requested pipeline. */ + pipelineId: string +} + +export interface GetPurgeRequestRequest { + /** ID of the requested purge request. */ + purgeRequestId: string +} + +export interface GetRouteStageRequest { + /** ID of the requested route stage. */ + routeStageId: string +} + +export interface GetTLSStageRequest { + /** ID of the requested TLS stage. */ + tlsStageId: string +} + +export interface GetWafStageRequest { + /** ID of the requested WAF stage. */ + wafStageId: string +} + +export interface HeadStageResponse { + /** Modified or created head stage. */ + headStage?: HeadStageResponseHeadStage +} + +export interface ListBackendStagesRequest { + /** + * Pipeline ID to filter for. Only backend stages from this pipeline will be + * returned. + */ + pipelineId: string + /** Sort order of backend stages in the response. */ + orderBy?: ListBackendStagesRequestOrderBy + /** Page number to return, from the paginated results. */ + page?: number + /** Number of backend stages to return per page. */ + pageSize?: number + /** + * Bucket name to filter for. Only backend stages from this Bucket will be + * returned. + */ + bucketName?: string + /** + * Bucket region to filter for. Only backend stages with buckets in this + * region will be returned. + */ + bucketRegion?: string + /** + * Load Balancer ID to filter for. Only backend stages with this Load Balancer + * will be returned. + */ + lbId?: string +} + +export interface ListBackendStagesResponse { + /** Paginated list of backend stages. */ + stages: BackendStage[] + /** Count of all backend stages matching the requested criteria. */ + totalCount: number +} + +export interface ListCacheStagesRequest { + /** + * Pipeline ID to filter for. Only cache stages from this pipeline will be + * returned. + */ + pipelineId: string + /** Sort order of cache stages in the response. */ + orderBy?: ListCacheStagesRequestOrderBy + /** Page number to return, from the paginated results. */ + page?: number + /** Number of cache stages to return per page. */ + pageSize?: number +} + +export interface ListCacheStagesResponse { + /** Paginated list of cache stages. */ + stages: CacheStage[] + /** Count of all cache stages matching the requested criteria. */ + totalCount: number +} + +export interface ListDNSStagesRequest { + /** + * Pipeline ID to filter for. Only DNS stages from this pipeline will be + * returned. + */ + pipelineId: string + /** Sort order of DNS stages in the response. */ + orderBy?: ListDNSStagesRequestOrderBy + /** Page number to return, from the paginated results. */ + page?: number + /** Number of DNS stages to return per page. */ + pageSize?: number + /** + * Fully Qualified Domain Name to filter for (in the format + * subdomain.example.com). Only DNS stages with this FQDN will be returned. + */ + fqdn?: string +} + +export interface ListDNSStagesResponse { + /** Paginated list of DNS stages. */ + stages: DNSStage[] + /** Count of all DNS stages matching the requested criteria. */ + totalCount: number +} + +export interface ListHeadStagesRequest { + /** ID of the pipeline to update. */ + pipelineId: string + /** Page number to return, from the paginated results. */ + page?: number + /** Number of head stages to return per page. */ + pageSize?: number +} + +export interface ListHeadStagesResponse { + /** Number of head stages to return per page. */ + headStages: ListHeadStagesResponseHeadStage[] + /** Count of all head stages matching the requested pipeline_id. */ + totalCount: number +} + +export interface ListPipelinesRequest { + /** Sort order of pipelines in the response. */ + orderBy?: ListPipelinesRequestOrderBy + /** Page number to return, from the paginated results. */ + page?: number + /** Number of pipelines to return per page. */ + pageSize?: number + /** + * Pipeline name to filter for. Only pipelines with this string within their + * name will be returned. + */ + name?: string + /** + * Organization ID to filter for. Only pipelines from this Organization will + * be returned. + */ + organizationId?: string + /** + * Project ID to filter for. Only pipelines from this Project will be + * returned. + */ + projectId?: string + /** + * Filter on backend stage. Only pipelines with a Load Balancer origin will be + * returned. + */ + hasBackendStageLb?: boolean +} + +export interface ListPipelinesResponse { + /** Paginated list of pipelines. */ + pipelines: Pipeline[] + /** Count of all pipelines matching the requested criteria. */ + totalCount: number +} + +export interface ListPipelinesWithStagesRequest { + orderBy?: ListPipelinesWithStagesRequestOrderBy + page?: number + pageSize?: number + name?: string + organizationId?: string + projectId?: string +} + +export interface ListPipelinesWithStagesResponse { + pipelines: PipelineStages[] + totalCount: number +} + +export interface ListPlansResponse { + totalCount: number + plans: PlanDetails[] +} + +export interface ListPurgeRequestsRequest { + /** Sort order of purge requests in the response. */ + orderBy?: ListPurgeRequestsRequestOrderBy + /** Page number to return, from the paginated results. */ + page?: number + /** Number of purge requests to return per page. */ + pageSize?: number + /** + * Organization ID to filter for. Only purge requests from this Project will + * be returned. + */ + organizationId?: string + /** + * Project ID to filter for. Only purge requests from this Project will be + * returned. + */ + projectId?: string + /** + * Pipeline ID to filter for. Only purge requests from this pipeline will be + * returned. + */ + pipelineId?: string +} + +export interface ListPurgeRequestsResponse { + /** Paginated list of purge requests. */ + purgeRequests: PurgeRequest[] + /** Count of all purge requests matching the requested criteria. */ + totalCount: number +} + +export interface ListRouteRulesRequest { + /** + * Route stage ID to filter for. Only route rules from this route stage will + * be returned. + */ + routeStageId: string +} + +export interface ListRouteRulesResponse { + /** + * List of rules to be checked against every HTTP request. The first matching + * rule will forward the request to its specified backend stage. If no rules + * are matched, the request is forwarded to the WAF stage defined by + * `waf_stage_id`. + */ + routeRules: RouteRule[] +} + +export interface ListRouteStagesRequest { + /** + * Pipeline ID to filter for. Only route stages from this pipeline will be + * returned. + */ + pipelineId: string + /** Sort order of route stages in the response. */ + orderBy?: ListRouteStagesRequestOrderBy + /** Page number to return, from the paginated results. */ + page?: number + /** Number of route stages to return per page. */ + pageSize?: number +} + +export interface ListRouteStagesResponse { + /** Paginated list of summarized route stages. */ + stages: RouteStage[] + /** Count of all route stages matching the requested criteria. */ + totalCount: number +} + +export interface ListTLSStagesRequest { + /** + * Pipeline ID to filter for. Only TLS stages from this pipeline will be + * returned. + */ + pipelineId: string + /** Sort order of TLS stages in the response. */ + orderBy?: ListTLSStagesRequestOrderBy + /** Page number to return, from the paginated results. */ + page?: number + /** Number of TLS stages to return per page. */ + pageSize?: number + /** + * Secret ID to filter for. Only TLS stages with this Secret ID will be + * returned. + */ + secretId?: string + /** + * Secret region to filter for. Only TLS stages with a Secret in this region + * will be returned. + */ + secretRegion?: string +} + +export interface ListTLSStagesResponse { + /** Paginated list of TLS stages. */ + stages: TLSStage[] + /** Count of all TLS stages matching the requested criteria. */ + totalCount: number +} + +export interface ListWafStagesRequest { + /** + * Pipeline ID to filter for. Only WAF stages from this pipeline will be + * returned. + */ + pipelineId: string + /** Sort order of WAF stages in the response. */ + orderBy?: ListWafStagesRequestOrderBy + /** Page number to return, from the paginated results. */ + page?: number + /** Number of WAF stages to return per page. */ + pageSize?: number +} + +export interface ListWafStagesResponse { + /** Paginated list of WAF stages. */ + stages: WafStage[] + /** Count of all WAF stages matching the requested criteria. */ + totalCount: number +} + +export interface Plan { + planName: PlanName +} + +export interface SearchBackendStagesRequest { + orderBy?: SearchBackendStagesRequestOrderBy + page?: number + pageSize?: number + projectId?: string + bucketName?: string + bucketRegion?: string + lbId?: string +} + +export interface SelectPlanRequest { + projectId?: string + planName?: PlanName +} + +export interface SetHeadStageRequest { + /** ID of the pipeline to update. */ + pipelineId: string + /** + * Add a new head stage. + * + * One-of ('action'): at most one of 'addNewHeadStage', 'removeHeadStage', + * 'swapHeadStage' could be set. + */ + addNewHeadStage?: SetHeadStageRequestAddNewHeadStage + /** + * Remove a head stage. + * + * One-of ('action'): at most one of 'addNewHeadStage', 'removeHeadStage', + * 'swapHeadStage' could be set. + */ + removeHeadStage?: SetHeadStageRequestRemoveHeadStage + /** + * Replace a head stage with a new one. + * + * One-of ('action'): at most one of 'addNewHeadStage', 'removeHeadStage', + * 'swapHeadStage' could be set. + */ + swapHeadStage?: SetHeadStageRequestSwapHeadStage +} + +export interface SetRouteRulesRequest { + /** ID of the route stage to update. */ + routeStageId: string + /** + * List of rules to be checked against every HTTP request. The first matching + * rule will forward the request to its specified backend stage. If no rules + * are matched, the request is forwarded to the WAF stage defined by + * `waf_stage_id`. + */ + routeRules?: SetRouteRulesRequestRouteRule[] +} + +export interface SetRouteRulesResponse { + /** + * List of rules to be checked against every HTTP request. The first matching + * rule will forward the request to its specified backend stage. If no rules + * are matched, the request is forwarded to the WAF stage defined by + * `waf_stage_id`. + */ + routeRules: RouteRule[] +} + +export interface UpdateBackendStageRequest { + /** ID of the backend stage to update. */ + backendStageId: string + /** + * Scaleway Object Storage origin bucket (S3) linked to the backend stage. + * + * One-of ('backendConfig'): at most one of 'scalewayS3', 'scalewayLb' could + * be set. + */ + scalewayS3?: ScalewayS3BackendConfig + /** + * Scaleway Load Balancer origin linked to the backend stage. + * + * One-of ('backendConfig'): at most one of 'scalewayS3', 'scalewayLb' could + * be set. + */ + scalewayLb?: ScalewayLbBackendConfig + /** Pipeline ID the Backend stage belongs to. */ + pipelineId: string +} + +export interface UpdateCacheStageRequest { + /** ID of the cache stage to update. */ + cacheStageId: string + /** Time To Live (TTL) in seconds. Defines how long content is cached. */ + fallbackTtl?: string + /** + * Backend stage ID the cache stage will be linked to. + * + * One-of ('next'): at most one of 'backendStageId', 'wafStageId', + * 'routeStageId' could be set. + */ + backendStageId?: string + /** + * One-of ('next'): at most one of 'backendStageId', 'wafStageId', + * 'routeStageId' could be set. + */ + wafStageId?: string + /** + * One-of ('next'): at most one of 'backendStageId', 'wafStageId', + * 'routeStageId' could be set. + */ + routeStageId?: string +} + +export interface UpdateDNSStageRequest { + /** ID of the DNS stage to update. */ + dnsStageId: string + /** + * Fully Qualified Domain Name (in the format subdomain.example.com) attached + * to the stage. + */ + fqdns?: string[] + /** + * TLS stage ID the DNS stage will be linked to. + * + * One-of ('next'): at most one of 'tlsStageId', 'cacheStageId', + * 'backendStageId' could be set. + */ + tlsStageId?: string + /** + * Cache stage ID the DNS stage will be linked to. + * + * One-of ('next'): at most one of 'tlsStageId', 'cacheStageId', + * 'backendStageId' could be set. + */ + cacheStageId?: string + /** + * Backend stage ID the DNS stage will be linked to. + * + * One-of ('next'): at most one of 'tlsStageId', 'cacheStageId', + * 'backendStageId' could be set. + */ + backendStageId?: string +} + +export interface UpdatePipelineRequest { + /** ID of the pipeline to update. */ + pipelineId: string + /** Name of the pipeline. */ + name?: string + /** Description of the pipeline. */ + description?: string +} + +export interface UpdateRouteStageRequest { + /** ID of the route stage to update. */ + routeStageId: string + /** + * ID of the WAF stage HTTP requests should be forwarded to when no rules are + * matched. + * + * One-of ('next'): at most one of 'wafStageId' could be set. + */ + wafStageId?: string +} + +export interface UpdateTLSStageRequest { + /** ID of the TLS stage to update. */ + tlsStageId: string + /** Secret (from Scaleway Secret-Manager) containing your custom certificate. */ + tlsSecretsConfig?: TLSSecretsConfig + /** + * True when Scaleway generates and manages a Let's Encrypt certificate for + * the TLS stage/custom endpoint. + */ + managedCertificate?: boolean + /** + * Cache stage ID the TLS stage will be linked to. + * + * One-of ('next'): at most one of 'cacheStageId', 'backendStageId', + * 'routeStageId', 'wafStageId' could be set. + */ + cacheStageId?: string + /** + * Backend stage ID the TLS stage will be linked to. + * + * One-of ('next'): at most one of 'cacheStageId', 'backendStageId', + * 'routeStageId', 'wafStageId' could be set. + */ + backendStageId?: string + /** + * One-of ('next'): at most one of 'cacheStageId', 'backendStageId', + * 'routeStageId', 'wafStageId' could be set. + */ + routeStageId?: string + /** + * One-of ('next'): at most one of 'cacheStageId', 'backendStageId', + * 'routeStageId', 'wafStageId' could be set. + */ + wafStageId?: string +} + +export interface UpdateWafStageRequest { + /** ID of the WAF stage to update. */ + wafStageId: string + /** Mode defining WAF behavior (`disable`/`log_only`/`enable`). */ + mode?: WafStageMode + /** + * Sensitivity level (`1`,`2`,`3`,`4`) to use when classifying requests as + * malicious. With a high level, requests are more likely to be classed as + * malicious, and false positives are expected. With a lower level, requests + * are more likely to be classed as benign. + */ + paranoiaLevel?: number + /** + * ID of the backend stage to forward requests to after the WAF stage. + * + * One-of ('next'): at most one of 'backendStageId' could be set. + */ + backendStageId?: string +} diff --git a/packages/clients/src/api/edge_services/v1beta1/validation-rules.gen.ts b/packages/clients/src/api/edge_services/v1beta1/validation-rules.gen.ts new file mode 100644 index 000000000..598c8089e --- /dev/null +++ b/packages/clients/src/api/edge_services/v1beta1/validation-rules.gen.ts @@ -0,0 +1,23 @@ +// This file was automatically generated. DO NOT EDIT. +// If you have any remark or suggestion do not hesitate to open an issue. + +export const CreateWafStageRequest = { + paranoiaLevel: { + greaterThanOrEqual: 1, + lessThanOrEqual: 4, + }, +} + +export const UpdateWafStageRequest = { + paranoiaLevel: { + greaterThanOrEqual: 1, + lessThanOrEqual: 4, + }, +} + +export const WafStage = { + paranoiaLevel: { + greaterThanOrEqual: 1, + lessThanOrEqual: 4, + }, +}