diff --git a/packages/clients/src/api/document_db/v1beta1/api.gen.ts b/packages/clients/src/api/document_db/v1beta1/api.gen.ts index d5c9a64de..c2b7218ad 100644 --- a/packages/clients/src/api/document_db/v1beta1/api.gen.ts +++ b/packages/clients/src/api/document_db/v1beta1/api.gen.ts @@ -56,6 +56,7 @@ import { unmarshalListPrivilegesResponse, unmarshalListSnapshotsResponse, unmarshalListUsersResponse, + unmarshalMaintenance, unmarshalPrivilege, unmarshalReadReplica, unmarshalSetInstanceACLRulesResponse, @@ -68,6 +69,7 @@ import type { AddInstanceACLRulesResponse, AddInstanceSettingsRequest, AddInstanceSettingsResponse, + ApplyInstanceMaintenanceRequest, CloneInstanceRequest, CreateDatabaseRequest, CreateEndpointRequest, @@ -119,6 +121,7 @@ import type { ListSnapshotsResponse, ListUsersRequest, ListUsersResponse, + Maintenance, MigrateEndpointRequest, Privilege, PromoteReadReplicaRequest, @@ -1292,4 +1295,24 @@ export class API extends ParentAPI { }, unmarshalEndpoint, ) + + /** + * Apply an instance maintenance. Apply a pending instance maintenance on your + * instance. This action can generate some service interruption. + * + * @param request - The request {@link ApplyInstanceMaintenanceRequest} + * @returns A Promise of Maintenance + */ + applyInstanceMaintenance = ( + 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)}/apply-maintenance`, + }, + unmarshalMaintenance, + ) } diff --git a/packages/clients/src/api/document_db/v1beta1/content.gen.ts b/packages/clients/src/api/document_db/v1beta1/content.gen.ts index a4939bdd0..009906d64 100644 --- a/packages/clients/src/api/document_db/v1beta1/content.gen.ts +++ b/packages/clients/src/api/document_db/v1beta1/content.gen.ts @@ -24,7 +24,10 @@ export const INSTANCE_TRANSIENT_STATUSES: InstanceStatus[] = [ ] /** Lists transient statutes of the enum {@link MaintenanceStatus}. */ -export const MAINTENANCE_TRANSIENT_STATUSES: MaintenanceStatus[] = ['pending'] +export const MAINTENANCE_TRANSIENT_STATUSES: MaintenanceStatus[] = [ + 'pending', + 'ongoing', +] /** Lists transient statutes of the enum {@link ReadReplicaStatus}. */ export const READ_REPLICA_TRANSIENT_STATUSES: ReadReplicaStatus[] = [ diff --git a/packages/clients/src/api/document_db/v1beta1/index.gen.ts b/packages/clients/src/api/document_db/v1beta1/index.gen.ts index 66b55bba9..1039d815f 100644 --- a/packages/clients/src/api/document_db/v1beta1/index.gen.ts +++ b/packages/clients/src/api/document_db/v1beta1/index.gen.ts @@ -12,6 +12,7 @@ export type { AddInstanceACLRulesResponse, AddInstanceSettingsRequest, AddInstanceSettingsResponse, + ApplyInstanceMaintenanceRequest, BackupSchedule, CloneInstanceRequest, CreateDatabaseRequest, diff --git a/packages/clients/src/api/document_db/v1beta1/marshalling.gen.ts b/packages/clients/src/api/document_db/v1beta1/marshalling.gen.ts index 3037e1b73..d77fa87b9 100644 --- a/packages/clients/src/api/document_db/v1beta1/marshalling.gen.ts +++ b/packages/clients/src/api/document_db/v1beta1/marshalling.gen.ts @@ -152,6 +152,23 @@ export const unmarshalEndpoint = (data: unknown): Endpoint => { } as Endpoint } +export const unmarshalMaintenance = (data: unknown): Maintenance => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'Maintenance' failed as data isn't a dictionary.`, + ) + } + + return { + closedAt: unmarshalDate(data.closed_at), + forcedAt: unmarshalDate(data.forced_at), + reason: data.reason, + startsAt: unmarshalDate(data.starts_at), + status: data.status, + stopsAt: unmarshalDate(data.stops_at), + } as Maintenance +} + export const unmarshalReadReplica = (data: unknown): ReadReplica => { if (!isJSONObject(data)) { throw new TypeError( @@ -242,22 +259,6 @@ const unmarshalLogsPolicy = (data: unknown): LogsPolicy => { } as LogsPolicy } -const unmarshalMaintenance = (data: unknown): Maintenance => { - 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 unmarshalUpgradableVersion = (data: unknown): UpgradableVersion => { if (!isJSONObject(data)) { throw new TypeError( diff --git a/packages/clients/src/api/document_db/v1beta1/types.gen.ts b/packages/clients/src/api/document_db/v1beta1/types.gen.ts index 5d1fce2fc..1f6b24778 100644 --- a/packages/clients/src/api/document_db/v1beta1/types.gen.ts +++ b/packages/clients/src/api/document_db/v1beta1/types.gen.ts @@ -66,7 +66,12 @@ export type ListUsersRequestOrderBy = | 'is_admin_asc' | 'is_admin_desc' -export type MaintenanceStatus = 'unknown' | 'pending' | 'done' | 'canceled' +export type MaintenanceStatus = + | 'unknown' + | 'pending' + | 'done' + | 'canceled' + | 'ongoing' export type NodeTypeGeneration = | 'unknown_generation' @@ -290,6 +295,8 @@ export interface Maintenance { reason: string /** Status of the maintenance. */ status: MaintenanceStatus + /** Time when Scaleway-side maintenance will be applied. */ + forcedAt?: Date } export interface ReadReplica { @@ -623,6 +630,16 @@ export interface AddInstanceSettingsResponse { settings: InstanceSetting[] } +export type ApplyInstanceMaintenanceRequest = { + /** + * Region to target. If none is passed will use default region from the + * config. + */ + region?: Region + /** UUID of the Database Instance to which you want to apply maintenance. */ + instanceId: string +} + export type CloneInstanceRequest = { /** * Region to target. If none is passed will use default region from the diff --git a/packages/clients/src/api/rdb/v1/api.gen.ts b/packages/clients/src/api/rdb/v1/api.gen.ts index 6d7866f70..6f45ad330 100644 --- a/packages/clients/src/api/rdb/v1/api.gen.ts +++ b/packages/clients/src/api/rdb/v1/api.gen.ts @@ -63,6 +63,7 @@ import { unmarshalListPrivilegesResponse, unmarshalListSnapshotsResponse, unmarshalListUsersResponse, + unmarshalMaintenance, unmarshalPrepareInstanceLogsResponse, unmarshalPrivilege, unmarshalReadReplica, @@ -76,6 +77,7 @@ import type { AddInstanceACLRulesResponse, AddInstanceSettingsRequest, AddInstanceSettingsResponse, + ApplyInstanceMaintenanceRequest, CloneInstanceRequest, CreateDatabaseBackupRequest, CreateDatabaseRequest, @@ -134,6 +136,7 @@ import type { ListSnapshotsResponse, ListUsersRequest, ListUsersResponse, + Maintenance, MigrateEndpointRequest, PrepareInstanceLogsRequest, PrepareInstanceLogsResponse, @@ -1509,4 +1512,27 @@ export class API extends ParentAPI { }, unmarshalEndpoint, ) + + /** + * Apply Database Instance maintenance. Apply maintenance tasks to your + * Database Instance. This will trigger pending maintenance tasks to start in + * your Database Instance and can generate service interruption. Maintenance + * tasks can be applied between `starts_at` and `stops_at` times, and are run + * directly by Scaleway at `forced_at` timestamp. + * + * @param request - The request {@link ApplyInstanceMaintenanceRequest} + * @returns A Promise of Maintenance + */ + applyInstanceMaintenance = ( + request: Readonly, + ) => + this.client.fetch( + { + body: '{}', + headers: jsonContentHeaders, + method: 'POST', + path: `/rdb/v1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/instances/${validatePathParam('instanceId', request.instanceId)}/apply-maintenance`, + }, + unmarshalMaintenance, + ) } diff --git a/packages/clients/src/api/rdb/v1/content.gen.ts b/packages/clients/src/api/rdb/v1/content.gen.ts index acdbf9b7e..d7dca9d00 100644 --- a/packages/clients/src/api/rdb/v1/content.gen.ts +++ b/packages/clients/src/api/rdb/v1/content.gen.ts @@ -33,7 +33,10 @@ export const INSTANCE_TRANSIENT_STATUSES: InstanceStatus[] = [ ] /** Lists transient statutes of the enum {@link MaintenanceStatus}. */ -export const MAINTENANCE_TRANSIENT_STATUSES: MaintenanceStatus[] = ['pending'] +export const MAINTENANCE_TRANSIENT_STATUSES: MaintenanceStatus[] = [ + 'pending', + 'ongoing', +] /** Lists transient statutes of the enum {@link ReadReplicaStatus}. */ export const READ_REPLICA_TRANSIENT_STATUSES: ReadReplicaStatus[] = [ diff --git a/packages/clients/src/api/rdb/v1/index.gen.ts b/packages/clients/src/api/rdb/v1/index.gen.ts index bf209a20b..781f53eba 100644 --- a/packages/clients/src/api/rdb/v1/index.gen.ts +++ b/packages/clients/src/api/rdb/v1/index.gen.ts @@ -12,6 +12,7 @@ export type { AddInstanceACLRulesResponse, AddInstanceSettingsRequest, AddInstanceSettingsResponse, + ApplyInstanceMaintenanceRequest, BackupSchedule, CloneInstanceRequest, CreateDatabaseBackupRequest, diff --git a/packages/clients/src/api/rdb/v1/marshalling.gen.ts b/packages/clients/src/api/rdb/v1/marshalling.gen.ts index 677c10ae8..c14f1c780 100644 --- a/packages/clients/src/api/rdb/v1/marshalling.gen.ts +++ b/packages/clients/src/api/rdb/v1/marshalling.gen.ts @@ -159,6 +159,23 @@ export const unmarshalEndpoint = (data: unknown): Endpoint => { } as Endpoint } +export const unmarshalMaintenance = (data: unknown): Maintenance => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'Maintenance' failed as data isn't a dictionary.`, + ) + } + + return { + closedAt: unmarshalDate(data.closed_at), + forcedAt: unmarshalDate(data.forced_at), + reason: data.reason, + startsAt: unmarshalDate(data.starts_at), + status: data.status, + stopsAt: unmarshalDate(data.stops_at), + } as Maintenance +} + export const unmarshalReadReplica = (data: unknown): ReadReplica => { if (!isJSONObject(data)) { throw new TypeError( @@ -275,22 +292,6 @@ const unmarshalLogsPolicy = (data: unknown): LogsPolicy => { } as LogsPolicy } -const unmarshalMaintenance = (data: unknown): Maintenance => { - 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 unmarshalUpgradableVersion = (data: unknown): UpgradableVersion => { if (!isJSONObject(data)) { throw new TypeError( diff --git a/packages/clients/src/api/rdb/v1/types.gen.ts b/packages/clients/src/api/rdb/v1/types.gen.ts index 6023d6253..f6355580a 100644 --- a/packages/clients/src/api/rdb/v1/types.gen.ts +++ b/packages/clients/src/api/rdb/v1/types.gen.ts @@ -84,7 +84,12 @@ export type ListUsersRequestOrderBy = | 'is_admin_asc' | 'is_admin_desc' -export type MaintenanceStatus = 'unknown' | 'pending' | 'done' | 'canceled' +export type MaintenanceStatus = + | 'unknown' + | 'pending' + | 'done' + | 'canceled' + | 'ongoing' export type NodeTypeGeneration = | 'unknown_generation' @@ -308,6 +313,8 @@ export interface Maintenance { reason: string /** Status of the maintenance. */ status: MaintenanceStatus + /** Time when Scaleway-side maintenance will be applied. */ + forcedAt?: Date } export interface ReadReplica { @@ -674,6 +681,16 @@ export interface AddInstanceSettingsResponse { settings: InstanceSetting[] } +export type ApplyInstanceMaintenanceRequest = { + /** + * Region to target. If none is passed will use default region from the + * config. + */ + region?: Region + /** UUID of the Database Instance you want to apply maintenance. */ + instanceId: string +} + export type CloneInstanceRequest = { /** * Region to target. If none is passed will use default region from the