Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions packages/clients/src/api/document_db/v1beta1/api.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ import {
unmarshalListPrivilegesResponse,
unmarshalListSnapshotsResponse,
unmarshalListUsersResponse,
unmarshalMaintenance,
unmarshalPrivilege,
unmarshalReadReplica,
unmarshalSetInstanceACLRulesResponse,
Expand All @@ -68,6 +69,7 @@ import type {
AddInstanceACLRulesResponse,
AddInstanceSettingsRequest,
AddInstanceSettingsResponse,
ApplyInstanceMaintenanceRequest,
CloneInstanceRequest,
CreateDatabaseRequest,
CreateEndpointRequest,
Expand Down Expand Up @@ -119,6 +121,7 @@ import type {
ListSnapshotsResponse,
ListUsersRequest,
ListUsersResponse,
Maintenance,
MigrateEndpointRequest,
Privilege,
PromoteReadReplicaRequest,
Expand Down Expand Up @@ -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<ApplyInstanceMaintenanceRequest>,
) =>
this.client.fetch<Maintenance>(
{
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,
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -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[] = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export type {
AddInstanceACLRulesResponse,
AddInstanceSettingsRequest,
AddInstanceSettingsResponse,
ApplyInstanceMaintenanceRequest,
BackupSchedule,
CloneInstanceRequest,
CreateDatabaseRequest,
Expand Down
33 changes: 17 additions & 16 deletions packages/clients/src/api/document_db/v1beta1/marshalling.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down
19 changes: 18 additions & 1 deletion packages/clients/src/api/document_db/v1beta1/types.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand Down
26 changes: 26 additions & 0 deletions packages/clients/src/api/rdb/v1/api.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ import {
unmarshalListPrivilegesResponse,
unmarshalListSnapshotsResponse,
unmarshalListUsersResponse,
unmarshalMaintenance,
unmarshalPrepareInstanceLogsResponse,
unmarshalPrivilege,
unmarshalReadReplica,
Expand All @@ -76,6 +77,7 @@ import type {
AddInstanceACLRulesResponse,
AddInstanceSettingsRequest,
AddInstanceSettingsResponse,
ApplyInstanceMaintenanceRequest,
CloneInstanceRequest,
CreateDatabaseBackupRequest,
CreateDatabaseRequest,
Expand Down Expand Up @@ -134,6 +136,7 @@ import type {
ListSnapshotsResponse,
ListUsersRequest,
ListUsersResponse,
Maintenance,
MigrateEndpointRequest,
PrepareInstanceLogsRequest,
PrepareInstanceLogsResponse,
Expand Down Expand Up @@ -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<ApplyInstanceMaintenanceRequest>,
) =>
this.client.fetch<Maintenance>(
{
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,
)
}
5 changes: 4 additions & 1 deletion packages/clients/src/api/rdb/v1/content.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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[] = [
Expand Down
1 change: 1 addition & 0 deletions packages/clients/src/api/rdb/v1/index.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export type {
AddInstanceACLRulesResponse,
AddInstanceSettingsRequest,
AddInstanceSettingsResponse,
ApplyInstanceMaintenanceRequest,
BackupSchedule,
CloneInstanceRequest,
CreateDatabaseBackupRequest,
Expand Down
33 changes: 17 additions & 16 deletions packages/clients/src/api/rdb/v1/marshalling.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down
19 changes: 18 additions & 1 deletion packages/clients/src/api/rdb/v1/types.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand Down