Skip to content

Commit afde985

Browse files
authored
feat(serverless_sqldb): generate SDKs (#1063)
1 parent 1881131 commit afde985

File tree

6 files changed

+735
-0
lines changed

6 files changed

+735
-0
lines changed
Lines changed: 297 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,297 @@
1+
// This file was automatically generated. DO NOT EDIT.
2+
// If you have any remark or suggestion do not hesitate to open an issue.
3+
import {
4+
API as ParentAPI,
5+
enrichForPagination,
6+
urlParams,
7+
validatePathParam,
8+
waitForResource,
9+
} from '../../../bridge'
10+
import type { Region, WaitForOptions } from '../../../bridge'
11+
import { DATABASE_TRANSIENT_STATUSES } from './content.gen'
12+
import {
13+
marshalCreateDatabaseRequest,
14+
marshalRestoreDatabaseFromBackupRequest,
15+
marshalUpdateDatabaseRequest,
16+
unmarshalDatabase,
17+
unmarshalDatabaseBackup,
18+
unmarshalListDatabaseBackupsResponse,
19+
unmarshalListDatabasesResponse,
20+
} from './marshalling.gen'
21+
import type {
22+
CreateDatabaseRequest,
23+
Database,
24+
DatabaseBackup,
25+
DeleteDatabaseRequest,
26+
ExportDatabaseBackupRequest,
27+
GetDatabaseBackupRequest,
28+
GetDatabaseRequest,
29+
ListDatabaseBackupsRequest,
30+
ListDatabaseBackupsResponse,
31+
ListDatabasesRequest,
32+
ListDatabasesResponse,
33+
RestoreDatabaseFromBackupRequest,
34+
UpdateDatabaseRequest,
35+
} from './types.gen'
36+
37+
const jsonContentHeaders = {
38+
'Content-Type': 'application/json; charset=utf-8',
39+
}
40+
41+
/**
42+
* Serverless SQL Databases API.
43+
*
44+
* This API allows you to manage your Serverless SQL DB databases.
45+
*/
46+
export class API extends ParentAPI {
47+
/** Lists the available regions of the API. */
48+
public static readonly LOCALITIES: Region[] = ['fr-par']
49+
50+
/**
51+
* Create a new Serverless SQL Database. You must provide the following
52+
* parameters: `organization_id`, `project_id`, `name`, `cpu_min`, `cpu_max`.
53+
* You can also provide `from_backup_id` to create a database from a backup.
54+
*
55+
* @param request - The request {@link CreateDatabaseRequest}
56+
* @returns A Promise of Database
57+
*/
58+
createDatabase = (request: Readonly<CreateDatabaseRequest>) =>
59+
this.client.fetch<Database>(
60+
{
61+
body: JSON.stringify(
62+
marshalCreateDatabaseRequest(request, this.client.settings),
63+
),
64+
headers: jsonContentHeaders,
65+
method: 'POST',
66+
path: `/serverless-sqldb/v1alpha1/regions/${validatePathParam(
67+
'region',
68+
request.region ?? this.client.settings.defaultRegion,
69+
)}/databases`,
70+
},
71+
unmarshalDatabase,
72+
)
73+
74+
/**
75+
* Get a database information. Retrieve information about your Serverless SQL
76+
* Database. You must provide the `database_id` parameter.
77+
*
78+
* @param request - The request {@link GetDatabaseRequest}
79+
* @returns A Promise of Database
80+
*/
81+
getDatabase = (request: Readonly<GetDatabaseRequest>) =>
82+
this.client.fetch<Database>(
83+
{
84+
method: 'GET',
85+
path: `/serverless-sqldb/v1alpha1/regions/${validatePathParam(
86+
'region',
87+
request.region ?? this.client.settings.defaultRegion,
88+
)}/databases/${validatePathParam('databaseId', request.databaseId)}`,
89+
},
90+
unmarshalDatabase,
91+
)
92+
93+
/**
94+
* Waits for {@link Database} to be in a final state.
95+
*
96+
* @param request - The request {@link GetDatabaseRequest}
97+
* @param options - The waiting options
98+
* @returns A Promise of Database
99+
*/
100+
waitForDatabase = (
101+
request: Readonly<GetDatabaseRequest>,
102+
options?: Readonly<WaitForOptions<Database>>,
103+
) =>
104+
waitForResource(
105+
options?.stop ??
106+
(res =>
107+
Promise.resolve(!DATABASE_TRANSIENT_STATUSES.includes(res.status))),
108+
this.getDatabase,
109+
request,
110+
options,
111+
)
112+
113+
/**
114+
* Delete a database. Deletes a database. You must provide the `database_id`
115+
* parameter. All data stored in the database will be permanently deleted.
116+
*
117+
* @param request - The request {@link DeleteDatabaseRequest}
118+
* @returns A Promise of Database
119+
*/
120+
deleteDatabase = (request: Readonly<DeleteDatabaseRequest>) =>
121+
this.client.fetch<Database>(
122+
{
123+
method: 'DELETE',
124+
path: `/serverless-sqldb/v1alpha1/regions/${validatePathParam(
125+
'region',
126+
request.region ?? this.client.settings.defaultRegion,
127+
)}/databases/${validatePathParam('databaseId', request.databaseId)}`,
128+
},
129+
unmarshalDatabase,
130+
)
131+
132+
protected pageOfListDatabases = (
133+
request: Readonly<ListDatabasesRequest> = {},
134+
) =>
135+
this.client.fetch<ListDatabasesResponse>(
136+
{
137+
method: 'GET',
138+
path: `/serverless-sqldb/v1alpha1/regions/${validatePathParam(
139+
'region',
140+
request.region ?? this.client.settings.defaultRegion,
141+
)}/databases`,
142+
urlParams: urlParams(
143+
['name', request.name],
144+
['order_by', request.orderBy],
145+
['page', request.page],
146+
['page_size', request.pageSize],
147+
[
148+
'project_id',
149+
request.projectId ?? this.client.settings.defaultProjectId,
150+
],
151+
),
152+
},
153+
unmarshalListDatabasesResponse,
154+
)
155+
156+
/**
157+
* List your Serverless SQL Databases. List all Serverless SQL Databases for a
158+
* given Scaleway Organization or Scaleway Project. By default, the databases
159+
* returned in the list are ordered by creation date in ascending order,
160+
* though this can be modified via the order_by field. For the `name`
161+
* parameter, the value you include will be checked against the whole name
162+
* string to see if it includes the string you put in the parameter.
163+
*
164+
* @param request - The request {@link ListDatabasesRequest}
165+
* @returns A Promise of ListDatabasesResponse
166+
*/
167+
listDatabases = (request: Readonly<ListDatabasesRequest> = {}) =>
168+
enrichForPagination('databases', this.pageOfListDatabases, request)
169+
170+
/**
171+
* Update database information. Update CPU limits of your Serverless SQL
172+
* Database. You must provide the `database_id` parameter.
173+
*
174+
* @param request - The request {@link UpdateDatabaseRequest}
175+
* @returns A Promise of Database
176+
*/
177+
updateDatabase = (request: Readonly<UpdateDatabaseRequest>) =>
178+
this.client.fetch<Database>(
179+
{
180+
body: JSON.stringify(
181+
marshalUpdateDatabaseRequest(request, this.client.settings),
182+
),
183+
headers: jsonContentHeaders,
184+
method: 'PATCH',
185+
path: `/serverless-sqldb/v1alpha1/regions/${validatePathParam(
186+
'region',
187+
request.region ?? this.client.settings.defaultRegion,
188+
)}/databases/${validatePathParam('databaseId', request.databaseId)}`,
189+
},
190+
unmarshalDatabase,
191+
)
192+
193+
/**
194+
* Restore a database from a backup. Restore a database from a backup. You
195+
* must provide the `backup_id` parameter.
196+
*
197+
* @param request - The request {@link RestoreDatabaseFromBackupRequest}
198+
* @returns A Promise of Database
199+
*/
200+
restoreDatabaseFromBackup = (
201+
request: Readonly<RestoreDatabaseFromBackupRequest>,
202+
) =>
203+
this.client.fetch<Database>(
204+
{
205+
body: JSON.stringify(
206+
marshalRestoreDatabaseFromBackupRequest(
207+
request,
208+
this.client.settings,
209+
),
210+
),
211+
headers: jsonContentHeaders,
212+
method: 'POST',
213+
path: `/serverless-sqldb/v1alpha1/regions/${validatePathParam(
214+
'region',
215+
request.region ?? this.client.settings.defaultRegion,
216+
)}/databases/${validatePathParam(
217+
'databaseId',
218+
request.databaseId,
219+
)}/restore`,
220+
},
221+
unmarshalDatabase,
222+
)
223+
224+
/**
225+
* Get a database backup information. Retrieve information about your
226+
* Serverless SQL Database backup. You must provide the `backup_id`
227+
* parameter.
228+
*
229+
* @param request - The request {@link GetDatabaseBackupRequest}
230+
* @returns A Promise of DatabaseBackup
231+
*/
232+
getDatabaseBackup = (request: Readonly<GetDatabaseBackupRequest>) =>
233+
this.client.fetch<DatabaseBackup>(
234+
{
235+
method: 'GET',
236+
path: `/serverless-sqldb/v1alpha1/regions/${validatePathParam(
237+
'region',
238+
request.region ?? this.client.settings.defaultRegion,
239+
)}/backups/${validatePathParam('backupId', request.backupId)}`,
240+
},
241+
unmarshalDatabaseBackup,
242+
)
243+
244+
protected pageOfListDatabaseBackups = (
245+
request: Readonly<ListDatabaseBackupsRequest>,
246+
) =>
247+
this.client.fetch<ListDatabaseBackupsResponse>(
248+
{
249+
method: 'GET',
250+
path: `/serverless-sqldb/v1alpha1/regions/${validatePathParam(
251+
'region',
252+
request.region ?? this.client.settings.defaultRegion,
253+
)}/backups`,
254+
urlParams: urlParams(
255+
['database_id', request.databaseId],
256+
['order_by', request.orderBy],
257+
['page', request.page],
258+
['page_size', request.pageSize],
259+
),
260+
},
261+
unmarshalListDatabaseBackupsResponse,
262+
)
263+
264+
/**
265+
* List your Serverless SQL Database backups. List all Serverless SQL Database
266+
* backups for a given Scaleway Project or Database. By default, the backups
267+
* returned in the list are ordered by creation date in ascending order,
268+
* though this can be modified via the order_by field.
269+
*
270+
* @param request - The request {@link ListDatabaseBackupsRequest}
271+
* @returns A Promise of ListDatabaseBackupsResponse
272+
*/
273+
listDatabaseBackups = (request: Readonly<ListDatabaseBackupsRequest>) =>
274+
enrichForPagination('backups', this.pageOfListDatabaseBackups, request)
275+
276+
/**
277+
* Export a database backup. Export a database backup providing a download
278+
* link once the export process is completed. You must provide the `backup_id`
279+
* parameter.
280+
*
281+
* @param request - The request {@link ExportDatabaseBackupRequest}
282+
* @returns A Promise of DatabaseBackup
283+
*/
284+
exportDatabaseBackup = (request: Readonly<ExportDatabaseBackupRequest>) =>
285+
this.client.fetch<DatabaseBackup>(
286+
{
287+
body: '{}',
288+
headers: jsonContentHeaders,
289+
method: 'POST',
290+
path: `/serverless-sqldb/v1alpha1/regions/${validatePathParam(
291+
'region',
292+
request.region ?? this.client.settings.defaultRegion,
293+
)}/backups/${validatePathParam('backupId', request.backupId)}/export`,
294+
},
295+
unmarshalDatabaseBackup,
296+
)
297+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// This file was automatically generated. DO NOT EDIT.
2+
// If you have any remark or suggestion do not hesitate to open an issue.
3+
import type { DatabaseStatus } from './types.gen'
4+
5+
/** Lists transient statutes of the enum {@link DatabaseStatus}. */
6+
export const DATABASE_TRANSIENT_STATUSES: DatabaseStatus[] = [
7+
'creating',
8+
'deleting',
9+
'restoring',
10+
]
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// This file was automatically generated. DO NOT EDIT.
2+
// If you have any remark or suggestion do not hesitate to open an issue.
3+
export { API } from './api.gen'
4+
export * from './content.gen'
5+
export type {
6+
CreateDatabaseRequest,
7+
Database,
8+
DatabaseBackup,
9+
DatabaseBackupStatus,
10+
DatabaseStatus,
11+
DeleteDatabaseRequest,
12+
ExportDatabaseBackupRequest,
13+
GetDatabaseBackupRequest,
14+
GetDatabaseRequest,
15+
ListDatabaseBackupsRequest,
16+
ListDatabaseBackupsRequestOrderBy,
17+
ListDatabaseBackupsResponse,
18+
ListDatabasesRequest,
19+
ListDatabasesRequestOrderBy,
20+
ListDatabasesResponse,
21+
RestoreDatabaseFromBackupRequest,
22+
UpdateDatabaseRequest,
23+
} from './types.gen'
24+
export * as ValidationRules from './validation-rules.gen'

0 commit comments

Comments
 (0)