From 58f9413634cc7e543cd8da483833806cb96f1fa0 Mon Sep 17 00:00:00 2001 From: Scaleway Bot Date: Tue, 26 Sep 2023 22:55:12 +0200 Subject: [PATCH] feat(document-db): set all docs and SDK public (#890) --- .../src/api/document_db/v1beta1/api.gen.ts | 1544 +++++++++++++++++ .../api/document_db/v1beta1/content.gen.ts | 43 + .../src/api/document_db/v1beta1/index.gen.ts | 126 ++ .../document_db/v1beta1/marshalling.gen.ts | 1104 ++++++++++++ .../src/api/document_db/v1beta1/types.gen.ts | 1429 +++++++++++++++ .../v1beta1/validation-rules.gen.ts | 8 + 6 files changed, 4254 insertions(+) create mode 100644 packages/clients/src/api/document_db/v1beta1/api.gen.ts create mode 100644 packages/clients/src/api/document_db/v1beta1/content.gen.ts create mode 100644 packages/clients/src/api/document_db/v1beta1/index.gen.ts create mode 100644 packages/clients/src/api/document_db/v1beta1/marshalling.gen.ts create mode 100644 packages/clients/src/api/document_db/v1beta1/types.gen.ts create mode 100644 packages/clients/src/api/document_db/v1beta1/validation-rules.gen.ts diff --git a/packages/clients/src/api/document_db/v1beta1/api.gen.ts b/packages/clients/src/api/document_db/v1beta1/api.gen.ts new file mode 100644 index 000000000..e1c41ee72 --- /dev/null +++ b/packages/clients/src/api/document_db/v1beta1/api.gen.ts @@ -0,0 +1,1544 @@ +// 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 { + INSTANCE_LOG_TRANSIENT_STATUSES, + INSTANCE_TRANSIENT_STATUSES, + READ_REPLICA_TRANSIENT_STATUSES, + SNAPSHOT_TRANSIENT_STATUSES, +} from './content.gen' +import { + marshalAddInstanceACLRulesRequest, + marshalAddInstanceSettingsRequest, + marshalCloneInstanceRequest, + marshalCreateDatabaseRequest, + marshalCreateEndpointRequest, + marshalCreateInstanceFromSnapshotRequest, + marshalCreateInstanceRequest, + marshalCreateReadReplicaEndpointRequest, + marshalCreateReadReplicaRequest, + marshalCreateSnapshotRequest, + marshalCreateUserRequest, + marshalDeleteInstanceACLRulesRequest, + marshalDeleteInstanceSettingsRequest, + marshalMigrateEndpointRequest, + marshalPurgeInstanceLogsRequest, + marshalSetInstanceACLRulesRequest, + marshalSetInstanceSettingsRequest, + marshalSetPrivilegeRequest, + marshalUpdateInstanceRequest, + marshalUpdateSnapshotRequest, + marshalUpdateUserRequest, + marshalUpgradeInstanceRequest, + unmarshalAddInstanceACLRulesResponse, + unmarshalAddInstanceSettingsResponse, + unmarshalDatabase, + unmarshalDeleteInstanceACLRulesResponse, + unmarshalDeleteInstanceSettingsResponse, + unmarshalEndpoint, + unmarshalInstance, + unmarshalInstanceLog, + unmarshalInstanceMetrics, + unmarshalListDatabaseEnginesResponse, + unmarshalListDatabasesResponse, + unmarshalListInstanceACLRulesResponse, + unmarshalListInstanceLogsDetailsResponse, + unmarshalListInstanceLogsResponse, + unmarshalListInstancesResponse, + unmarshalListNodeTypesResponse, + unmarshalListPrivilegesResponse, + unmarshalListSnapshotsResponse, + unmarshalListUsersResponse, + unmarshalPrivilege, + unmarshalReadReplica, + unmarshalSetInstanceACLRulesResponse, + unmarshalSetInstanceSettingsResponse, + unmarshalSnapshot, + unmarshalUser, +} from './marshalling.gen' +import type { + AddInstanceACLRulesRequest, + AddInstanceACLRulesResponse, + AddInstanceSettingsRequest, + AddInstanceSettingsResponse, + CloneInstanceRequest, + CreateDatabaseRequest, + CreateEndpointRequest, + CreateInstanceFromSnapshotRequest, + CreateInstanceRequest, + CreateReadReplicaEndpointRequest, + CreateReadReplicaRequest, + CreateSnapshotRequest, + CreateUserRequest, + Database, + DeleteDatabaseRequest, + DeleteEndpointRequest, + DeleteInstanceACLRulesRequest, + DeleteInstanceACLRulesResponse, + DeleteInstanceRequest, + DeleteInstanceSettingsRequest, + DeleteInstanceSettingsResponse, + DeleteReadReplicaRequest, + DeleteSnapshotRequest, + DeleteUserRequest, + Endpoint, + GetEndpointRequest, + GetInstanceCertificateRequest, + GetInstanceLogRequest, + GetInstanceMetricsRequest, + GetInstanceRequest, + GetReadReplicaRequest, + GetSnapshotRequest, + Instance, + InstanceLog, + InstanceMetrics, + ListDatabaseEnginesRequest, + ListDatabaseEnginesResponse, + ListDatabasesRequest, + ListDatabasesResponse, + ListInstanceACLRulesRequest, + ListInstanceACLRulesResponse, + ListInstanceLogsDetailsRequest, + ListInstanceLogsDetailsResponse, + ListInstanceLogsRequest, + ListInstanceLogsResponse, + ListInstancesRequest, + ListInstancesResponse, + ListNodeTypesRequest, + ListNodeTypesResponse, + ListPrivilegesRequest, + ListPrivilegesResponse, + ListSnapshotsRequest, + ListSnapshotsResponse, + ListUsersRequest, + ListUsersResponse, + MigrateEndpointRequest, + Privilege, + PromoteReadReplicaRequest, + PurgeInstanceLogsRequest, + ReadReplica, + RenewInstanceCertificateRequest, + ResetReadReplicaRequest, + RestartInstanceRequest, + SetInstanceACLRulesRequest, + SetInstanceACLRulesResponse, + SetInstanceSettingsRequest, + SetInstanceSettingsResponse, + SetPrivilegeRequest, + Snapshot, + UpdateInstanceRequest, + UpdateSnapshotRequest, + UpdateUserRequest, + UpgradeInstanceRequest, + User, +} from './types.gen' + +const jsonContentHeaders = { + 'Content-Type': 'application/json; charset=utf-8', +} + +/** Managed Database for FerretDB API. */ +export class API extends ParentAPI { + /** Lists the available regions of the API. */ + public static readonly LOCALITIES: Region[] = ['fr-par', 'nl-ams', 'pl-waw'] + + protected pageOfListDatabaseEngines = ( + request: Readonly = {}, + ) => + this.client.fetch( + { + method: 'GET', + path: `/document-db/v1beta1/regions/${validatePathParam( + 'region', + request.region ?? this.client.settings.defaultRegion, + )}/database-engines`, + urlParams: urlParams( + ['name', request.name], + ['page', request.page], + [ + 'page_size', + request.pageSize ?? this.client.settings.defaultPageSize, + ], + ['version', request.version], + ), + }, + unmarshalListDatabaseEnginesResponse, + ) + + /** + * List available database engines. List the FerretDB database engines + * available at Scaleway. + * + * @param request - The request {@link ListDatabaseEnginesRequest} + * @returns A Promise of ListDatabaseEnginesResponse + */ + listDatabaseEngines = (request: Readonly = {}) => + enrichForPagination('engines', this.pageOfListDatabaseEngines, request) + + protected pageOfListNodeTypes = (request: Readonly) => + this.client.fetch( + { + method: 'GET', + path: `/document-db/v1beta1/regions/${validatePathParam( + 'region', + request.region ?? this.client.settings.defaultRegion, + )}/node-types`, + urlParams: urlParams( + ['include_disabled_types', request.includeDisabledTypes], + ['page', request.page], + [ + 'page_size', + request.pageSize ?? this.client.settings.defaultPageSize, + ], + ), + }, + unmarshalListNodeTypesResponse, + ) + + /** + * List available node types. List all available node types. By default, the + * node types returned in the list are ordered by creation date in ascending + * order, though this can be modified via the `order_by` field. + * + * @param request - The request {@link ListNodeTypesRequest} + * @returns A Promise of ListNodeTypesResponse + */ + listNodeTypes = (request: Readonly) => + enrichForPagination('nodeTypes', this.pageOfListNodeTypes, request) + + /** + * Upgrade a Database Instance. Upgrade your current Database Instance + * specifications like node type, high availability, volume, or the database + * engine version. Note that upon upgrade the `enable_ha` parameter can only + * be set to `true`. + * + * @param request - The request {@link UpgradeInstanceRequest} + * @returns A Promise of Instance + */ + upgradeInstance = (request: Readonly) => + this.client.fetch( + { + body: JSON.stringify( + marshalUpgradeInstanceRequest(request, this.client.settings), + ), + headers: jsonContentHeaders, + method: 'POST', + path: `/document-db/v1beta1/regions/${validatePathParam( + 'region', + request.region ?? this.client.settings.defaultRegion, + )}/instances/${validatePathParam( + 'instanceId', + request.instanceId, + )}/upgrade`, + }, + unmarshalInstance, + ) + + protected pageOfListInstances = ( + request: Readonly = {}, + ) => + this.client.fetch( + { + method: 'GET', + path: `/document-db/v1beta1/regions/${validatePathParam( + 'region', + request.region ?? this.client.settings.defaultRegion, + )}/instances`, + urlParams: urlParams( + ['name', request.name], + ['order_by', request.orderBy ?? 'created_at_asc'], + ['organization_id', request.organizationId], + ['page', request.page], + [ + 'page_size', + request.pageSize ?? this.client.settings.defaultPageSize, + ], + ['project_id', request.projectId], + ['tags', request.tags], + ), + }, + unmarshalListInstancesResponse, + ) + + /** + * List Database Instances. List all Database Instances in the specified + * region, for a given Scaleway Organization or Scaleway Project. By default, + * the Database Instances returned in the list are ordered by creation date in + * ascending order, though this can be modified via the order_by field. You + * can define additional parameters for your query, such as `tags` and `name`. + * For the `name` parameter, the value you include will be checked against the + * whole name string to see if it includes the string you put in the + * parameter. + * + * @param request - The request {@link ListInstancesRequest} + * @returns A Promise of ListInstancesResponse + */ + listInstances = (request: Readonly = {}) => + enrichForPagination('instances', this.pageOfListInstances, request) + + /** + * Get a Database Instance. Retrieve information about a given Database + * Instance, specified by the `region` and `instance_id` parameters. Its full + * details, including name, status, IP address and port, are returned in the + * response object. + * + * @param request - The request {@link GetInstanceRequest} + * @returns A Promise of Instance + */ + getInstance = (request: Readonly) => + this.client.fetch( + { + method: 'GET', + path: `/document-db/v1beta1/regions/${validatePathParam( + 'region', + request.region ?? this.client.settings.defaultRegion, + )}/instances/${validatePathParam('instanceId', request.instanceId)}`, + }, + unmarshalInstance, + ) + + /** + * Waits for {@link Instance} to be in a final state. + * + * @param request - The request {@link GetInstanceRequest} + * @param options - The waiting options + * @returns A Promise of Instance + */ + waitForInstance = ( + request: Readonly, + options?: Readonly>, + ) => + waitForResource( + options?.stop ?? + (res => + Promise.resolve(!INSTANCE_TRANSIENT_STATUSES.includes(res.status))), + this.getInstance, + request, + options, + ) + + /** + * Create a Database Instance. Create a new Database Instance. You must set + * the `engine`, `user_name`, `password` and `node_type` parameters. + * Optionally, you can specify the volume type and size. + * + * @param request - The request {@link CreateInstanceRequest} + * @returns A Promise of Instance + */ + createInstance = (request: Readonly) => + this.client.fetch( + { + body: JSON.stringify( + marshalCreateInstanceRequest(request, this.client.settings), + ), + headers: jsonContentHeaders, + method: 'POST', + path: `/document-db/v1beta1/regions/${validatePathParam( + 'region', + request.region ?? this.client.settings.defaultRegion, + )}/instances`, + }, + unmarshalInstance, + ) + + /** + * Update a Database Instance. Update the parameters of a Database Instance, + * including name, tags and backup schedule details. + * + * @param request - The request {@link UpdateInstanceRequest} + * @returns A Promise of Instance + */ + updateInstance = (request: Readonly) => + this.client.fetch( + { + body: JSON.stringify( + marshalUpdateInstanceRequest(request, this.client.settings), + ), + headers: jsonContentHeaders, + method: 'PATCH', + path: `/document-db/v1beta1/regions/${validatePathParam( + 'region', + request.region ?? this.client.settings.defaultRegion, + )}/instances/${validatePathParam('instanceId', request.instanceId)}`, + }, + unmarshalInstance, + ) + + /** + * Delete a Database Instance. Delete a given Database Instance, specified by + * the `region` and `instance_id` parameters. Deleting a Database Instance is + * permanent, and cannot be undone. Note that upon deletion all your data will + * be lost. + * + * @param request - The request {@link DeleteInstanceRequest} + * @returns A Promise of Instance + */ + deleteInstance = (request: Readonly) => + this.client.fetch( + { + method: 'DELETE', + path: `/document-db/v1beta1/regions/${validatePathParam( + 'region', + request.region ?? this.client.settings.defaultRegion, + )}/instances/${validatePathParam('instanceId', request.instanceId)}`, + }, + unmarshalInstance, + ) + + /** + * Clone a Database Instance. Clone a given Database Instance, specified by + * the `region` and `instance_id` parameters. The clone feature allows you to + * create a new Database Instance from an existing one. The clone includes all + * existing databases, users and permissions. You can create a clone on a + * Database Instance bigger than your current one. + * + * @param request - The request {@link CloneInstanceRequest} + * @returns A Promise of Instance + */ + cloneInstance = (request: Readonly) => + this.client.fetch( + { + body: JSON.stringify( + marshalCloneInstanceRequest(request, this.client.settings), + ), + headers: jsonContentHeaders, + method: 'POST', + path: `/document-db/v1beta1/regions/${validatePathParam( + 'region', + request.region ?? this.client.settings.defaultRegion, + )}/instances/${validatePathParam( + 'instanceId', + request.instanceId, + )}/clone`, + }, + unmarshalInstance, + ) + + /** + * Restart Database Instance. Restart a given Database Instance, specified by + * the `region` and `instance_id` parameters. The status of the Database + * Instance returned in the response. + * + * @param request - The request {@link RestartInstanceRequest} + * @returns A Promise of Instance + */ + restartInstance = (request: Readonly) => + this.client.fetch( + { + body: '{}', + headers: jsonContentHeaders, + method: 'POST', + path: `/document-db/v1beta1/regions/${validatePathParam( + 'region', + request.region ?? this.client.settings.defaultRegion, + )}/instances/${validatePathParam( + 'instanceId', + request.instanceId, + )}/restart`, + }, + unmarshalInstance, + ) + + /** + * Get the TLS certificate of a Database Instance. Retrieve information about + * the TLS certificate of a given Database Instance. Details like name and + * content are returned in the response. + * + * @param request - The request {@link GetInstanceCertificateRequest} + * @returns A Promise of Blob + */ + getInstanceCertificate = (request: Readonly) => + this.client.fetch({ + method: 'GET', + path: `/document-db/v1beta1/regions/${validatePathParam( + 'region', + request.region ?? this.client.settings.defaultRegion, + )}/instances/${validatePathParam( + 'instanceId', + request.instanceId, + )}/certificate`, + urlParams: urlParams(['dl', 1]), + responseType: 'blob', + }) + + /** + * Renew the TLS certificate of a Database Instance. Renew a TLS for a + * Database Instance. Renewing a certificate means that you will not be able + * to connect to your Database Instance using the previous certificate. You + * will also need to download and update the new certificate for all database + * clients. + * + * @param request - The request {@link RenewInstanceCertificateRequest} + */ + renewInstanceCertificate = ( + request: Readonly, + ) => + this.client.fetch({ + body: '{}', + headers: jsonContentHeaders, + method: 'POST', + path: `/document-db/v1beta1/regions/${validatePathParam( + 'region', + request.region ?? this.client.settings.defaultRegion, + )}/instances/${validatePathParam( + 'instanceId', + request.instanceId, + )}/renew-certificate`, + }) + + /** + * Get Database Instance metrics. Retrieve the time series metrics of a given + * Database Instance. You can define the period from which to retrieve metrics + * by specifying the `start_date` and `end_date`. + * + * @param request - The request {@link GetInstanceMetricsRequest} + * @returns A Promise of InstanceMetrics + */ + getInstanceMetrics = (request: Readonly) => + this.client.fetch( + { + method: 'GET', + path: `/document-db/v1beta1/regions/${validatePathParam( + 'region', + request.region ?? this.client.settings.defaultRegion, + )}/instances/${validatePathParam( + 'instanceId', + request.instanceId, + )}/metrics`, + urlParams: urlParams( + ['end_date', request.endDate], + ['metric_name', request.metricName], + ['start_date', request.startDate], + ), + }, + unmarshalInstanceMetrics, + ) + + /** + * Create a Read Replica. Create a new Read Replica of a Database Instance. + * You must specify the `region` and the `instance_id`. You can only create a + * maximum of 3 Read Replicas per Database Instance. + * + * @param request - The request {@link CreateReadReplicaRequest} + * @returns A Promise of ReadReplica + */ + createReadReplica = (request: Readonly) => + this.client.fetch( + { + body: JSON.stringify( + marshalCreateReadReplicaRequest(request, this.client.settings), + ), + headers: jsonContentHeaders, + method: 'POST', + path: `/document-db/v1beta1/regions/${validatePathParam( + 'region', + request.region ?? this.client.settings.defaultRegion, + )}/read-replicas`, + }, + unmarshalReadReplica, + ) + + /** + * Get a Read Replica. Retrieve information about a Database Instance Read + * Replica. Full details about the Read Replica, like `endpoints`, `status` + * and `region` are returned in the response. + * + * @param request - The request {@link GetReadReplicaRequest} + * @returns A Promise of ReadReplica + */ + getReadReplica = (request: Readonly) => + this.client.fetch( + { + method: 'GET', + path: `/document-db/v1beta1/regions/${validatePathParam( + 'region', + request.region ?? this.client.settings.defaultRegion, + )}/read-replicas/${validatePathParam( + 'readReplicaId', + request.readReplicaId, + )}`, + }, + unmarshalReadReplica, + ) + + /** + * Waits for {@link ReadReplica} to be in a final state. + * + * @param request - The request {@link GetReadReplicaRequest} + * @param options - The waiting options + * @returns A Promise of ReadReplica + */ + waitForReadReplica = ( + request: Readonly, + options?: Readonly>, + ) => + waitForResource( + options?.stop ?? + (res => + Promise.resolve( + !READ_REPLICA_TRANSIENT_STATUSES.includes(res.status), + )), + this.getReadReplica, + request, + options, + ) + + /** + * Delete a Read Replica. Delete a Read Replica of a Database Instance. You + * must specify the `region` and `read_replica_id` parameters of the Read + * Replica you want to delete. + * + * @param request - The request {@link DeleteReadReplicaRequest} + * @returns A Promise of ReadReplica + */ + deleteReadReplica = (request: Readonly) => + this.client.fetch( + { + method: 'DELETE', + path: `/document-db/v1beta1/regions/${validatePathParam( + 'region', + request.region ?? this.client.settings.defaultRegion, + )}/read-replicas/${validatePathParam( + 'readReplicaId', + request.readReplicaId, + )}`, + }, + unmarshalReadReplica, + ) + + /** + * Resync a Read Replica. When you resync a Read Replica, first it is reset, + * then its data is resynchronized from the primary node. Your Read Replica + * remains unavailable during the resync process. The duration of this process + * is proportional to the size of your Database Instance. The configured + * endpoints do not change. + * + * @param request - The request {@link ResetReadReplicaRequest} + * @returns A Promise of ReadReplica + */ + resetReadReplica = (request: Readonly) => + this.client.fetch( + { + body: '{}', + headers: jsonContentHeaders, + method: 'POST', + path: `/document-db/v1beta1/regions/${validatePathParam( + 'region', + request.region ?? this.client.settings.defaultRegion, + )}/read-replicas/${validatePathParam( + 'readReplicaId', + request.readReplicaId, + )}/reset`, + }, + unmarshalReadReplica, + ) + + /** + * Promote a Read Replica. Promote a Read Replica to Database Instance + * automatically. + * + * @param request - The request {@link PromoteReadReplicaRequest} + * @returns A Promise of Instance + */ + promoteReadReplica = (request: Readonly) => + this.client.fetch( + { + body: '{}', + headers: jsonContentHeaders, + method: 'POST', + path: `/document-db/v1beta1/regions/${validatePathParam( + 'region', + request.region ?? this.client.settings.defaultRegion, + )}/read-replicas/${validatePathParam( + 'readReplicaId', + request.readReplicaId, + )}/promote`, + }, + unmarshalInstance, + ) + + /** + * Create an endpoint for a Read Replica. Create a new endpoint for a Read + * Replica. Read Replicas can have at most one direct access and one Private + * Network endpoint. + * + * @param request - The request {@link CreateReadReplicaEndpointRequest} + * @returns A Promise of ReadReplica + */ + createReadReplicaEndpoint = ( + request: Readonly, + ) => + this.client.fetch( + { + body: JSON.stringify( + marshalCreateReadReplicaEndpointRequest( + request, + this.client.settings, + ), + ), + headers: jsonContentHeaders, + method: 'POST', + path: `/document-db/v1beta1/regions/${validatePathParam( + 'region', + request.region ?? this.client.settings.defaultRegion, + )}/read-replicas/${validatePathParam( + 'readReplicaId', + request.readReplicaId, + )}/endpoints`, + }, + unmarshalReadReplica, + ) + + /** + * List available logs of a Database Instance. List the available logs of a + * Database Instance. By default, the logs returned in the list are ordered by + * creation date in ascending order, though this can be modified via the + * order_by field. + * + * @param request - The request {@link ListInstanceLogsRequest} + * @returns A Promise of ListInstanceLogsResponse + */ + listInstanceLogs = (request: Readonly) => + this.client.fetch( + { + method: 'GET', + path: `/document-db/v1beta1/regions/${validatePathParam( + 'region', + request.region ?? this.client.settings.defaultRegion, + )}/instances/${validatePathParam( + 'instanceId', + request.instanceId, + )}/logs`, + urlParams: urlParams(['order_by', request.orderBy ?? 'created_at_asc']), + }, + unmarshalListInstanceLogsResponse, + ) + + /** + * Get given logs of a Database Instance. Retrieve information about the logs + * of a Database Instance. Specify the `instance_log_id` and `region` in your + * request to get information such as `download_url`, `status`, `expires_at` + * and `created_at` about your logs in the response. + * + * @param request - The request {@link GetInstanceLogRequest} + * @returns A Promise of InstanceLog + */ + getInstanceLog = (request: Readonly) => + this.client.fetch( + { + method: 'GET', + path: `/document-db/v1beta1/regions/${validatePathParam( + 'region', + request.region ?? this.client.settings.defaultRegion, + )}/logs/${validatePathParam('instanceLogId', request.instanceLogId)}`, + }, + unmarshalInstanceLog, + ) + + /** + * Waits for {@link InstanceLog} to be in a final state. + * + * @param request - The request {@link GetInstanceLogRequest} + * @param options - The waiting options + * @returns A Promise of InstanceLog + */ + waitForInstanceLog = ( + request: Readonly, + options?: Readonly>, + ) => + waitForResource( + options?.stop ?? + (res => + Promise.resolve( + !INSTANCE_LOG_TRANSIENT_STATUSES.includes(res.status), + )), + this.getInstanceLog, + request, + options, + ) + + /** + * Purge remote Database Instance logs. Purge a given remote log from a + * Database Instance. You can specify the `log_name` of the log you wish to + * clean from your Database Instance. + * + * @param request - The request {@link PurgeInstanceLogsRequest} + */ + purgeInstanceLogs = (request: Readonly) => + this.client.fetch({ + body: JSON.stringify( + marshalPurgeInstanceLogsRequest(request, this.client.settings), + ), + headers: jsonContentHeaders, + method: 'POST', + path: `/document-db/v1beta1/regions/${validatePathParam( + 'region', + request.region ?? this.client.settings.defaultRegion, + )}/instances/${validatePathParam( + 'instanceId', + request.instanceId, + )}/purge-logs`, + }) + + /** + * List remote Database Instance logs details. List remote log details. By + * default, the details returned in the list are ordered by creation date in + * ascending order, though this can be modified via the order_by field. + * + * @param request - The request {@link ListInstanceLogsDetailsRequest} + * @returns A Promise of ListInstanceLogsDetailsResponse + */ + listInstanceLogsDetails = ( + request: Readonly, + ) => + this.client.fetch( + { + method: 'GET', + path: `/document-db/v1beta1/regions/${validatePathParam( + 'region', + request.region ?? this.client.settings.defaultRegion, + )}/instances/${validatePathParam( + 'instanceId', + request.instanceId, + )}/logs-details`, + }, + unmarshalListInstanceLogsDetailsResponse, + ) + + /** + * Add Database Instance advanced settings. Add an advanced setting to a + * Database Instance. You must set the `name` and the `value` of each + * setting. + * + * @param request - The request {@link AddInstanceSettingsRequest} + * @returns A Promise of AddInstanceSettingsResponse + */ + addInstanceSettings = (request: Readonly) => + this.client.fetch( + { + body: JSON.stringify( + marshalAddInstanceSettingsRequest(request, this.client.settings), + ), + headers: jsonContentHeaders, + method: 'POST', + path: `/document-db/v1beta1/regions/${validatePathParam( + 'region', + request.region ?? this.client.settings.defaultRegion, + )}/instances/${validatePathParam( + 'instanceId', + request.instanceId, + )}/settings`, + }, + unmarshalAddInstanceSettingsResponse, + ) + + /** + * Delete Database Instance advanced settings. Delete an advanced setting in a + * Database Instance. You must specify the names of the settings you want to + * delete in the request. + * + * @param request - The request {@link DeleteInstanceSettingsRequest} + * @returns A Promise of DeleteInstanceSettingsResponse + */ + deleteInstanceSettings = (request: Readonly) => + this.client.fetch( + { + body: JSON.stringify( + marshalDeleteInstanceSettingsRequest(request, this.client.settings), + ), + headers: jsonContentHeaders, + method: 'DELETE', + path: `/document-db/v1beta1/regions/${validatePathParam( + 'region', + request.region ?? this.client.settings.defaultRegion, + )}/instances/${validatePathParam( + 'instanceId', + request.instanceId, + )}/settings`, + }, + unmarshalDeleteInstanceSettingsResponse, + ) + + /** + * Set Database Instance advanced settings. Update an advanced setting for a + * Database Instance. Settings added upon database engine initalization can + * only be defined once, and cannot, therefore, be updated. + * + * @param request - The request {@link SetInstanceSettingsRequest} + * @returns A Promise of SetInstanceSettingsResponse + */ + setInstanceSettings = (request: Readonly) => + this.client.fetch( + { + body: JSON.stringify( + marshalSetInstanceSettingsRequest(request, this.client.settings), + ), + headers: jsonContentHeaders, + method: 'PUT', + path: `/document-db/v1beta1/regions/${validatePathParam( + 'region', + request.region ?? this.client.settings.defaultRegion, + )}/instances/${validatePathParam( + 'instanceId', + request.instanceId, + )}/settings`, + }, + unmarshalSetInstanceSettingsResponse, + ) + + protected pageOfListInstanceACLRules = ( + request: Readonly, + ) => + this.client.fetch( + { + method: 'GET', + path: `/document-db/v1beta1/regions/${validatePathParam( + 'region', + request.region ?? this.client.settings.defaultRegion, + )}/instances/${validatePathParam( + 'instanceId', + request.instanceId, + )}/acls`, + urlParams: urlParams( + ['page', request.page], + [ + 'page_size', + request.pageSize ?? this.client.settings.defaultPageSize, + ], + ), + }, + unmarshalListInstanceACLRulesResponse, + ) + + /** + * List ACL rules of a Database Instance. List the ACL rules for a given + * Database Instance. The response is an array of ACL objects, each one + * representing an ACL that denies, allows or redirects traffic based on + * certain conditions. + * + * @param request - The request {@link ListInstanceACLRulesRequest} + * @returns A Promise of ListInstanceACLRulesResponse + */ + listInstanceACLRules = (request: Readonly) => + enrichForPagination('rules', this.pageOfListInstanceACLRules, request) + + /** + * Add an ACL rule to a Database Instance. Add an additional ACL rule to a + * Database Instance. + * + * @param request - The request {@link AddInstanceACLRulesRequest} + * @returns A Promise of AddInstanceACLRulesResponse + */ + addInstanceACLRules = (request: Readonly) => + this.client.fetch( + { + body: JSON.stringify( + marshalAddInstanceACLRulesRequest(request, this.client.settings), + ), + headers: jsonContentHeaders, + method: 'POST', + path: `/document-db/v1beta1/regions/${validatePathParam( + 'region', + request.region ?? this.client.settings.defaultRegion, + )}/instances/${validatePathParam( + 'instanceId', + request.instanceId, + )}/acls`, + }, + unmarshalAddInstanceACLRulesResponse, + ) + + /** + * Set ACL rules for a Database Instance. Replace all the ACL rules of a + * Database Instance. + * + * @param request - The request {@link SetInstanceACLRulesRequest} + * @returns A Promise of SetInstanceACLRulesResponse + */ + setInstanceACLRules = (request: Readonly) => + this.client.fetch( + { + body: JSON.stringify( + marshalSetInstanceACLRulesRequest(request, this.client.settings), + ), + headers: jsonContentHeaders, + method: 'PUT', + path: `/document-db/v1beta1/regions/${validatePathParam( + 'region', + request.region ?? this.client.settings.defaultRegion, + )}/instances/${validatePathParam( + 'instanceId', + request.instanceId, + )}/acls`, + }, + unmarshalSetInstanceACLRulesResponse, + ) + + /** + * Delete ACL rules of a Database Instance. Delete one or more ACL rules of a + * Database Instance. + * + * @param request - The request {@link DeleteInstanceACLRulesRequest} + * @returns A Promise of DeleteInstanceACLRulesResponse + */ + deleteInstanceACLRules = (request: Readonly) => + this.client.fetch( + { + body: JSON.stringify( + marshalDeleteInstanceACLRulesRequest(request, this.client.settings), + ), + headers: jsonContentHeaders, + method: 'DELETE', + path: `/document-db/v1beta1/regions/${validatePathParam( + 'region', + request.region ?? this.client.settings.defaultRegion, + )}/instances/${validatePathParam( + 'instanceId', + request.instanceId, + )}/acls`, + }, + unmarshalDeleteInstanceACLRulesResponse, + ) + + protected pageOfListUsers = (request: Readonly) => + this.client.fetch( + { + method: 'GET', + path: `/document-db/v1beta1/regions/${validatePathParam( + 'region', + request.region ?? this.client.settings.defaultRegion, + )}/instances/${validatePathParam( + 'instanceId', + request.instanceId, + )}/users`, + urlParams: urlParams( + ['name', request.name], + ['order_by', request.orderBy ?? 'name_asc'], + ['page', request.page], + [ + 'page_size', + request.pageSize ?? this.client.settings.defaultPageSize, + ], + ), + }, + unmarshalListUsersResponse, + ) + + /** + * List users of a Database Instance. List all users of a given Database + * Instance. By default, the users returned in the list are ordered by + * creation date in ascending order, though this can be modified via the + * order_by field. + * + * @param request - The request {@link ListUsersRequest} + * @returns A Promise of ListUsersResponse + */ + listUsers = (request: Readonly) => + enrichForPagination('users', this.pageOfListUsers, request) + + /** + * Create a user for a Database Instance. Create a new user for a Database + * Instance. You must define the `name`, `password` and `is_admin` + * parameters. + * + * @param request - The request {@link CreateUserRequest} + * @returns A Promise of User + */ + createUser = (request: Readonly) => + this.client.fetch( + { + body: JSON.stringify( + marshalCreateUserRequest(request, this.client.settings), + ), + headers: jsonContentHeaders, + method: 'POST', + path: `/document-db/v1beta1/regions/${validatePathParam( + 'region', + request.region ?? this.client.settings.defaultRegion, + )}/instances/${validatePathParam( + 'instanceId', + request.instanceId, + )}/users`, + }, + unmarshalUser, + ) + + /** + * Update a user on a Database Instance. Update the parameters of a user on a + * Database Instance. You can update the `password` and `is_admin` parameters, + * but you cannot change the name of the user. + * + * @param request - The request {@link UpdateUserRequest} + * @returns A Promise of User + */ + updateUser = (request: Readonly) => + this.client.fetch( + { + body: JSON.stringify( + marshalUpdateUserRequest(request, this.client.settings), + ), + headers: jsonContentHeaders, + method: 'PATCH', + path: `/document-db/v1beta1/regions/${validatePathParam( + 'region', + request.region ?? this.client.settings.defaultRegion, + )}/instances/${validatePathParam( + 'instanceId', + request.instanceId, + )}/users/${validatePathParam('name', request.name)}`, + }, + unmarshalUser, + ) + + /** + * Delete a user on a Database Instance. Delete a given user on a Database + * Instance. You must specify, in the endpoint, the `region`, `instance_id` + * and `name` parameters of the user you want to delete. + * + * @param request - The request {@link DeleteUserRequest} + */ + deleteUser = (request: Readonly) => + this.client.fetch({ + method: 'DELETE', + path: `/document-db/v1beta1/regions/${validatePathParam( + 'region', + request.region ?? this.client.settings.defaultRegion, + )}/instances/${validatePathParam( + 'instanceId', + request.instanceId, + )}/users/${validatePathParam('name', request.name)}`, + }) + + protected pageOfListDatabases = (request: Readonly) => + this.client.fetch( + { + method: 'GET', + path: `/document-db/v1beta1/regions/${validatePathParam( + 'region', + request.region ?? this.client.settings.defaultRegion, + )}/instances/${validatePathParam( + 'instanceId', + request.instanceId, + )}/databases`, + urlParams: urlParams( + ['managed', request.managed], + ['name', request.name], + ['order_by', request.orderBy ?? 'name_asc'], + ['owner', request.owner], + ['page', request.page], + [ + 'page_size', + request.pageSize ?? this.client.settings.defaultPageSize, + ], + ), + }, + unmarshalListDatabasesResponse, + ) + + /** + * List databases in a Database Instance. List all databases of a given + * Database Instance. By default, the databases returned in the list are + * ordered by creation date in ascending order, though this can be modified + * via the order_by field. You can define additional parameters for your + * query, such as `name`, `managed` and `owner`. + * + * @param request - The request {@link ListDatabasesRequest} + * @returns A Promise of ListDatabasesResponse + */ + listDatabases = (request: Readonly) => + enrichForPagination('databases', this.pageOfListDatabases, request) + + /** + * Create a database in a Database Instance. Create a new database. You must + * define the `name` parameter in the request. + * + * @param request - The request {@link CreateDatabaseRequest} + * @returns A Promise of Database + */ + createDatabase = (request: Readonly) => + this.client.fetch( + { + body: JSON.stringify( + marshalCreateDatabaseRequest(request, this.client.settings), + ), + headers: jsonContentHeaders, + method: 'POST', + path: `/document-db/v1beta1/regions/${validatePathParam( + 'region', + request.region ?? this.client.settings.defaultRegion, + )}/instances/${validatePathParam( + 'instanceId', + request.instanceId, + )}/databases`, + }, + unmarshalDatabase, + ) + + /** + * Delete a database in a Database Instance. Delete a given database on a + * Database Instance. You must specify, in the endpoint, the `region`, + * `instance_id` and `name` parameters of the database you want to delete. + * + * @param request - The request {@link DeleteDatabaseRequest} + */ + deleteDatabase = (request: Readonly) => + this.client.fetch({ + method: 'DELETE', + path: `/document-db/v1beta1/regions/${validatePathParam( + 'region', + request.region ?? this.client.settings.defaultRegion, + )}/instances/${validatePathParam( + 'instanceId', + request.instanceId, + )}/databases/${validatePathParam('name', request.name)}`, + }) + + protected pageOfListPrivileges = (request: Readonly) => + this.client.fetch( + { + method: 'GET', + path: `/document-db/v1beta1/regions/${validatePathParam( + 'region', + request.region ?? this.client.settings.defaultRegion, + )}/instances/${validatePathParam( + 'instanceId', + request.instanceId, + )}/privileges`, + urlParams: urlParams( + ['database_name', request.databaseName], + ['order_by', request.orderBy ?? 'user_name_asc'], + ['page', request.page], + [ + 'page_size', + request.pageSize ?? this.client.settings.defaultPageSize, + ], + ['user_name', request.userName], + ), + }, + unmarshalListPrivilegesResponse, + ) + + /** + * List user privileges for a database. List privileges of a user on a + * database. By default, the details returned in the list are ordered by + * creation date in ascending order, though this can be modified via the + * order_by field. You can define additional parameters for your query, such + * as `database_name` and `user_name`. + * + * @param request - The request {@link ListPrivilegesRequest} + * @returns A Promise of ListPrivilegesResponse + */ + listPrivileges = (request: Readonly) => + enrichForPagination('privileges', this.pageOfListPrivileges, request) + + /** + * Set user privileges for a database. Set the privileges of a user on a + * database. You must define `database_name`, `user_name` and `permission` in + * the request body. + * + * @param request - The request {@link SetPrivilegeRequest} + * @returns A Promise of Privilege + */ + setPrivilege = (request: Readonly) => + this.client.fetch( + { + body: JSON.stringify( + marshalSetPrivilegeRequest(request, this.client.settings), + ), + headers: jsonContentHeaders, + method: 'PUT', + path: `/document-db/v1beta1/regions/${validatePathParam( + 'region', + request.region ?? this.client.settings.defaultRegion, + )}/instances/${validatePathParam( + 'instanceId', + request.instanceId, + )}/privileges`, + }, + unmarshalPrivilege, + ) + + protected pageOfListSnapshots = ( + request: Readonly = {}, + ) => + this.client.fetch( + { + method: 'GET', + path: `/document-db/v1beta1/regions/${validatePathParam( + 'region', + request.region ?? this.client.settings.defaultRegion, + )}/snapshots`, + urlParams: urlParams( + ['instance_id', request.instanceId], + ['name', request.name], + ['order_by', request.orderBy ?? 'created_at_asc'], + ['organization_id', request.organizationId], + ['page', request.page], + [ + 'page_size', + request.pageSize ?? this.client.settings.defaultPageSize, + ], + ['project_id', request.projectId], + ), + }, + unmarshalListSnapshotsResponse, + ) + + /** + * List snapshots. List snapshots. You can include the `instance_id` or + * `project_id` in your query to get the list of snapshots for specific + * Database Instances and/or Projects. By default, the details returned in the + * list are ordered by creation date in ascending order, though this can be + * modified via the `order_by` field. + * + * @param request - The request {@link ListSnapshotsRequest} + * @returns A Promise of ListSnapshotsResponse + */ + listSnapshots = (request: Readonly = {}) => + enrichForPagination('snapshots', this.pageOfListSnapshots, request) + + /** + * Get a Database Instance snapshot. Retrieve information about a given + * snapshot, specified by its `snapshot_id` and `region`. Full details about + * the snapshot, like size and expiration date, are returned in the response. + * + * @param request - The request {@link GetSnapshotRequest} + * @returns A Promise of Snapshot + */ + getSnapshot = (request: Readonly) => + this.client.fetch( + { + method: 'GET', + path: `/document-db/v1beta1/regions/${validatePathParam( + 'region', + request.region ?? this.client.settings.defaultRegion, + )}/snapshots/${validatePathParam('snapshotId', request.snapshotId)}`, + }, + unmarshalSnapshot, + ) + + /** + * Waits for {@link Snapshot} to be in a final state. + * + * @param request - The request {@link GetSnapshotRequest} + * @param options - The waiting options + * @returns A Promise of Snapshot + */ + waitForSnapshot = ( + request: Readonly, + options?: Readonly>, + ) => + waitForResource( + options?.stop ?? + (res => + Promise.resolve(!SNAPSHOT_TRANSIENT_STATUSES.includes(res.status))), + this.getSnapshot, + request, + options, + ) + + /** + * Create a Database Instance snapshot. Create a new snapshot of a Database + * Instance. You must define the `name` parameter in the request. + * + * @param request - The request {@link CreateSnapshotRequest} + * @returns A Promise of Snapshot + */ + createSnapshot = (request: Readonly) => + this.client.fetch( + { + body: JSON.stringify( + marshalCreateSnapshotRequest(request, this.client.settings), + ), + headers: jsonContentHeaders, + method: 'POST', + path: `/document-db/v1beta1/regions/${validatePathParam( + 'region', + request.region ?? this.client.settings.defaultRegion, + )}/instances/${validatePathParam( + 'instanceId', + request.instanceId, + )}/snapshots`, + }, + unmarshalSnapshot, + ) + + /** + * Update a Database Instance snapshot. Update the parameters of a snapshot of + * a Database Instance. You can update the `name` and `expires_at` + * parameters. + * + * @param request - The request {@link UpdateSnapshotRequest} + * @returns A Promise of Snapshot + */ + updateSnapshot = (request: Readonly) => + this.client.fetch( + { + body: JSON.stringify( + marshalUpdateSnapshotRequest(request, this.client.settings), + ), + headers: jsonContentHeaders, + method: 'PATCH', + path: `/document-db/v1beta1/regions/${validatePathParam( + 'region', + request.region ?? this.client.settings.defaultRegion, + )}/snapshots/${validatePathParam('snapshotId', request.snapshotId)}`, + }, + unmarshalSnapshot, + ) + + /** + * Delete a Database Instance snapshot. Delete a given snapshot of a Database + * Instance. You must specify, in the endpoint, the `region` and `snapshot_id` + * parameters of the snapshot you want to delete. + * + * @param request - The request {@link DeleteSnapshotRequest} + * @returns A Promise of Snapshot + */ + deleteSnapshot = (request: Readonly) => + this.client.fetch( + { + method: 'DELETE', + path: `/document-db/v1beta1/regions/${validatePathParam( + 'region', + request.region ?? this.client.settings.defaultRegion, + )}/snapshots/${validatePathParam('snapshotId', request.snapshotId)}`, + }, + unmarshalSnapshot, + ) + + /** + * Create a new Database Instance from a snapshot. Restore a snapshot. When + * you restore a snapshot, a new Instance is created and billed to your + * account. Note that is possible to select a larger node type for your new + * Database Instance. However, the Block volume size will be the same as the + * size of the restored snapshot. All Instance settings will be restored if + * you chose a node type with the same or more memory size than the initial + * Instance. Settings will be reset to the default if your node type has less + * memory. + * + * @param request - The request {@link CreateInstanceFromSnapshotRequest} + * @returns A Promise of Instance + */ + createInstanceFromSnapshot = ( + request: Readonly, + ) => + this.client.fetch( + { + body: JSON.stringify( + marshalCreateInstanceFromSnapshotRequest( + request, + this.client.settings, + ), + ), + headers: jsonContentHeaders, + method: 'POST', + path: `/document-db/v1beta1/regions/${validatePathParam( + 'region', + request.region ?? this.client.settings.defaultRegion, + )}/snapshots/${validatePathParam( + 'snapshotId', + request.snapshotId, + )}/create-instance`, + }, + unmarshalInstance, + ) + + /** + * Create a new Database Instance endpoint. Create a new endpoint for a + * Database Instance. You can add `load_balancer` and `private_network` + * specifications to the body of the request. + * + * @param request - The request {@link CreateEndpointRequest} + * @returns A Promise of Endpoint + */ + createEndpoint = (request: Readonly) => + this.client.fetch( + { + body: JSON.stringify( + marshalCreateEndpointRequest(request, this.client.settings), + ), + headers: jsonContentHeaders, + method: 'POST', + path: `/document-db/v1beta1/regions/${validatePathParam( + 'region', + request.region ?? this.client.settings.defaultRegion, + )}/instances/${validatePathParam( + 'instanceId', + request.instanceId, + )}/endpoints`, + }, + unmarshalEndpoint, + ) + + /** + * Delete a Database Instance endpoint. Delete the endpoint of a Database + * Instance. You must specify the `region` and `endpoint_id` parameters of the + * endpoint you want to delete. Note that might need to update any environment + * configurations that point to the deleted endpoint. + * + * @param request - The request {@link DeleteEndpointRequest} + */ + deleteEndpoint = (request: Readonly) => + this.client.fetch({ + method: 'DELETE', + path: `/document-db/v1beta1/regions/${validatePathParam( + 'region', + request.region ?? this.client.settings.defaultRegion, + )}/endpoints/${validatePathParam('endpointId', request.endpointId)}`, + }) + + /** + * Get a Database Instance endpoint. Retrieve information about a Database + * Instance endpoint. Full details about the endpoint, like `ip`, `port`, + * `private_network` and `load_balancer` specifications are returned in the + * response. + * + * @param request - The request {@link GetEndpointRequest} + * @returns A Promise of Endpoint + */ + getEndpoint = (request: Readonly) => + this.client.fetch( + { + method: 'GET', + path: `/document-db/v1beta1/regions/${validatePathParam( + 'region', + request.region ?? this.client.settings.defaultRegion, + )}/endpoints/${validatePathParam('endpointId', request.endpointId)}`, + }, + unmarshalEndpoint, + ) + + /** + * Migrate Database Instance endpoint. Migrate an existing Database Instance + * endpoint to another Database Instance. + * + * @param request - The request {@link MigrateEndpointRequest} + * @returns A Promise of Endpoint + */ + migrateEndpoint = (request: Readonly) => + this.client.fetch( + { + body: JSON.stringify( + marshalMigrateEndpointRequest(request, this.client.settings), + ), + headers: jsonContentHeaders, + method: 'POST', + path: `/document-db/v1beta1/regions/${validatePathParam( + 'region', + request.region ?? this.client.settings.defaultRegion, + )}/endpoints/${validatePathParam( + 'endpointId', + request.endpointId, + )}/migrate`, + }, + unmarshalEndpoint, + ) +} diff --git a/packages/clients/src/api/document_db/v1beta1/content.gen.ts b/packages/clients/src/api/document_db/v1beta1/content.gen.ts new file mode 100644 index 000000000..a4939bdd0 --- /dev/null +++ b/packages/clients/src/api/document_db/v1beta1/content.gen.ts @@ -0,0 +1,43 @@ +// This file was automatically generated. DO NOT EDIT. +// If you have any remark or suggestion do not hesitate to open an issue. +import type { + InstanceLogStatus, + InstanceStatus, + MaintenanceStatus, + ReadReplicaStatus, + SnapshotStatus, +} from './types.gen' + +/** Lists transient statutes of the enum {@link InstanceLogStatus}. */ +export const INSTANCE_LOG_TRANSIENT_STATUSES: InstanceLogStatus[] = ['creating'] + +/** Lists transient statutes of the enum {@link InstanceStatus}. */ +export const INSTANCE_TRANSIENT_STATUSES: InstanceStatus[] = [ + 'provisioning', + 'configuring', + 'deleting', + 'autohealing', + 'initializing', + 'backuping', + 'snapshotting', + 'restarting', +] + +/** Lists transient statutes of the enum {@link MaintenanceStatus}. */ +export const MAINTENANCE_TRANSIENT_STATUSES: MaintenanceStatus[] = ['pending'] + +/** Lists transient statutes of the enum {@link ReadReplicaStatus}. */ +export const READ_REPLICA_TRANSIENT_STATUSES: ReadReplicaStatus[] = [ + 'provisioning', + 'initializing', + 'deleting', + 'configuring', + 'promoting', +] + +/** Lists transient statutes of the enum {@link SnapshotStatus}. */ +export const SNAPSHOT_TRANSIENT_STATUSES: SnapshotStatus[] = [ + 'creating', + 'restoring', + 'deleting', +] diff --git a/packages/clients/src/api/document_db/v1beta1/index.gen.ts b/packages/clients/src/api/document_db/v1beta1/index.gen.ts new file mode 100644 index 000000000..045d2b2b8 --- /dev/null +++ b/packages/clients/src/api/document_db/v1beta1/index.gen.ts @@ -0,0 +1,126 @@ +// 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 { + ACLRule, + ACLRuleAction, + ACLRuleDirection, + ACLRuleProtocol, + ACLRuleRequest, + AddInstanceACLRulesRequest, + AddInstanceACLRulesResponse, + AddInstanceSettingsRequest, + AddInstanceSettingsResponse, + BackupSchedule, + CloneInstanceRequest, + CreateDatabaseRequest, + CreateEndpointRequest, + CreateInstanceFromSnapshotRequest, + CreateInstanceRequest, + CreateReadReplicaEndpointRequest, + CreateReadReplicaRequest, + CreateSnapshotRequest, + CreateUserRequest, + Database, + DatabaseEngine, + DeleteDatabaseRequest, + DeleteEndpointRequest, + DeleteInstanceACLRulesRequest, + DeleteInstanceACLRulesResponse, + DeleteInstanceRequest, + DeleteInstanceSettingsRequest, + DeleteInstanceSettingsResponse, + DeleteReadReplicaRequest, + DeleteSnapshotRequest, + DeleteUserRequest, + Endpoint, + EndpointDirectAccessDetails, + EndpointLoadBalancerDetails, + EndpointPrivateNetworkDetails, + EndpointSpec, + EndpointSpecLoadBalancer, + EndpointSpecPrivateNetwork, + EndpointSpecPrivateNetworkIpamConfig, + EngineSetting, + EngineSettingPropertyType, + EngineVersion, + GetEndpointRequest, + GetInstanceCertificateRequest, + GetInstanceLogRequest, + GetInstanceMetricsRequest, + GetInstanceRequest, + GetReadReplicaRequest, + GetSnapshotRequest, + Instance, + InstanceLog, + InstanceLogStatus, + InstanceMetrics, + InstanceSetting, + InstanceStatus, + ListDatabaseEnginesRequest, + ListDatabaseEnginesResponse, + ListDatabasesRequest, + ListDatabasesRequestOrderBy, + ListDatabasesResponse, + ListInstanceACLRulesRequest, + ListInstanceACLRulesResponse, + ListInstanceLogsDetailsRequest, + ListInstanceLogsDetailsResponse, + ListInstanceLogsDetailsResponseInstanceLogDetail, + ListInstanceLogsRequest, + ListInstanceLogsRequestOrderBy, + ListInstanceLogsResponse, + ListInstancesRequest, + ListInstancesRequestOrderBy, + ListInstancesResponse, + ListNodeTypesRequest, + ListNodeTypesResponse, + ListPrivilegesRequest, + ListPrivilegesRequestOrderBy, + ListPrivilegesResponse, + ListSnapshotsRequest, + ListSnapshotsRequestOrderBy, + ListSnapshotsResponse, + ListUsersRequest, + ListUsersRequestOrderBy, + ListUsersResponse, + LogsPolicy, + Maintenance, + MaintenanceStatus, + MigrateEndpointRequest, + NodeType, + NodeTypeGeneration, + NodeTypeStock, + NodeTypeVolumeConstraintSizes, + NodeTypeVolumeType, + Permission, + Privilege, + PromoteReadReplicaRequest, + PurgeInstanceLogsRequest, + ReadReplica, + ReadReplicaEndpointSpec, + ReadReplicaEndpointSpecDirectAccess, + ReadReplicaEndpointSpecPrivateNetwork, + ReadReplicaEndpointSpecPrivateNetworkIpamConfig, + ReadReplicaStatus, + RenewInstanceCertificateRequest, + ResetReadReplicaRequest, + RestartInstanceRequest, + SetInstanceACLRulesRequest, + SetInstanceACLRulesResponse, + SetInstanceSettingsRequest, + SetInstanceSettingsResponse, + SetPrivilegeRequest, + Snapshot, + SnapshotStatus, + UpdateInstanceRequest, + UpdateSnapshotRequest, + UpdateUserRequest, + UpgradableVersion, + UpgradeInstanceRequest, + User, + Volume, + VolumeType, +} from './types.gen' +export * as ValidationRules from './validation-rules.gen' diff --git a/packages/clients/src/api/document_db/v1beta1/marshalling.gen.ts b/packages/clients/src/api/document_db/v1beta1/marshalling.gen.ts new file mode 100644 index 000000000..76b53dc8d --- /dev/null +++ b/packages/clients/src/api/document_db/v1beta1/marshalling.gen.ts @@ -0,0 +1,1104 @@ +// This file was automatically generated. DO NOT EDIT. +// If you have any remark or suggestion do not hesitate to open an issue. +import randomName from '@scaleway/random-name' +import { + isJSONObject, + resolveOneOf, + unmarshalArrayOfObject, + unmarshalDate, + unmarshalTimeSeries, +} from '../../../bridge' +import type { DefaultValues } from '../../../bridge' +import type { + ACLRule, + ACLRuleRequest, + AddInstanceACLRulesRequest, + AddInstanceACLRulesResponse, + AddInstanceSettingsRequest, + AddInstanceSettingsResponse, + BackupSchedule, + CloneInstanceRequest, + CreateDatabaseRequest, + CreateEndpointRequest, + CreateInstanceFromSnapshotRequest, + CreateInstanceRequest, + CreateReadReplicaEndpointRequest, + CreateReadReplicaRequest, + CreateSnapshotRequest, + CreateUserRequest, + Database, + DatabaseEngine, + DeleteInstanceACLRulesRequest, + DeleteInstanceACLRulesResponse, + DeleteInstanceSettingsRequest, + DeleteInstanceSettingsResponse, + Endpoint, + EndpointDirectAccessDetails, + EndpointLoadBalancerDetails, + EndpointPrivateNetworkDetails, + EndpointSpec, + EndpointSpecLoadBalancer, + EndpointSpecPrivateNetwork, + EndpointSpecPrivateNetworkIpamConfig, + EngineSetting, + EngineVersion, + Instance, + InstanceLog, + InstanceMetrics, + InstanceSetting, + ListDatabaseEnginesResponse, + ListDatabasesResponse, + ListInstanceACLRulesResponse, + ListInstanceLogsDetailsResponse, + ListInstanceLogsDetailsResponseInstanceLogDetail, + ListInstanceLogsResponse, + ListInstancesResponse, + ListNodeTypesResponse, + ListPrivilegesResponse, + ListSnapshotsResponse, + ListUsersResponse, + LogsPolicy, + Maintenance, + MigrateEndpointRequest, + NodeType, + NodeTypeVolumeConstraintSizes, + NodeTypeVolumeType, + Privilege, + PurgeInstanceLogsRequest, + ReadReplica, + ReadReplicaEndpointSpec, + ReadReplicaEndpointSpecDirectAccess, + ReadReplicaEndpointSpecPrivateNetwork, + ReadReplicaEndpointSpecPrivateNetworkIpamConfig, + SetInstanceACLRulesRequest, + SetInstanceACLRulesResponse, + SetInstanceSettingsRequest, + SetInstanceSettingsResponse, + SetPrivilegeRequest, + Snapshot, + UpdateInstanceRequest, + UpdateSnapshotRequest, + UpdateUserRequest, + UpgradableVersion, + UpgradeInstanceRequest, + User, + Volume, +} from './types.gen' + +const unmarshalEndpointDirectAccessDetails = (data: unknown) => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'EndpointDirectAccessDetails' failed as data isn't a dictionary.`, + ) + } + + return {} as EndpointDirectAccessDetails +} + +const unmarshalEndpointLoadBalancerDetails = (data: unknown) => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'EndpointLoadBalancerDetails' failed as data isn't a dictionary.`, + ) + } + + return {} as EndpointLoadBalancerDetails +} + +const unmarshalEndpointPrivateNetworkDetails = (data: unknown) => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'EndpointPrivateNetworkDetails' failed as data isn't a dictionary.`, + ) + } + + return { + privateNetworkId: data.private_network_id, + serviceIp: data.service_ip, + zone: data.zone, + } as EndpointPrivateNetworkDetails +} + +export const unmarshalEndpoint = (data: unknown) => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'Endpoint' failed as data isn't a dictionary.`, + ) + } + + return { + directAccess: data.direct_access + ? unmarshalEndpointDirectAccessDetails(data.direct_access) + : undefined, + hostname: data.hostname, + id: data.id, + ip: data.ip, + loadBalancer: data.load_balancer + ? unmarshalEndpointLoadBalancerDetails(data.load_balancer) + : undefined, + name: data.name, + port: data.port, + privateNetwork: data.private_network + ? unmarshalEndpointPrivateNetworkDetails(data.private_network) + : undefined, + } as Endpoint +} + +const unmarshalEngineSetting = (data: unknown) => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'EngineSetting' failed as data isn't a dictionary.`, + ) + } + + return { + defaultValue: data.default_value, + description: data.description, + floatMax: data.float_max, + floatMin: data.float_min, + hotConfigurable: data.hot_configurable, + intMax: data.int_max, + intMin: data.int_min, + name: data.name, + propertyType: data.property_type, + stringConstraint: data.string_constraint, + unit: data.unit, + } as EngineSetting +} + +const unmarshalBackupSchedule = (data: unknown) => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'BackupSchedule' failed as data isn't a dictionary.`, + ) + } + + return { + disabled: data.disabled, + frequency: data.frequency, + nextRunAt: unmarshalDate(data.next_run_at), + retention: data.retention, + } as BackupSchedule +} + +const unmarshalEngineVersion = (data: unknown) => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'EngineVersion' failed as data isn't a dictionary.`, + ) + } + + return { + availableInitSettings: unmarshalArrayOfObject( + data.available_init_settings, + unmarshalEngineSetting, + ), + availableSettings: unmarshalArrayOfObject( + data.available_settings, + unmarshalEngineSetting, + ), + beta: data.beta, + disabled: data.disabled, + endOfLife: unmarshalDate(data.end_of_life), + name: data.name, + version: data.version, + } as EngineVersion +} + +const unmarshalInstanceSetting = (data: unknown) => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'InstanceSetting' failed as data isn't a dictionary.`, + ) + } + + return { name: data.name, value: data.value } as InstanceSetting +} + +const unmarshalLogsPolicy = (data: unknown) => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'LogsPolicy' failed as data isn't a dictionary.`, + ) + } + + return { + maxAgeRetention: data.max_age_retention, + totalDiskRetention: data.total_disk_retention, + } as LogsPolicy +} + +const unmarshalMaintenance = (data: unknown) => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'Maintenance' failed as data isn't a dictionary.`, + ) + } + + return { + closedAt: unmarshalDate(data.closed_at), + reason: data.reason, + startsAt: unmarshalDate(data.starts_at), + status: data.status, + stopsAt: unmarshalDate(data.stops_at), + } as Maintenance +} + +const unmarshalNodeTypeVolumeConstraintSizes = (data: unknown) => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'NodeTypeVolumeConstraintSizes' failed as data isn't a dictionary.`, + ) + } + + return { + maxSize: data.max_size, + minSize: data.min_size, + } as NodeTypeVolumeConstraintSizes +} + +const unmarshalNodeTypeVolumeType = (data: unknown) => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'NodeTypeVolumeType' failed as data isn't a dictionary.`, + ) + } + + return { + chunkSize: data.chunk_size, + description: data.description, + maxSize: data.max_size, + minSize: data.min_size, + type: data.type, + } as NodeTypeVolumeType +} + +export const unmarshalReadReplica = (data: unknown) => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'ReadReplica' failed as data isn't a dictionary.`, + ) + } + + return { + endpoints: unmarshalArrayOfObject(data.endpoints, unmarshalEndpoint), + id: data.id, + region: data.region, + sameZone: data.same_zone, + status: data.status, + } as ReadReplica +} + +const unmarshalUpgradableVersion = (data: unknown) => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'UpgradableVersion' failed as data isn't a dictionary.`, + ) + } + + return { + id: data.id, + minorVersion: data.minor_version, + name: data.name, + version: data.version, + } as UpgradableVersion +} + +const unmarshalVolume = (data: unknown) => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'Volume' failed as data isn't a dictionary.`, + ) + } + + return { size: data.size, type: data.type } as Volume +} + +const unmarshalACLRule = (data: unknown) => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'ACLRule' failed as data isn't a dictionary.`, + ) + } + + return { + action: data.action, + description: data.description, + direction: data.direction, + ip: data.ip, + port: data.port, + protocol: data.protocol, + } as ACLRule +} + +export const unmarshalDatabase = (data: unknown) => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'Database' failed as data isn't a dictionary.`, + ) + } + + return { + managed: data.managed, + name: data.name, + owner: data.owner, + size: data.size, + } as Database +} + +const unmarshalDatabaseEngine = (data: unknown) => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'DatabaseEngine' failed as data isn't a dictionary.`, + ) + } + + return { + logoUrl: data.logo_url, + name: data.name, + region: data.region, + versions: unmarshalArrayOfObject(data.versions, unmarshalEngineVersion), + } as DatabaseEngine +} + +export const unmarshalInstance = (data: unknown) => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'Instance' failed as data isn't a dictionary.`, + ) + } + + return { + backupSameRegion: data.backup_same_region, + backupSchedule: data.backup_schedule + ? unmarshalBackupSchedule(data.backup_schedule) + : undefined, + createdAt: unmarshalDate(data.created_at), + endpoint: data.endpoint ? unmarshalEndpoint(data.endpoint) : undefined, + endpoints: unmarshalArrayOfObject(data.endpoints, unmarshalEndpoint), + engine: data.engine, + id: data.id, + initSettings: unmarshalArrayOfObject( + data.init_settings, + unmarshalInstanceSetting, + ), + isHaCluster: data.is_ha_cluster, + logsPolicy: data.logs_policy + ? unmarshalLogsPolicy(data.logs_policy) + : undefined, + maintenances: unmarshalArrayOfObject( + data.maintenances, + unmarshalMaintenance, + ), + name: data.name, + nodeType: data.node_type, + organizationId: data.organization_id, + projectId: data.project_id, + readReplicas: unmarshalArrayOfObject( + data.read_replicas, + unmarshalReadReplica, + ), + region: data.region, + settings: unmarshalArrayOfObject(data.settings, unmarshalInstanceSetting), + status: data.status, + tags: data.tags, + upgradableVersion: unmarshalArrayOfObject( + data.upgradable_version, + unmarshalUpgradableVersion, + ), + volume: data.volume ? unmarshalVolume(data.volume) : undefined, + } as Instance +} + +export const unmarshalInstanceLog = (data: unknown) => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'InstanceLog' failed as data isn't a dictionary.`, + ) + } + + return { + createdAt: unmarshalDate(data.created_at), + downloadUrl: data.download_url, + expiresAt: unmarshalDate(data.expires_at), + id: data.id, + nodeName: data.node_name, + region: data.region, + status: data.status, + } as InstanceLog +} + +const unmarshalListInstanceLogsDetailsResponseInstanceLogDetail = ( + data: unknown, +) => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'ListInstanceLogsDetailsResponseInstanceLogDetail' failed as data isn't a dictionary.`, + ) + } + + return { + logName: data.log_name, + size: data.size, + } as ListInstanceLogsDetailsResponseInstanceLogDetail +} + +const unmarshalNodeType = (data: unknown) => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'NodeType' failed as data isn't a dictionary.`, + ) + } + + return { + availableVolumeTypes: unmarshalArrayOfObject( + data.available_volume_types, + unmarshalNodeTypeVolumeType, + ), + beta: data.beta, + description: data.description, + disabled: data.disabled, + generation: data.generation, + instanceRange: data.instance_range, + isBssdCompatible: data.is_bssd_compatible, + isHaRequired: data.is_ha_required, + memory: data.memory, + name: data.name, + region: data.region, + stockStatus: data.stock_status, + vcpus: data.vcpus, + volumeConstraint: data.volume_constraint + ? unmarshalNodeTypeVolumeConstraintSizes(data.volume_constraint) + : undefined, + } as NodeType +} + +export const unmarshalPrivilege = (data: unknown) => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'Privilege' failed as data isn't a dictionary.`, + ) + } + + return { + databaseName: data.database_name, + permission: data.permission, + userName: data.user_name, + } as Privilege +} + +export const unmarshalSnapshot = (data: unknown) => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'Snapshot' failed as data isn't a dictionary.`, + ) + } + + return { + createdAt: unmarshalDate(data.created_at), + expiresAt: unmarshalDate(data.expires_at), + id: data.id, + instanceId: data.instance_id, + instanceName: data.instance_name, + name: data.name, + nodeType: data.node_type, + region: data.region, + size: data.size, + status: data.status, + updatedAt: unmarshalDate(data.updated_at), + } as Snapshot +} + +export const unmarshalUser = (data: unknown) => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'User' failed as data isn't a dictionary.`, + ) + } + + return { isAdmin: data.is_admin, name: data.name } as User +} + +export const unmarshalAddInstanceACLRulesResponse = (data: unknown) => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'AddInstanceACLRulesResponse' failed as data isn't a dictionary.`, + ) + } + + return { + rules: unmarshalArrayOfObject(data.rules, unmarshalACLRule), + } as AddInstanceACLRulesResponse +} + +export const unmarshalAddInstanceSettingsResponse = (data: unknown) => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'AddInstanceSettingsResponse' failed as data isn't a dictionary.`, + ) + } + + return { + settings: unmarshalArrayOfObject(data.settings, unmarshalInstanceSetting), + } as AddInstanceSettingsResponse +} + +export const unmarshalDeleteInstanceACLRulesResponse = (data: unknown) => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'DeleteInstanceACLRulesResponse' failed as data isn't a dictionary.`, + ) + } + + return { + rules: unmarshalArrayOfObject(data.rules, unmarshalACLRule), + } as DeleteInstanceACLRulesResponse +} + +export const unmarshalDeleteInstanceSettingsResponse = (data: unknown) => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'DeleteInstanceSettingsResponse' failed as data isn't a dictionary.`, + ) + } + + return { + settings: unmarshalArrayOfObject(data.settings, unmarshalInstanceSetting), + } as DeleteInstanceSettingsResponse +} + +export const unmarshalInstanceMetrics = (data: unknown) => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'InstanceMetrics' failed as data isn't a dictionary.`, + ) + } + + return { + timeseries: unmarshalArrayOfObject(data.timeseries, unmarshalTimeSeries), + } as InstanceMetrics +} + +export const unmarshalListDatabaseEnginesResponse = (data: unknown) => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'ListDatabaseEnginesResponse' failed as data isn't a dictionary.`, + ) + } + + return { + engines: unmarshalArrayOfObject(data.engines, unmarshalDatabaseEngine), + totalCount: data.total_count, + } as ListDatabaseEnginesResponse +} + +export const unmarshalListDatabasesResponse = (data: unknown) => { + 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 unmarshalListInstanceACLRulesResponse = (data: unknown) => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'ListInstanceACLRulesResponse' failed as data isn't a dictionary.`, + ) + } + + return { + rules: unmarshalArrayOfObject(data.rules, unmarshalACLRule), + totalCount: data.total_count, + } as ListInstanceACLRulesResponse +} + +export const unmarshalListInstanceLogsDetailsResponse = (data: unknown) => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'ListInstanceLogsDetailsResponse' failed as data isn't a dictionary.`, + ) + } + + return { + details: unmarshalArrayOfObject( + data.details, + unmarshalListInstanceLogsDetailsResponseInstanceLogDetail, + ), + } as ListInstanceLogsDetailsResponse +} + +export const unmarshalListInstanceLogsResponse = (data: unknown) => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'ListInstanceLogsResponse' failed as data isn't a dictionary.`, + ) + } + + return { + instanceLogs: unmarshalArrayOfObject( + data.instance_logs, + unmarshalInstanceLog, + ), + } as ListInstanceLogsResponse +} + +export const unmarshalListInstancesResponse = (data: unknown) => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'ListInstancesResponse' failed as data isn't a dictionary.`, + ) + } + + return { + instances: unmarshalArrayOfObject(data.instances, unmarshalInstance), + totalCount: data.total_count, + } as ListInstancesResponse +} + +export const unmarshalListNodeTypesResponse = (data: unknown) => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'ListNodeTypesResponse' failed as data isn't a dictionary.`, + ) + } + + return { + nodeTypes: unmarshalArrayOfObject(data.node_types, unmarshalNodeType), + totalCount: data.total_count, + } as ListNodeTypesResponse +} + +export const unmarshalListPrivilegesResponse = (data: unknown) => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'ListPrivilegesResponse' failed as data isn't a dictionary.`, + ) + } + + return { + privileges: unmarshalArrayOfObject(data.privileges, unmarshalPrivilege), + totalCount: data.total_count, + } as ListPrivilegesResponse +} + +export const unmarshalListSnapshotsResponse = (data: unknown) => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'ListSnapshotsResponse' failed as data isn't a dictionary.`, + ) + } + + return { + snapshots: unmarshalArrayOfObject(data.snapshots, unmarshalSnapshot), + totalCount: data.total_count, + } as ListSnapshotsResponse +} + +export const unmarshalListUsersResponse = (data: unknown) => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'ListUsersResponse' failed as data isn't a dictionary.`, + ) + } + + return { + totalCount: data.total_count, + users: unmarshalArrayOfObject(data.users, unmarshalUser), + } as ListUsersResponse +} + +export const unmarshalSetInstanceACLRulesResponse = (data: unknown) => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'SetInstanceACLRulesResponse' failed as data isn't a dictionary.`, + ) + } + + return { + rules: unmarshalArrayOfObject(data.rules, unmarshalACLRule), + } as SetInstanceACLRulesResponse +} + +export const unmarshalSetInstanceSettingsResponse = (data: unknown) => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'SetInstanceSettingsResponse' failed as data isn't a dictionary.`, + ) + } + + return { + settings: unmarshalArrayOfObject(data.settings, unmarshalInstanceSetting), + } as SetInstanceSettingsResponse +} + +const marshalEndpointSpecPrivateNetworkIpamConfig = ( + request: EndpointSpecPrivateNetworkIpamConfig, + defaults: DefaultValues, +): Record => ({}) + +const marshalReadReplicaEndpointSpecPrivateNetworkIpamConfig = ( + request: ReadReplicaEndpointSpecPrivateNetworkIpamConfig, + defaults: DefaultValues, +): Record => ({}) + +const marshalEndpointSpecLoadBalancer = ( + request: EndpointSpecLoadBalancer, + defaults: DefaultValues, +): Record => ({}) + +const marshalEndpointSpecPrivateNetwork = ( + request: EndpointSpecPrivateNetwork, + defaults: DefaultValues, +): Record => ({ + private_network_id: request.privateNetworkId, + ...resolveOneOf([ + { + param: 'service_ip', + value: request.serviceIp, + }, + { + param: 'ipam_config', + value: request.ipamConfig + ? marshalEndpointSpecPrivateNetworkIpamConfig( + request.ipamConfig, + defaults, + ) + : undefined, + }, + ]), +}) + +const marshalReadReplicaEndpointSpecDirectAccess = ( + request: ReadReplicaEndpointSpecDirectAccess, + defaults: DefaultValues, +): Record => ({}) + +const marshalReadReplicaEndpointSpecPrivateNetwork = ( + request: ReadReplicaEndpointSpecPrivateNetwork, + defaults: DefaultValues, +): Record => ({ + private_network_id: request.privateNetworkId, + ...resolveOneOf([ + { + param: 'service_ip', + value: request.serviceIp, + }, + { + param: 'ipam_config', + value: request.ipamConfig + ? marshalReadReplicaEndpointSpecPrivateNetworkIpamConfig( + request.ipamConfig, + defaults, + ) + : undefined, + }, + ]), +}) + +const marshalACLRuleRequest = ( + request: ACLRuleRequest, + defaults: DefaultValues, +): Record => ({ + description: request.description, + ip: request.ip, +}) + +const marshalEndpointSpec = ( + request: EndpointSpec, + defaults: DefaultValues, +): Record => ({ + ...resolveOneOf([ + { + param: 'load_balancer', + value: request.loadBalancer + ? marshalEndpointSpecLoadBalancer(request.loadBalancer, defaults) + : undefined, + }, + { + param: 'private_network', + value: request.privateNetwork + ? marshalEndpointSpecPrivateNetwork(request.privateNetwork, defaults) + : undefined, + }, + ]), +}) + +const marshalInstanceSetting = ( + request: InstanceSetting, + defaults: DefaultValues, +): Record => ({ + name: request.name, + value: request.value, +}) + +const marshalLogsPolicy = ( + request: LogsPolicy, + defaults: DefaultValues, +): Record => ({ + max_age_retention: request.maxAgeRetention, + total_disk_retention: request.totalDiskRetention, +}) + +const marshalReadReplicaEndpointSpec = ( + request: ReadReplicaEndpointSpec, + defaults: DefaultValues, +): Record => ({ + ...resolveOneOf([ + { + param: 'direct_access', + value: request.directAccess + ? marshalReadReplicaEndpointSpecDirectAccess( + request.directAccess, + defaults, + ) + : undefined, + }, + { + param: 'private_network', + value: request.privateNetwork + ? marshalReadReplicaEndpointSpecPrivateNetwork( + request.privateNetwork, + defaults, + ) + : undefined, + }, + ]), +}) + +export const marshalAddInstanceACLRulesRequest = ( + request: AddInstanceACLRulesRequest, + defaults: DefaultValues, +): Record => ({ + rules: request.rules.map(elt => marshalACLRuleRequest(elt, defaults)), +}) + +export const marshalAddInstanceSettingsRequest = ( + request: AddInstanceSettingsRequest, + defaults: DefaultValues, +): Record => ({ + settings: request.settings.map(elt => marshalInstanceSetting(elt, defaults)), +}) + +export const marshalCloneInstanceRequest = ( + request: CloneInstanceRequest, + defaults: DefaultValues, +): Record => ({ + name: request.name, + node_type: request.nodeType, +}) + +export const marshalCreateDatabaseRequest = ( + request: CreateDatabaseRequest, + defaults: DefaultValues, +): Record => ({ + name: request.name, +}) + +export const marshalCreateEndpointRequest = ( + request: CreateEndpointRequest, + defaults: DefaultValues, +): Record => ({ + endpoint_spec: request.endpointSpec + ? marshalEndpointSpec(request.endpointSpec, defaults) + : undefined, +}) + +export const marshalCreateInstanceFromSnapshotRequest = ( + request: CreateInstanceFromSnapshotRequest, + defaults: DefaultValues, +): Record => ({ + instance_name: request.instanceName, + is_ha_cluster: request.isHaCluster, + node_type: request.nodeType, +}) + +export const marshalCreateInstanceRequest = ( + request: CreateInstanceRequest, + defaults: DefaultValues, +): Record => ({ + backup_same_region: request.backupSameRegion, + disable_backup: request.disableBackup, + engine: request.engine, + init_endpoints: request.initEndpoints + ? request.initEndpoints.map(elt => marshalEndpointSpec(elt, defaults)) + : undefined, + init_settings: request.initSettings + ? request.initSettings.map(elt => marshalInstanceSetting(elt, defaults)) + : undefined, + is_ha_cluster: request.isHaCluster, + name: request.name || randomName('ins'), + node_type: request.nodeType, + password: request.password, + tags: request.tags, + user_name: request.userName, + volume_size: request.volumeSize, + volume_type: request.volumeType ?? 'lssd', + ...resolveOneOf([ + { + default: defaults.defaultProjectId, + param: 'project_id', + value: request.projectId, + }, + { + default: defaults.defaultOrganizationId, + param: 'organization_id', + value: request.organizationId, + }, + ]), +}) + +export const marshalCreateReadReplicaEndpointRequest = ( + request: CreateReadReplicaEndpointRequest, + defaults: DefaultValues, +): Record => ({ + endpoint_spec: request.endpointSpec.map(elt => + marshalReadReplicaEndpointSpec(elt, defaults), + ), +}) + +export const marshalCreateReadReplicaRequest = ( + request: CreateReadReplicaRequest, + defaults: DefaultValues, +): Record => ({ + endpoint_spec: request.endpointSpec + ? request.endpointSpec.map(elt => + marshalReadReplicaEndpointSpec(elt, defaults), + ) + : undefined, + instance_id: request.instanceId, + same_zone: request.sameZone, +}) + +export const marshalCreateSnapshotRequest = ( + request: CreateSnapshotRequest, + defaults: DefaultValues, +): Record => ({ + expires_at: request.expiresAt, + name: request.name || randomName('snp'), +}) + +export const marshalCreateUserRequest = ( + request: CreateUserRequest, + defaults: DefaultValues, +): Record => ({ + is_admin: request.isAdmin, + name: request.name, + password: request.password, +}) + +export const marshalDeleteInstanceACLRulesRequest = ( + request: DeleteInstanceACLRulesRequest, + defaults: DefaultValues, +): Record => ({ + acl_rule_ips: request.aclRuleIps, +}) + +export const marshalDeleteInstanceSettingsRequest = ( + request: DeleteInstanceSettingsRequest, + defaults: DefaultValues, +): Record => ({ + setting_names: request.settingNames, +}) + +export const marshalMigrateEndpointRequest = ( + request: MigrateEndpointRequest, + defaults: DefaultValues, +): Record => ({ + instance_id: request.instanceId, +}) + +export const marshalPurgeInstanceLogsRequest = ( + request: PurgeInstanceLogsRequest, + defaults: DefaultValues, +): Record => ({ + log_name: request.logName, +}) + +export const marshalSetInstanceACLRulesRequest = ( + request: SetInstanceACLRulesRequest, + defaults: DefaultValues, +): Record => ({ + rules: request.rules.map(elt => marshalACLRuleRequest(elt, defaults)), +}) + +export const marshalSetInstanceSettingsRequest = ( + request: SetInstanceSettingsRequest, + defaults: DefaultValues, +): Record => ({ + settings: request.settings.map(elt => marshalInstanceSetting(elt, defaults)), +}) + +export const marshalSetPrivilegeRequest = ( + request: SetPrivilegeRequest, + defaults: DefaultValues, +): Record => ({ + database_name: request.databaseName, + permission: request.permission ?? 'readonly', + user_name: request.userName, +}) + +export const marshalUpdateInstanceRequest = ( + request: UpdateInstanceRequest, + defaults: DefaultValues, +): Record => ({ + backup_same_region: request.backupSameRegion, + backup_schedule_frequency: request.backupScheduleFrequency, + backup_schedule_retention: request.backupScheduleRetention, + backup_schedule_start_hour: request.backupScheduleStartHour, + is_backup_schedule_disabled: request.isBackupScheduleDisabled, + logs_policy: request.logsPolicy + ? marshalLogsPolicy(request.logsPolicy, defaults) + : undefined, + name: request.name, + tags: request.tags, +}) + +export const marshalUpdateSnapshotRequest = ( + request: UpdateSnapshotRequest, + defaults: DefaultValues, +): Record => ({ + expires_at: request.expiresAt, + name: request.name, +}) + +export const marshalUpdateUserRequest = ( + request: UpdateUserRequest, + defaults: DefaultValues, +): Record => ({ + is_admin: request.isAdmin, + password: request.password, +}) + +export const marshalUpgradeInstanceRequest = ( + request: UpgradeInstanceRequest, + defaults: DefaultValues, +): Record => ({ + ...resolveOneOf([ + { + param: 'node_type', + value: request.nodeType, + }, + { + param: 'enable_ha', + value: request.enableHa, + }, + { + param: 'volume_size', + value: request.volumeSize, + }, + { + param: 'volume_type', + value: request.volumeType, + }, + { + param: 'upgradable_version_id', + value: request.upgradableVersionId, + }, + ]), +}) diff --git a/packages/clients/src/api/document_db/v1beta1/types.gen.ts b/packages/clients/src/api/document_db/v1beta1/types.gen.ts new file mode 100644 index 000000000..8e07852ce --- /dev/null +++ b/packages/clients/src/api/document_db/v1beta1/types.gen.ts @@ -0,0 +1,1429 @@ +// This file was automatically generated. DO NOT EDIT. +// If you have any remark or suggestion do not hesitate to open an issue. +import type { Region, TimeSeries, Zone } from '../../../bridge' + +export type ACLRuleAction = 'allow' | 'deny' + +export type ACLRuleDirection = 'inbound' | 'outbound' + +export type ACLRuleProtocol = 'tcp' | 'udp' | 'icmp' + +export type EngineSettingPropertyType = 'BOOLEAN' | 'INT' | 'STRING' | 'FLOAT' + +export type InstanceLogStatus = 'unknown' | 'ready' | 'creating' | 'error' + +export type InstanceStatus = + | 'unknown' + | 'ready' + | 'provisioning' + | 'configuring' + | 'deleting' + | 'error' + | 'autohealing' + | 'locked' + | 'initializing' + | 'disk_full' + | 'backuping' + | 'snapshotting' + | 'restarting' + +export type ListDatabasesRequestOrderBy = + | 'name_asc' + | 'name_desc' + | 'size_asc' + | 'size_desc' + +export type ListInstanceLogsRequestOrderBy = + | 'created_at_asc' + | 'created_at_desc' + +export type ListInstancesRequestOrderBy = + | 'created_at_asc' + | 'created_at_desc' + | 'name_asc' + | 'name_desc' + | 'region' + | 'status_asc' + | 'status_desc' + +export type ListPrivilegesRequestOrderBy = + | 'user_name_asc' + | 'user_name_desc' + | 'database_name_asc' + | 'database_name_desc' + +export type ListSnapshotsRequestOrderBy = + | 'created_at_asc' + | 'created_at_desc' + | 'name_asc' + | 'name_desc' + | 'expires_at_asc' + | 'expires_at_desc' + +export type ListUsersRequestOrderBy = + | 'name_asc' + | 'name_desc' + | 'is_admin_asc' + | 'is_admin_desc' + +export type MaintenanceStatus = 'unknown' | 'pending' | 'done' | 'canceled' + +export type NodeTypeGeneration = + | 'unknown_generation' + | 'generation_v1' + | 'generation_v2' + +export type NodeTypeStock = + | 'unknown' + | 'low_stock' + | 'out_of_stock' + | 'available' + +export type Permission = 'readonly' | 'readwrite' | 'all' | 'custom' | 'none' + +/** Read replica. status. */ +export type ReadReplicaStatus = + | 'unknown' + | 'provisioning' + | 'initializing' + | 'ready' + | 'deleting' + | 'error' + | 'locked' + | 'configuring' + | 'promoting' + +export type SnapshotStatus = + | 'unknown' + | 'creating' + | 'ready' + | 'restoring' + | 'deleting' + | 'error' + | 'locked' + +export type VolumeType = 'lssd' | 'bssd' + +export interface ACLRule { + ip: string + /** @deprecated */ + port?: number + protocol: ACLRuleProtocol + direction: ACLRuleDirection + action: ACLRuleAction + description: string +} + +export interface ACLRuleRequest { + ip: string + description: string +} + +/** Add instance acl rules response. */ +export interface AddInstanceACLRulesResponse { + /** ACL Rules enabled for the Database Instance. */ + rules: ACLRule[] +} + +/** Add instance settings response. */ +export interface AddInstanceSettingsResponse { + /** Settings available on the Database Instance. */ + settings: InstanceSetting[] +} + +/** Backup schedule. */ +export interface BackupSchedule { + /** Frequency of the backup schedule (in hours). */ + frequency: number + /** Default retention period of backups (in days). */ + retention: number + /** Defines whether the backup schedule feature is disabled. */ + disabled: boolean + /** Next run of the backup schedule (accurate to 10 minutes). */ + nextRunAt?: Date +} + +/** Database. */ +export interface Database { + /** Name of the database. */ + name: string + /** Name of the database owner. */ + owner: string + /** Defines whether the database is managed or not. */ + managed: boolean + /** Size of the database. */ + size: number +} + +/** Database engine. */ +export interface DatabaseEngine { + /** Engine name. */ + name: string + /** Engine logo URL. */ + logoUrl: string + /** Available versions. */ + versions: EngineVersion[] + /** Region of this Database Instance. */ + region: Region +} + +/** Delete instance acl rules response. */ +export interface DeleteInstanceACLRulesResponse { + /** IP addresses defined in the ACL rules of the Database Instance. */ + rules: ACLRule[] +} + +/** Delete instance settings response. */ +export interface DeleteInstanceSettingsResponse { + /** Settings names to delete from the Database Instance. */ + settings: InstanceSetting[] +} + +/** Endpoint. */ +export interface Endpoint { + /** UUID of the endpoint. */ + id: string + /** + * IPv4 address of the endpoint. + * + * One-of ('address'): at most one of 'ip', 'hostname' could be set. + */ + ip?: string + /** TCP port of the endpoint. */ + port: number + /** Name of the endpoint. */ + name?: string + /** + * Private Network details. One maximum per Database Instance or Read Replica + * (a Database Instance and its Read Replica can have different Private + * Networks). Cannot be updated (has to be deleted and recreated). + * + * One-of ('details'): at most one of 'privateNetwork', 'loadBalancer', + * 'directAccess' could be set. + */ + privateNetwork?: EndpointPrivateNetworkDetails + /** + * Load Balancer details. Public endpoint for Database Instance which is + * systematically present. One per Database Instance. + * + * One-of ('details'): at most one of 'privateNetwork', 'loadBalancer', + * 'directAccess' could be set. + */ + loadBalancer?: EndpointLoadBalancerDetails + /** + * Direct access details. Public endpoint reserved for Read Replicas. One per + * Read Replica. + * + * One-of ('details'): at most one of 'privateNetwork', 'loadBalancer', + * 'directAccess' could be set. + */ + directAccess?: EndpointDirectAccessDetails + /** + * Hostname of the endpoint. + * + * One-of ('address'): at most one of 'ip', 'hostname' could be set. + */ + hostname?: string +} + +export interface EndpointDirectAccessDetails {} + +export interface EndpointLoadBalancerDetails {} + +/** Endpoint. private network details. */ +export interface EndpointPrivateNetworkDetails { + /** UUID of the Private Network. */ + privateNetworkId: string + /** CIDR notation of the endpoint IPv4 address. */ + serviceIp: string + /** Private network zone. */ + zone: Zone +} + +/** Endpoint spec. */ +export interface EndpointSpec { + /** + * Load Balancer endpoint specifications. Public endpoint for Database + * Instance which is systematically present. One per Document Database + * Instance. + * + * One-of ('spec'): at most one of 'loadBalancer', 'privateNetwork' could be + * set. + */ + loadBalancer?: EndpointSpecLoadBalancer + /** + * Private Network endpoint specifications. One maximum per Database Instance + * or Read Replica (a Database Instance and its Read Replica can have + * different Private Networks). Cannot be updated (has to be deleted and + * recreated). + * + * One-of ('spec'): at most one of 'loadBalancer', 'privateNetwork' could be + * set. + */ + privateNetwork?: EndpointSpecPrivateNetwork +} + +export interface EndpointSpecLoadBalancer {} + +/** Endpoint spec. private network. */ +export interface EndpointSpecPrivateNetwork { + /** UUID of the Private Network to be connected to the Database Instance. */ + privateNetworkId: string + /** + * Endpoint IPv4 address with a CIDR notation. Refer to the official Scaleway + * documentation to learn more about IP and subnet limitations. + * + * One-of ('config'): at most one of 'serviceIp', 'ipamConfig' could be set. + */ + serviceIp?: string + /** + * Automated configuration of your Private Network endpoint with Scaleway IPAM + * service. One at the most per Database Instance or Read Replica (a Database + * Instance and its Read Replica can have different Private Networks). Cannot + * be updated (has to be deleted and recreated). + * + * One-of ('config'): at most one of 'serviceIp', 'ipamConfig' could be set. + */ + ipamConfig?: EndpointSpecPrivateNetworkIpamConfig +} + +export interface EndpointSpecPrivateNetworkIpamConfig {} + +/** Engine setting. */ +export interface EngineSetting { + /** Setting name from the database engine. */ + name: string + /** Value set when not specified. */ + defaultValue: string + /** Setting can be applied without restarting. */ + hotConfigurable: boolean + /** Setting description. */ + description: string + /** Setting type. */ + propertyType: EngineSettingPropertyType + /** Setting base unit. */ + unit?: string + /** Validation regex for string type settings. */ + stringConstraint?: string + /** Minimum value for int types. */ + intMin?: number + /** Maximum value for int types. */ + intMax?: number + /** Minimum value for float types. */ + floatMin?: number + /** Maximum value for float types. */ + floatMax?: number +} + +/** Engine version. */ +export interface EngineVersion { + /** Database engine version. */ + version: string + /** Database engine name. */ + name: string + /** End of life date. */ + endOfLife?: Date + /** Engine settings available to be set. */ + availableSettings: EngineSetting[] + /** Disabled versions cannot be created. */ + disabled: boolean + /** Beta status of engine version. */ + beta: boolean + /** Engine settings available to be set at database initialization. */ + availableInitSettings: EngineSetting[] +} + +/** Instance. */ +export interface Instance { + /** Creation date (must follow the ISO 8601 format). */ + createdAt?: Date + /** Volumes of the Database Instance. */ + volume?: Volume + /** Region the Database Instance is in. */ + region: Region + /** UUID of the Database Instance. */ + id: string + /** Name of the Database Instance. */ + name: string + /** Organization ID the Database Instance belongs to. */ + organizationId: string + /** Project ID the Database Instance belongs to. */ + projectId: string + /** Status of the Database Instance. */ + status: InstanceStatus + /** Database engine of the database. */ + engine: string + /** Available database engine versions for upgrade. */ + upgradableVersion: UpgradableVersion[] + /** @deprecated Endpoint of the Database Instance. */ + endpoint?: Endpoint + /** List of tags applied to the Database Instance. */ + tags: string[] + /** Advanced settings of the Database Instance. */ + settings: InstanceSetting[] + /** Backup schedule of the Database Instance. */ + backupSchedule?: BackupSchedule + /** Defines whether or not High-Availability is enabled. */ + isHaCluster: boolean + /** Read Replicas of the Database Instance. */ + readReplicas: ReadReplica[] + /** Node type of the Database Instance. */ + nodeType: string + /** List of engine settings to be set at Database Instance initialization. */ + initSettings: InstanceSetting[] + /** List of Database Instance endpoints. */ + endpoints: Endpoint[] + /** Logs policy of the Database Instance. */ + logsPolicy?: LogsPolicy + /** Store logical backups in the same region as the Database Instance. */ + backupSameRegion: boolean + /** List of Database Instance maintenance events. */ + maintenances: Maintenance[] +} + +/** Instance log. */ +export interface InstanceLog { + /** Presigned S3 URL to download your log file. */ + downloadUrl?: string + /** UUID of the Database Instance log. */ + id: string + /** Status of the logs in a Database Instance. */ + status: InstanceLogStatus + /** Name of the underlying node. */ + nodeName: string + /** Expiration date (must follow the ISO 8601 format). */ + expiresAt?: Date + /** Creation date (must follow the ISO 8601 format). */ + createdAt?: Date + /** Region the Database Instance is in. */ + region: Region +} + +/** Instance metrics. */ +export interface InstanceMetrics { + /** Time series of metrics of a Database Instance. */ + timeseries: TimeSeries[] +} + +export interface InstanceSetting { + name: string + value: string +} + +/** List database engines response. */ +export interface ListDatabaseEnginesResponse { + /** List of the available database engines. */ + engines: DatabaseEngine[] + /** Total count of database engines available. */ + totalCount: number +} + +/** List databases response. */ +export interface ListDatabasesResponse { + /** List of the databases. */ + databases: Database[] + /** Total count of databases present on a Database Instance. */ + totalCount: number +} + +/** List instance acl rules response. */ +export interface ListInstanceACLRulesResponse { + /** List of ACL rules present on a Database Instance. */ + rules: ACLRule[] + /** Total count of ACL rules present on a Database Instance. */ + totalCount: number +} + +/** List instance logs details response. */ +export interface ListInstanceLogsDetailsResponse { + /** Remote Database Instance logs details. */ + details: ListInstanceLogsDetailsResponseInstanceLogDetail[] +} + +export interface ListInstanceLogsDetailsResponseInstanceLogDetail { + logName: string + size: number +} + +/** List instance logs response. */ +export interface ListInstanceLogsResponse { + /** Available logs in a Database Instance. */ + instanceLogs: InstanceLog[] +} + +/** List instances response. */ +export interface ListInstancesResponse { + /** List of all Database Instances available in an Organization or Project. */ + instances: Instance[] + /** Total count of Database Instances available in a Organization or Project. */ + totalCount: number +} + +/** List node types response. */ +export interface ListNodeTypesResponse { + /** Types of the node. */ + nodeTypes: NodeType[] + /** Total count of node-types available. */ + totalCount: number +} + +/** List privileges response. */ +export interface ListPrivilegesResponse { + /** Privileges of a user in a database in a Database Instance. */ + privileges: Privilege[] + /** Total count of privileges present on a database. */ + totalCount: number +} + +/** List snapshots response. */ +export interface ListSnapshotsResponse { + /** List of snapshots. */ + snapshots: Snapshot[] + /** Total count of snapshots available. */ + totalCount: number +} + +/** List users response. */ +export interface ListUsersResponse { + /** List of users in a Database Instance. */ + users: User[] + /** Total count of users present on a Database Instance. */ + totalCount: number +} + +/** Logs policy. */ +export interface LogsPolicy { + /** Max age (in days) of remote logs to keep on the Database Instance. */ + maxAgeRetention?: number + /** Max disk size of remote logs to keep on the Database Instance. */ + totalDiskRetention?: number +} + +/** Maintenance. */ +export interface Maintenance { + /** Start date of the maintenance window. */ + startsAt?: Date + /** End date of the maintenance window. */ + stopsAt?: Date + /** Closed maintenance date. */ + closedAt?: Date + /** Maintenance information message. */ + reason: string + /** Status of the maintenance. */ + status: MaintenanceStatus +} + +/** Node type. */ +export interface NodeType { + /** Node Type name identifier. */ + name: string + /** Current stock status for the Node Type. */ + stockStatus: NodeTypeStock + /** Current specs of the offer. */ + description: string + /** Number of virtual CPUs. */ + vcpus: number + /** Quantity of RAM. */ + memory: number + /** @deprecated {undefined} Deprecated Node Type volume constraints. */ + volumeConstraint?: NodeTypeVolumeConstraintSizes + /** @deprecated The Node Type is compliant with Block Storage. */ + isBssdCompatible?: boolean + /** The Node Type is currently disabled. */ + disabled: boolean + /** The Node Type is currently in beta. */ + beta: boolean + /** Available storage options for the Node Type. */ + availableVolumeTypes: NodeTypeVolumeType[] + /** The Node Type can be used only with the High Availability option. */ + isHaRequired: boolean + /** Generation associated the NodeType offer. */ + generation: NodeTypeGeneration + /** Instance range associated with the NodeType offer. */ + instanceRange: string + /** Region the Node Type is in. */ + region: Region +} + +/** Node type. volume constraint sizes. */ +export interface NodeTypeVolumeConstraintSizes { + /** [deprecated] Mimimum size required for the Volume. */ + minSize: number + /** [deprecated] Maximum size required for the Volume. */ + maxSize: number +} + +/** Node type. volume type. */ +export interface NodeTypeVolumeType { + /** Volume Type. */ + type: VolumeType + /** The description of the Volume. */ + description: string + /** Mimimum size required for the Volume. */ + minSize: number + /** Maximum size required for the Volume. */ + maxSize: number + /** Minimum increment level for a Block Storage volume size. */ + chunkSize: number +} + +/** Privilege. */ +export interface Privilege { + /** Permission (Read, Read/Write, All, Custom). */ + permission: Permission + /** Name of the database. */ + databaseName: string + /** Name of the user. */ + userName: string +} + +/** Read replica. */ +export interface ReadReplica { + /** UUID of the Read Replica. */ + id: string + /** Display Read Replica connection information. */ + endpoints: Endpoint[] + /** Read replica status. */ + status: ReadReplicaStatus + /** Region the Read Replica is in. */ + region: Region + /** + * Whether the replica is in the same Availability Zone as the main Database + * Instance nodes or not. + */ + sameZone: boolean +} + +/** Read replica endpoint spec. */ +export interface ReadReplicaEndpointSpec { + /** + * Direct access endpoint specifications. Public endpoint reserved for Read + * Replicas. One per Read Replica. + * + * One-of ('spec'): at most one of 'directAccess', 'privateNetwork' could be + * set. + */ + directAccess?: ReadReplicaEndpointSpecDirectAccess + /** + * Private Network endpoint specifications. One at most, per Read Replica. + * Cannot be updated (has to be deleted and recreated). + * + * One-of ('spec'): at most one of 'directAccess', 'privateNetwork' could be + * set. + */ + privateNetwork?: ReadReplicaEndpointSpecPrivateNetwork +} + +export interface ReadReplicaEndpointSpecDirectAccess {} + +/** Read replica endpoint spec. private network. */ +export interface ReadReplicaEndpointSpecPrivateNetwork { + /** UUID of the Private Network to be connected to the Read Replica. */ + privateNetworkId: string + /** + * Endpoint IPv4 address with a CIDR notation. Refer to the official Scaleway + * documentation to learn more about IP and subnet limitations. + * + * One-of ('config'): at most one of 'serviceIp', 'ipamConfig' could be set. + */ + serviceIp?: string + /** + * Automated configuration of your Private Network endpoint with Scaleway IPAM + * service. One at the most per Database Instance or Read Replica (a Database + * Instance and its Read Replica can have different private networks). Cannot + * be updated (has to be deleted and recreated). + * + * One-of ('config'): at most one of 'serviceIp', 'ipamConfig' could be set. + */ + ipamConfig?: ReadReplicaEndpointSpecPrivateNetworkIpamConfig +} + +export interface ReadReplicaEndpointSpecPrivateNetworkIpamConfig {} + +/** Set instance acl rules response. */ +export interface SetInstanceACLRulesResponse { + /** ACLs rules configured for a Database Instance. */ + rules: ACLRule[] +} + +/** Set instance settings response. */ +export interface SetInstanceSettingsResponse { + /** Settings configured for a Database Instance. */ + settings: InstanceSetting[] +} + +/** Snapshot. */ +export interface Snapshot { + /** UUID of the snapshot. */ + id: string + /** UUID of the Database Instance. */ + instanceId: string + /** Name of the snapshot. */ + name: string + /** Status of the snapshot. */ + status: SnapshotStatus + /** Size of the snapshot. */ + size?: number + /** Expiration date (must follow the ISO 8601 format). */ + expiresAt?: Date + /** Creation date (must follow the ISO 8601 format). */ + createdAt?: Date + /** Updated date (must follow the ISO 8601 format). */ + updatedAt?: Date + /** Name of the Database Instance of the snapshot. */ + instanceName: string + /** Source node type. */ + nodeType: string + /** Region of this snapshot. */ + region: Region +} + +export interface UpgradableVersion { + id: string + name: string + version: string + minorVersion: string +} + +/** User. */ +export interface User { + /** + * Name of the user (Length must be between 1 and 63 characters. First + * character must be an alphabet character (a-zA-Z). Your username cannot + * start with '_rdb' or 'pg_'. Only a-zA-Z0-9_$- characters are accepted). + */ + name: string + /** + * Defines whether or not a user got administrative privileges on the Database + * Instance. + */ + isAdmin: boolean +} + +export interface Volume { + type: VolumeType + size: number +} + +export type ListDatabaseEnginesRequest = { + /** + * Region to target. If none is passed will use default region from the + * config. + */ + region?: Region + /** Name of the database engine. */ + name?: string + /** Version of the database engine. */ + version?: string + page?: number + pageSize?: number +} + +export type ListNodeTypesRequest = { + /** + * Region to target. If none is passed will use default region from the + * config. + */ + region?: Region + /** Defines whether or not to include disabled types. */ + includeDisabledTypes: boolean + page?: number + pageSize?: number +} + +export type UpgradeInstanceRequest = { + /** + * Region to target. If none is passed will use default region from the + * config. + */ + region?: Region + /** UUID of the Database Instance you want to upgrade. */ + instanceId: string + /** + * Node type of the Database Instance you want to upgrade to. + * + * One-of ('upgradeTarget'): at most one of 'nodeType', 'enableHa', + * 'volumeSize', 'volumeType', 'upgradableVersionId' could be set. + */ + nodeType?: string + /** + * Defines whether or not High Availability should be enabled on the Database + * Instance. + * + * One-of ('upgradeTarget'): at most one of 'nodeType', 'enableHa', + * 'volumeSize', 'volumeType', 'upgradableVersionId' could be set. + */ + enableHa?: boolean + /** + * Increase your Block volume size. + * + * One-of ('upgradeTarget'): at most one of 'nodeType', 'enableHa', + * 'volumeSize', 'volumeType', 'upgradableVersionId' could be set. + */ + volumeSize?: number + /** + * Change your Database Instance storage type. + * + * One-of ('upgradeTarget'): at most one of 'nodeType', 'enableHa', + * 'volumeSize', 'volumeType', 'upgradableVersionId' could be set. + */ + volumeType?: VolumeType + /** + * Update your database engine to a newer version. This will create a new + * Database Instance with same specifications as the current one and perform a + * Database Engine upgrade. + * + * One-of ('upgradeTarget'): at most one of 'nodeType', 'enableHa', + * 'volumeSize', 'volumeType', 'upgradableVersionId' could be set. + */ + upgradableVersionId?: string +} + +export type ListInstancesRequest = { + /** + * Region to target. If none is passed will use default region from the + * config. + */ + region?: Region + /** List Database Instances that have a given tag. */ + tags?: string[] + /** Lists Database Instances that match a name pattern. */ + name?: string + /** Criteria to use when ordering Database Instance listings. */ + orderBy?: ListInstancesRequestOrderBy + /** Please use project_id instead. */ + organizationId?: string + /** Project ID to list the Database Instance of. */ + projectId?: string + page?: number + pageSize?: number +} + +export type GetInstanceRequest = { + /** + * Region to target. If none is passed will use default region from the + * config. + */ + region?: Region + /** UUID of the Database Instance. */ + instanceId: string +} + +export type CreateInstanceRequest = { + /** + * Region to target. If none is passed will use default region from the + * config. + */ + region?: Region + /** + * @deprecated Please use project_id instead. + * + * One-of ('projectIdentifier'): at most one of 'organizationId', 'projectId' + * could be set. + */ + organizationId?: string + /** + * The Project ID on which the Database Instance will be created. + * + * One-of ('projectIdentifier'): at most one of 'organizationId', 'projectId' + * could be set. + */ + projectId?: string + /** Name of the Database Instance. */ + name?: string + /** Database engine of the Database Instance. */ + engine: string + /** Username created when the Database Instance is created. */ + userName: string + /** Password of the user. */ + password: string + /** Type of node to use for the Database Instance. */ + nodeType: string + /** Defines whether or not High-Availability is enabled. */ + isHaCluster: boolean + /** Defines whether or not backups are disabled. */ + disableBackup: boolean + /** Tags to apply to the Database Instance. */ + tags?: string[] + /** List of engine settings to be set upon Database Instance initialization. */ + initSettings?: InstanceSetting[] + /** Type of volume where data is stored (lssd, bssd, ...). */ + volumeType?: VolumeType + /** Volume size when volume_type is not lssd. */ + volumeSize: number + /** + * One or multiple EndpointSpec used to expose your Database Instance. A + * load_balancer public endpoint is systematically created. + */ + initEndpoints?: EndpointSpec[] + /** + * Defines whether to or not to store logical backups in the same region as + * the Database Instance. + */ + backupSameRegion: boolean +} + +export type UpdateInstanceRequest = { + /** + * Region to target. If none is passed will use default region from the + * config. + */ + region?: Region + /** UUID of the Database Instance to update. */ + instanceId: string + /** In hours. */ + backupScheduleFrequency?: number + /** In days. */ + backupScheduleRetention?: number + /** Defines whether or not the backup schedule is disabled. */ + isBackupScheduleDisabled?: boolean + /** Name of the Database Instance. */ + name?: string + /** Tags of a Database Instance. */ + tags?: string[] + /** Logs policy of the Database Instance. */ + logsPolicy?: LogsPolicy + /** Store logical backups in the same region as the Database Instance. */ + backupSameRegion?: boolean + /** Defines the start time of the autobackup. */ + backupScheduleStartHour?: number +} + +export type DeleteInstanceRequest = { + /** + * Region to target. If none is passed will use default region from the + * config. + */ + region?: Region + /** UUID of the Database Instance to delete. */ + instanceId: string +} + +export type CloneInstanceRequest = { + /** + * Region to target. If none is passed will use default region from the + * config. + */ + region?: Region + /** UUID of the Database Instance you want to clone. */ + instanceId: string + /** Name of the Database Instance clone. */ + name: string + /** Node type of the clone. */ + nodeType?: string +} + +export type RestartInstanceRequest = { + /** + * Region to target. If none is passed will use default region from the + * config. + */ + region?: Region + /** UUID of the Database Instance you want to restart. */ + instanceId: string +} + +export type GetInstanceCertificateRequest = { + /** + * Region to target. If none is passed will use default region from the + * config. + */ + region?: Region + /** UUID of the Database Instance. */ + instanceId: string +} + +export type RenewInstanceCertificateRequest = { + /** + * Region to target. If none is passed will use default region from the + * config. + */ + region?: Region + /** UUID of the Database Instance you want logs of. */ + instanceId: string +} + +export type GetInstanceMetricsRequest = { + /** + * Region to target. If none is passed will use default region from the + * config. + */ + region?: Region + /** UUID of the Database Instance. */ + instanceId: string + /** Start date to gather metrics from. */ + startDate?: Date + /** End date to gather metrics from. */ + endDate?: Date + /** Name of the metric to gather. */ + metricName?: string +} + +export type CreateReadReplicaRequest = { + /** + * Region to target. If none is passed will use default region from the + * config. + */ + region?: Region + /** UUID of the Database Instance you want to create a Read Replica from. */ + instanceId: string + /** Specification of the endpoint you want to create. */ + endpointSpec?: ReadReplicaEndpointSpec[] + /** + * Defines whether or not to create the replica in the same Availability Zone + * as the main Database Instance nodes. + */ + sameZone?: boolean +} + +export type GetReadReplicaRequest = { + /** + * Region to target. If none is passed will use default region from the + * config. + */ + region?: Region + /** UUID of the Read Replica. */ + readReplicaId: string +} + +export type DeleteReadReplicaRequest = { + /** + * Region to target. If none is passed will use default region from the + * config. + */ + region?: Region + /** UUID of the Read Replica. */ + readReplicaId: string +} + +export type ResetReadReplicaRequest = { + /** + * Region to target. If none is passed will use default region from the + * config. + */ + region?: Region + /** UUID of the Read Replica. */ + readReplicaId: string +} + +export type PromoteReadReplicaRequest = { + /** + * Region to target. If none is passed will use default region from the + * config. + */ + region?: Region + /** UUID of the Read Replica. */ + readReplicaId: string +} + +export type CreateReadReplicaEndpointRequest = { + /** + * Region to target. If none is passed will use default region from the + * config. + */ + region?: Region + /** UUID of the Read Replica. */ + readReplicaId: string + /** Specification of the endpoint you want to create. */ + endpointSpec: ReadReplicaEndpointSpec[] +} + +export type ListInstanceLogsRequest = { + /** + * Region to target. If none is passed will use default region from the + * config. + */ + region?: Region + /** UUID of the Database Instance you want logs of. */ + instanceId: string + /** Criteria to use when ordering Database Instance logs listing. */ + orderBy?: ListInstanceLogsRequestOrderBy +} + +export type GetInstanceLogRequest = { + /** + * Region to target. If none is passed will use default region from the + * config. + */ + region?: Region + /** UUID of the instance_log you want. */ + instanceLogId: string +} + +export type PurgeInstanceLogsRequest = { + /** + * Region to target. If none is passed will use default region from the + * config. + */ + region?: Region + /** UUID of the Database Instance you want logs of. */ + instanceId: string + /** Given log name to purge. */ + logName?: string +} + +export type ListInstanceLogsDetailsRequest = { + /** + * Region to target. If none is passed will use default region from the + * config. + */ + region?: Region + /** UUID of the Database Instance you want logs of. */ + instanceId: string +} + +export type AddInstanceSettingsRequest = { + /** + * Region to target. If none is passed will use default region from the + * config. + */ + region?: Region + /** UUID of the Database Instance you want to add settings to. */ + instanceId: string + /** Settings to add to the Database Instance. */ + settings: InstanceSetting[] +} + +export type DeleteInstanceSettingsRequest = { + /** + * Region to target. If none is passed will use default region from the + * config. + */ + region?: Region + /** UUID of the Database Instance to delete settings from. */ + instanceId: string + /** Settings names to delete. */ + settingNames: string[] +} + +export type SetInstanceSettingsRequest = { + /** + * Region to target. If none is passed will use default region from the + * config. + */ + region?: Region + /** UUID of the Database Instance where the settings must be set. */ + instanceId: string + /** Settings to define for the Database Instance. */ + settings: InstanceSetting[] +} + +export type ListInstanceACLRulesRequest = { + /** + * Region to target. If none is passed will use default region from the + * config. + */ + region?: Region + /** UUID of the Database Instance. */ + instanceId: string + page?: number + pageSize?: number +} + +export type AddInstanceACLRulesRequest = { + /** + * Region to target. If none is passed will use default region from the + * config. + */ + region?: Region + /** UUID of the Database Instance you want to add ACL rules to. */ + instanceId: string + /** ACL rules to add to the Database Instance. */ + rules: ACLRuleRequest[] +} + +export type SetInstanceACLRulesRequest = { + /** + * Region to target. If none is passed will use default region from the + * config. + */ + region?: Region + /** UUID of the Database Instance where the ACL rules must be set. */ + instanceId: string + /** ACL rules to define for the Database Instance. */ + rules: ACLRuleRequest[] +} + +export type DeleteInstanceACLRulesRequest = { + /** + * Region to target. If none is passed will use default region from the + * config. + */ + region?: Region + /** UUID of the Database Instance you want to delete an ACL rule from. */ + instanceId: string + /** IP addresses defined in the ACL rules of the Database Instance. */ + aclRuleIps: string[] +} + +export type ListUsersRequest = { + /** + * Region to target. If none is passed will use default region from the + * config. + */ + region?: Region + /** UUID of the Database Instance. */ + instanceId: string + /** Name of the user. */ + name?: string + /** Criteria to use when requesting user listing. */ + orderBy?: ListUsersRequestOrderBy + page?: number + pageSize?: number +} + +export type CreateUserRequest = { + /** + * Region to target. If none is passed will use default region from the + * config. + */ + region?: Region + /** UUID of the Database Instance in which you want to create a user. */ + instanceId: string + /** Name of the user you want to create. */ + name: string + /** Password of the user you want to create. */ + password: string + /** Defines whether the user will have administrative privileges. */ + isAdmin: boolean +} + +export type UpdateUserRequest = { + /** + * Region to target. If none is passed will use default region from the + * config. + */ + region?: Region + /** UUID of the Database Instance the user belongs to. */ + instanceId: string + /** Name of the database user. */ + name: string + /** Password of the database user. */ + password?: string + /** Defines whether or not this user got administrative privileges. */ + isAdmin?: boolean +} + +export type DeleteUserRequest = { + /** + * Region to target. If none is passed will use default region from the + * config. + */ + region?: Region + /** UUID of the Database Instance to delete the user from. */ + instanceId: string + /** Name of the user. */ + name: string +} + +export type ListDatabasesRequest = { + /** + * Region to target. If none is passed will use default region from the + * config. + */ + region?: Region + /** UUID of the Database Instance to list the databases of. */ + instanceId: string + /** Name of the database. */ + name?: string + /** Defines whether or not the database is managed. */ + managed?: boolean + /** User that owns this database. */ + owner?: string + /** Criteria to use when ordering database listing. */ + orderBy?: ListDatabasesRequestOrderBy + page?: number + pageSize?: number +} + +export type CreateDatabaseRequest = { + /** + * Region to target. If none is passed will use default region from the + * config. + */ + region?: Region + /** UUID of the Database Instance where to create the database. */ + instanceId: string + /** Name of the database. */ + name: string +} + +export type DeleteDatabaseRequest = { + /** + * Region to target. If none is passed will use default region from the + * config. + */ + region?: Region + /** UUID of the Database Instance where to delete the database. */ + instanceId: string + /** Name of the database to delete. */ + name: string +} + +export type ListPrivilegesRequest = { + /** + * Region to target. If none is passed will use default region from the + * config. + */ + region?: Region + /** UUID of the Database Instance. */ + instanceId: string + /** Criteria to use when ordering privileges listing. */ + orderBy?: ListPrivilegesRequestOrderBy + page?: number + pageSize?: number + /** Name of the database. */ + databaseName?: string + /** Name of the user. */ + userName?: string +} + +export type SetPrivilegeRequest = { + /** + * Region to target. If none is passed will use default region from the + * config. + */ + region?: Region + /** UUID of the Database Instance. */ + instanceId: string + /** Name of the database. */ + databaseName: string + /** Name of the user. */ + userName: string + /** Permission to set (Read, Read/Write, All, Custom). */ + permission?: Permission +} + +export type ListSnapshotsRequest = { + /** + * Region to target. If none is passed will use default region from the + * config. + */ + region?: Region + /** Name of the snapshot. */ + name?: string + /** Criteria to use when ordering snapshot listing. */ + orderBy?: ListSnapshotsRequestOrderBy + /** UUID of the Database Instance. */ + instanceId?: string + /** Organization ID the snapshots belongs to. */ + organizationId?: string + /** Project ID the snapshots belongs to. */ + projectId?: string + page?: number + pageSize?: number +} + +export type GetSnapshotRequest = { + /** + * Region to target. If none is passed will use default region from the + * config. + */ + region?: Region + /** UUID of the snapshot. */ + snapshotId: string +} + +export type CreateSnapshotRequest = { + /** + * Region to target. If none is passed will use default region from the + * config. + */ + region?: Region + /** UUID of the Database Instance. */ + instanceId: string + /** Name of the snapshot. */ + name?: string + /** Expiration date (must follow the ISO 8601 format). */ + expiresAt?: Date +} + +export type UpdateSnapshotRequest = { + /** + * Region to target. If none is passed will use default region from the + * config. + */ + region?: Region + /** UUID of the snapshot to update. */ + snapshotId: string + /** Name of the snapshot. */ + name?: string + /** Expiration date (must follow the ISO 8601 format). */ + expiresAt?: Date +} + +export type DeleteSnapshotRequest = { + /** + * Region to target. If none is passed will use default region from the + * config. + */ + region?: Region + /** UUID of the snapshot to delete. */ + snapshotId: string +} + +export type CreateInstanceFromSnapshotRequest = { + /** + * Region to target. If none is passed will use default region from the + * config. + */ + region?: Region + /** Block snapshot of the Database Instance. */ + snapshotId: string + /** Name of the Database Instance created with the snapshot. */ + instanceName: string + /** + * Defines whether or not High Availability is enabled on the new Database + * Instance. + */ + isHaCluster?: boolean + /** The node type used to restore the snapshot. */ + nodeType?: string +} + +export type CreateEndpointRequest = { + /** + * Region to target. If none is passed will use default region from the + * config. + */ + region?: Region + /** UUID of the Database Instance you to which you want to add an endpoint. */ + instanceId: string + /** Specification of the endpoint you want to create. */ + endpointSpec?: EndpointSpec +} + +export type DeleteEndpointRequest = { + /** + * Region to target. If none is passed will use default region from the + * config. + */ + region?: Region + /** + * UUID of the endpoint you want to delete. This endpoint can also be used to + * delete a Read Replica endpoint. + */ + endpointId: string +} + +export type GetEndpointRequest = { + /** + * Region to target. If none is passed will use default region from the + * config. + */ + region?: Region + /** UUID of the endpoint you want to get. */ + endpointId: string +} + +export type MigrateEndpointRequest = { + /** + * Region to target. If none is passed will use default region from the + * config. + */ + region?: Region + /** UUID of the endpoint you want to migrate. */ + endpointId: string + /** UUID of the instance you want to attach the endpoint to. */ + instanceId: string +} diff --git a/packages/clients/src/api/document_db/v1beta1/validation-rules.gen.ts b/packages/clients/src/api/document_db/v1beta1/validation-rules.gen.ts new file mode 100644 index 000000000..d1ac36559 --- /dev/null +++ b/packages/clients/src/api/document_db/v1beta1/validation-rules.gen.ts @@ -0,0 +1,8 @@ +// This file was automatically generated. DO NOT EDIT. +// If you have any remark or suggestion do not hesitate to open an issue. + +export const UpdateInstanceRequest = { + backupScheduleStartHour: { + lessThanOrEqual: 23, + }, +}