diff --git a/packages/clients/src/api/edge_services/index.ts b/packages/clients/src/api/edge_services/index.ts new file mode 100644 index 000000000..e49bded05 --- /dev/null +++ b/packages/clients/src/api/edge_services/index.ts @@ -0,0 +1 @@ +export * as v1alpha1 from './v1alpha1/index.gen' diff --git a/packages/clients/src/api/edge_services/v1alpha1/api.gen.ts b/packages/clients/src/api/edge_services/v1alpha1/api.gen.ts new file mode 100644 index 000000000..35960c018 --- /dev/null +++ b/packages/clients/src/api/edge_services/v1alpha1/api.gen.ts @@ -0,0 +1,782 @@ +// 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 { + marshalCheckDomainRequest, + marshalCheckLbOriginRequest, + marshalCheckPEMChainRequest, + marshalCreateBackendStageRequest, + marshalCreateCacheStageRequest, + marshalCreateDNSStageRequest, + marshalCreatePipelineRequest, + marshalCreatePurgeRequestRequest, + marshalCreateTLSStageRequest, + marshalUpdateBackendStageRequest, + marshalUpdateCacheStageRequest, + marshalUpdateDNSStageRequest, + marshalUpdatePipelineRequest, + marshalUpdateTLSStageRequest, + unmarshalBackendStage, + unmarshalCacheStage, + unmarshalCheckDomainResponse, + unmarshalCheckLbOriginResponse, + unmarshalCheckPEMChainResponse, + unmarshalDNSStage, + unmarshalListBackendStagesResponse, + unmarshalListCacheStagesResponse, + unmarshalListDNSStagesResponse, + unmarshalListPipelinesResponse, + unmarshalListPurgeRequestsResponse, + unmarshalListTLSStagesResponse, + unmarshalPipeline, + unmarshalPurgeRequest, + unmarshalTLSStage, +} from './marshalling.gen' +import type { + BackendStage, + CacheStage, + CheckDomainRequest, + CheckDomainResponse, + CheckLbOriginRequest, + CheckLbOriginResponse, + CheckPEMChainRequest, + CheckPEMChainResponse, + CreateBackendStageRequest, + CreateCacheStageRequest, + CreateDNSStageRequest, + CreatePipelineRequest, + CreatePurgeRequestRequest, + CreateTLSStageRequest, + DNSStage, + DeleteBackendStageRequest, + DeleteCacheStageRequest, + DeleteDNSStageRequest, + DeletePipelineRequest, + DeleteTLSStageRequest, + GetBackendStageRequest, + GetCacheStageRequest, + GetDNSStageRequest, + GetPipelineRequest, + GetPurgeRequestRequest, + GetTLSStageRequest, + ListBackendStagesRequest, + ListBackendStagesResponse, + ListCacheStagesRequest, + ListCacheStagesResponse, + ListDNSStagesRequest, + ListDNSStagesResponse, + ListPipelinesRequest, + ListPipelinesResponse, + ListPurgeRequestsRequest, + ListPurgeRequestsResponse, + ListTLSStagesRequest, + ListTLSStagesResponse, + Pipeline, + PurgeRequest, + TLSStage, + UpdateBackendStageRequest, + UpdateCacheStageRequest, + UpdateDNSStageRequest, + UpdatePipelineRequest, + UpdateTLSStageRequest, +} 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/v1alpha1/pipelines`, + 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], + ), + }, + 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/v1alpha1/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/v1alpha1/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, + ) + + /** + * 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/v1alpha1/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/v1alpha1/pipelines/${validatePathParam('pipelineId', request.pipelineId)}`, + }) + + protected pageOfListDNSStages = ( + request: Readonly = {}, + ) => + this.client.fetch( + { + method: 'GET', + path: `/edge-services/v1alpha1/dns-stages`, + urlParams: urlParams( + ['fqdn', request.fqdn], + ['order_by', request.orderBy], + ['page', request.page], + [ + 'page_size', + request.pageSize ?? this.client.settings.defaultPageSize, + ], + ['pipeline_id', request.pipelineId], + ['project_id', request.projectId], + ), + }, + 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/v1alpha1/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/v1alpha1/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/v1alpha1/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/v1alpha1/dns-stages/${validatePathParam('dnsStageId', request.dnsStageId)}`, + }) + + protected pageOfListTLSStages = ( + request: Readonly = {}, + ) => + this.client.fetch( + { + method: 'GET', + path: `/edge-services/v1alpha1/tls-stages`, + urlParams: urlParams( + ['order_by', request.orderBy], + ['page', request.page], + [ + 'page_size', + request.pageSize ?? this.client.settings.defaultPageSize, + ], + ['pipeline_id', request.pipelineId], + ['project_id', request.projectId], + ['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/v1alpha1/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/v1alpha1/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/v1alpha1/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/v1alpha1/tls-stages/${validatePathParam('tlsStageId', request.tlsStageId)}`, + }) + + protected pageOfListCacheStages = ( + request: Readonly = {}, + ) => + this.client.fetch( + { + method: 'GET', + path: `/edge-services/v1alpha1/cache-stages`, + urlParams: urlParams( + ['order_by', request.orderBy], + ['page', request.page], + [ + 'page_size', + request.pageSize ?? this.client.settings.defaultPageSize, + ], + ['pipeline_id', request.pipelineId], + ['project_id', request.projectId], + ), + }, + 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/v1alpha1/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/v1alpha1/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/v1alpha1/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/v1alpha1/cache-stages/${validatePathParam('cacheStageId', request.cacheStageId)}`, + }) + + protected pageOfListBackendStages = ( + request: Readonly = {}, + ) => + this.client.fetch( + { + method: 'GET', + path: `/edge-services/v1alpha1/backend-stages`, + urlParams: urlParams( + ['bucket_name', request.bucketName], + ['bucket_region', request.bucketRegion], + ['order_by', request.orderBy], + ['page', request.page], + [ + 'page_size', + request.pageSize ?? this.client.settings.defaultPageSize, + ], + ['pipeline_id', request.pipelineId], + ['project_id', request.projectId], + ), + }, + 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/v1alpha1/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/v1alpha1/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/v1alpha1/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/v1alpha1/backend-stages/${validatePathParam('backendStageId', request.backendStageId)}`, + }) + + checkDomain = (request: Readonly) => + this.client.fetch( + { + body: JSON.stringify( + marshalCheckDomainRequest(request, this.client.settings), + ), + headers: jsonContentHeaders, + method: 'POST', + path: `/edge-services/v1alpha1/check-domain`, + }, + unmarshalCheckDomainResponse, + ) + + checkPEMChain = (request: Readonly) => + this.client.fetch( + { + body: JSON.stringify( + marshalCheckPEMChainRequest(request, this.client.settings), + ), + headers: jsonContentHeaders, + method: 'POST', + path: `/edge-services/v1alpha1/check-pem-chain`, + }, + unmarshalCheckPEMChainResponse, + ) + + protected pageOfListPurgeRequests = ( + request: Readonly = {}, + ) => + this.client.fetch( + { + method: 'GET', + path: `/edge-services/v1alpha1/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/v1alpha1/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/v1alpha1/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/v1alpha1/check-lb-origin`, + }, + unmarshalCheckLbOriginResponse, + ) +} diff --git a/packages/clients/src/api/edge_services/v1alpha1/content.gen.ts b/packages/clients/src/api/edge_services/v1alpha1/content.gen.ts new file mode 100644 index 000000000..fc2747c15 --- /dev/null +++ b/packages/clients/src/api/edge_services/v1alpha1/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/v1alpha1/index.gen.ts b/packages/clients/src/api/edge_services/v1alpha1/index.gen.ts new file mode 100644 index 000000000..f4404a2fb --- /dev/null +++ b/packages/clients/src/api/edge_services/v1alpha1/index.gen.ts @@ -0,0 +1,73 @@ +// 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 { + BackendStage, + CacheStage, + CheckDomainRequest, + CheckDomainResponse, + CheckLbOriginRequest, + CheckLbOriginResponse, + CheckPEMChainRequest, + CheckPEMChainRequestSecretChain, + CheckPEMChainResponse, + CreateBackendStageRequest, + CreateCacheStageRequest, + CreateDNSStageRequest, + CreatePipelineRequest, + CreatePurgeRequestRequest, + CreateTLSStageRequest, + DNSStage, + DNSStageType, + DeleteBackendStageRequest, + DeleteCacheStageRequest, + DeleteDNSStageRequest, + DeletePipelineRequest, + DeleteTLSStageRequest, + GetBackendStageRequest, + GetCacheStageRequest, + GetDNSStageRequest, + GetPipelineRequest, + GetPurgeRequestRequest, + GetTLSStageRequest, + LbOriginError, + ListBackendStagesRequest, + ListBackendStagesRequestOrderBy, + ListBackendStagesResponse, + ListCacheStagesRequest, + ListCacheStagesRequestOrderBy, + ListCacheStagesResponse, + ListDNSStagesRequest, + ListDNSStagesRequestOrderBy, + ListDNSStagesResponse, + ListPipelinesRequest, + ListPipelinesRequestOrderBy, + ListPipelinesResponse, + ListPurgeRequestsRequest, + ListPurgeRequestsRequestOrderBy, + ListPurgeRequestsResponse, + ListTLSStagesRequest, + ListTLSStagesRequestOrderBy, + ListTLSStagesResponse, + Pipeline, + PipelineError, + PipelineErrorCode, + PipelineErrorSeverity, + PipelineErrorStage, + PipelineErrorType, + PipelineStatus, + PurgeRequest, + PurgeRequestStatus, + ScalewayLb, + ScalewayLbBackendConfig, + ScalewayS3BackendConfig, + TLSSecret, + TLSSecretsConfig, + TLSStage, + UpdateBackendStageRequest, + UpdateCacheStageRequest, + UpdateDNSStageRequest, + UpdatePipelineRequest, + UpdateTLSStageRequest, +} from './types.gen' diff --git a/packages/clients/src/api/edge_services/v1alpha1/marshalling.gen.ts b/packages/clients/src/api/edge_services/v1alpha1/marshalling.gen.ts new file mode 100644 index 000000000..83e817c11 --- /dev/null +++ b/packages/clients/src/api/edge_services/v1alpha1/marshalling.gen.ts @@ -0,0 +1,617 @@ +// 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, +} from '../../../bridge' +import type { DefaultValues } from '../../../bridge' +import type { + BackendStage, + CacheStage, + CheckDomainRequest, + CheckDomainResponse, + CheckLbOriginRequest, + CheckLbOriginResponse, + CheckPEMChainRequest, + CheckPEMChainRequestSecretChain, + CheckPEMChainResponse, + CreateBackendStageRequest, + CreateCacheStageRequest, + CreateDNSStageRequest, + CreatePipelineRequest, + CreatePurgeRequestRequest, + CreateTLSStageRequest, + DNSStage, + ListBackendStagesResponse, + ListCacheStagesResponse, + ListDNSStagesResponse, + ListPipelinesResponse, + ListPurgeRequestsResponse, + ListTLSStagesResponse, + Pipeline, + PipelineError, + PurgeRequest, + ScalewayLb, + ScalewayLbBackendConfig, + ScalewayS3BackendConfig, + TLSSecret, + TLSSecretsConfig, + TLSStage, + UpdateBackendStageRequest, + UpdateCacheStageRequest, + UpdateDNSStageRequest, + UpdatePipelineRequest, + UpdateTLSStageRequest, +} 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, + projectId: data.project_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, + projectId: data.project_id, + updatedAt: unmarshalDate(data.updated_at), + } 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, + projectId: data.project_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, + dnsStageId: data.dns_stage_id, + errors: unmarshalArrayOfObject(data.errors, unmarshalPipelineError), + id: data.id, + name: data.name, + projectId: data.project_id, + status: data.status, + updatedAt: unmarshalDate(data.updated_at), + } as Pipeline +} + +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 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, + projectId: data.project_id, + secrets: unmarshalArrayOfObject(data.secrets, unmarshalTLSSecret), + updatedAt: unmarshalDate(data.updated_at), + } as TLSStage +} + +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 +} + +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 +} + +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 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 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 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 => ({ + project_id: request.projectId ?? defaults.defaultProjectId, + ...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, + project_id: request.projectId ?? defaults.defaultProjectId, + ...resolveOneOf([ + { param: 'backend_stage_id', value: request.backendStageId }, + ]), +}) + +export const marshalCreateDNSStageRequest = ( + request: CreateDNSStageRequest, + defaults: DefaultValues, +): Record => ({ + fqdns: request.fqdns, + project_id: request.projectId ?? defaults.defaultProjectId, + ...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, + ...resolveOneOf([{ param: 'dns_stage_id', value: request.dnsStageId }]), +}) + +export const marshalCreatePurgeRequestRequest = ( + request: CreatePurgeRequestRequest, + defaults: DefaultValues, +): Record => ({ + pipeline_id: request.pipelineId, + ...resolveOneOf([ + { param: 'assets', value: request.assets }, + { param: 'all', value: request.all }, + ]), +}) + +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, + project_id: request.projectId ?? defaults.defaultProjectId, + 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 }, + ]), +}) + +export const marshalUpdateBackendStageRequest = ( + request: UpdateBackendStageRequest, + 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 marshalUpdateCacheStageRequest = ( + request: UpdateCacheStageRequest, + defaults: DefaultValues, +): Record => ({ + fallback_ttl: request.fallbackTtl, + ...resolveOneOf([ + { param: 'backend_stage_id', value: request.backendStageId }, + ]), +}) + +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, + ...resolveOneOf([{ param: 'dns_stage_id', value: request.dnsStageId }]), +}) + +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 }, + ]), +}) diff --git a/packages/clients/src/api/edge_services/v1alpha1/types.gen.ts b/packages/clients/src/api/edge_services/v1alpha1/types.gen.ts new file mode 100644 index 000000000..fd57c9eb7 --- /dev/null +++ b/packages/clients/src/api/edge_services/v1alpha1/types.gen.ts @@ -0,0 +1,810 @@ +// This file was automatically generated. DO NOT EDIT. +// If you have any remark or suggestion do not hesitate to open an issue. +import type { Region, Zone } 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 ListPurgeRequestsRequestOrderBy = + | 'created_at_asc' + | 'created_at_desc' + +export type ListTLSStagesRequestOrderBy = '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' + +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 PurgeRequestStatus = 'unknown_status' | 'done' | 'error' | 'pending' + +export interface ScalewayLb { + /** ID of the Load Balancer. */ + id: string + /** Zone of the Load Balancer. */ + zone: Zone + /** 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 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: Region +} + +export interface CheckPEMChainRequestSecretChain { + secretId: string + secretRegion: string +} + +export interface BackendStage { + /** ID of the backend stage. */ + id: string + /** Pipeline ID the backend stage belongs to. */ + pipelineId?: string + /** Project ID of the backend stage. */ + projectId: 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 + /** Project ID of the cache stage. */ + projectId: 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' could be set. + */ + backendStageId?: 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 + /** Project ID of the DNS stage. */ + projectId: 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 + /** Date the pipeline was created. */ + createdAt?: Date + /** Date the pipeline was last updated. */ + updatedAt?: Date + /** + * DNS stage ID the pipeline is attached to. + * + * One-of ('head'): at most one of 'dnsStageId' could be set. + */ + dnsStageId?: string +} + +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 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 + /** Project ID of the TLS stage. */ + projectId: 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' could be + * set. + */ + cacheStageId?: string + /** + * Backend stage ID the TLS stage is linked to. + * + * One-of ('next'): at most one of 'cacheStageId', 'backendStageId' could be + * set. + */ + backendStageId?: string +} + +export interface TLSSecretsConfig { + /** Secret information (from Secret Manager). */ + tlsSecrets: TLSSecret[] +} + +export type CheckDomainRequest = { + projectId?: string + fqdn: string + cname: string +} + +export interface CheckDomainResponse { + isValid: boolean +} + +export type CheckLbOriginRequest = { + lb?: ScalewayLb +} + +export interface CheckLbOriginResponse { + isValid: boolean + errorType: LbOriginError +} + +export type 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 type CreateBackendStageRequest = { + /** Project ID in which the backend stage will be created. */ + projectId?: 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 type CreateCacheStageRequest = { + /** Project ID in which the cache stage will be created. */ + projectId?: 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' could be set. + */ + backendStageId?: string +} + +export type CreateDNSStageRequest = { + /** Project ID in which the DNS stage will be created. */ + projectId?: 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 type CreatePipelineRequest = { + /** Project ID in which the pipeline will be created. */ + projectId?: string + /** Name of the pipeline. */ + name: string + /** Description of the pipeline. */ + description: string + /** + * DNS stage ID the pipeline will be attached to. + * + * One-of ('head'): at most one of 'dnsStageId' could be set. + */ + dnsStageId?: string +} + +export type 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 type CreateTLSStageRequest = { + /** Project ID in which the TLS stage will be created. */ + projectId?: 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' could be + * set. + */ + cacheStageId?: string + /** + * Backend stage ID the TLS stage will be linked to. + * + * One-of ('next'): at most one of 'cacheStageId', 'backendStageId' could be + * set. + */ + backendStageId?: string +} + +export type DeleteBackendStageRequest = { + /** ID of the backend stage to delete. */ + backendStageId: string +} + +export type DeleteCacheStageRequest = { + /** ID of the cache stage to delete. */ + cacheStageId: string +} + +export type DeleteDNSStageRequest = { + /** ID of the DNS stage to delete. */ + dnsStageId: string +} + +export type DeletePipelineRequest = { + /** ID of the pipeline to delete. */ + pipelineId: string +} + +export type DeleteTLSStageRequest = { + /** ID of the TLS stage to delete. */ + tlsStageId: string +} + +export type GetBackendStageRequest = { + /** ID of the requested backend stage. */ + backendStageId: string +} + +export type GetCacheStageRequest = { + /** ID of the requested cache stage. */ + cacheStageId: string +} + +export type GetDNSStageRequest = { + /** ID of the requested DNS stage. */ + dnsStageId: string +} + +export type GetPipelineRequest = { + /** ID of the requested pipeline. */ + pipelineId: string +} + +export type GetPurgeRequestRequest = { + /** ID of the requested purge request. */ + purgeRequestId: string +} + +export type GetTLSStageRequest = { + /** ID of the requested TLS stage. */ + tlsStageId: string +} + +export type ListBackendStagesRequest = { + /** 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 + /** + * Pipeline ID to filter for, only backend stages from this pipeline will be + * returned. + */ + pipelineId?: string + /** + * Project ID to filter for, only backend stages from this Project will be + * returned. + */ + projectId?: string + /** + * 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 +} + +export interface ListBackendStagesResponse { + /** Paginated list of backend stages. */ + stages: BackendStage[] + /** Count of all backend stages matching the requested criteria. */ + totalCount: number +} + +export type ListCacheStagesRequest = { + /** 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 + /** + * Pipeline ID to filter for, only cache stages from this pipeline will be + * returned. + */ + pipelineId?: string + /** + * Project ID to filter for, only cache stages from this Project will be + * returned. + */ + projectId?: string +} + +export interface ListCacheStagesResponse { + /** Paginated list of cache stages. */ + stages: CacheStage[] + /** Count of all cache stages matching the requested criteria. */ + totalCount: number +} + +export type ListDNSStagesRequest = { + /** 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 + /** + * Pipeline ID to filter for, only DNS stages from this pipeline will be + * returned. + */ + pipelineId?: string + /** + * Project ID to filter for, only DNS stages from this Project will be + * returned. + */ + projectId?: string + /** + * 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 type 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 +} + +export interface ListPipelinesResponse { + /** Paginated list of pipelines. */ + pipelines: Pipeline[] + /** Count of all pipelines matching the requested criteria. */ + totalCount: number +} + +export type 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 type ListTLSStagesRequest = { + /** 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 + /** + * Pipeline ID to filter for, only TLS stages from this pipeline will be + * returned. + */ + pipelineId?: string + /** + * Project ID to filter for, only TLS stages from this Project will be + * returned. + */ + projectId?: string + /** + * 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 type 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 +} + +export type 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' could be set. + */ + backendStageId?: string +} + +export type 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 type UpdatePipelineRequest = { + /** ID of the pipeline to update. */ + pipelineId: string + /** Name of the pipeline. */ + name?: string + /** Description of the pipeline. */ + description?: string + /** + * DNS stage ID the pipeline will be attached to. + * + * One-of ('head'): at most one of 'dnsStageId' could be set. + */ + dnsStageId?: string +} + +export type 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' could be + * set. + */ + cacheStageId?: string + /** + * Backend stage ID the TLS stage will be linked to. + * + * One-of ('next'): at most one of 'cacheStageId', 'backendStageId' could be + * set. + */ + backendStageId?: string +}