From 2588c1882faa0e5a0ffbc04ac13e318937133869 Mon Sep 17 00:00:00 2001 From: scaleway-bot Date: Thu, 12 Sep 2024 13:45:50 +0000 Subject: [PATCH] feat: update generated APIs --- packages/clients/src/api/ipam/v1/api.gen.ts | 18 +- packages/clients/src/api/ipam/v1/types.gen.ts | 13 +- .../clients/src/api/qaas/v1alpha1/api.gen.ts | 703 ++++++++++++++ .../src/api/qaas/v1alpha1/content.gen.ts | 23 + .../src/api/qaas/v1alpha1/index.gen.ts | 67 ++ .../src/api/qaas/v1alpha1/marshalling.gen.ts | 410 +++++++++ .../src/api/qaas/v1alpha1/types.gen.ts | 608 ++++++++++++ .../api/qaas/v1alpha1/validation-rules.gen.ts | 14 + .../clients/src/api/vpc/v2/marshalling.gen.ts | 1 + packages/clients/src/api/vpc/v2/types.gen.ts | 2 + .../clients/src/api/webhosting/v1/api.gen.ts | 862 ++++++++++++++++++ .../src/api/webhosting/v1/content.gen.ts | 17 + .../src/api/webhosting/v1/index.gen.ts | 80 ++ .../src/api/webhosting/v1/marshalling.gen.ts | 535 +++++++++++ .../src/api/webhosting/v1/types.gen.ts | 788 ++++++++++++++++ .../api/webhosting/v1/validation-rules.gen.ts | 82 ++ 16 files changed, 4209 insertions(+), 14 deletions(-) create mode 100644 packages/clients/src/api/qaas/v1alpha1/api.gen.ts create mode 100644 packages/clients/src/api/qaas/v1alpha1/content.gen.ts create mode 100644 packages/clients/src/api/qaas/v1alpha1/index.gen.ts create mode 100644 packages/clients/src/api/qaas/v1alpha1/marshalling.gen.ts create mode 100644 packages/clients/src/api/qaas/v1alpha1/types.gen.ts create mode 100644 packages/clients/src/api/qaas/v1alpha1/validation-rules.gen.ts create mode 100644 packages/clients/src/api/webhosting/v1/api.gen.ts create mode 100644 packages/clients/src/api/webhosting/v1/content.gen.ts create mode 100644 packages/clients/src/api/webhosting/v1/index.gen.ts create mode 100644 packages/clients/src/api/webhosting/v1/marshalling.gen.ts create mode 100644 packages/clients/src/api/webhosting/v1/types.gen.ts create mode 100644 packages/clients/src/api/webhosting/v1/validation-rules.gen.ts diff --git a/packages/clients/src/api/ipam/v1/api.gen.ts b/packages/clients/src/api/ipam/v1/api.gen.ts index c6861455f..92a1ee5e9 100644 --- a/packages/clients/src/api/ipam/v1/api.gen.ts +++ b/packages/clients/src/api/ipam/v1/api.gen.ts @@ -47,8 +47,8 @@ export class API extends ParentAPI { public static readonly LOCALITIES: Region[] = ['fr-par', 'nl-ams', 'pl-waw'] /** - * Book a new IP. Book a new IP from the specified source. Currently IPs can - * only be booked from a Private Network. + * Reserve a new IP. Reserve a new IP from the specified source. Currently IPs + * can only be reserved from a Private Network. * * @param request - The request {@link BookIPRequest} * @returns A Promise of IP @@ -173,7 +173,7 @@ export class API extends ParentAPI { enrichForPagination('ips', this.pageOfListIPs, request) /** - * Attach existing IP to custom resource. Attach an existing IP from a Private + * Attach IP to custom resource. Attach an existing reserved IP from a Private * Network subnet to a custom, named resource via its MAC address. An example * of a custom resource is a virtual machine hosted on an Elastic Metal * server. Do not use this method for attaching IP addresses to standard @@ -197,11 +197,11 @@ export class API extends ParentAPI { ) /** - * Detach existing IP from a custom resource. Detach a private IP from a - * custom resource. An example of a custom resource is a virtual machine - * hosted on an Elastic Metal server. Do not use this method for attaching IP - * addresses to standard Scaleway resources (e.g. Instances, Load Balancers) - * as it will fail - see the relevant product API for an equivalent method. + * Detach IP from a custom resource. Detach a private IP from a custom + * resource. An example of a custom resource is a virtual machine hosted on an + * Elastic Metal server. Do not use this method for detaching IP addresses + * from standard Scaleway resources (e.g. Instances, Load Balancers) as it + * will fail - see the relevant product API for an equivalent method. * * @param request - The request {@link DetachIPRequest} * @returns A Promise of IP @@ -220,7 +220,7 @@ export class API extends ParentAPI { ) /** - * Move existing IP to a custom resource. Move an existing private IP from one + * Move IP to a custom resource. Move an existing reserved private IP from one * custom resource (e.g. a virtual machine hosted on an Elastic Metal server) * to another custom resource. This will detach it from the first resource, * and attach it to the second. Do not use this method for moving IP addresses diff --git a/packages/clients/src/api/ipam/v1/types.gen.ts b/packages/clients/src/api/ipam/v1/types.gen.ts index 4b225bf27..f94085ed0 100644 --- a/packages/clients/src/api/ipam/v1/types.gen.ts +++ b/packages/clients/src/api/ipam/v1/types.gen.ts @@ -92,11 +92,11 @@ export interface IP { projectId: string /** Defines whether the IP is an IPv6 (false = IPv4). */ isIpv6: boolean - /** Date the IP was booked. */ + /** Date the IP was reserved. */ createdAt?: Date /** Date the IP was last modified. */ updatedAt?: Date - /** Source pool where the IP was booked in. */ + /** Source pool where the IP was reserved in. */ source?: Source /** Resource which the IP is attached to. */ resource?: Resource @@ -133,20 +133,23 @@ export type BookIPRequest = { * Private Network's Project. */ projectId?: string - /** Source in which to book the IP. Not all sources are available for booking. */ + /** + * Source in which to reserve the IP. Not all sources are available for + * reservation. + */ source: Source /** Request an IPv6 instead of an IPv4. */ isIpv6: boolean /** * The requested address should not include the subnet mask (/suffix). Note * that only the Private Network source allows you to pick a specific IP. If - * the requested IP is already booked, then the call will fail. + * the requested IP is already reserved, then the call will fail. */ address?: string /** Tags for the IP. */ tags?: string[] /** - * Custom resource to attach to the IP being booked. An example of a custom + * Custom resource to attach to the IP being reserved. An example of a custom * resource is a virtual machine hosted on an Elastic Metal server. Do not use * this for attaching IP addresses to standard Scaleway resources, as it will * fail - instead, see the relevant product API for an equivalent method. diff --git a/packages/clients/src/api/qaas/v1alpha1/api.gen.ts b/packages/clients/src/api/qaas/v1alpha1/api.gen.ts new file mode 100644 index 000000000..f51e4994e --- /dev/null +++ b/packages/clients/src/api/qaas/v1alpha1/api.gen.ts @@ -0,0 +1,703 @@ +// 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, + resolveOneOf, + urlParams, + validatePathParam, + waitForResource, +} from '../../../bridge' +import type { WaitForOptions } from '../../../bridge' +import { + JOB_TRANSIENT_STATUSES, + PROCESS_TRANSIENT_STATUSES, + SESSION_TRANSIENT_STATUSES, +} from './content.gen' +import { + marshalCreateJobRequest, + marshalCreateProcessRequest, + marshalCreateSessionRequest, + marshalUpdateJobRequest, + marshalUpdateProcessRequest, + marshalUpdateSessionRequest, + unmarshalApplication, + unmarshalJob, + unmarshalJobCircuit, + unmarshalListApplicationsResponse, + unmarshalListJobResultsResponse, + unmarshalListJobsResponse, + unmarshalListPlatformsResponse, + unmarshalListProcessResultsResponse, + unmarshalListProcessesResponse, + unmarshalListSessionACLsResponse, + unmarshalListSessionsResponse, + unmarshalPlatform, + unmarshalProcess, + unmarshalSession, +} from './marshalling.gen' +import type { + Application, + CancelJobRequest, + CancelProcessRequest, + CreateJobRequest, + CreateProcessRequest, + CreateSessionRequest, + DeleteJobRequest, + DeleteProcessRequest, + DeleteSessionRequest, + GetApplicationRequest, + GetJobCircuitRequest, + GetJobRequest, + GetPlatformRequest, + GetProcessRequest, + GetSessionRequest, + Job, + JobCircuit, + ListApplicationsRequest, + ListApplicationsResponse, + ListJobResultsRequest, + ListJobResultsResponse, + ListJobsRequest, + ListJobsResponse, + ListPlatformsRequest, + ListPlatformsResponse, + ListProcessResultsRequest, + ListProcessResultsResponse, + ListProcessesRequest, + ListProcessesResponse, + ListSessionACLsRequest, + ListSessionACLsResponse, + ListSessionsRequest, + ListSessionsResponse, + Platform, + Process, + Session, + TerminateSessionRequest, + UpdateJobRequest, + UpdateProcessRequest, + UpdateSessionRequest, +} from './types.gen' + +const jsonContentHeaders = { + 'Content-Type': 'application/json; charset=utf-8', +} + +/** + * Quantum as a Service API. + * + * This API allows you to manage Scaleway Quantum as a Service. + */ +export class API extends ParentAPI { + /** + * Get job information. Retrieve information about the provided **job ID**, + * such as status, payload, and result. + * + * @param request - The request {@link GetJobRequest} + * @returns A Promise of Job + */ + getJob = (request: Readonly) => + this.client.fetch( + { + method: 'GET', + path: `/qaas/v1alpha1/jobs/${validatePathParam('jobId', request.jobId)}`, + }, + unmarshalJob, + ) + + /** + * Waits for {@link Job} to be in a final state. + * + * @param request - The request {@link GetJobRequest} + * @param options - The waiting options + * @returns A Promise of Job + */ + waitForJob = ( + request: Readonly, + options?: Readonly>, + ) => + waitForResource( + options?.stop ?? + (res => Promise.resolve(!JOB_TRANSIENT_STATUSES.includes(res.status))), + this.getJob, + request, + options, + ) + + protected pageOfListJobs = (request: Readonly = {}) => + this.client.fetch( + { + method: 'GET', + path: `/qaas/v1alpha1/jobs`, + urlParams: urlParams( + ['order_by', request.orderBy], + ['page', request.page], + [ + 'page_size', + request.pageSize ?? this.client.settings.defaultPageSize, + ], + ['tags', request.tags], + ...Object.entries( + resolveOneOf([ + { param: 'session_id', value: request.sessionId }, + { + default: this.client.settings.defaultProjectId, + param: 'project_id', + value: request.projectId, + }, + ]), + ), + ), + }, + unmarshalListJobsResponse, + ) + + /** + * List all jobs within a project or session. Retrieve information about all + * jobs within a given project or session. + * + * @param request - The request {@link ListJobsRequest} + * @returns A Promise of ListJobsResponse + */ + listJobs = (request: Readonly = {}) => + enrichForPagination('jobs', this.pageOfListJobs, request) + + protected pageOfListJobResults = (request: Readonly) => + this.client.fetch( + { + method: 'GET', + path: `/qaas/v1alpha1/jobs/${validatePathParam('jobId', request.jobId)}/results`, + urlParams: urlParams( + ['order_by', request.orderBy], + ['page', request.page], + [ + 'page_size', + request.pageSize ?? this.client.settings.defaultPageSize, + ], + ), + }, + unmarshalListJobResultsResponse, + ) + + /** + * List all results of a job. Retrieve all intermediate and final results of a + * job. + * + * @param request - The request {@link ListJobResultsRequest} + * @returns A Promise of ListJobResultsResponse + */ + listJobResults = (request: Readonly) => + enrichForPagination('jobResults', this.pageOfListJobResults, request) + + /** + * Create a job. Create a job to be executed inside a session. + * + * @param request - The request {@link CreateJobRequest} + * @returns A Promise of Job + */ + createJob = (request: Readonly) => + this.client.fetch( + { + body: JSON.stringify( + marshalCreateJobRequest(request, this.client.settings), + ), + headers: jsonContentHeaders, + method: 'POST', + path: `/qaas/v1alpha1/jobs`, + }, + unmarshalJob, + ) + + /** + * Update job information. Update job information about the provided **job + * ID**. + * + * @param request - The request {@link UpdateJobRequest} + * @returns A Promise of Job + */ + updateJob = (request: Readonly) => + this.client.fetch( + { + body: JSON.stringify( + marshalUpdateJobRequest(request, this.client.settings), + ), + headers: jsonContentHeaders, + method: 'PATCH', + path: `/qaas/v1alpha1/jobs/${validatePathParam('jobId', request.jobId)}`, + }, + unmarshalJob, + ) + + /** + * Cancel a job. Cancel the job corresponding to the provided **job ID**. + * + * @param request - The request {@link CancelJobRequest} + * @returns A Promise of Job + */ + cancelJob = (request: Readonly) => + this.client.fetch( + { + body: '{}', + headers: jsonContentHeaders, + method: 'POST', + path: `/qaas/v1alpha1/jobs/${validatePathParam('jobId', request.jobId)}/cancel`, + }, + unmarshalJob, + ) + + /** + * Delete a job. Delete the job corresponding to the provided **job ID**. + * + * @param request - The request {@link DeleteJobRequest} + */ + deleteJob = (request: Readonly) => + this.client.fetch({ + method: 'DELETE', + path: `/qaas/v1alpha1/jobs/${validatePathParam('jobId', request.jobId)}`, + }) + + /** + * Get a job circuit. Retrieve the circuit of the provided **job ID**. + * + * @param request - The request {@link GetJobCircuitRequest} + * @returns A Promise of JobCircuit + */ + getJobCircuit = (request: Readonly) => + this.client.fetch( + { + method: 'GET', + path: `/qaas/v1alpha1/jobs/${validatePathParam('jobId', request.jobId)}/circuit`, + }, + unmarshalJobCircuit, + ) + + /** + * Get platform information. Retrieve information about the provided + * **platform ID**, such as provider name, technology, and type. + * + * @param request - The request {@link GetPlatformRequest} + * @returns A Promise of Platform + */ + getPlatform = (request: Readonly) => + this.client.fetch( + { + method: 'GET', + path: `/qaas/v1alpha1/platforms/${validatePathParam('platformId', request.platformId)}`, + }, + unmarshalPlatform, + ) + + protected pageOfListPlatforms = ( + request: Readonly = {}, + ) => + this.client.fetch( + { + method: 'GET', + path: `/qaas/v1alpha1/platforms`, + urlParams: urlParams( + ['backend_name', request.backendName], + ['name', request.name], + ['order_by', request.orderBy], + ['page', request.page], + [ + 'page_size', + request.pageSize ?? this.client.settings.defaultPageSize, + ], + ['platform_technology', request.platformTechnology], + ['platform_type', request.platformType], + ['provider_name', request.providerName], + ), + }, + unmarshalListPlatformsResponse, + ) + + /** + * List all available platforms. Retrieve information about all platforms. + * + * @param request - The request {@link ListPlatformsRequest} + * @returns A Promise of ListPlatformsResponse + */ + listPlatforms = (request: Readonly = {}) => + enrichForPagination('platforms', this.pageOfListPlatforms, request) + + /** + * Get session infrormation. Retrieve information about the provided **session + * ID**, such as name, status, and number of executed jobs. + * + * @param request - The request {@link GetSessionRequest} + * @returns A Promise of Session + */ + getSession = (request: Readonly) => + this.client.fetch( + { + method: 'GET', + path: `/qaas/v1alpha1/sessions/${validatePathParam('sessionId', request.sessionId)}`, + }, + unmarshalSession, + ) + + /** + * Waits for {@link Session} to be in a final state. + * + * @param request - The request {@link GetSessionRequest} + * @param options - The waiting options + * @returns A Promise of Session + */ + waitForSession = ( + request: Readonly, + options?: Readonly>, + ) => + waitForResource( + options?.stop ?? + (res => + Promise.resolve(!SESSION_TRANSIENT_STATUSES.includes(res.status))), + this.getSession, + request, + options, + ) + + protected pageOfListSessions = ( + request: Readonly = {}, + ) => + this.client.fetch( + { + method: 'GET', + path: `/qaas/v1alpha1/sessions`, + urlParams: urlParams( + ['order_by', request.orderBy], + ['page', request.page], + [ + 'page_size', + request.pageSize ?? this.client.settings.defaultPageSize, + ], + ['platform_id', request.platformId], + [ + 'project_id', + request.projectId ?? this.client.settings.defaultProjectId, + ], + ['tags', request.tags], + ), + }, + unmarshalListSessionsResponse, + ) + + /** + * List all sessions. Retrieve information about all sessions. + * + * @param request - The request {@link ListSessionsRequest} + * @returns A Promise of ListSessionsResponse + */ + listSessions = (request: Readonly = {}) => + enrichForPagination('sessions', this.pageOfListSessions, request) + + /** + * Create a session. Create a dedicated session for the specified platform. + * + * @param request - The request {@link CreateSessionRequest} + * @returns A Promise of Session + */ + createSession = (request: Readonly) => + this.client.fetch( + { + body: JSON.stringify( + marshalCreateSessionRequest(request, this.client.settings), + ), + headers: jsonContentHeaders, + method: 'POST', + path: `/qaas/v1alpha1/sessions`, + }, + unmarshalSession, + ) + + /** + * Update session information. Update session information of the provided + * **session ID**. + * + * @param request - The request {@link UpdateSessionRequest} + * @returns A Promise of Session + */ + updateSession = (request: Readonly) => + this.client.fetch( + { + body: JSON.stringify( + marshalUpdateSessionRequest(request, this.client.settings), + ), + headers: jsonContentHeaders, + method: 'PATCH', + path: `/qaas/v1alpha1/sessions/${validatePathParam('sessionId', request.sessionId)}`, + }, + unmarshalSession, + ) + + /** + * Terminate an existing session. Terminate a session by its unique ID and + * cancel all its attached jobs. + * + * @param request - The request {@link TerminateSessionRequest} + * @returns A Promise of Session + */ + terminateSession = (request: Readonly) => + this.client.fetch( + { + body: '{}', + headers: jsonContentHeaders, + method: 'POST', + path: `/qaas/v1alpha1/sessions/${validatePathParam('sessionId', request.sessionId)}/terminate`, + }, + unmarshalSession, + ) + + /** + * Delete an existing session. Delete a session by its unique ID and delete + * all its attached jobs. + * + * @param request - The request {@link DeleteSessionRequest} + */ + deleteSession = (request: Readonly) => + this.client.fetch({ + method: 'DELETE', + path: `/qaas/v1alpha1/sessions/${validatePathParam('sessionId', request.sessionId)}`, + }) + + protected pageOfListSessionACLs = ( + request: Readonly, + ) => + this.client.fetch( + { + method: 'GET', + path: `/qaas/v1alpha1/sessions/${validatePathParam('sessionId', request.sessionId)}/acls`, + urlParams: urlParams( + ['order_by', request.orderBy], + ['page', request.page], + [ + 'page_size', + request.pageSize ?? this.client.settings.defaultPageSize, + ], + ), + }, + unmarshalListSessionACLsResponse, + ) + + listSessionACLs = (request: Readonly) => + enrichForPagination('acls', this.pageOfListSessionACLs, request) + + /** + * Create a process. Create a new process for the specified application on a + * specified platform. + * + * @param request - The request {@link CreateProcessRequest} + * @returns A Promise of Process + */ + createProcess = (request: Readonly) => + this.client.fetch( + { + body: JSON.stringify( + marshalCreateProcessRequest(request, this.client.settings), + ), + headers: jsonContentHeaders, + method: 'POST', + path: `/qaas/v1alpha1/processes`, + }, + unmarshalProcess, + ) + + /** + * Get process infrormation. Retrieve information about the provided **process + * ID**, such as name, status and progress. + * + * @param request - The request {@link GetProcessRequest} + * @returns A Promise of Process + */ + getProcess = (request: Readonly) => + this.client.fetch( + { + method: 'GET', + path: `/qaas/v1alpha1/processes/${validatePathParam('processId', request.processId)}`, + }, + unmarshalProcess, + ) + + /** + * Waits for {@link Process} to be in a final state. + * + * @param request - The request {@link GetProcessRequest} + * @param options - The waiting options + * @returns A Promise of Process + */ + waitForProcess = ( + request: Readonly, + options?: Readonly>, + ) => + waitForResource( + options?.stop ?? + (res => + Promise.resolve(!PROCESS_TRANSIENT_STATUSES.includes(res.status))), + this.getProcess, + request, + options, + ) + + protected pageOfListProcesses = ( + request: Readonly = {}, + ) => + this.client.fetch( + { + method: 'GET', + path: `/qaas/v1alpha1/processes`, + urlParams: urlParams( + ['application_id', request.applicationId], + ['order_by', request.orderBy], + ['page', request.page], + [ + 'page_size', + request.pageSize ?? this.client.settings.defaultPageSize, + ], + [ + 'project_id', + request.projectId ?? this.client.settings.defaultProjectId, + ], + ['tags', request.tags], + ), + }, + unmarshalListProcessesResponse, + ) + + /** + * List all processes. Retrieve information about all processes. + * + * @param request - The request {@link ListProcessesRequest} + * @returns A Promise of ListProcessesResponse + */ + listProcesses = (request: Readonly = {}) => + enrichForPagination('processes', this.pageOfListProcesses, request) + + /** + * Update process information. Update process information of the provided + * **process ID**. + * + * @param request - The request {@link UpdateProcessRequest} + * @returns A Promise of Process + */ + updateProcess = (request: Readonly) => + this.client.fetch( + { + body: JSON.stringify( + marshalUpdateProcessRequest(request, this.client.settings), + ), + headers: jsonContentHeaders, + method: 'PATCH', + path: `/qaas/v1alpha1/processes/${validatePathParam('processId', request.processId)}`, + }, + unmarshalProcess, + ) + + /** + * Cancel a running process. Cancel a process by its unique ID. Intermediate + * results are still available. + * + * @param request - The request {@link CancelProcessRequest} + * @returns A Promise of Process + */ + cancelProcess = (request: Readonly) => + this.client.fetch( + { + body: '{}', + headers: jsonContentHeaders, + method: 'POST', + path: `/qaas/v1alpha1/processes/${validatePathParam('processId', request.processId)}/cancel`, + }, + unmarshalProcess, + ) + + /** + * Delete an existing process. Delete a process by its unique ID and delete + * all its data. + * + * @param request - The request {@link DeleteProcessRequest} + */ + deleteProcess = (request: Readonly) => + this.client.fetch({ + method: 'DELETE', + path: `/qaas/v1alpha1/processes/${validatePathParam('processId', request.processId)}`, + }) + + protected pageOfListProcessResults = ( + request: Readonly, + ) => + this.client.fetch( + { + method: 'GET', + path: `/qaas/v1alpha1/processes/${validatePathParam('processId', request.processId)}/results`, + urlParams: urlParams( + ['order_by', request.orderBy], + ['page', request.page], + [ + 'page_size', + request.pageSize ?? this.client.settings.defaultPageSize, + ], + ), + }, + unmarshalListProcessResultsResponse, + ) + + /** + * List all results of a process. Retrieve all intermediate and final result + * of a process. + * + * @param request - The request {@link ListProcessResultsRequest} + * @returns A Promise of ListProcessResultsResponse + */ + listProcessResults = (request: Readonly) => + enrichForPagination( + 'processResults', + this.pageOfListProcessResults, + request, + ) + + /** + * Get application information. Retrieve information about the provided + * **applcation ID**, such as name, type and compatible platforms. + * + * @param request - The request {@link GetApplicationRequest} + * @returns A Promise of Application + */ + getApplication = (request: Readonly) => + this.client.fetch( + { + method: 'GET', + path: `/qaas/v1alpha1/applications/${validatePathParam('applicationId', request.applicationId)}`, + }, + unmarshalApplication, + ) + + protected pageOfListApplications = ( + request: Readonly = {}, + ) => + this.client.fetch( + { + method: 'GET', + path: `/qaas/v1alpha1/applications`, + urlParams: urlParams( + ['application_type', request.applicationType], + ['name', request.name], + ['order_by', request.orderBy], + ['page', request.page], + [ + 'page_size', + request.pageSize ?? this.client.settings.defaultPageSize, + ], + ), + }, + unmarshalListApplicationsResponse, + ) + + /** + * List all available applications. Retrieve information about all + * applications. + * + * @param request - The request {@link ListApplicationsRequest} + * @returns A Promise of ListApplicationsResponse + */ + listApplications = (request: Readonly = {}) => + enrichForPagination('applications', this.pageOfListApplications, request) +} diff --git a/packages/clients/src/api/qaas/v1alpha1/content.gen.ts b/packages/clients/src/api/qaas/v1alpha1/content.gen.ts new file mode 100644 index 000000000..de90902ac --- /dev/null +++ b/packages/clients/src/api/qaas/v1alpha1/content.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. +import type { JobStatus, ProcessStatus, SessionStatus } from './types.gen' + +/** Lists transient statutes of the enum {@link JobStatus}. */ +export const JOB_TRANSIENT_STATUSES: JobStatus[] = [ + 'waiting', + 'running', + 'cancelling', +] + +/** Lists transient statutes of the enum {@link ProcessStatus}. */ +export const PROCESS_TRANSIENT_STATUSES: ProcessStatus[] = [ + 'starting', + 'running', + 'cancelling', +] + +/** Lists transient statutes of the enum {@link SessionStatus}. */ +export const SESSION_TRANSIENT_STATUSES: SessionStatus[] = [ + 'starting', + 'stopping', +] diff --git a/packages/clients/src/api/qaas/v1alpha1/index.gen.ts b/packages/clients/src/api/qaas/v1alpha1/index.gen.ts new file mode 100644 index 000000000..af50cc925 --- /dev/null +++ b/packages/clients/src/api/qaas/v1alpha1/index.gen.ts @@ -0,0 +1,67 @@ +// 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 { + Application, + ApplicationType, + CancelJobRequest, + CancelProcessRequest, + CreateJobRequest, + CreateProcessRequest, + CreateSessionRequest, + DeleteJobRequest, + DeleteProcessRequest, + DeleteSessionRequest, + GetApplicationRequest, + GetJobCircuitRequest, + GetJobRequest, + GetPlatformRequest, + GetProcessRequest, + GetSessionRequest, + Job, + JobCircuit, + JobResult, + JobStatus, + ListApplicationsRequest, + ListApplicationsRequestOrderBy, + ListApplicationsResponse, + ListJobResultsRequest, + ListJobResultsRequestOrderBy, + ListJobResultsResponse, + ListJobsRequest, + ListJobsRequestOrderBy, + ListJobsResponse, + ListPlatformsRequest, + ListPlatformsRequestOrderBy, + ListPlatformsResponse, + ListProcessResultsRequest, + ListProcessResultsRequestOrderBy, + ListProcessResultsResponse, + ListProcessesRequest, + ListProcessesRequestOrderBy, + ListProcessesResponse, + ListSessionACLsRequest, + ListSessionACLsRequestOrderBy, + ListSessionACLsResponse, + ListSessionsRequest, + ListSessionsRequestOrderBy, + ListSessionsResponse, + Platform, + PlatformAvailability, + PlatformHardware, + PlatformTechnology, + PlatformType, + Process, + ProcessResult, + ProcessStatus, + Session, + SessionAccess, + SessionOriginType, + SessionStatus, + TerminateSessionRequest, + UpdateJobRequest, + UpdateProcessRequest, + UpdateSessionRequest, +} from './types.gen' +export * as ValidationRules from './validation-rules.gen' diff --git a/packages/clients/src/api/qaas/v1alpha1/marshalling.gen.ts b/packages/clients/src/api/qaas/v1alpha1/marshalling.gen.ts new file mode 100644 index 000000000..7e27b36e6 --- /dev/null +++ b/packages/clients/src/api/qaas/v1alpha1/marshalling.gen.ts @@ -0,0 +1,410 @@ +// 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, + unmarshalMoney, +} from '../../../bridge' +import type { DefaultValues } from '../../../bridge' +import type { + Application, + CreateJobRequest, + CreateProcessRequest, + CreateSessionRequest, + Job, + JobCircuit, + JobResult, + ListApplicationsResponse, + ListJobResultsResponse, + ListJobsResponse, + ListPlatformsResponse, + ListProcessResultsResponse, + ListProcessesResponse, + ListSessionACLsResponse, + ListSessionsResponse, + Platform, + PlatformHardware, + Process, + ProcessResult, + Session, + UpdateJobRequest, + UpdateProcessRequest, + UpdateSessionRequest, +} from './types.gen' + +export const unmarshalJobCircuit = (data: unknown): JobCircuit => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'JobCircuit' failed as data isn't a dictionary.`, + ) + } + + return { + percevalCircuit: data.perceval_circuit, + qiskitCircuit: data.qiskit_circuit, + } as JobCircuit +} + +export const unmarshalApplication = (data: unknown): Application => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'Application' failed as data isn't a dictionary.`, + ) + } + + return { + compatiblePlatformIds: data.compatible_platform_ids, + id: data.id, + inputTemplate: data.input_template, + name: data.name, + type: data.type, + } as Application +} + +export const unmarshalJob = (data: unknown): Job => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'Job' failed as data isn't a dictionary.`, + ) + } + + return { + createdAt: unmarshalDate(data.created_at), + id: data.id, + jobDuration: data.job_duration, + name: data.name, + progressMessage: data.progress_message, + resultDistribution: data.result_distribution, + sessionId: data.session_id, + startedAt: unmarshalDate(data.started_at), + status: data.status, + tags: data.tags, + updatedAt: unmarshalDate(data.updated_at), + } as Job +} + +const unmarshalPlatformHardware = (data: unknown): PlatformHardware => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'PlatformHardware' failed as data isn't a dictionary.`, + ) + } + + return { + gpus: data.gpus, + gpusNetwork: data.gpus_network, + name: data.name, + ram: data.ram, + vcpus: data.vcpus, + vram: data.vram, + } as PlatformHardware +} + +export const unmarshalPlatform = (data: unknown): Platform => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'Platform' failed as data isn't a dictionary.`, + ) + } + + return { + availability: data.availability, + backendName: data.backend_name, + hardware: data.hardware + ? unmarshalPlatformHardware(data.hardware) + : undefined, + id: data.id, + maxQubitCount: data.max_qubit_count, + metadata: data.metadata, + name: data.name, + pricePerHour: data.price_per_hour + ? unmarshalMoney(data.price_per_hour) + : undefined, + providerName: data.provider_name, + technology: data.technology, + type: data.type, + version: data.version, + } as Platform +} + +export const unmarshalProcess = (data: unknown): Process => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'Process' failed as data isn't a dictionary.`, + ) + } + + return { + applicationId: data.application_id, + attachedSessionIds: data.attached_session_ids, + createdAt: unmarshalDate(data.created_at), + finishedAt: unmarshalDate(data.finished_at), + id: data.id, + input: data.input, + name: data.name, + platformId: data.platform_id, + progress: data.progress, + progressMessage: data.progress_message, + projectId: data.project_id, + startedAt: unmarshalDate(data.started_at), + status: data.status, + tags: data.tags, + updatedAt: unmarshalDate(data.updated_at), + } as Process +} + +export const unmarshalSession = (data: unknown): Session => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'Session' failed as data isn't a dictionary.`, + ) + } + + return { + createdAt: unmarshalDate(data.created_at), + deduplicationId: data.deduplication_id, + finishedJobCount: data.finished_job_count, + id: data.id, + maxDuration: data.max_duration, + maxIdleDuration: data.max_idle_duration, + name: data.name, + originId: data.origin_id, + originType: data.origin_type, + platformId: data.platform_id, + progressMessage: data.progress_message, + projectId: data.project_id, + startedAt: unmarshalDate(data.started_at), + status: data.status, + tags: data.tags, + terminatedAt: unmarshalDate(data.terminated_at), + updatedAt: unmarshalDate(data.updated_at), + waitingJobCount: data.waiting_job_count, + } as Session +} + +export const unmarshalListApplicationsResponse = ( + data: unknown, +): ListApplicationsResponse => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'ListApplicationsResponse' failed as data isn't a dictionary.`, + ) + } + + return { + applications: unmarshalArrayOfObject( + data.applications, + unmarshalApplication, + ), + totalCount: data.total_count, + } as ListApplicationsResponse +} + +const unmarshalJobResult = (data: unknown): JobResult => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'JobResult' failed as data isn't a dictionary.`, + ) + } + + return { + createdAt: unmarshalDate(data.created_at), + jobId: data.job_id, + result: data.result, + url: data.url, + } as JobResult +} + +export const unmarshalListJobResultsResponse = ( + data: unknown, +): ListJobResultsResponse => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'ListJobResultsResponse' failed as data isn't a dictionary.`, + ) + } + + return { + jobResults: unmarshalArrayOfObject(data.job_results, unmarshalJobResult), + totalCount: data.total_count, + } as ListJobResultsResponse +} + +export const unmarshalListJobsResponse = (data: unknown): ListJobsResponse => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'ListJobsResponse' failed as data isn't a dictionary.`, + ) + } + + return { + jobs: unmarshalArrayOfObject(data.jobs, unmarshalJob), + totalCount: data.total_count, + } as ListJobsResponse +} + +export const unmarshalListPlatformsResponse = ( + data: unknown, +): ListPlatformsResponse => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'ListPlatformsResponse' failed as data isn't a dictionary.`, + ) + } + + return { + platforms: unmarshalArrayOfObject(data.platforms, unmarshalPlatform), + totalCount: data.total_count, + } as ListPlatformsResponse +} + +const unmarshalProcessResult = (data: unknown): ProcessResult => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'ProcessResult' failed as data isn't a dictionary.`, + ) + } + + return { + createdAt: unmarshalDate(data.created_at), + processId: data.process_id, + result: data.result, + } as ProcessResult +} + +export const unmarshalListProcessResultsResponse = ( + data: unknown, +): ListProcessResultsResponse => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'ListProcessResultsResponse' failed as data isn't a dictionary.`, + ) + } + + return { + processResults: unmarshalArrayOfObject( + data.process_results, + unmarshalProcessResult, + ), + totalCount: data.total_count, + } as ListProcessResultsResponse +} + +export const unmarshalListProcessesResponse = ( + data: unknown, +): ListProcessesResponse => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'ListProcessesResponse' failed as data isn't a dictionary.`, + ) + } + + return { + processes: unmarshalArrayOfObject(data.processes, unmarshalProcess), + totalCount: data.total_count, + } as ListProcessesResponse +} + +export const unmarshalListSessionACLsResponse = ( + data: unknown, +): ListSessionACLsResponse => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'ListSessionACLsResponse' failed as data isn't a dictionary.`, + ) + } + + return { + acls: data.acls, + totalCount: data.total_count, + } as ListSessionACLsResponse +} + +export const unmarshalListSessionsResponse = ( + data: unknown, +): ListSessionsResponse => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'ListSessionsResponse' failed as data isn't a dictionary.`, + ) + } + + return { + sessions: unmarshalArrayOfObject(data.sessions, unmarshalSession), + totalCount: data.total_count, + } as ListSessionsResponse +} + +const marshalJobCircuit = ( + request: JobCircuit, + defaults: DefaultValues, +): Record => ({ + ...resolveOneOf([ + { param: 'perceval_circuit', value: request.percevalCircuit }, + { param: 'qiskit_circuit', value: request.qiskitCircuit }, + ]), +}) + +export const marshalCreateJobRequest = ( + request: CreateJobRequest, + defaults: DefaultValues, +): Record => ({ + circuit: marshalJobCircuit(request.circuit, defaults), + max_duration: request.maxDuration, + name: request.name, + session_id: request.sessionId, + tags: request.tags, +}) + +export const marshalCreateProcessRequest = ( + request: CreateProcessRequest, + defaults: DefaultValues, +): Record => ({ + application_id: request.applicationId, + input: request.input, + name: request.name, + platform_id: request.platformId, + project_id: request.projectId ?? defaults.defaultProjectId, + tags: request.tags, +}) + +export const marshalCreateSessionRequest = ( + request: CreateSessionRequest, + defaults: DefaultValues, +): Record => ({ + deduplication_id: request.deduplicationId, + max_duration: request.maxDuration, + max_idle_duration: request.maxIdleDuration, + name: request.name, + platform_id: request.platformId, + project_id: request.projectId ?? defaults.defaultProjectId, + tags: request.tags, +}) + +export const marshalUpdateJobRequest = ( + request: UpdateJobRequest, + defaults: DefaultValues, +): Record => ({ + name: request.name, + tags: request.tags, +}) + +export const marshalUpdateProcessRequest = ( + request: UpdateProcessRequest, + defaults: DefaultValues, +): Record => ({ + name: request.name, + tags: request.tags, +}) + +export const marshalUpdateSessionRequest = ( + request: UpdateSessionRequest, + defaults: DefaultValues, +): Record => ({ + max_duration: request.maxDuration, + max_idle_duration: request.maxIdleDuration, + name: request.name, + tags: request.tags, +}) diff --git a/packages/clients/src/api/qaas/v1alpha1/types.gen.ts b/packages/clients/src/api/qaas/v1alpha1/types.gen.ts new file mode 100644 index 000000000..3a189b916 --- /dev/null +++ b/packages/clients/src/api/qaas/v1alpha1/types.gen.ts @@ -0,0 +1,608 @@ +// 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 } from '../../../bridge' + +export type ApplicationType = 'unknown_type' | 'vqe' + +export type JobStatus = + | 'unknown_status' + | 'waiting' + | 'error' + | 'running' + | 'completed' + | 'cancelling' + | 'cancelled' + +export type ListApplicationsRequestOrderBy = + | 'name_asc' + | 'name_desc' + | 'type_asc' + | 'type_desc' + +export type ListJobResultsRequestOrderBy = 'created_at_desc' | 'created_at_asc' + +export type ListJobsRequestOrderBy = + | 'created_at_desc' + | 'created_at_asc' + | 'status_asc' + | 'status_desc' + | 'platform_name_asc' + | 'platform_name_desc' + | 'name_asc' + | 'name_desc' + | 'session_name_asc' + | 'session_name_desc' + +export type ListPlatformsRequestOrderBy = + | 'name_asc' + | 'name_desc' + | 'provider_name_asc' + | 'provider_name_desc' + | 'type_asc' + | 'type_desc' + | 'technology_asc' + | 'technology_desc' + | 'backend_name_asc' + | 'backend_name_desc' + +export type ListProcessResultsRequestOrderBy = + | 'created_at_desc' + | 'created_at_asc' + +export type ListProcessesRequestOrderBy = + | 'created_at_desc' + | 'created_at_asc' + | 'name_asc' + | 'name_desc' + | 'started_at_asc' + | 'started_at_desc' + | 'status_asc' + | 'status_desc' + +export type ListSessionACLsRequestOrderBy = 'access_asc' | 'access_desc' + +export type ListSessionsRequestOrderBy = + | 'name_asc' + | 'name_desc' + | 'started_at_asc' + | 'started_at_desc' + | 'status_asc' + | 'status_desc' + | 'created_at_desc' + | 'created_at_asc' + +export type PlatformAvailability = + | 'unknown_availability' + | 'available' + | 'shortage' + | 'scarce' + +export type PlatformTechnology = + | 'unknown_technology' + | 'photonic' + | 'general_purpose' + +export type PlatformType = 'unknown_type' | 'simulator' | 'qpu' + +export type ProcessStatus = + | 'unknown_status' + | 'error' + | 'starting' + | 'running' + | 'completed' + | 'cancelling' + | 'cancelled' + +export type SessionAccess = + | 'unknown_access' + | 'full' + | 'read_session' + | 'read_write_session' + | 'read_job_result' + | 'read_job_circuit' + | 'read_job' + | 'read_write_job' + +export type SessionOriginType = 'unknown_origin_type' | 'customer' | 'process' + +export type SessionStatus = + | 'unknown_status' + | 'running' + | 'stopped' + | 'starting' + | 'stopping' + +export interface PlatformHardware { + /** Product name of the hardware. */ + name: string + /** Number of vCPUs available. */ + vcpus: number + /** Number of GPUs available (0 if no GPU). */ + gpus: number + /** Network topology of GPUs (PCIe, NVLink...). */ + gpusNetwork: string + /** Amount of RAM available in byte. */ + ram: number + /** Amount of VRAM available in byte (0 if no GPU). */ + vram: number +} + +export interface JobCircuit { + /** + * Circuit generated by Perceval that should be executed. + * + * One-of ('circuitSerialization'): at most one of 'percevalCircuit', + * 'qiskitCircuit' could be set. + */ + percevalCircuit?: string + /** + * Circuit generated by Qiskit that should be executed. + * + * One-of ('circuitSerialization'): at most one of 'percevalCircuit', + * 'qiskitCircuit' could be set. + */ + qiskitCircuit?: string +} + +export interface Application { + /** Unique ID of the application. */ + id: string + /** Name of the application. */ + name: string + /** Type of the application. */ + type: ApplicationType + /** List of compatible platform (by IDs) able to run this application. */ + compatiblePlatformIds: string[] + /** JSON format describing the expected input. */ + inputTemplate: string +} + +export interface JobResult { + /** ID of the parent job. */ + jobId: string + /** Result in JSON format. */ + result?: string + /** URL to download a large result (optional). */ + url?: string + /** Creation time of the result. */ + createdAt?: Date +} + +export interface Job { + /** Unique ID of the job. */ + id: string + /** Job name. */ + name: string + /** Tags of the job. */ + tags?: string[] + /** Session ID in which the job is executed. */ + sessionId: string + /** Time at which the job was created. */ + createdAt?: Date + /** Time at which the job was started. */ + startedAt?: Date + /** Time at which the job was updated. */ + updatedAt?: Date + /** Job status. */ + status: JobStatus + /** Last progress message, if the job has started. */ + progressMessage?: string + /** Duration of the job, if the job is finished. */ + jobDuration?: string + /** Result of the job, if the job is finished. */ + resultDistribution?: string +} + +export interface Platform { + /** Unique ID of the platform. */ + id: string + /** Verison of the platform. */ + version: string + /** Name of the platform. */ + name: string + /** Provider name of the platform. */ + providerName: string + /** Name of the running backend over the platform (ascella, qsim, aer...). */ + backendName: string + /** Type of the platform. */ + type: PlatformType + /** Technology used by the platform. */ + technology: PlatformTechnology + /** Estimated maximum number of qubits supported by the platform. */ + maxQubitCount: number + /** Availability of the platform. */ + availability: PlatformAvailability + /** Metadata provided by the platform. */ + metadata: string + /** Price to be payed per hour (excluding free tiers). */ + pricePerHour?: Money + /** Specifications of the underlying hardware. */ + hardware?: PlatformHardware +} + +export interface ProcessResult { + /** ID of the parent process. */ + processId: string + /** Result in JSON format. */ + result: string + /** Creation time of the result. */ + createdAt?: Date +} + +export interface Process { + /** Unique ID of the process. */ + id: string + /** Name of the process. */ + name: string + /** Application ID for which the process has been created. */ + applicationId?: string + /** Platform ID for which the process has been created. */ + platformId?: string + /** List of sessions generated by the process. */ + attachedSessionIds: string[] + /** Tme at which the process was created. */ + createdAt?: Date + /** Time at which the process started. */ + startedAt?: Date + /** Time at which the process was updated. */ + updatedAt?: Date + /** Time at which the process was finished. */ + finishedAt?: Date + /** Status of the process. */ + status: ProcessStatus + /** Project ID in which the process has been created. */ + projectId: string + /** Tags of the process. */ + tags: string[] + /** Progress of the process, from 0 to 1. */ + progress?: number + /** Any progress of the process. */ + progressMessage?: string + /** Input payload of the process as JSON string. */ + input?: string +} + +export interface Session { + /** Unique ID of the session. */ + id: string + /** Name of the session. */ + name: string + /** Platform ID for which the session has been created. */ + platformId: string + /** The time at which the session was created. */ + createdAt?: Date + /** The time at which the session started. */ + startedAt?: Date + /** The time at which the session was updated. */ + updatedAt?: Date + /** The time at which the session was terminated. */ + terminatedAt?: Date + /** Maximum idle time before the session ends. */ + maxIdleDuration?: string + /** Maximum duration before the session ends. */ + maxDuration?: string + /** Number of waiting jobs linked to the session. */ + waitingJobCount: number + /** Number of finished jobs linked to the session. */ + finishedJobCount: number + /** Status of the session. */ + status: SessionStatus + /** Project ID in which the session has been created. */ + projectId: string + /** Tags of the session. */ + tags?: string[] + /** Deduplication ID of the session. */ + deduplicationId: string + /** Resource type that creates the session. */ + originType: SessionOriginType + /** Unique ID of the session's origin resource (if exists). */ + originId?: string + /** Any progress of the session. */ + progressMessage?: string +} + +export type CancelJobRequest = { + /** Unique ID of the job. */ + jobId: string +} + +export type CancelProcessRequest = { + /** Unique ID of the process. */ + processId: string +} + +export type CreateJobRequest = { + /** Name of the job. */ + name: string + /** Tags of the job. */ + tags?: string[] + /** Session in which the job is executed. */ + sessionId: string + /** Quantum circuit that should be executed. */ + circuit: JobCircuit + /** Maximum duration of the job. */ + maxDuration?: string +} + +export type CreateProcessRequest = { + /** ID of the project in which the process was created. */ + projectId?: string + /** ID of the platform for which the process was created. */ + platformId?: string + /** ID of the application for which the process was created. */ + applicationId?: string + /** Name of the process. */ + name: string + /** Process parameters in JSON format. */ + input?: string + /** Tags of the process. */ + tags?: string[] +} + +export type CreateSessionRequest = { + /** ID of the Project in which the session was created. */ + projectId?: string + /** ID of the Platform for which the session was created. */ + platformId: string + /** Name of the session. */ + name?: string + /** Maximum idle duration before the session ends. */ + maxIdleDuration?: string + /** Maximum duration before the session ends. */ + maxDuration?: string + /** Tags of the session. */ + tags?: string[] + /** Deduplication ID of the session. */ + deduplicationId?: string +} + +export type DeleteJobRequest = { + /** Unique ID of the job. */ + jobId: string +} + +export type DeleteProcessRequest = { + /** Unique ID of the process. */ + processId: string +} + +export type DeleteSessionRequest = { + /** Unique ID of the session. */ + sessionId: string +} + +export type GetApplicationRequest = { + /** Unique ID of the application. */ + applicationId: string +} + +export type GetJobCircuitRequest = { + /** Unique ID of the job. */ + jobId: string +} + +export type GetJobRequest = { + /** Unique ID of the job you want to get. */ + jobId: string +} + +export type GetPlatformRequest = { + /** Unique ID of the platform. */ + platformId: string +} + +export type GetProcessRequest = { + /** Unique ID of the process. */ + processId: string +} + +export type GetSessionRequest = { + /** Unique ID of the session. */ + sessionId: string +} + +export type ListApplicationsRequest = { + /** List applications with this name. */ + name?: string + /** List applications with this type. */ + applicationType?: ApplicationType + /** Page number. */ + page?: number + /** Maximum number of applications a to return per page. */ + pageSize?: number + /** Sort order of the returned applications. */ + orderBy?: ListApplicationsRequestOrderBy +} + +export interface ListApplicationsResponse { + /** Total number of applications. */ + totalCount: number + /** List of applications. */ + applications: Application[] +} + +export type ListJobResultsRequest = { + /** ID of the job. */ + jobId: string + /** Page number. */ + page?: number + /** Maximum number of results to return per page. */ + pageSize?: number + /** Sort order of the returned results. */ + orderBy?: ListJobResultsRequestOrderBy +} + +export interface ListJobResultsResponse { + /** Total number of results. */ + totalCount: number + /** List of results. */ + jobResults: JobResult[] +} + +export type ListJobsRequest = { + /** + * List jobs with this session ID. + * + * One-of ('resourceId'): at most one of 'sessionId', 'projectId' could be + * set. + */ + sessionId?: string + /** + * List jobs with this project ID. + * + * One-of ('resourceId'): at most one of 'sessionId', 'projectId' could be + * set. + */ + projectId?: string + /** List jobs with these tags. */ + tags?: string[] + /** Page number. */ + page?: number + /** Maximum number of jobs to return per page. */ + pageSize?: number + /** Sort order of the returned jobs. */ + orderBy?: ListJobsRequestOrderBy +} + +export interface ListJobsResponse { + /** Total number of jobs. */ + totalCount: number + /** List of jobs. */ + jobs: Job[] +} + +export type ListPlatformsRequest = { + /** List platforms with this provider name. */ + providerName?: string + /** List platforms with this backend name. */ + backendName?: string + /** List platforms with this name. */ + name?: string + /** List platforms with this type. */ + platformType?: PlatformType + /** List platforms with this technology. */ + platformTechnology?: PlatformTechnology + /** Page number. */ + page?: number + /** Maximum number of platforms to return per page. */ + pageSize?: number + /** Sort order of the returned platforms. */ + orderBy?: ListPlatformsRequestOrderBy +} + +export interface ListPlatformsResponse { + /** Total number of platforms. */ + totalCount: number + /** List of platforms. */ + platforms: Platform[] +} + +export type ListProcessResultsRequest = { + /** ID of the process. */ + processId: string + /** Page number. */ + page?: number + /** Maximum number of results to return per page. */ + pageSize?: number + /** Sort order of the returned results. */ + orderBy?: ListProcessResultsRequestOrderBy +} + +export interface ListProcessResultsResponse { + /** Total number of results. */ + totalCount: number + /** List of results. */ + processResults: ProcessResult[] +} + +export type ListProcessesRequest = { + /** List processes that have been created for this application. */ + applicationId?: string + /** List processes with these tags. */ + tags?: string[] + /** Page number. */ + page?: number + /** Maximum number of processes to return per page. */ + pageSize?: number + /** Sort order of the returned processes. */ + orderBy?: ListProcessesRequestOrderBy + /** List processes belonging to this project ID. */ + projectId?: string +} + +export interface ListProcessesResponse { + /** Total number of processes. */ + totalCount: number + /** List of processes. */ + processes: Process[] +} + +export type ListSessionACLsRequest = { + sessionId: string + page?: number + pageSize?: number + orderBy?: ListSessionACLsRequestOrderBy +} + +export interface ListSessionACLsResponse { + totalCount: number + acls: SessionAccess[] +} + +export type ListSessionsRequest = { + /** List sessions that have been created for this platform. */ + platformId?: string + /** List sessions with these tags. */ + tags?: string[] + /** Page number. */ + page?: number + /** Maximum number of sessions to return per page. */ + pageSize?: number + /** Sort order of the returned sessions. */ + orderBy?: ListSessionsRequestOrderBy + /** List sessions belonging to this project ID. */ + projectId?: string +} + +export interface ListSessionsResponse { + /** Total number of sessions. */ + totalCount: number + /** List of sessions. */ + sessions: Session[] +} + +export type TerminateSessionRequest = { + /** Unique ID of the session. */ + sessionId: string +} + +export type UpdateJobRequest = { + /** Unique ID of the job. */ + jobId: string + /** Name of the job. */ + name?: string + /** Tags of the job. */ + tags?: string[] +} + +export type UpdateProcessRequest = { + /** Unique ID of the process. */ + processId: string + /** Name of the process. */ + name?: string + /** Tags of the process. */ + tags?: string[] +} + +export type UpdateSessionRequest = { + /** Unique ID of the session. */ + sessionId: string + /** Name of the session. */ + name?: string + /** Maximum idle duration before the session ends. */ + maxIdleDuration?: string + /** Maximum time before the session ends. */ + maxDuration?: string + /** Tags of the session. */ + tags?: string[] +} diff --git a/packages/clients/src/api/qaas/v1alpha1/validation-rules.gen.ts b/packages/clients/src/api/qaas/v1alpha1/validation-rules.gen.ts new file mode 100644 index 000000000..5256a2ac1 --- /dev/null +++ b/packages/clients/src/api/qaas/v1alpha1/validation-rules.gen.ts @@ -0,0 +1,14 @@ +// This file was automatically generated. DO NOT EDIT. +// If you have any remark or suggestion do not hesitate to open an issue. + +export const CreateJobRequest = { + name: { + minLength: 1, + }, +} + +export const CreateProcessRequest = { + name: { + minLength: 1, + }, +} diff --git a/packages/clients/src/api/vpc/v2/marshalling.gen.ts b/packages/clients/src/api/vpc/v2/marshalling.gen.ts index ca5b2a640..8e7e2723c 100644 --- a/packages/clients/src/api/vpc/v2/marshalling.gen.ts +++ b/packages/clients/src/api/vpc/v2/marshalling.gen.ts @@ -83,6 +83,7 @@ export const unmarshalRoute = (data: unknown): Route => { description: data.description, destination: data.destination, id: data.id, + isReadOnly: data.is_read_only, nexthopPrivateNetworkId: data.nexthop_private_network_id, nexthopResourceId: data.nexthop_resource_id, region: data.region, diff --git a/packages/clients/src/api/vpc/v2/types.gen.ts b/packages/clients/src/api/vpc/v2/types.gen.ts index 12ba8bb1f..635aa30f1 100644 --- a/packages/clients/src/api/vpc/v2/types.gen.ts +++ b/packages/clients/src/api/vpc/v2/types.gen.ts @@ -77,6 +77,8 @@ export interface Route { createdAt?: Date /** Date the Route was last modified. */ updatedAt?: Date + /** Defines whether the route can be modified or deleted by the user. */ + isReadOnly: boolean /** Region of the Route. */ region: Region } diff --git a/packages/clients/src/api/webhosting/v1/api.gen.ts b/packages/clients/src/api/webhosting/v1/api.gen.ts new file mode 100644 index 000000000..cf0dc1d3f --- /dev/null +++ b/packages/clients/src/api/webhosting/v1/api.gen.ts @@ -0,0 +1,862 @@ +// 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 { Region, WaitForOptions } from '../../../bridge' +import { HOSTING_TRANSIENT_STATUSES } from './content.gen' +import { + marshalDatabaseApiAssignDatabaseUserRequest, + marshalDatabaseApiChangeDatabaseUserPasswordRequest, + marshalDatabaseApiCreateDatabaseRequest, + marshalDatabaseApiCreateDatabaseUserRequest, + marshalDatabaseApiUnassignDatabaseUserRequest, + marshalFtpAccountApiChangeFtpAccountPasswordRequest, + marshalFtpAccountApiCreateFtpAccountRequest, + marshalHostingApiCreateHostingRequest, + marshalHostingApiUpdateHostingRequest, + marshalMailAccountApiChangeMailAccountPasswordRequest, + marshalMailAccountApiCreateMailAccountRequest, + marshalMailAccountApiRemoveMailAccountRequest, + unmarshalDatabase, + unmarshalDatabaseUser, + unmarshalFtpAccount, + unmarshalHosting, + unmarshalListControlPanelsResponse, + unmarshalListDatabaseUsersResponse, + unmarshalListDatabasesResponse, + unmarshalListFtpAccountsResponse, + unmarshalListHostingsResponse, + unmarshalListMailAccountsResponse, + unmarshalListOffersResponse, + unmarshalListWebsitesResponse, + unmarshalMailAccount, + unmarshalResetHostingPasswordResponse, + unmarshalSession, +} from './marshalling.gen' +import type { + ControlPanelApiListControlPanelsRequest, + Database, + DatabaseApiAssignDatabaseUserRequest, + DatabaseApiChangeDatabaseUserPasswordRequest, + DatabaseApiCreateDatabaseRequest, + DatabaseApiCreateDatabaseUserRequest, + DatabaseApiDeleteDatabaseRequest, + DatabaseApiDeleteDatabaseUserRequest, + DatabaseApiGetDatabaseRequest, + DatabaseApiGetDatabaseUserRequest, + DatabaseApiListDatabaseUsersRequest, + DatabaseApiListDatabasesRequest, + DatabaseApiUnassignDatabaseUserRequest, + DatabaseUser, + FtpAccount, + FtpAccountApiChangeFtpAccountPasswordRequest, + FtpAccountApiCreateFtpAccountRequest, + FtpAccountApiListFtpAccountsRequest, + FtpAccountApiRemoveFtpAccountRequest, + Hosting, + HostingApiCreateHostingRequest, + HostingApiCreateSessionRequest, + HostingApiDeleteHostingRequest, + HostingApiGetHostingRequest, + HostingApiListHostingsRequest, + HostingApiResetHostingPasswordRequest, + HostingApiUpdateHostingRequest, + ListControlPanelsResponse, + ListDatabaseUsersResponse, + ListDatabasesResponse, + ListFtpAccountsResponse, + ListHostingsResponse, + ListMailAccountsResponse, + ListOffersResponse, + ListWebsitesResponse, + MailAccount, + MailAccountApiChangeMailAccountPasswordRequest, + MailAccountApiCreateMailAccountRequest, + MailAccountApiListMailAccountsRequest, + MailAccountApiRemoveMailAccountRequest, + OfferApiListOffersRequest, + ResetHostingPasswordResponse, + Session, + WebsiteApiListWebsitesRequest, +} from './types.gen' + +const jsonContentHeaders = { + 'Content-Type': 'application/json; charset=utf-8', +} + +/** + * Web Hosting API. + * + * This API allows you to manage your Web Hosting services. + */ +export class ControlPanelAPI extends ParentAPI { + /** Lists the available regions of the API. */ + public static readonly LOCALITIES: Region[] = ['fr-par', 'nl-ams'] + + protected pageOfListControlPanels = ( + request: Readonly = {}, + ) => + this.client.fetch( + { + method: 'GET', + path: `/webhosting/v1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/control-panels`, + urlParams: urlParams( + ['page', request.page], + [ + 'page_size', + request.pageSize ?? this.client.settings.defaultPageSize, + ], + ), + }, + unmarshalListControlPanelsResponse, + ) + + /** + * "List the control panels type: cpanel or plesk.". + * + * @param request - The request {@link ControlPanelApiListControlPanelsRequest} + * @returns A Promise of ListControlPanelsResponse + */ + listControlPanels = ( + request: Readonly = {}, + ) => + enrichForPagination('controlPanels', this.pageOfListControlPanels, request) +} + +/** + * Web Hosting Database API. + * + * This API allows you to manage your databases and database users for your Web + * Hosting services. + */ +export class DatabaseAPI extends ParentAPI { + /** Lists the available regions of the API. */ + public static readonly LOCALITIES: Region[] = ['fr-par', 'nl-ams', 'pl-waw'] + + /** + * "Create a new database within your hosting plan". + * + * @param request - The request {@link DatabaseApiCreateDatabaseRequest} + * @returns A Promise of Database + */ + createDatabase = (request: Readonly) => + this.client.fetch( + { + body: JSON.stringify( + marshalDatabaseApiCreateDatabaseRequest( + request, + this.client.settings, + ), + ), + headers: jsonContentHeaders, + method: 'POST', + path: `/webhosting/v1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/hostings/${validatePathParam('hostingId', request.hostingId)}/databases`, + }, + unmarshalDatabase, + ) + + protected pageOfListDatabases = ( + request: Readonly, + ) => + this.client.fetch( + { + method: 'GET', + path: `/webhosting/v1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/hostings/${validatePathParam('hostingId', request.hostingId)}/databases`, + urlParams: urlParams( + ['order_by', request.orderBy], + ['page', request.page], + [ + 'page_size', + request.pageSize ?? this.client.settings.defaultPageSize, + ], + ), + }, + unmarshalListDatabasesResponse, + ) + + /** + * "List all databases within your hosting plan". + * + * @param request - The request {@link DatabaseApiListDatabasesRequest} + * @returns A Promise of ListDatabasesResponse + */ + listDatabases = (request: Readonly) => + enrichForPagination('databases', this.pageOfListDatabases, request) + + /** + * "Get details of a database within your hosting plan". + * + * @param request - The request {@link DatabaseApiGetDatabaseRequest} + * @returns A Promise of Database + */ + getDatabase = (request: Readonly) => + this.client.fetch( + { + method: 'GET', + path: `/webhosting/v1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/hostings/${validatePathParam('hostingId', request.hostingId)}/databases/${validatePathParam('databaseName', request.databaseName)}`, + }, + unmarshalDatabase, + ) + + /** + * "Delete a database within your hosting plan". + * + * @param request - The request {@link DatabaseApiDeleteDatabaseRequest} + * @returns A Promise of Database + */ + deleteDatabase = (request: Readonly) => + this.client.fetch( + { + method: 'DELETE', + path: `/webhosting/v1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/hostings/${validatePathParam('hostingId', request.hostingId)}/databases/${validatePathParam('databaseName', request.databaseName)}`, + }, + unmarshalDatabase, + ) + + /** + * "Create a new database user". + * + * @param request - The request {@link DatabaseApiCreateDatabaseUserRequest} + * @returns A Promise of DatabaseUser + */ + createDatabaseUser = ( + request: Readonly, + ) => + this.client.fetch( + { + body: JSON.stringify( + marshalDatabaseApiCreateDatabaseUserRequest( + request, + this.client.settings, + ), + ), + headers: jsonContentHeaders, + method: 'POST', + path: `/webhosting/v1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/hostings/${validatePathParam('hostingId', request.hostingId)}/databases-users`, + }, + unmarshalDatabaseUser, + ) + + protected pageOfListDatabaseUsers = ( + request: Readonly, + ) => + this.client.fetch( + { + method: 'GET', + path: `/webhosting/v1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/hostings/${validatePathParam('hostingId', request.hostingId)}/database-users`, + urlParams: urlParams( + ['order_by', request.orderBy], + ['page', request.page], + [ + 'page_size', + request.pageSize ?? this.client.settings.defaultPageSize, + ], + ), + }, + unmarshalListDatabaseUsersResponse, + ) + + /** + * "List all database users". + * + * @param request - The request {@link DatabaseApiListDatabaseUsersRequest} + * @returns A Promise of ListDatabaseUsersResponse + */ + listDatabaseUsers = ( + request: Readonly, + ) => enrichForPagination('users', this.pageOfListDatabaseUsers, request) + + /** + * "Get details of a database user". + * + * @param request - The request {@link DatabaseApiGetDatabaseUserRequest} + * @returns A Promise of DatabaseUser + */ + getDatabaseUser = (request: Readonly) => + this.client.fetch( + { + method: 'GET', + path: `/webhosting/v1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/hostings/${validatePathParam('hostingId', request.hostingId)}/databases-users/${validatePathParam('username', request.username)}`, + }, + unmarshalDatabaseUser, + ) + + /** + * "Delete a database user". + * + * @param request - The request {@link DatabaseApiDeleteDatabaseUserRequest} + * @returns A Promise of DatabaseUser + */ + deleteDatabaseUser = ( + request: Readonly, + ) => + this.client.fetch( + { + method: 'DELETE', + path: `/webhosting/v1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/hostings/${validatePathParam('hostingId', request.hostingId)}/database-users/${validatePathParam('username', request.username)}`, + }, + unmarshalDatabaseUser, + ) + + /** + * "Change the password of a database user". + * + * @param request - The request + * {@link DatabaseApiChangeDatabaseUserPasswordRequest} + * @returns A Promise of DatabaseUser + */ + changeDatabaseUserPassword = ( + request: Readonly, + ) => + this.client.fetch( + { + body: JSON.stringify( + marshalDatabaseApiChangeDatabaseUserPasswordRequest( + request, + this.client.settings, + ), + ), + headers: jsonContentHeaders, + method: 'POST', + path: `/webhosting/v1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/hostings/${validatePathParam('hostingId', request.hostingId)}/databases-users/${validatePathParam('username', request.username)}/change-password`, + }, + unmarshalDatabaseUser, + ) + + /** + * "Assign a database user to a database". + * + * @param request - The request {@link DatabaseApiAssignDatabaseUserRequest} + * @returns A Promise of DatabaseUser + */ + assignDatabaseUser = ( + request: Readonly, + ) => + this.client.fetch( + { + body: JSON.stringify( + marshalDatabaseApiAssignDatabaseUserRequest( + request, + this.client.settings, + ), + ), + headers: jsonContentHeaders, + method: 'POST', + path: `/webhosting/v1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/hostings/${validatePathParam('hostingId', request.hostingId)}/databases/${validatePathParam('databaseName', request.databaseName)}/assign-user`, + }, + unmarshalDatabaseUser, + ) + + /** + * "Unassign a database user from a database". + * + * @param request - The request {@link DatabaseApiUnassignDatabaseUserRequest} + * @returns A Promise of DatabaseUser + */ + unassignDatabaseUser = ( + request: Readonly, + ) => + this.client.fetch( + { + body: JSON.stringify( + marshalDatabaseApiUnassignDatabaseUserRequest( + request, + this.client.settings, + ), + ), + headers: jsonContentHeaders, + method: 'POST', + path: `/webhosting/v1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/hostings/${validatePathParam('hostingId', request.hostingId)}/databases/${validatePathParam('databaseName', request.databaseName)}/unassign-user`, + }, + unmarshalDatabaseUser, + ) +} + +/** + * Web Hosting Offer API. + * + * This API allows you to manage your offer for your Web Hosting services. + */ +export class OfferAPI extends ParentAPI { + /** Lists the available regions of the API. */ + public static readonly LOCALITIES: Region[] = ['fr-par', 'nl-ams', 'pl-waw'] + + protected pageOfListOffers = ( + request: Readonly = {}, + ) => + this.client.fetch( + { + method: 'GET', + path: `/webhosting/v1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/offers`, + urlParams: urlParams( + ['control_panels', request.controlPanels], + ['hosting_id', request.hostingId], + ['order_by', request.orderBy], + ['page', request.page], + [ + 'page_size', + request.pageSize ?? this.client.settings.defaultPageSize, + ], + ), + }, + unmarshalListOffersResponse, + ) + + /** + * List all available hosting offers along with their specific options.. List + * all available hosting offers along with their specific options. + * + * @param request - The request {@link OfferApiListOffersRequest} + * @returns A Promise of ListOffersResponse + */ + listOffers = (request: Readonly = {}) => + enrichForPagination('offers', this.pageOfListOffers, request) +} + +/** + * Web Hosting API. + * + * This API allows you to manage your Web Hosting services. + */ +export class HostingAPI extends ParentAPI { + /** Lists the available regions of the API. */ + public static readonly LOCALITIES: Region[] = ['fr-par', 'nl-ams'] + + /** + * Order a Web Hosting plan. Order a Web Hosting plan, specifying the offer + * type required via the `offer_id` parameter. + * + * @param request - The request {@link HostingApiCreateHostingRequest} + * @returns A Promise of Hosting + */ + createHosting = (request: Readonly) => + this.client.fetch( + { + body: JSON.stringify( + marshalHostingApiCreateHostingRequest(request, this.client.settings), + ), + headers: jsonContentHeaders, + method: 'POST', + path: `/webhosting/v1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/hostings`, + }, + unmarshalHosting, + ) + + protected pageOfListHostings = ( + request: Readonly = {}, + ) => + this.client.fetch( + { + method: 'GET', + path: `/webhosting/v1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/hostings`, + urlParams: urlParams( + ['control_panels', request.controlPanels], + ['domain', request.domain], + ['order_by', request.orderBy], + [ + 'organization_id', + request.organizationId ?? + this.client.settings.defaultOrganizationId, + ], + ['page', request.page], + [ + 'page_size', + request.pageSize ?? this.client.settings.defaultPageSize, + ], + [ + 'project_id', + request.projectId ?? this.client.settings.defaultProjectId, + ], + ['statuses', request.statuses], + ['tags', request.tags], + ), + }, + unmarshalListHostingsResponse, + ) + + /** + * List all Web Hosting plans. List all of your existing Web Hosting plans. + * Various filters are available to limit the results, including filtering by + * domain, status, tag and Project ID. + * + * @param request - The request {@link HostingApiListHostingsRequest} + * @returns A Promise of ListHostingsResponse + */ + listHostings = (request: Readonly = {}) => + enrichForPagination('hostings', this.pageOfListHostings, request) + + /** + * Get a Web Hosting plan. Get the details of one of your existing Web Hosting + * plans, specified by its `hosting_id`. + * + * @param request - The request {@link HostingApiGetHostingRequest} + * @returns A Promise of Hosting + */ + getHosting = (request: Readonly) => + this.client.fetch( + { + method: 'GET', + path: `/webhosting/v1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/hostings/${validatePathParam('hostingId', request.hostingId)}`, + }, + unmarshalHosting, + ) + + /** + * Waits for {@link Hosting} to be in a final state. + * + * @param request - The request {@link HostingApiGetHostingRequest} + * @param options - The waiting options + * @returns A Promise of Hosting + */ + waitForHosting = ( + request: Readonly, + options?: Readonly>, + ) => + waitForResource( + options?.stop ?? + (res => + Promise.resolve(!HOSTING_TRANSIENT_STATUSES.includes(res.status))), + this.getHosting, + request, + options, + ) + + /** + * Update a Web Hosting plan. Update the details of one of your existing Web + * Hosting plans, specified by its `hosting_id`. You can update parameters + * including the contact email address, tags, options and offer. + * + * @param request - The request {@link HostingApiUpdateHostingRequest} + * @returns A Promise of Hosting + */ + updateHosting = (request: Readonly) => + this.client.fetch( + { + body: JSON.stringify( + marshalHostingApiUpdateHostingRequest(request, this.client.settings), + ), + headers: jsonContentHeaders, + method: 'PATCH', + path: `/webhosting/v1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/hostings/${validatePathParam('hostingId', request.hostingId)}`, + }, + unmarshalHosting, + ) + + /** + * Delete a Web Hosting plan. Delete a Web Hosting plan, specified by its + * `hosting_id`. Note that deletion is not immediate: it will take place at + * the end of the calendar month, after which time your Web Hosting plan and + * all its data (files and emails) will be irreversibly lost. + * + * @param request - The request {@link HostingApiDeleteHostingRequest} + * @returns A Promise of Hosting + */ + deleteHosting = (request: Readonly) => + this.client.fetch( + { + method: 'DELETE', + path: `/webhosting/v1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/hostings/${validatePathParam('hostingId', request.hostingId)}`, + }, + unmarshalHosting, + ) + + /** + * Create a user session. + * + * @param request - The request {@link HostingApiCreateSessionRequest} + * @returns A Promise of Session + */ + createSession = (request: Readonly) => + this.client.fetch( + { + body: '{}', + headers: jsonContentHeaders, + method: 'POST', + path: `/webhosting/v1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/hostings/${validatePathParam('hostingId', request.hostingId)}/sessions`, + }, + unmarshalSession, + ) + + /** + * Reset a Web Hosting plan password. + * + * @param request - The request {@link HostingApiResetHostingPasswordRequest} + * @returns A Promise of ResetHostingPasswordResponse + */ + resetHostingPassword = ( + request: Readonly, + ) => + this.client.fetch( + { + body: '{}', + headers: jsonContentHeaders, + method: 'POST', + path: `/webhosting/v1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/hostings/${validatePathParam('hostingId', request.hostingId)}/reset-password`, + }, + unmarshalResetHostingPasswordResponse, + ) +} + +/** + * Web Hosting FTP Account API. + * + * This API allows you to manage your FTP accounts for your Web Hosting + * services. + */ +export class FtpAccountAPI extends ParentAPI { + /** Lists the available regions of the API. */ + public static readonly LOCALITIES: Region[] = ['fr-par', 'nl-ams', 'pl-waw'] + + /** + * Create a new FTP account within your hosting plan.. Create a new FTP + * account within your hosting plan. + * + * @param request - The request {@link FtpAccountApiCreateFtpAccountRequest} + * @returns A Promise of FtpAccount + */ + createFtpAccount = ( + request: Readonly, + ) => + this.client.fetch( + { + body: JSON.stringify( + marshalFtpAccountApiCreateFtpAccountRequest( + request, + this.client.settings, + ), + ), + headers: jsonContentHeaders, + method: 'POST', + path: `/webhosting/v1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/hostings/${validatePathParam('hostingId', request.hostingId)}/ftp-accounts`, + }, + unmarshalFtpAccount, + ) + + protected pageOfListFtpAccounts = ( + request: Readonly, + ) => + this.client.fetch( + { + method: 'GET', + path: `/webhosting/v1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/hostings/${validatePathParam('hostingId', request.hostingId)}/ftp-accounts`, + urlParams: urlParams( + ['domain', request.domain], + ['order_by', request.orderBy], + ['page', request.page], + [ + 'page_size', + request.pageSize ?? this.client.settings.defaultPageSize, + ], + ), + }, + unmarshalListFtpAccountsResponse, + ) + + /** + * List all FTP accounts within your hosting plan.. List all FTP accounts + * within your hosting plan. + * + * @param request - The request {@link FtpAccountApiListFtpAccountsRequest} + * @returns A Promise of ListFtpAccountsResponse + */ + listFtpAccounts = (request: Readonly) => + enrichForPagination('ftpAccounts', this.pageOfListFtpAccounts, request) + + /** + * Delete a specific FTP account within your hosting plan.. Delete a specific + * FTP account within your hosting plan. + * + * @param request - The request {@link FtpAccountApiRemoveFtpAccountRequest} + * @returns A Promise of FtpAccount + */ + removeFtpAccount = ( + request: Readonly, + ) => + this.client.fetch( + { + method: 'DELETE', + path: `/webhosting/v1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/hostings/${validatePathParam('hostingId', request.hostingId)}/ftp-accounts/${validatePathParam('username', request.username)}`, + }, + unmarshalFtpAccount, + ) + + changeFtpAccountPassword = ( + request: Readonly, + ) => + this.client.fetch( + { + body: JSON.stringify( + marshalFtpAccountApiChangeFtpAccountPasswordRequest( + request, + this.client.settings, + ), + ), + headers: jsonContentHeaders, + method: 'POST', + path: `/webhosting/v1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/hostings/${validatePathParam('hostingId', request.hostingId)}/ftp-accounts/${validatePathParam('username', request.username)}/change-password`, + }, + unmarshalFtpAccount, + ) +} + +/** + * Web Hosting Mail Account API. + * + * This API allows you to manage your mail accounts for your Web Hosting + * services. + */ +export class MailAccountAPI extends ParentAPI { + /** Lists the available regions of the API. */ + public static readonly LOCALITIES: Region[] = ['fr-par', 'nl-ams', 'pl-waw'] + + /** + * Create a new mail account within your hosting plan.. Create a new mail + * account within your hosting plan. + * + * @param request - The request {@link MailAccountApiCreateMailAccountRequest} + * @returns A Promise of MailAccount + */ + createMailAccount = ( + request: Readonly, + ) => + this.client.fetch( + { + body: JSON.stringify( + marshalMailAccountApiCreateMailAccountRequest( + request, + this.client.settings, + ), + ), + headers: jsonContentHeaders, + method: 'POST', + path: `/webhosting/v1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/hostings/${validatePathParam('hostingId', request.hostingId)}/mail-accounts`, + }, + unmarshalMailAccount, + ) + + protected pageOfListMailAccounts = ( + request: Readonly, + ) => + this.client.fetch( + { + method: 'GET', + path: `/webhosting/v1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/hostings/${validatePathParam('hostingId', request.hostingId)}/mail-accounts`, + urlParams: urlParams( + ['domain', request.domain], + ['order_by', request.orderBy], + ['page', request.page], + [ + 'page_size', + request.pageSize ?? this.client.settings.defaultPageSize, + ], + ), + }, + unmarshalListMailAccountsResponse, + ) + + /** + * List all mail accounts within your hosting plan.. List all mail accounts + * within your hosting plan. + * + * @param request - The request {@link MailAccountApiListMailAccountsRequest} + * @returns A Promise of ListMailAccountsResponse + */ + listMailAccounts = ( + request: Readonly, + ) => enrichForPagination('mailAccounts', this.pageOfListMailAccounts, request) + + /** + * Delete a mail account within your hosting plan.. Delete a mail account + * within your hosting plan. + * + * @param request - The request {@link MailAccountApiRemoveMailAccountRequest} + * @returns A Promise of MailAccount + */ + removeMailAccount = ( + request: Readonly, + ) => + this.client.fetch( + { + body: JSON.stringify( + marshalMailAccountApiRemoveMailAccountRequest( + request, + this.client.settings, + ), + ), + headers: jsonContentHeaders, + method: 'POST', + path: `/webhosting/v1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/hostings/${validatePathParam('hostingId', request.hostingId)}/remove-mail-account`, + }, + unmarshalMailAccount, + ) + + /** + * Update the password of a mail account within your hosting plan.. Update the + * password of a mail account within your hosting plan. + * + * @param request - The request + * {@link MailAccountApiChangeMailAccountPasswordRequest} + * @returns A Promise of MailAccount + */ + changeMailAccountPassword = ( + request: Readonly, + ) => + this.client.fetch( + { + body: JSON.stringify( + marshalMailAccountApiChangeMailAccountPasswordRequest( + request, + this.client.settings, + ), + ), + headers: jsonContentHeaders, + method: 'POST', + path: `/webhosting/v1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/hostings/${validatePathParam('hostingId', request.hostingId)}/change-mail-password`, + }, + unmarshalMailAccount, + ) +} + +/** + * Web Hosting Website API. + * + * This API allows you to manage your websites for your Web Hosting services. + */ +export class WebsiteAPI extends ParentAPI { + /** Lists the available regions of the API. */ + public static readonly LOCALITIES: Region[] = ['fr-par', 'nl-ams', 'pl-waw'] + + protected pageOfListWebsites = ( + request: Readonly, + ) => + this.client.fetch( + { + method: 'GET', + path: `/webhosting/v1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/hostings/${validatePathParam('hostingId', request.hostingId)}/websites`, + urlParams: urlParams( + ['order_by', request.orderBy], + ['page', request.page], + [ + 'page_size', + request.pageSize ?? this.client.settings.defaultPageSize, + ], + ), + }, + unmarshalListWebsitesResponse, + ) + + /** + * List all websites for a specific hosting.. List all websites for a specific + * hosting. + * + * @param request - The request {@link WebsiteApiListWebsitesRequest} + * @returns A Promise of ListWebsitesResponse + */ + listWebsites = (request: Readonly) => + enrichForPagination('websites', this.pageOfListWebsites, request) +} diff --git a/packages/clients/src/api/webhosting/v1/content.gen.ts b/packages/clients/src/api/webhosting/v1/content.gen.ts new file mode 100644 index 000000000..d4b6b3eb5 --- /dev/null +++ b/packages/clients/src/api/webhosting/v1/content.gen.ts @@ -0,0 +1,17 @@ +// This file was automatically generated. DO NOT EDIT. +// If you have any remark or suggestion do not hesitate to open an issue. +import type { HostingStatus, HostingSummaryStatus } from './types.gen' + +/** Lists transient statutes of the enum {@link HostingStatus}. */ +export const HOSTING_TRANSIENT_STATUSES: HostingStatus[] = [ + 'delivering', + 'deleting', + 'migrating', +] + +/** Lists transient statutes of the enum {@link HostingSummaryStatus}. */ +export const HOSTING_SUMMARY_TRANSIENT_STATUSES: HostingSummaryStatus[] = [ + 'delivering', + 'deleting', + 'migrating', +] diff --git a/packages/clients/src/api/webhosting/v1/index.gen.ts b/packages/clients/src/api/webhosting/v1/index.gen.ts new file mode 100644 index 000000000..a4e80599e --- /dev/null +++ b/packages/clients/src/api/webhosting/v1/index.gen.ts @@ -0,0 +1,80 @@ +// This file was automatically generated. DO NOT EDIT. +// If you have any remark or suggestion do not hesitate to open an issue. +export { + ControlPanelAPI, + DatabaseAPI, + FtpAccountAPI, + HostingAPI, + MailAccountAPI, + OfferAPI, + WebsiteAPI, +} from './api.gen' +export * from './content.gen' +export type { + ControlPanel, + ControlPanelApiListControlPanelsRequest, + CreateHostingRequestDomainConfiguration, + Database, + DatabaseApiAssignDatabaseUserRequest, + DatabaseApiChangeDatabaseUserPasswordRequest, + DatabaseApiCreateDatabaseRequest, + DatabaseApiCreateDatabaseUserRequest, + DatabaseApiDeleteDatabaseRequest, + DatabaseApiDeleteDatabaseUserRequest, + DatabaseApiGetDatabaseRequest, + DatabaseApiGetDatabaseUserRequest, + DatabaseApiListDatabaseUsersRequest, + DatabaseApiListDatabasesRequest, + DatabaseApiUnassignDatabaseUserRequest, + DatabaseUser, + FtpAccount, + FtpAccountApiChangeFtpAccountPasswordRequest, + FtpAccountApiCreateFtpAccountRequest, + FtpAccountApiListFtpAccountsRequest, + FtpAccountApiRemoveFtpAccountRequest, + Hosting, + HostingApiCreateHostingRequest, + HostingApiCreateSessionRequest, + HostingApiDeleteHostingRequest, + HostingApiGetHostingRequest, + HostingApiListHostingsRequest, + HostingApiResetHostingPasswordRequest, + HostingApiUpdateHostingRequest, + HostingCpanelUrls, + HostingDnsStatus, + HostingOption, + HostingStatus, + HostingSummary, + HostingSummaryStatus, + ListControlPanelsResponse, + ListDatabaseUsersRequestOrderBy, + ListDatabaseUsersResponse, + ListDatabasesRequestOrderBy, + ListDatabasesResponse, + ListFtpAccountsRequestOrderBy, + ListFtpAccountsResponse, + ListHostingsRequestOrderBy, + ListHostingsResponse, + ListMailAccountsRequestOrderBy, + ListMailAccountsResponse, + ListOffersRequestOrderBy, + ListOffersResponse, + ListWebsitesRequestOrderBy, + ListWebsitesResponse, + MailAccount, + MailAccountApiChangeMailAccountPasswordRequest, + MailAccountApiCreateMailAccountRequest, + MailAccountApiListMailAccountsRequest, + MailAccountApiRemoveMailAccountRequest, + Offer, + OfferApiListOffersRequest, + OfferOption, + OfferOptionName, + OfferOptionRequest, + OfferOptionWarning, + ResetHostingPasswordResponse, + Session, + Website, + WebsiteApiListWebsitesRequest, +} from './types.gen' +export * as ValidationRules from './validation-rules.gen' diff --git a/packages/clients/src/api/webhosting/v1/marshalling.gen.ts b/packages/clients/src/api/webhosting/v1/marshalling.gen.ts new file mode 100644 index 000000000..c78292693 --- /dev/null +++ b/packages/clients/src/api/webhosting/v1/marshalling.gen.ts @@ -0,0 +1,535 @@ +// This file was automatically generated. DO NOT EDIT. +// If you have any remark or suggestion do not hesitate to open an issue. +import { + isJSONObject, + unmarshalArrayOfObject, + unmarshalDate, + unmarshalMoney, +} from '../../../bridge' +import type { DefaultValues } from '../../../bridge' +import type { + ControlPanel, + CreateHostingRequestDomainConfiguration, + Database, + DatabaseApiAssignDatabaseUserRequest, + DatabaseApiChangeDatabaseUserPasswordRequest, + DatabaseApiCreateDatabaseRequest, + DatabaseApiCreateDatabaseUserRequest, + DatabaseApiUnassignDatabaseUserRequest, + DatabaseUser, + FtpAccount, + FtpAccountApiChangeFtpAccountPasswordRequest, + FtpAccountApiCreateFtpAccountRequest, + Hosting, + HostingApiCreateHostingRequest, + HostingApiUpdateHostingRequest, + HostingCpanelUrls, + HostingOption, + HostingSummary, + ListControlPanelsResponse, + ListDatabaseUsersResponse, + ListDatabasesResponse, + ListFtpAccountsResponse, + ListHostingsResponse, + ListMailAccountsResponse, + ListOffersResponse, + ListWebsitesResponse, + MailAccount, + MailAccountApiChangeMailAccountPasswordRequest, + MailAccountApiCreateMailAccountRequest, + MailAccountApiRemoveMailAccountRequest, + Offer, + OfferOption, + OfferOptionRequest, + ResetHostingPasswordResponse, + Session, + Website, +} from './types.gen' + +export const unmarshalDatabaseUser = (data: unknown): DatabaseUser => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'DatabaseUser' failed as data isn't a dictionary.`, + ) + } + + return { + databases: data.databases, + username: data.username, + } as DatabaseUser +} + +export const unmarshalDatabase = (data: unknown): Database => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'Database' failed as data isn't a dictionary.`, + ) + } + + return { + databaseName: data.database_name, + users: data.users, + } as Database +} + +export const unmarshalFtpAccount = (data: unknown): FtpAccount => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'FtpAccount' failed as data isn't a dictionary.`, + ) + } + + return { + path: data.path, + username: data.username, + } as FtpAccount +} + +export const unmarshalMailAccount = (data: unknown): MailAccount => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'MailAccount' failed as data isn't a dictionary.`, + ) + } + + return { + domain: data.domain, + username: data.username, + } as MailAccount +} + +const unmarshalHostingCpanelUrls = (data: unknown): HostingCpanelUrls => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'HostingCpanelUrls' failed as data isn't a dictionary.`, + ) + } + + return { + dashboard: data.dashboard, + webmail: data.webmail, + } as HostingCpanelUrls +} + +const unmarshalHostingOption = (data: unknown): HostingOption => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'HostingOption' failed as data isn't a dictionary.`, + ) + } + + return { + id: data.id, + name: data.name, + quantity: data.quantity, + } as HostingOption +} + +export const unmarshalHosting = (data: unknown): Hosting => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'Hosting' failed as data isn't a dictionary.`, + ) + } + + return { + contactEmail: data.contact_email, + controlPanelName: data.control_panel_name, + cpanelUrls: data.cpanel_urls + ? unmarshalHostingCpanelUrls(data.cpanel_urls) + : undefined, + createdAt: unmarshalDate(data.created_at), + dnsStatus: data.dns_status, + domain: data.domain, + id: data.id, + ipv4: data.ipv4, + ipv6: data.ipv6, + offerEndOfLife: data.offer_end_of_life, + offerId: data.offer_id, + offerName: data.offer_name, + oneTimePassword: data.one_time_password, + options: unmarshalArrayOfObject(data.options, unmarshalHostingOption), + platformGroup: data.platform_group, + platformHostname: data.platform_hostname, + platformNumber: data.platform_number, + projectId: data.project_id, + protected: data.protected, + region: data.region, + status: data.status, + tags: data.tags, + updatedAt: unmarshalDate(data.updated_at), + username: data.username, + } as Hosting +} + +const unmarshalControlPanel = (data: unknown): ControlPanel => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'ControlPanel' failed as data isn't a dictionary.`, + ) + } + + return { + available: data.available, + availableLanguages: data.available_languages, + logoUrl: data.logo_url, + name: data.name, + } as ControlPanel +} + +export const unmarshalListControlPanelsResponse = ( + data: unknown, +): ListControlPanelsResponse => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'ListControlPanelsResponse' failed as data isn't a dictionary.`, + ) + } + + return { + controlPanels: unmarshalArrayOfObject( + data.control_panels, + unmarshalControlPanel, + ), + totalCount: data.total_count, + } as ListControlPanelsResponse +} + +export const unmarshalListDatabaseUsersResponse = ( + data: unknown, +): ListDatabaseUsersResponse => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'ListDatabaseUsersResponse' failed as data isn't a dictionary.`, + ) + } + + return { + totalCount: data.total_count, + users: unmarshalArrayOfObject(data.users, unmarshalDatabaseUser), + } as ListDatabaseUsersResponse +} + +export const unmarshalListDatabasesResponse = ( + data: unknown, +): ListDatabasesResponse => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'ListDatabasesResponse' failed as data isn't a dictionary.`, + ) + } + + return { + databases: unmarshalArrayOfObject(data.databases, unmarshalDatabase), + totalCount: data.total_count, + } as ListDatabasesResponse +} + +export const unmarshalListFtpAccountsResponse = ( + data: unknown, +): ListFtpAccountsResponse => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'ListFtpAccountsResponse' failed as data isn't a dictionary.`, + ) + } + + return { + ftpAccounts: unmarshalArrayOfObject(data.ftp_accounts, unmarshalFtpAccount), + totalCount: data.total_count, + } as ListFtpAccountsResponse +} + +const unmarshalHostingSummary = (data: unknown): HostingSummary => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'HostingSummary' failed as data isn't a dictionary.`, + ) + } + + return { + domain: data.domain, + id: data.id, + projectId: data.project_id, + protected: data.protected, + region: data.region, + status: data.status, + updatedAt: unmarshalDate(data.updated_at), + } as HostingSummary +} + +export const unmarshalListHostingsResponse = ( + data: unknown, +): ListHostingsResponse => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'ListHostingsResponse' failed as data isn't a dictionary.`, + ) + } + + return { + hostings: unmarshalArrayOfObject(data.hostings, unmarshalHostingSummary), + totalCount: data.total_count, + } as ListHostingsResponse +} + +export const unmarshalListMailAccountsResponse = ( + data: unknown, +): ListMailAccountsResponse => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'ListMailAccountsResponse' failed as data isn't a dictionary.`, + ) + } + + return { + mailAccounts: unmarshalArrayOfObject( + data.mail_accounts, + unmarshalMailAccount, + ), + totalCount: data.total_count, + } as ListMailAccountsResponse +} + +const unmarshalOfferOption = (data: unknown): OfferOption => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'OfferOption' failed as data isn't a dictionary.`, + ) + } + + return { + billingOperationPath: data.billing_operation_path, + currentValue: data.current_value, + id: data.id, + maxValue: data.max_value, + minValue: data.min_value, + name: data.name, + quotaWarning: data.quota_warning, + } as OfferOption +} + +const unmarshalOffer = (data: unknown): Offer => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'Offer' failed as data isn't a dictionary.`, + ) + } + + return { + available: data.available, + billingOperationPath: data.billing_operation_path, + controlPanelName: data.control_panel_name, + endOfLife: data.end_of_life, + id: data.id, + options: unmarshalArrayOfObject(data.options, unmarshalOfferOption), + price: data.price ? unmarshalMoney(data.price) : undefined, + } as Offer +} + +export const unmarshalListOffersResponse = ( + data: unknown, +): ListOffersResponse => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'ListOffersResponse' failed as data isn't a dictionary.`, + ) + } + + return { + offers: unmarshalArrayOfObject(data.offers, unmarshalOffer), + totalCount: data.total_count, + } as ListOffersResponse +} + +const unmarshalWebsite = (data: unknown): Website => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'Website' failed as data isn't a dictionary.`, + ) + } + + return { + domain: data.domain, + path: data.path, + sslStatus: data.ssl_status, + } as Website +} + +export const unmarshalListWebsitesResponse = ( + data: unknown, +): ListWebsitesResponse => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'ListWebsitesResponse' failed as data isn't a dictionary.`, + ) + } + + return { + totalCount: data.total_count, + websites: unmarshalArrayOfObject(data.websites, unmarshalWebsite), + } as ListWebsitesResponse +} + +export const unmarshalResetHostingPasswordResponse = ( + data: unknown, +): ResetHostingPasswordResponse => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'ResetHostingPasswordResponse' failed as data isn't a dictionary.`, + ) + } + + return { + oneTimePassword: data.one_time_password, + } as ResetHostingPasswordResponse +} + +export const unmarshalSession = (data: unknown): Session => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'Session' failed as data isn't a dictionary.`, + ) + } + + return { + url: data.url, + } as Session +} + +export const marshalDatabaseApiAssignDatabaseUserRequest = ( + request: DatabaseApiAssignDatabaseUserRequest, + defaults: DefaultValues, +): Record => ({ + username: request.username, +}) + +export const marshalDatabaseApiChangeDatabaseUserPasswordRequest = ( + request: DatabaseApiChangeDatabaseUserPasswordRequest, + defaults: DefaultValues, +): Record => ({ + password: request.password, +}) + +export const marshalDatabaseApiCreateDatabaseRequest = ( + request: DatabaseApiCreateDatabaseRequest, + defaults: DefaultValues, +): Record => ({ + database_name: request.databaseName, +}) + +export const marshalDatabaseApiCreateDatabaseUserRequest = ( + request: DatabaseApiCreateDatabaseUserRequest, + defaults: DefaultValues, +): Record => ({ + password: request.password, + username: request.username, +}) + +export const marshalDatabaseApiUnassignDatabaseUserRequest = ( + request: DatabaseApiUnassignDatabaseUserRequest, + defaults: DefaultValues, +): Record => ({ + username: request.username, +}) + +export const marshalFtpAccountApiChangeFtpAccountPasswordRequest = ( + request: FtpAccountApiChangeFtpAccountPasswordRequest, + defaults: DefaultValues, +): Record => ({ + password: request.password, +}) + +export const marshalFtpAccountApiCreateFtpAccountRequest = ( + request: FtpAccountApiCreateFtpAccountRequest, + defaults: DefaultValues, +): Record => ({ + password: request.password, + path: request.path, + username: request.username, +}) + +const marshalCreateHostingRequestDomainConfiguration = ( + request: CreateHostingRequestDomainConfiguration, + defaults: DefaultValues, +): Record => ({ + update_all_records: request.updateAllRecords, + update_mail_record: request.updateMailRecord, + update_nameservers: request.updateNameservers, + update_web_record: request.updateWebRecord, +}) + +const marshalOfferOptionRequest = ( + request: OfferOptionRequest, + defaults: DefaultValues, +): Record => ({ + id: request.id, + quantity: request.quantity, +}) + +export const marshalHostingApiCreateHostingRequest = ( + request: HostingApiCreateHostingRequest, + defaults: DefaultValues, +): Record => ({ + domain: request.domain, + domain_configuration: + request.domainConfiguration !== undefined + ? marshalCreateHostingRequestDomainConfiguration( + request.domainConfiguration, + defaults, + ) + : undefined, + email: request.email, + language: request.language, + offer_id: request.offerId, + offer_options: + request.offerOptions !== undefined + ? request.offerOptions.map(elt => + marshalOfferOptionRequest(elt, defaults), + ) + : undefined, + project_id: request.projectId ?? defaults.defaultProjectId, + tags: request.tags, +}) + +export const marshalHostingApiUpdateHostingRequest = ( + request: HostingApiUpdateHostingRequest, + defaults: DefaultValues, +): Record => ({ + email: request.email, + offer_id: request.offerId, + offer_options: + request.offerOptions !== undefined + ? request.offerOptions.map(elt => + marshalOfferOptionRequest(elt, defaults), + ) + : undefined, + protected: request.protected, + tags: request.tags, +}) + +export const marshalMailAccountApiChangeMailAccountPasswordRequest = ( + request: MailAccountApiChangeMailAccountPasswordRequest, + defaults: DefaultValues, +): Record => ({ + domain: request.domain, + password: request.password, + username: request.username, +}) + +export const marshalMailAccountApiCreateMailAccountRequest = ( + request: MailAccountApiCreateMailAccountRequest, + defaults: DefaultValues, +): Record => ({ + domain: request.domain, + password: request.password, + username: request.username, +}) + +export const marshalMailAccountApiRemoveMailAccountRequest = ( + request: MailAccountApiRemoveMailAccountRequest, + defaults: DefaultValues, +): Record => ({ + domain: request.domain, + username: request.username, +}) diff --git a/packages/clients/src/api/webhosting/v1/types.gen.ts b/packages/clients/src/api/webhosting/v1/types.gen.ts new file mode 100644 index 000000000..05440a163 --- /dev/null +++ b/packages/clients/src/api/webhosting/v1/types.gen.ts @@ -0,0 +1,788 @@ +// 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 } from '../../../bridge' +import type { LanguageCode as StdLanguageCode } from '../../std/types.gen' + +export type HostingDnsStatus = 'unknown_dns_status' | 'valid' | 'invalid' + +export type HostingStatus = + | 'unknown_status' + | 'delivering' + | 'ready' + | 'deleting' + | 'error' + | 'locked' + | 'migrating' + +export type HostingSummaryStatus = + | 'unknown_status' + | 'delivering' + | 'ready' + | 'deleting' + | 'error' + | 'locked' + | 'migrating' + +export type ListDatabaseUsersRequestOrderBy = 'username_asc' | 'username_desc' + +export type ListDatabasesRequestOrderBy = + | 'database_name_asc' + | 'database_name_desc' + +export type ListFtpAccountsRequestOrderBy = 'username_asc' | 'username_desc' + +export type ListHostingsRequestOrderBy = 'created_at_asc' | 'created_at_desc' + +export type ListMailAccountsRequestOrderBy = + | 'username_asc' + | 'username_desc' + | 'domain_asc' + | 'domain_desc' + +export type ListOffersRequestOrderBy = 'price_asc' + +export type ListWebsitesRequestOrderBy = 'domain_asc' | 'domain_desc' + +export type OfferOptionName = + | 'unknown_name' + | 'domain_count' + | 'email_count' + | 'storage_gb' + | 'vcpu_count' + | 'ram_gb' + | 'backup' + | 'dedicated_ip' + +export type OfferOptionWarning = 'unknown_warning' | 'quota_exceeded_warning' + +export interface OfferOption { + /** Option ID. */ + id: string + /** Name of the option. */ + name: OfferOptionName + /** Unique identifier used for billing. */ + billingOperationPath: string + /** Minimum value for the option in the offer. */ + minValue: number + /** + * If a hosting_id was specified in the call, defines the current value of the + * option in the hosting. + */ + currentValue: number + /** Maximum value for the option in the offer. */ + maxValue: number + /** Defines a warning if the maximum value for the option has been reached. */ + quotaWarning: OfferOptionWarning +} + +export interface CreateHostingRequestDomainConfiguration { + updateNameservers: boolean + updateWebRecord: boolean + updateMailRecord: boolean + updateAllRecords: boolean +} + +export interface OfferOptionRequest { + /** Offer option ID. */ + id: string + /** The option requested quantity to set for the Web Hosting plan. */ + quantity: number +} + +export interface HostingCpanelUrls { + dashboard: string + webmail: string +} + +export interface HostingOption { + /** Option ID. */ + id: string + /** Option name. */ + name: OfferOptionName + /** Option quantity. */ + quantity: number +} + +export interface ControlPanel { + /** Control panel name. */ + name: string + /** Define if the control panel type is available to order. */ + available: boolean + /** URL of the control panel's logo. */ + logoUrl: string + /** List of available languages for the control panel. */ + availableLanguages: StdLanguageCode[] +} + +export interface DatabaseUser { + /** Name of the database user. */ + username: string + /** List of databases accessible by the user. */ + databases: string[] +} + +export interface Database { + /** Name of the database. */ + databaseName: string + /** List of users who have access to the database. */ + users: string[] +} + +export interface FtpAccount { + /** The username of the FTP account. */ + username: string + /** The path associated with the FTP account. */ + path: string +} + +export interface HostingSummary { + /** ID of the Web Hosting plan. */ + id: string + /** ID of the Scaleway Project the Web Hosting plan belongs to. */ + projectId: string + /** Date on which the Web Hosting plan was last updated. */ + updatedAt?: Date + /** Status of the Web Hosting plan. */ + status: HostingSummaryStatus + /** Main domain associated with the Web Hosting plan. */ + domain: string + /** Whether the hosting is protected or not. */ + protected: boolean + /** Region where the Web Hosting plan is hosted. */ + region: Region +} + +export interface MailAccount { + /** Domain part of the mail account address. */ + domain: string + /** Username part address of the mail account address. */ + username: string +} + +export interface Offer { + /** Offer ID. */ + id: string + /** Unique identifier used for billing. */ + billingOperationPath: string + /** Options available for the offer. */ + options: OfferOption[] + /** Price of the offer. */ + price?: Money + /** + * If a hosting_id was specified in the call, defines whether the offer is + * available for a specified hosting plan to migrate (update) to. + */ + available: boolean + /** Name of the control panel. */ + controlPanelName: string + /** Indicates if the offer has reached its end of life. */ + endOfLife: boolean +} + +export interface Website { + /** The domain of the website. */ + domain: string + /** The directory path of the website. */ + path: string + /** The SSL status of the website. */ + sslStatus: boolean +} + +export type ControlPanelApiListControlPanelsRequest = { + /** + * Region to target. If none is passed will use default region from the + * config. + */ + region?: Region + /** Page number (must be a positive integer). */ + page?: number + /** + * Number of control panels to return (must be a positive integer lower or + * equal to 100). + */ + pageSize?: number +} + +export type DatabaseApiAssignDatabaseUserRequest = { + /** + * Region to target. If none is passed will use default region from the + * config. + */ + region?: Region + /** UUID of the hosting plan. */ + hostingId: string + /** Name of the database to be assigned. */ + databaseName: string + /** Name of the user to assign. */ + username: string +} + +export type DatabaseApiChangeDatabaseUserPasswordRequest = { + /** + * Region to target. If none is passed will use default region from the + * config. + */ + region?: Region + /** UUID of the hosting plan. */ + hostingId: string + /** Name of the user to update. */ + username: string + /** New password. */ + password: string +} + +export type DatabaseApiCreateDatabaseRequest = { + /** + * Region to target. If none is passed will use default region from the + * config. + */ + region?: Region + /** UUID of the hosting plan where the database will be created. */ + hostingId: string + /** Name of the database to be created. */ + databaseName: string +} + +export type DatabaseApiCreateDatabaseUserRequest = { + /** + * Region to target. If none is passed will use default region from the + * config. + */ + region?: Region + /** UUID of the hosting plan. */ + hostingId: string + /** Name of the user to create. */ + username: string + /** Password of the user to create. */ + password: string +} + +export type DatabaseApiDeleteDatabaseRequest = { + /** + * Region to target. If none is passed will use default region from the + * config. + */ + region?: Region + /** UUID of the hosting plan. */ + hostingId: string + /** Name of the database to delete. */ + databaseName: string +} + +export type DatabaseApiDeleteDatabaseUserRequest = { + /** + * Region to target. If none is passed will use default region from the + * config. + */ + region?: Region + /** UUID of the hosting plan. */ + hostingId: string + /** Name of the database user to delete. */ + username: string +} + +export type DatabaseApiGetDatabaseRequest = { + /** + * Region to target. If none is passed will use default region from the + * config. + */ + region?: Region + /** UUID of the hosting plan. */ + hostingId: string + /** Name of the database. */ + databaseName: string +} + +export type DatabaseApiGetDatabaseUserRequest = { + /** + * Region to target. If none is passed will use default region from the + * config. + */ + region?: Region + /** UUID of the hosting plan. */ + hostingId: string + /** Name of the database user to retrieve details. */ + username: string +} + +export type DatabaseApiListDatabaseUsersRequest = { + /** + * Region to target. If none is passed will use default region from the + * config. + */ + region?: Region + /** UUID of the hosting plan. */ + hostingId: string + /** Page number (must be a positive integer). */ + page?: number + /** + * Number of database users to return (must be a positive integer lower or + * equal to 100). + */ + pageSize?: number + /** Sort order of database users in the response. */ + orderBy?: ListDatabaseUsersRequestOrderBy +} + +export type DatabaseApiListDatabasesRequest = { + /** + * Region to target. If none is passed will use default region from the + * config. + */ + region?: Region + /** UUID of the hosting plan. */ + hostingId: string + /** Page number (must be a positive integer). */ + page?: number + /** + * Number of databases to return (must be a positive integer lower or equal to + * 100). + */ + pageSize?: number + /** Sort order of databases in the response. */ + orderBy?: ListDatabasesRequestOrderBy +} + +export type DatabaseApiUnassignDatabaseUserRequest = { + /** + * Region to target. If none is passed will use default region from the + * config. + */ + region?: Region + /** UUID of the hosting plan. */ + hostingId: string + /** Name of the database to be unassigned. */ + databaseName: string + /** Name of the user to unassign. */ + username: string +} + +export type FtpAccountApiChangeFtpAccountPasswordRequest = { + /** + * Region to target. If none is passed will use default region from the + * config. + */ + region?: Region + /** UUID of the hosting plan. */ + hostingId: string + /** Username of the FTP account. */ + username: string + /** New password for the FTP account. */ + password: string +} + +export type FtpAccountApiCreateFtpAccountRequest = { + /** + * Region to target. If none is passed will use default region from the + * config. + */ + region?: Region + /** UUID of the hosting plan. */ + hostingId: string + /** Username for the new FTP account. */ + username: string + /** Path for the new FTP account. */ + path: string + /** Password for the new FTP account. */ + password: string +} + +export type FtpAccountApiListFtpAccountsRequest = { + /** + * Region to target. If none is passed will use default region from the + * config. + */ + region?: Region + /** UUID of the hosting plan. */ + hostingId: string + /** Page number (must be a positive integer). */ + page?: number + /** + * Number of FTP accounts to return (must be a positive integer lower or equal + * to 100). + */ + pageSize?: number + /** Sort order of FTP accounts in the response. */ + orderBy?: ListFtpAccountsRequestOrderBy + /** Domain to filter the FTP accounts. */ + domain?: string +} + +export type FtpAccountApiRemoveFtpAccountRequest = { + /** + * Region to target. If none is passed will use default region from the + * config. + */ + region?: Region + /** UUID of the hosting plan. */ + hostingId: string + /** Username of the FTP account to be deleted. */ + username: string +} + +export interface Hosting { + /** ID of the Web Hosting plan. */ + id: string + /** ID of the Scaleway Project the Web Hosting plan belongs to. */ + projectId: string + /** Date on which the Web Hosting plan was last updated. */ + updatedAt?: Date + /** Date on which the Web Hosting plan was created. */ + createdAt?: Date + /** Status of the Web Hosting plan. */ + status: HostingStatus + /** Hostname of the host platform. */ + platformHostname: string + /** Number of the host platform. */ + platformNumber: number + /** ID of the active offer for the Web Hosting plan. */ + offerId: string + /** Name of the active offer for the Web Hosting plan. */ + offerName: string + /** Main domain associated with the Web Hosting plan. */ + domain: string + /** List of tags associated with the Web Hosting plan. */ + tags: string[] + /** List of the Web Hosting plan options. */ + options: HostingOption[] + /** DNS status of the Web Hosting plan. */ + dnsStatus: HostingDnsStatus + /** URL to connect to cPanel dashboard and to Webmail interface. */ + cpanelUrls?: HostingCpanelUrls + /** Main Web Hosting cPanel username. */ + username: string + /** Indicates if the hosting offer has reached its end of life. */ + offerEndOfLife: boolean + /** Name of the control panel. */ + controlPanelName: string + /** Group of the hosting's host server/platform. */ + platformGroup: string + /** IPv4 address of the hosting's host server. */ + ipv4: string + /** IPv6 address of the hosting's host server. */ + ipv6: string + /** Whether the hosting is protected or not. */ + protected: boolean + /** + * One-time-password used for the first login or reset password, empty after + * first use. + */ + oneTimePassword: string + /** Contact email used for the hosting. */ + contactEmail: string + /** Region where the Web Hosting plan is hosted. */ + region: Region +} + +export type HostingApiCreateHostingRequest = { + /** + * Region to target. If none is passed will use default region from the + * config. + */ + region?: Region + /** ID of the selected offer for the Web Hosting plan. */ + offerId: string + /** ID of the Scaleway Project in which to create the Web Hosting plan. */ + projectId?: string + /** Contact email for the Web Hosting client. */ + email: string + /** List of tags for the Web Hosting plan. */ + tags?: string[] + /** + * Domain name to link to the Web Hosting plan. You must already own this + * domain name, and have completed the DNS validation process beforehand. + */ + domain: string + /** List of the Web Hosting plan options IDs with their quantities. */ + offerOptions?: OfferOptionRequest[] + /** Default language for the control panel interface. */ + language?: StdLanguageCode + /** + * Indicates whether to update hosting domain name servers and DNS records for + * domains managed by Scaleway Elements. + */ + domainConfiguration?: CreateHostingRequestDomainConfiguration +} + +export type HostingApiCreateSessionRequest = { + /** + * Region to target. If none is passed will use default region from the + * config. + */ + region?: Region + /** Hosting ID. */ + hostingId: string +} + +export type HostingApiDeleteHostingRequest = { + /** + * Region to target. If none is passed will use default region from the + * config. + */ + region?: Region + /** Hosting ID. */ + hostingId: string +} + +export type HostingApiGetHostingRequest = { + /** + * Region to target. If none is passed will use default region from the + * config. + */ + region?: Region + /** Hosting ID. */ + hostingId: string +} + +export type HostingApiListHostingsRequest = { + /** + * Region to target. If none is passed will use default region from the + * config. + */ + region?: Region + /** + * Page number to return, from the paginated results (must be a positive + * integer). + */ + page?: number + /** + * Number of Web Hosting plans to return (must be a positive integer lower or + * equal to 100). + */ + pageSize?: number + /** Sort order for Web Hosting plans in the response. */ + orderBy?: ListHostingsRequestOrderBy + /** + * Tags to filter for, only Web Hosting plans with matching tags will be + * returned. + */ + tags?: string[] + /** + * Statuses to filter for, only Web Hosting plans with matching statuses will + * be returned. + */ + statuses?: HostingStatus[] + /** + * Domain to filter for, only Web Hosting plans associated with this domain + * will be returned. + */ + domain?: string + /** + * Project ID to filter for, only Web Hosting plans from this Project will be + * returned. + */ + projectId?: string + /** + * Organization ID to filter for, only Web Hosting plans from this + * Organization will be returned. + */ + organizationId?: string + /** + * Name of the control panel to filter for, only Web Hosting plans from this + * control panel will be returned. + */ + controlPanels?: string[] +} + +export type HostingApiResetHostingPasswordRequest = { + /** + * Region to target. If none is passed will use default region from the + * config. + */ + region?: Region + /** UUID of the hosting. */ + hostingId: string +} + +export type HostingApiUpdateHostingRequest = { + /** + * Region to target. If none is passed will use default region from the + * config. + */ + region?: Region + /** Hosting ID. */ + hostingId: string + /** New contact email for the Web Hosting plan. */ + email?: string + /** New tags for the Web Hosting plan. */ + tags?: string[] + /** List of the Web Hosting plan options IDs with their quantities. */ + offerOptions?: OfferOptionRequest[] + /** ID of the new offer for the Web Hosting plan. */ + offerId?: string + /** Whether the hosting is protected or not. */ + protected?: boolean +} + +export interface ListControlPanelsResponse { + /** Number of control panels returned. */ + totalCount: number + /** List of control panels. */ + controlPanels: ControlPanel[] +} + +export interface ListDatabaseUsersResponse { + /** Total number of database users. */ + totalCount: number + /** List of database users. */ + users: DatabaseUser[] +} + +export interface ListDatabasesResponse { + /** Total number of databases. */ + totalCount: number + /** List of databases. */ + databases: Database[] +} + +export interface ListFtpAccountsResponse { + /** Total number of FTP accounts. */ + totalCount: number + /** List of FTP accounts. */ + ftpAccounts: FtpAccount[] +} + +export interface ListHostingsResponse { + /** Number of Web Hosting plans returned. */ + totalCount: number + /** List of Web Hosting plans. */ + hostings: HostingSummary[] +} + +export interface ListMailAccountsResponse { + /** Total number of mail accounts. */ + totalCount: number + /** List of mail accounts. */ + mailAccounts: MailAccount[] +} + +export interface ListOffersResponse { + /** Total number of offers. */ + totalCount: number + /** List of offers. */ + offers: Offer[] +} + +export interface ListWebsitesResponse { + /** Total number of websites. */ + totalCount: number + /** List of websites. */ + websites: Website[] +} + +export type MailAccountApiChangeMailAccountPasswordRequest = { + /** + * Region to target. If none is passed will use default region from the + * config. + */ + region?: Region + /** UUID of the hosting plan. */ + hostingId: string + /** Domain part of the mail account address. */ + domain: string + /** Username part of the mail account address. */ + username: string + /** New password for the mail account. */ + password: string +} + +export type MailAccountApiCreateMailAccountRequest = { + /** + * Region to target. If none is passed will use default region from the + * config. + */ + region?: Region + /** UUID of the hosting plan. */ + hostingId: string + /** Domain part of the mail account address. */ + domain: string + /** Username part address of the mail account address. */ + username: string + /** Password for the new mail account. */ + password: string +} + +export type MailAccountApiListMailAccountsRequest = { + /** + * Region to target. If none is passed will use default region from the + * config. + */ + region?: Region + /** UUID of the hosting plan. */ + hostingId: string + /** Page number (must be a positive integer). */ + page?: number + /** + * Number of mail accounts to return (must be a positive integer lower or + * equal to 100). + */ + pageSize?: number + /** Sort order of mail accounts in the response. */ + orderBy?: ListMailAccountsRequestOrderBy + /** Domain to filter the mail accounts. */ + domain?: string +} + +export type MailAccountApiRemoveMailAccountRequest = { + /** + * Region to target. If none is passed will use default region from the + * config. + */ + region?: Region + /** UUID of the hosting plan. */ + hostingId: string + /** Domain part of the mail account address. */ + domain: string + /** Username part of the mail account address. */ + username: string +} + +export type OfferApiListOffersRequest = { + /** + * Region to target. If none is passed will use default region from the + * config. + */ + region?: Region + /** Page number (must be a positive integer). */ + page?: number + /** + * Number of websites to return (must be a positive integer lower or equal to + * 100). + */ + pageSize?: number + /** Sort order for Web Hosting offers in the response. */ + orderBy?: ListOffersRequestOrderBy + /** UUID of the hosting plan. */ + hostingId?: string + /** Name of the control panel(s) to filter for. */ + controlPanels?: string[] +} + +export interface ResetHostingPasswordResponse { + /** New temporary password. */ + oneTimePassword: string +} + +export interface Session { + /** Logged user's session URL. */ + url: string +} + +export type WebsiteApiListWebsitesRequest = { + /** + * Region to target. If none is passed will use default region from the + * config. + */ + region?: Region + /** UUID of the hosting plan. */ + hostingId: string + /** Page number (must be a positive integer). */ + page?: number + /** + * Number of websites to return (must be a positive integer lower or equal to + * 100). + */ + pageSize?: number + /** Sort order for Web Hosting websites in the response. */ + orderBy?: ListWebsitesRequestOrderBy +} diff --git a/packages/clients/src/api/webhosting/v1/validation-rules.gen.ts b/packages/clients/src/api/webhosting/v1/validation-rules.gen.ts new file mode 100644 index 000000000..659447614 --- /dev/null +++ b/packages/clients/src/api/webhosting/v1/validation-rules.gen.ts @@ -0,0 +1,82 @@ +// This file was automatically generated. DO NOT EDIT. +// If you have any remark or suggestion do not hesitate to open an issue. + +export const ControlPanelApiListControlPanelsRequest = { + page: { + greaterThan: 0, + }, + pageSize: { + greaterThan: 0, + lessThanOrEqual: 100, + }, +} + +export const DatabaseApiListDatabaseUsersRequest = { + page: { + greaterThan: 0, + }, + pageSize: { + greaterThan: 0, + lessThanOrEqual: 100, + }, +} + +export const DatabaseApiListDatabasesRequest = { + page: { + greaterThan: 0, + }, + pageSize: { + greaterThan: 0, + lessThanOrEqual: 100, + }, +} + +export const FtpAccountApiListFtpAccountsRequest = { + page: { + greaterThan: 0, + }, + pageSize: { + greaterThan: 0, + lessThanOrEqual: 100, + }, +} + +export const HostingApiListHostingsRequest = { + page: { + greaterThan: 0, + }, + pageSize: { + greaterThan: 0, + lessThanOrEqual: 100, + }, +} + +export const MailAccountApiListMailAccountsRequest = { + page: { + greaterThan: 0, + }, + pageSize: { + greaterThan: 0, + lessThanOrEqual: 100, + }, +} + +export const OfferApiListOffersRequest = { + page: { + greaterThan: 0, + }, + pageSize: { + greaterThan: 0, + lessThanOrEqual: 100, + }, +} + +export const WebsiteApiListWebsitesRequest = { + page: { + greaterThan: 0, + }, + pageSize: { + greaterThan: 0, + lessThanOrEqual: 100, + }, +}