alchemy 0.63.0 → 0.64.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (181) hide show
  1. package/bin/alchemy.js +97 -87
  2. package/bin/commands/init.ts +1 -1
  3. package/bin/services/github-workflow.ts +2 -2
  4. package/lib/alchemy.d.ts +4 -0
  5. package/lib/alchemy.d.ts.map +1 -1
  6. package/lib/alchemy.js +10 -4
  7. package/lib/alchemy.js.map +1 -1
  8. package/lib/apply.d.ts +3 -0
  9. package/lib/apply.d.ts.map +1 -1
  10. package/lib/apply.js +11 -1
  11. package/lib/apply.js.map +1 -1
  12. package/lib/cloudflare/bindings.d.ts +3 -1
  13. package/lib/cloudflare/bindings.d.ts.map +1 -1
  14. package/lib/cloudflare/bucket.d.ts +2 -1
  15. package/lib/cloudflare/bucket.d.ts.map +1 -1
  16. package/lib/cloudflare/bucket.js.map +1 -1
  17. package/lib/cloudflare/bundle/cloudflare-internal.d.ts +6 -0
  18. package/lib/cloudflare/bundle/cloudflare-internal.d.ts.map +1 -0
  19. package/lib/cloudflare/bundle/cloudflare-internal.js +39 -0
  20. package/lib/cloudflare/bundle/cloudflare-internal.js.map +1 -0
  21. package/lib/cloudflare/bundle/nodejs-builtin-modules.d.ts +2 -0
  22. package/lib/cloudflare/bundle/nodejs-builtin-modules.d.ts.map +1 -0
  23. package/lib/cloudflare/bundle/nodejs-builtin-modules.js +9 -0
  24. package/lib/cloudflare/bundle/nodejs-builtin-modules.js.map +1 -0
  25. package/lib/cloudflare/bundle/plugin-als-external.d.ts +6 -0
  26. package/lib/cloudflare/bundle/plugin-als-external.d.ts.map +1 -0
  27. package/lib/cloudflare/bundle/plugin-als-external.js +12 -0
  28. package/lib/cloudflare/bundle/plugin-als-external.js.map +1 -0
  29. package/lib/cloudflare/bundle/plugin-hybrid-node-compat.d.ts +4 -1
  30. package/lib/cloudflare/bundle/plugin-hybrid-node-compat.d.ts.map +1 -1
  31. package/lib/cloudflare/bundle/plugin-hybrid-node-compat.js +23 -23
  32. package/lib/cloudflare/bundle/plugin-hybrid-node-compat.js.map +1 -1
  33. package/lib/cloudflare/bundle/plugin-node-compat.d.ts +11 -0
  34. package/lib/cloudflare/bundle/plugin-node-compat.d.ts.map +1 -0
  35. package/lib/cloudflare/bundle/plugin-node-compat.js +93 -0
  36. package/lib/cloudflare/bundle/plugin-node-compat.js.map +1 -0
  37. package/lib/cloudflare/cloudflare-env-proxy.js +1 -1
  38. package/lib/cloudflare/cloudflare-env-proxy.js.map +1 -1
  39. package/lib/cloudflare/compatibility-date.gen.d.ts +1 -1
  40. package/lib/cloudflare/compatibility-date.gen.js +1 -1
  41. package/lib/cloudflare/d1-local-migrations.js.map +1 -1
  42. package/lib/cloudflare/durable-object-namespace.d.ts +1 -0
  43. package/lib/cloudflare/durable-object-namespace.d.ts.map +1 -1
  44. package/lib/cloudflare/hyperdrive.js +1 -1
  45. package/lib/cloudflare/hyperdrive.js.map +1 -1
  46. package/lib/cloudflare/website.d.ts.map +1 -1
  47. package/lib/cloudflare/website.js +80 -82
  48. package/lib/cloudflare/website.js.map +1 -1
  49. package/lib/cloudflare/worker-bundle.d.ts +6 -0
  50. package/lib/cloudflare/worker-bundle.d.ts.map +1 -1
  51. package/lib/cloudflare/worker-bundle.js +34 -10
  52. package/lib/cloudflare/worker-bundle.js.map +1 -1
  53. package/lib/cloudflare/worker-metadata.d.ts.map +1 -1
  54. package/lib/cloudflare/worker-metadata.js +2 -1
  55. package/lib/cloudflare/worker-metadata.js.map +1 -1
  56. package/lib/cloudflare/worker.d.ts.map +1 -1
  57. package/lib/cloudflare/worker.js +24 -6
  58. package/lib/cloudflare/worker.js.map +1 -1
  59. package/lib/cloudflare/wrangler.json.d.ts +2 -4
  60. package/lib/cloudflare/wrangler.json.d.ts.map +1 -1
  61. package/lib/cloudflare/wrangler.json.js +16 -14
  62. package/lib/cloudflare/wrangler.json.js.map +1 -1
  63. package/lib/context.d.ts +3 -1
  64. package/lib/context.d.ts.map +1 -1
  65. package/lib/context.js +2 -2
  66. package/lib/context.js.map +1 -1
  67. package/lib/destroy.d.ts +8 -0
  68. package/lib/destroy.d.ts.map +1 -1
  69. package/lib/destroy.js +20 -4
  70. package/lib/destroy.js.map +1 -1
  71. package/lib/neon/project.d.ts.map +1 -1
  72. package/lib/neon/project.js +4 -5
  73. package/lib/neon/project.js.map +1 -1
  74. package/lib/planetscale/api/client.gen.d.ts +1750 -0
  75. package/lib/planetscale/api/client.gen.d.ts.map +1 -0
  76. package/lib/planetscale/api/client.gen.js +2401 -0
  77. package/lib/planetscale/api/client.gen.js.map +1 -0
  78. package/lib/planetscale/api/index.d.ts +3 -0
  79. package/lib/planetscale/api/index.d.ts.map +1 -0
  80. package/lib/planetscale/api/index.js +4 -0
  81. package/lib/planetscale/api/index.js.map +1 -0
  82. package/lib/planetscale/api/types.gen.d.ts +12156 -0
  83. package/lib/planetscale/api/types.gen.d.ts.map +1 -0
  84. package/lib/planetscale/api/types.gen.js +2 -0
  85. package/lib/planetscale/api/types.gen.js.map +1 -0
  86. package/lib/planetscale/branch.d.ts +5 -8
  87. package/lib/planetscale/branch.d.ts.map +1 -1
  88. package/lib/planetscale/branch.js +111 -97
  89. package/lib/planetscale/branch.js.map +1 -1
  90. package/lib/planetscale/database.d.ts +2 -6
  91. package/lib/planetscale/database.d.ts.map +1 -1
  92. package/lib/planetscale/database.js +157 -118
  93. package/lib/planetscale/database.js.map +1 -1
  94. package/lib/planetscale/index.d.ts +1 -1
  95. package/lib/planetscale/index.d.ts.map +1 -1
  96. package/lib/planetscale/index.js +1 -1
  97. package/lib/planetscale/index.js.map +1 -1
  98. package/lib/planetscale/password.d.ts +4 -7
  99. package/lib/planetscale/password.d.ts.map +1 -1
  100. package/lib/planetscale/password.js +71 -56
  101. package/lib/planetscale/password.js.map +1 -1
  102. package/lib/planetscale/utils.d.ts +8 -6
  103. package/lib/planetscale/utils.d.ts.map +1 -1
  104. package/lib/planetscale/utils.js +85 -70
  105. package/lib/planetscale/utils.js.map +1 -1
  106. package/lib/scope.d.ts +5 -1
  107. package/lib/scope.d.ts.map +1 -1
  108. package/lib/scope.js +11 -3
  109. package/lib/scope.js.map +1 -1
  110. package/lib/upstash/redis.js +1 -1
  111. package/lib/upstash/redis.js.map +1 -1
  112. package/lib/util/dedent.d.ts +3 -14
  113. package/lib/util/dedent.d.ts.map +1 -1
  114. package/lib/util/dedent.js +28 -52
  115. package/lib/util/dedent.js.map +1 -1
  116. package/lib/util/idempotent-spawn.d.ts.map +1 -1
  117. package/lib/util/idempotent-spawn.js +21 -2
  118. package/lib/util/idempotent-spawn.js.map +1 -1
  119. package/lib/util/xml.js +1 -1
  120. package/lib/util/xml.js.map +1 -1
  121. package/package.json +4 -3
  122. package/src/alchemy.ts +14 -6
  123. package/src/apply.ts +13 -1
  124. package/src/cloudflare/bindings.ts +3 -1
  125. package/src/cloudflare/bucket.ts +3 -1
  126. package/src/cloudflare/bundle/cloudflare-internal.ts +42 -0
  127. package/src/cloudflare/bundle/nodejs-builtin-modules.ts +14 -0
  128. package/src/cloudflare/bundle/plugin-als-external.ts +13 -0
  129. package/src/cloudflare/bundle/plugin-hybrid-node-compat.ts +29 -28
  130. package/src/cloudflare/bundle/plugin-node-compat.ts +114 -0
  131. package/src/cloudflare/cloudflare-env-proxy.ts +1 -1
  132. package/src/cloudflare/compatibility-date.gen.ts +1 -1
  133. package/src/cloudflare/d1-local-migrations.ts +2 -2
  134. package/src/cloudflare/durable-object-namespace.ts +1 -1
  135. package/src/cloudflare/hyperdrive.ts +1 -1
  136. package/src/cloudflare/website.ts +88 -89
  137. package/src/cloudflare/worker-bundle.ts +46 -9
  138. package/src/cloudflare/worker-metadata.ts +3 -1
  139. package/src/cloudflare/worker.ts +35 -7
  140. package/src/cloudflare/wrangler.json.ts +108 -110
  141. package/src/context.ts +5 -3
  142. package/src/destroy.ts +26 -8
  143. package/src/neon/project.ts +4 -5
  144. package/src/planetscale/api/client.gen.ts +2882 -0
  145. package/src/planetscale/api/index.ts +4 -0
  146. package/src/planetscale/api/types.gen.ts +13041 -0
  147. package/src/planetscale/branch.ts +152 -169
  148. package/src/planetscale/database.ts +195 -204
  149. package/src/planetscale/index.ts +1 -1
  150. package/src/planetscale/password.ts +86 -85
  151. package/src/planetscale/utils.ts +141 -122
  152. package/src/scope.ts +12 -3
  153. package/src/upstash/redis.ts +1 -1
  154. package/src/util/dedent.ts +33 -61
  155. package/src/util/idempotent-spawn.ts +23 -2
  156. package/src/util/xml.ts +1 -1
  157. package/templates/astro/alchemy.run.ts +1 -3
  158. package/templates/hono/alchemy.run.ts +0 -1
  159. package/templates/nuxt/alchemy.run.ts +1 -3
  160. package/templates/react-router/alchemy.run.ts +1 -3
  161. package/templates/rwsdk/alchemy.run.ts +0 -2
  162. package/templates/sveltekit/alchemy.run.ts +1 -3
  163. package/templates/tanstack-start/alchemy.run.ts +1 -3
  164. package/templates/typescript/alchemy.run.ts +0 -1
  165. package/templates/vite/alchemy.run.ts +0 -1
  166. package/workers/cloudflare-state-store.js +58 -58
  167. package/lib/cloudflare/bundle/externals.d.ts +0 -3
  168. package/lib/cloudflare/bundle/externals.d.ts.map +0 -1
  169. package/lib/cloudflare/bundle/externals.js +0 -35
  170. package/lib/cloudflare/bundle/externals.js.map +0 -1
  171. package/lib/cloudflare/bundle/plugin-compat-warning.d.ts +0 -10
  172. package/lib/cloudflare/bundle/plugin-compat-warning.d.ts.map +0 -1
  173. package/lib/cloudflare/bundle/plugin-compat-warning.js +0 -67
  174. package/lib/cloudflare/bundle/plugin-compat-warning.js.map +0 -1
  175. package/lib/planetscale/api.d.ts +0 -53
  176. package/lib/planetscale/api.d.ts.map +0 -1
  177. package/lib/planetscale/api.js +0 -84
  178. package/lib/planetscale/api.js.map +0 -1
  179. package/src/cloudflare/bundle/externals.ts +0 -36
  180. package/src/cloudflare/bundle/plugin-compat-warning.ts +0 -94
  181. package/src/planetscale/api.ts +0 -115
@@ -0,0 +1,2882 @@
1
+ // This file is auto-generated by scripts/planetscale/generate.ts. Do not edit manually.
2
+
3
+ import type {
4
+ Backup,
5
+ CancelBranchChangeRequestData,
6
+ CancelDeployRequestData,
7
+ CloseDeployRequestData,
8
+ CompleteErroredDeployData,
9
+ CompleteGatedDeployRequestData,
10
+ CompleteRevertData,
11
+ CreateBackupData,
12
+ CreateBranchData,
13
+ CreateDatabaseData,
14
+ CreateDeployRequestData,
15
+ CreateKeyspaceData,
16
+ CreateOauthTokenData,
17
+ CreatePasswordData,
18
+ CreateQueryPatternsReportData,
19
+ CreateRoleData,
20
+ CreateWebhookData,
21
+ CreateWorkflowData,
22
+ Database,
23
+ DatabaseBranch,
24
+ DatabaseBranchKeyspace,
25
+ DatabaseBranchPassword,
26
+ DatabaseDeployRequest,
27
+ DatabaseWebhook,
28
+ DeleteBackupData,
29
+ DeleteBranchData,
30
+ DeleteDatabaseData,
31
+ DeleteKeyspaceData,
32
+ DeleteOauthTokenData,
33
+ DeletePasswordData,
34
+ DeleteQueryPatternsReportData,
35
+ DeleteRoleData,
36
+ DeleteWebhookData,
37
+ DemoteBranchData,
38
+ DeployRequestReview,
39
+ Deployment,
40
+ DisableSafeMigrationsData,
41
+ EnableSafeMigrationsData,
42
+ GetBackupData,
43
+ GetBranchData,
44
+ GetBranchSchemaData,
45
+ GetBranchSchemaResponse,
46
+ GetCurrentUserData,
47
+ GetDatabaseData,
48
+ GetDatabaseThrottlerData,
49
+ GetDeployQueueData,
50
+ GetDeployRequestData,
51
+ GetDeployRequestThrottlerData,
52
+ GetDeploymentData,
53
+ GetInvoiceData,
54
+ GetInvoiceLineItemsData,
55
+ GetKeyspaceData,
56
+ GetKeyspaceRolloutStatusData,
57
+ GetKeyspaceRolloutStatusResponse,
58
+ GetKeyspaceVschemaData,
59
+ GetKeyspaceVschemaResponse,
60
+ GetOauthApplicationData,
61
+ GetOauthTokenData,
62
+ GetOrganizationData,
63
+ GetPasswordData,
64
+ GetQueryPatternsReportData,
65
+ GetQueryPatternsReportStatusData,
66
+ GetRoleData,
67
+ GetWebhookData,
68
+ GetWorkflowData,
69
+ Invoice,
70
+ LintBranchSchemaData,
71
+ ListAuditLogsData,
72
+ ListBackupsData,
73
+ ListBranchChangeRequestsData,
74
+ ListBranchesData,
75
+ ListDatabaseRegionsData,
76
+ ListDatabasesData,
77
+ ListDeployOperationsData,
78
+ ListDeployRequestReviewsData,
79
+ ListDeployRequestsData,
80
+ ListExtensionsData,
81
+ ListExtensionsResponse,
82
+ ListGeneratedQueryPatternsReportsData,
83
+ ListInvoicesData,
84
+ ListKeyspaceResizesData,
85
+ ListKeyspacesData,
86
+ ListOauthApplicationsData,
87
+ ListOauthTokensData,
88
+ ListOrganizationMembersData,
89
+ ListOrganizationsData,
90
+ ListParametersData,
91
+ ListParametersResponse,
92
+ ListPasswordsData,
93
+ ListPublicRegionsData,
94
+ ListReadOnlyRegionsData,
95
+ ListRegionsForOrganizationData,
96
+ ListRolesData,
97
+ ListWebhooksData,
98
+ ListWorkflowsData,
99
+ OauthApplication,
100
+ Organization,
101
+ PaginatedAuditLogEvent,
102
+ PaginatedBackup,
103
+ PaginatedDatabase,
104
+ PaginatedDatabaseBranch,
105
+ PaginatedDatabaseBranchKeyspace,
106
+ PaginatedDatabaseBranchPassword,
107
+ PaginatedDatabaseBranchReadOnlyRegion,
108
+ PaginatedDatabaseDeployRequest,
109
+ PaginatedDatabaseWebhook,
110
+ PaginatedDeployOperation,
111
+ PaginatedDeployRequestReview,
112
+ PaginatedDeployment,
113
+ PaginatedInvoice,
114
+ PaginatedKeyspaceResizeRequest,
115
+ PaginatedLineItem,
116
+ PaginatedOauthApplication,
117
+ PaginatedOrganization,
118
+ PaginatedOrganizationMembership,
119
+ PaginatedPlanetscaleRegion,
120
+ PaginatedPostgresClusterResizeRequest,
121
+ PaginatedPostgresRole,
122
+ PaginatedPublicPlanetscaleRegionSerializer,
123
+ PaginatedQueryPatternsDownload,
124
+ PaginatedSchemaLintError,
125
+ PaginatedServiceToken,
126
+ PaginatedWorkflow,
127
+ PostgresClusterResizeRequest,
128
+ PostgresRole,
129
+ PromoteBranchData,
130
+ QueryPatternsDownload,
131
+ QueueDeployRequestData,
132
+ RenewPasswordData,
133
+ RenewRoleData,
134
+ ReviewDeployRequestData,
135
+ ServiceToken,
136
+ SkipRevertPeriodData,
137
+ TestWebhookData,
138
+ ThrottlerConfigurations,
139
+ UpdateAutoApplyData,
140
+ UpdateBackupData,
141
+ UpdateBranchChangeRequestData,
142
+ UpdateBranchClusterConfigData,
143
+ UpdateDatabaseSettingsData,
144
+ UpdateDatabaseThrottlerData,
145
+ UpdateDeployRequestThrottlerData,
146
+ UpdateKeyspaceData,
147
+ UpdateKeyspaceVschemaData,
148
+ UpdateKeyspaceVschemaResponse,
149
+ UpdateOrganizationData,
150
+ UpdatePasswordData,
151
+ UpdateRoleData,
152
+ UpdateWebhookData,
153
+ User,
154
+ VerifyWorkflowData,
155
+ Workflow,
156
+ WorkflowCancelData,
157
+ WorkflowCompleteData,
158
+ WorkflowCutoverData,
159
+ WorkflowRetryData,
160
+ WorkflowReverseCutoverData,
161
+ WorkflowReverseTrafficData,
162
+ WorkflowSwitchPrimariesData,
163
+ WorkflowSwitchReplicasData,
164
+ } from "./types.gen.ts";
165
+ import type { Secret } from "../../secret.ts";
166
+
167
+ export class PlanetScaleError extends Error {
168
+ readonly code: string;
169
+ readonly status: number;
170
+ readonly url: string;
171
+ readonly method: string;
172
+
173
+ constructor(props: {
174
+ code: string;
175
+ message: string;
176
+ status: number;
177
+ url: string;
178
+ method: string;
179
+ }) {
180
+ super(
181
+ `A request to the PlanetScale API failed (${props.status} ${props.code}): ${props.message}`,
182
+ );
183
+ this.code = props.code;
184
+ this.status = props.status;
185
+ this.url = props.url;
186
+ this.method = props.method;
187
+ }
188
+ }
189
+
190
+ export interface PlanetScaleProps {
191
+ /**
192
+ * The base URL of the PlanetScale API. Defaults to https://api.planetscale.com/v1.
193
+ */
194
+ baseUrl?: string;
195
+ /**
196
+ * The ID of the service token to use for authentication. Defaults to the value of the PLANETSCALE_SERVICE_TOKEN_ID environment variable.
197
+ */
198
+ serviceTokenId?: Secret;
199
+ /**
200
+ * The secret of the service token to use for authentication. Defaults to the value of the PLANETSCALE_SERVICE_TOKEN environment variable.
201
+ */
202
+ serviceToken?: Secret;
203
+ /**
204
+ * The API key to use for authentication. Defaults to the value of the PLANETSCALE_API_TOKEN environment variable.
205
+ * @deprecated Use serviceTokenId and serviceToken instead.
206
+ */
207
+ apiKey?: Secret;
208
+ /**
209
+ * The organization to use for authentication. Defaults to the value of the PLANETSCALE_ORGANIZATION or PLANETSCALE_ORG_ID environment variable.
210
+ */
211
+ organizationId?: string;
212
+ }
213
+
214
+ type ResultType = "json" | "full";
215
+
216
+ type RequestType<TParams, TResult extends ResultType> = Omit<TParams, "url"> & {
217
+ /**
218
+ * The type of response to return.
219
+ * If "json", the response JSON will be returned and any errors will be thrown.
220
+ * If "response", the entire response will be returned regardless of errors.
221
+ * @default "json"
222
+ */
223
+ result?: TResult;
224
+ };
225
+
226
+ type ResponseType<T, TResult extends ResultType> = TResult extends "json"
227
+ ? T
228
+ :
229
+ | { status: number; data: T; error: null; response: Response }
230
+ | {
231
+ status: number;
232
+ data: null;
233
+ error: PlanetScaleError;
234
+ response: Response;
235
+ };
236
+
237
+ export class PlanetScaleClient {
238
+ private readonly baseUrl: string;
239
+ private readonly token: string;
240
+
241
+ constructor(props: PlanetScaleProps = {}) {
242
+ this.baseUrl = props.baseUrl ?? "https://api.planetscale.com/v1";
243
+ if (props.apiKey) {
244
+ this.token = props.apiKey.unencrypted;
245
+ } else if (props.serviceTokenId && props.serviceToken) {
246
+ this.token = `${props.serviceTokenId.unencrypted}:${props.serviceToken.unencrypted}`;
247
+ } else if (process.env.PLANETSCALE_API_TOKEN) {
248
+ this.token = process.env.PLANETSCALE_API_TOKEN;
249
+ } else if (
250
+ process.env.PLANETSCALE_SERVICE_TOKEN_ID &&
251
+ process.env.PLANETSCALE_SERVICE_TOKEN
252
+ ) {
253
+ this.token = `${process.env.PLANETSCALE_SERVICE_TOKEN_ID}:${process.env.PLANETSCALE_SERVICE_TOKEN}`;
254
+ } else {
255
+ throw new Error(
256
+ "No authentication token provided for PlanetScale. Please provide an API key, service token ID and secret, or set the PLANETSCALE_SERVICE_TOKEN_ID and PLANETSCALE_SERVICE_TOKEN environment variables.",
257
+ );
258
+ }
259
+ }
260
+
261
+ async request<T, TResult extends ResultType = "json">(input: {
262
+ method: "GET" | "POST" | "PUT" | "DELETE" | "PATCH";
263
+ path: `/${string}`;
264
+ params?: {
265
+ body?: Record<string, unknown>;
266
+ query?: Record<string, string | number | boolean>;
267
+ path?: Record<string, string>;
268
+ result?: TResult;
269
+ };
270
+ }): Promise<ResponseType<T, TResult>> {
271
+ const url = formatURL({
272
+ url: this.baseUrl + input.path,
273
+ path: input.params?.path,
274
+ query: input.params?.query,
275
+ });
276
+ const res = await fetch(url, {
277
+ method: input.method,
278
+ headers: {
279
+ Authorization: this.token,
280
+ ...(input.params?.body ? { "Content-Type": "application/json" } : {}),
281
+ },
282
+ ...(input.params?.body
283
+ ? { body: JSON.stringify(input.params.body) }
284
+ : {}),
285
+ });
286
+ if (!res.ok) {
287
+ const json = (await res.json()) as { code: string; message: string };
288
+ const error = new PlanetScaleError({
289
+ code: json.code,
290
+ message: json.message,
291
+ status: res.status,
292
+ url,
293
+ method: input.method,
294
+ });
295
+ if (input.params?.result === "full") {
296
+ return {
297
+ status: res.status,
298
+ data: null,
299
+ error,
300
+ response: res,
301
+ } as ResponseType<T, TResult>;
302
+ }
303
+ throw error;
304
+ }
305
+ const json = res.status === 204 ? null : ((await res.json()) as T);
306
+ return (
307
+ input.params?.result === "full"
308
+ ? { status: res.status, data: json, error: null, response: res }
309
+ : json
310
+ ) as ResponseType<T, TResult>;
311
+ }
312
+
313
+ organizations = {
314
+ /**
315
+ * List organizations
316
+ *
317
+ * @description When using a service token, returns the list of organizations the service token has access to. When using an OAuth token, returns the list of organizations the user has access to.
318
+ * ### Authorization
319
+ * A OAuth token must have at least one of the following scopes in order to use this API endpoint:
320
+ *
321
+ * **OAuth Scopes**
322
+ *
323
+ * | Resource | Scopes |
324
+ * | :------- | :---------- |
325
+ * | User | `read_organizations` |
326
+ */
327
+ list: async <TResult extends ResultType = "json">(
328
+ params?: RequestType<ListOrganizationsData, TResult>,
329
+ ) => {
330
+ return await this.request<PaginatedOrganization, TResult>({
331
+ method: "GET",
332
+ path: "/organizations",
333
+ params,
334
+ });
335
+ },
336
+ /**
337
+ * Get an organization
338
+ *
339
+ * @description ### Authorization
340
+ * A service token or OAuth token must have at least one of the following access or scopes in order to use this API endpoint:
341
+ *
342
+ * **Service Token Accesses**
343
+ * `read_organization`
344
+ *
345
+ * **OAuth Scopes**
346
+ *
347
+ * | Resource | Scopes |
348
+ * | :------- | :---------- |
349
+ * | User | `read_organizations` |
350
+ * | Organization | `read_organization` |
351
+ */
352
+ get: async <TResult extends ResultType = "json">(
353
+ params: RequestType<GetOrganizationData, TResult>,
354
+ ) => {
355
+ return await this.request<Organization, TResult>({
356
+ method: "GET",
357
+ path: "/organizations/{name}",
358
+ params,
359
+ });
360
+ },
361
+ /**
362
+ * Update an organization
363
+ *
364
+ * @description ### Authorization
365
+ * A OAuth token must have at least one of the following scopes in order to use this API endpoint:
366
+ *
367
+ * **OAuth Scopes**
368
+ *
369
+ * | Resource | Scopes |
370
+ * | :------- | :---------- |
371
+ * | Organization | `write_organization` |
372
+ */
373
+ patch: async <TResult extends ResultType = "json">(
374
+ params: RequestType<UpdateOrganizationData, TResult>,
375
+ ) => {
376
+ return await this.request<Organization, TResult>({
377
+ method: "PATCH",
378
+ path: "/organizations/{name}",
379
+ params,
380
+ });
381
+ },
382
+ auditLog: {
383
+ /**
384
+ * List audit logs
385
+ *
386
+ * @description ### Authorization
387
+ * A service token must have at least one of the following access in order to use this API endpoint:
388
+ *
389
+ * **Service Token Accesses**
390
+ * `read_audit_logs`
391
+ */
392
+ list: async <TResult extends ResultType = "json">(
393
+ params: RequestType<ListAuditLogsData, TResult>,
394
+ ) => {
395
+ return await this.request<PaginatedAuditLogEvent, TResult>({
396
+ method: "GET",
397
+ path: "/organizations/{name}/audit-log",
398
+ params,
399
+ });
400
+ },
401
+ },
402
+ regions: {
403
+ /**
404
+ * List regions for an organization
405
+ *
406
+ * @description ### Authorization
407
+ * A service token or OAuth token must have at least one of the following access or scopes in order to use this API endpoint:
408
+ *
409
+ * **Service Token Accesses**
410
+ * `read_organization`
411
+ *
412
+ * **OAuth Scopes**
413
+ *
414
+ * | Resource | Scopes |
415
+ * | :------- | :---------- |
416
+ * | User | `read_organizations` |
417
+ * | Organization | `read_organization` |
418
+ */
419
+ list: async <TResult extends ResultType = "json">(
420
+ params: RequestType<ListRegionsForOrganizationData, TResult>,
421
+ ) => {
422
+ return await this.request<PaginatedPlanetscaleRegion, TResult>({
423
+ method: "GET",
424
+ path: "/organizations/{name}/regions",
425
+ params,
426
+ });
427
+ },
428
+ },
429
+ databases: {
430
+ /**
431
+ * List databases
432
+ *
433
+ * @description ### Authorization
434
+ * A service token or OAuth token must have at least one of the following access or scopes in order to use this API endpoint:
435
+ *
436
+ * **Service Token Accesses**
437
+ * `read_database`, `delete_database`, `write_database`, `read_branch`, `delete_branch`, `create_branch`, `delete_production_branch`, `connect_branch`, `connect_production_branch`, `delete_branch_password`, `delete_production_branch_password`, `read_deploy_request`, `create_deploy_request`, `approve_deploy_request`, `read_schema_recommendations`, `close_schema_recommendations`, `read_comment`, `create_comment`, `restore_backup`, `restore_production_branch_backup`, `read_backups`, `write_backups`, `delete_backups`, `delete_production_branch_backups`, `write_branch_vschema`, `write_production_branch_vschema`
438
+ *
439
+ * **OAuth Scopes**
440
+ *
441
+ * | Resource | Scopes |
442
+ * | :------- | :---------- |
443
+ * | Organization | `read_databases` |
444
+ */
445
+ list: async <TResult extends ResultType = "json">(
446
+ params: RequestType<ListDatabasesData, TResult>,
447
+ ) => {
448
+ return await this.request<PaginatedDatabase, TResult>({
449
+ method: "GET",
450
+ path: "/organizations/{organization}/databases",
451
+ params,
452
+ });
453
+ },
454
+ /**
455
+ * Create a database
456
+ *
457
+ * @description ### Authorization
458
+ * A service token or OAuth token must have at least one of the following access or scopes in order to use this API endpoint:
459
+ *
460
+ * **Service Token Accesses**
461
+ * `create_databases`
462
+ *
463
+ * **OAuth Scopes**
464
+ *
465
+ * | Resource | Scopes |
466
+ * | :------- | :---------- |
467
+ * | Organization | `create_databases` |
468
+ */
469
+ post: async <TResult extends ResultType = "json">(
470
+ params: RequestType<CreateDatabaseData, TResult>,
471
+ ) => {
472
+ return await this.request<Database, TResult>({
473
+ method: "POST",
474
+ path: "/organizations/{organization}/databases",
475
+ params,
476
+ });
477
+ },
478
+ branches: {
479
+ /**
480
+ * List branches
481
+ *
482
+ * @description ### Authorization
483
+ * A service token or OAuth token must have at least one of the following access or scopes in order to use this API endpoint:
484
+ *
485
+ * **Service Token Accesses**
486
+ * `read_branch`, `delete_branch`, `create_branch`, `connect_production_branch`, `connect_branch`
487
+ *
488
+ * **OAuth Scopes**
489
+ *
490
+ * | Resource | Scopes |
491
+ * | :------- | :---------- |
492
+ * | Organization | `read_branches` |
493
+ * | Database | `read_branches` |
494
+ * | Branch | `read_branch` |
495
+ */
496
+ list: async <TResult extends ResultType = "json">(
497
+ params: RequestType<ListBranchesData, TResult>,
498
+ ) => {
499
+ return await this.request<PaginatedDatabaseBranch, TResult>({
500
+ method: "GET",
501
+ path: "/organizations/{organization}/databases/{database}/branches",
502
+ params,
503
+ });
504
+ },
505
+ /**
506
+ * Create a branch
507
+ *
508
+ * @description ### Authorization
509
+ * A service token or OAuth token must have at least one of the following access or scopes in order to use this API endpoint:
510
+ *
511
+ * **Service Token Accesses**
512
+ * `create_branch`, `restore_production_branch_backup`, `restore_backup`
513
+ *
514
+ * **OAuth Scopes**
515
+ *
516
+ * | Resource | Scopes |
517
+ * | :------- | :---------- |
518
+ * | Organization | `write_branches`, `restore_production_branch_backups`, `restore_backups` |
519
+ * | Database | `write_branches`, `restore_production_branch_backups`, `restore_backups` |
520
+ * | Branch | `restore_backups` |
521
+ */
522
+ post: async <TResult extends ResultType = "json">(
523
+ params: RequestType<CreateBranchData, TResult>,
524
+ ) => {
525
+ return await this.request<DatabaseBranch, TResult>({
526
+ method: "POST",
527
+ path: "/organizations/{organization}/databases/{database}/branches",
528
+ params,
529
+ });
530
+ },
531
+ backups: {
532
+ /**
533
+ * List backups
534
+ *
535
+ * @description ### Authorization
536
+ * A service token or OAuth token must have at least one of the following access or scopes in order to use this API endpoint:
537
+ *
538
+ * **Service Token Accesses**
539
+ * `read_backups`
540
+ *
541
+ * **OAuth Scopes**
542
+ *
543
+ * | Resource | Scopes |
544
+ * | :------- | :---------- |
545
+ * | Organization | `read_backups` |
546
+ * | Database | `read_backups` |
547
+ * | Branch | `read_backups` |
548
+ */
549
+ list: async <TResult extends ResultType = "json">(
550
+ params: RequestType<ListBackupsData, TResult>,
551
+ ) => {
552
+ return await this.request<PaginatedBackup, TResult>({
553
+ method: "GET",
554
+ path: "/organizations/{organization}/databases/{database}/branches/{branch}/backups",
555
+ params,
556
+ });
557
+ },
558
+ /**
559
+ * Create a backup
560
+ *
561
+ * @description ### Authorization
562
+ * A service token or OAuth token must have at least one of the following access or scopes in order to use this API endpoint:
563
+ *
564
+ * **Service Token Accesses**
565
+ * `write_backups`
566
+ *
567
+ * **OAuth Scopes**
568
+ *
569
+ * | Resource | Scopes |
570
+ * | :------- | :---------- |
571
+ * | Organization | `write_backups` |
572
+ * | Database | `write_backups` |
573
+ * | Branch | `write_backups` |
574
+ */
575
+ post: async <TResult extends ResultType = "json">(
576
+ params: RequestType<CreateBackupData, TResult>,
577
+ ) => {
578
+ return await this.request<Backup, TResult>({
579
+ method: "POST",
580
+ path: "/organizations/{organization}/databases/{database}/branches/{branch}/backups",
581
+ params,
582
+ });
583
+ },
584
+ /**
585
+ * Get a backup
586
+ *
587
+ * @description ### Authorization
588
+ * A service token or OAuth token must have at least one of the following access or scopes in order to use this API endpoint:
589
+ *
590
+ * **Service Token Accesses**
591
+ * `read_backups`
592
+ *
593
+ * **OAuth Scopes**
594
+ *
595
+ * | Resource | Scopes |
596
+ * | :------- | :---------- |
597
+ * | Organization | `read_backups` |
598
+ * | Database | `read_backups` |
599
+ * | Branch | `read_backups` |
600
+ */
601
+ get: async <TResult extends ResultType = "json">(
602
+ params: RequestType<GetBackupData, TResult>,
603
+ ) => {
604
+ return await this.request<Backup, TResult>({
605
+ method: "GET",
606
+ path: "/organizations/{organization}/databases/{database}/branches/{branch}/backups/{id}",
607
+ params,
608
+ });
609
+ },
610
+ /**
611
+ * Update a backup
612
+ *
613
+ * @description ### Authorization
614
+ * A service token or OAuth token must have at least one of the following access or scopes in order to use this API endpoint:
615
+ *
616
+ * **Service Token Accesses**
617
+ * `write_backups`
618
+ *
619
+ * **OAuth Scopes**
620
+ *
621
+ * | Resource | Scopes |
622
+ * | :------- | :---------- |
623
+ * | Organization | `write_backups` |
624
+ * | Database | `write_backups` |
625
+ * | Branch | `write_backups` |
626
+ */
627
+ patch: async <TResult extends ResultType = "json">(
628
+ params: RequestType<UpdateBackupData, TResult>,
629
+ ) => {
630
+ return await this.request<Backup, TResult>({
631
+ method: "PATCH",
632
+ path: "/organizations/{organization}/databases/{database}/branches/{branch}/backups/{id}",
633
+ params,
634
+ });
635
+ },
636
+ /**
637
+ * Delete a backup
638
+ *
639
+ * @description ### Authorization
640
+ * A service token or OAuth token must have at least one of the following access or scopes in order to use this API endpoint:
641
+ *
642
+ * **Service Token Accesses**
643
+ * `delete_backups`, `delete_production_branch_backups`
644
+ *
645
+ * **OAuth Scopes**
646
+ *
647
+ * | Resource | Scopes |
648
+ * | :------- | :---------- |
649
+ * | Organization | `delete_backups`, `delete_production_branch_backups` |
650
+ * | Database | `delete_backups`, `delete_production_branch_backups` |
651
+ * | Branch | `delete_backups` |
652
+ */
653
+ delete: async <TResult extends ResultType = "json">(
654
+ params: RequestType<DeleteBackupData, TResult>,
655
+ ) => {
656
+ return await this.request<unknown, TResult>({
657
+ method: "DELETE",
658
+ path: "/organizations/{organization}/databases/{database}/branches/{branch}/backups/{id}",
659
+ params,
660
+ });
661
+ },
662
+ },
663
+ changes: {
664
+ /**
665
+ * Get branch change requests
666
+ *
667
+ * @description ### Authorization
668
+ * A service token or OAuth token must have at least one of the following access or scopes in order to use this API endpoint:
669
+ *
670
+ * **Service Token Accesses**
671
+ * `read_branch`, `delete_branch`, `create_branch`, `connect_production_branch`, `connect_branch`
672
+ *
673
+ * **OAuth Scopes**
674
+ *
675
+ * | Resource | Scopes |
676
+ * | :------- | :---------- |
677
+ * | Organization | `read_branches` |
678
+ * | Database | `read_branches` |
679
+ * | Branch | `read_branch` |
680
+ */
681
+ list: async <TResult extends ResultType = "json">(
682
+ params: RequestType<ListBranchChangeRequestsData, TResult>,
683
+ ) => {
684
+ return await this.request<
685
+ PaginatedPostgresClusterResizeRequest,
686
+ TResult
687
+ >({
688
+ method: "GET",
689
+ path: "/organizations/{organization}/databases/{database}/branches/{branch}/changes",
690
+ params,
691
+ });
692
+ },
693
+ /**
694
+ * Upsert a change request
695
+ *
696
+ * @description ### Authorization
697
+ * A service token or OAuth token must have at least one of the following access or scopes in order to use this API endpoint:
698
+ *
699
+ * **Service Token Accesses**
700
+ * `write_database`
701
+ *
702
+ * **OAuth Scopes**
703
+ *
704
+ * | Resource | Scopes |
705
+ * | :------- | :---------- |
706
+ * | Organization | `write_databases` |
707
+ * | Database | `write_database` |
708
+ */
709
+ patch: async <TResult extends ResultType = "json">(
710
+ params: RequestType<UpdateBranchChangeRequestData, TResult>,
711
+ ) => {
712
+ return await this.request<PostgresClusterResizeRequest, TResult>({
713
+ method: "PATCH",
714
+ path: "/organizations/{organization}/databases/{database}/branches/{branch}/changes",
715
+ params,
716
+ });
717
+ },
718
+ },
719
+ extensions: {
720
+ /**
721
+ * List cluster extensions
722
+ *
723
+ * @description ### Authorization
724
+ * A service token or OAuth token must have at least one of the following access or scopes in order to use this API endpoint:
725
+ *
726
+ * **Service Token Accesses**
727
+ * `read_branch`, `delete_branch`, `create_branch`, `connect_production_branch`, `connect_branch`
728
+ *
729
+ * **OAuth Scopes**
730
+ *
731
+ * | Resource | Scopes |
732
+ * | :------- | :---------- |
733
+ * | Organization | `read_branches` |
734
+ * | Database | `read_branches` |
735
+ * | Branch | `read_branch` |
736
+ */
737
+ list: async <TResult extends ResultType = "json">(
738
+ params: RequestType<ListExtensionsData, TResult>,
739
+ ) => {
740
+ return await this.request<ListExtensionsResponse, TResult>({
741
+ method: "GET",
742
+ path: "/organizations/{organization}/databases/{database}/branches/{branch}/extensions",
743
+ params,
744
+ });
745
+ },
746
+ },
747
+ keyspaces: {
748
+ /**
749
+ * Get keyspaces
750
+ *
751
+ */
752
+ list: async <TResult extends ResultType = "json">(
753
+ params: RequestType<ListKeyspacesData, TResult>,
754
+ ) => {
755
+ return await this.request<PaginatedDatabaseBranchKeyspace, TResult>(
756
+ {
757
+ method: "GET",
758
+ path: "/organizations/{organization}/databases/{database}/branches/{branch}/keyspaces",
759
+ params,
760
+ },
761
+ );
762
+ },
763
+ /**
764
+ * Create a keyspace
765
+ *
766
+ */
767
+ post: async <TResult extends ResultType = "json">(
768
+ params: RequestType<CreateKeyspaceData, TResult>,
769
+ ) => {
770
+ return await this.request<DatabaseBranchKeyspace, TResult>({
771
+ method: "POST",
772
+ path: "/organizations/{organization}/databases/{database}/branches/{branch}/keyspaces",
773
+ params,
774
+ });
775
+ },
776
+ vschema: {
777
+ /**
778
+ * Get the VSchema for the keyspace
779
+ *
780
+ * @description ### Authorization
781
+ * A service token must have at least one of the following access in order to use this API endpoint:
782
+ *
783
+ * **Service Token Accesses**
784
+ * `read_branch`, `delete_branch`, `create_branch`, `connect_production_branch`, `connect_branch`
785
+ */
786
+ get: async <TResult extends ResultType = "json">(
787
+ params: RequestType<GetKeyspaceVschemaData, TResult>,
788
+ ) => {
789
+ return await this.request<GetKeyspaceVschemaResponse, TResult>({
790
+ method: "GET",
791
+ path: "/organizations/{organization}/databases/{database}/branches/{branch}/keyspaces/{keyspace}/vschema",
792
+ params,
793
+ });
794
+ },
795
+ /**
796
+ * Update the VSchema for the keyspace
797
+ *
798
+ * @description ### Authorization
799
+ * A service token must have at least one of the following access in order to use this API endpoint:
800
+ *
801
+ * **Service Token Accesses**
802
+ * `write_production_branch_vschema`, `write_branch_vschema`
803
+ */
804
+ patch: async <TResult extends ResultType = "json">(
805
+ params: RequestType<UpdateKeyspaceVschemaData, TResult>,
806
+ ) => {
807
+ return await this.request<UpdateKeyspaceVschemaResponse, TResult>(
808
+ {
809
+ method: "PATCH",
810
+ path: "/organizations/{organization}/databases/{database}/branches/{branch}/keyspaces/{keyspace}/vschema",
811
+ params,
812
+ },
813
+ );
814
+ },
815
+ },
816
+ /**
817
+ * Get a keyspace
818
+ *
819
+ */
820
+ get: async <TResult extends ResultType = "json">(
821
+ params: RequestType<GetKeyspaceData, TResult>,
822
+ ) => {
823
+ return await this.request<DatabaseBranchKeyspace, TResult>({
824
+ method: "GET",
825
+ path: "/organizations/{organization}/databases/{database}/branches/{branch}/keyspaces/{name}",
826
+ params,
827
+ });
828
+ },
829
+ /**
830
+ * Configure keyspace settings
831
+ *
832
+ */
833
+ patch: async <TResult extends ResultType = "json">(
834
+ params: RequestType<UpdateKeyspaceData, TResult>,
835
+ ) => {
836
+ return await this.request<DatabaseBranchKeyspace, TResult>({
837
+ method: "PATCH",
838
+ path: "/organizations/{organization}/databases/{database}/branches/{branch}/keyspaces/{name}",
839
+ params,
840
+ });
841
+ },
842
+ /**
843
+ * Delete a keyspace
844
+ *
845
+ */
846
+ delete: async <TResult extends ResultType = "json">(
847
+ params: RequestType<DeleteKeyspaceData, TResult>,
848
+ ) => {
849
+ return await this.request<unknown, TResult>({
850
+ method: "DELETE",
851
+ path: "/organizations/{organization}/databases/{database}/branches/{branch}/keyspaces/{name}",
852
+ params,
853
+ });
854
+ },
855
+ rolloutStatus: {
856
+ /**
857
+ * Get keyspace rollout status
858
+ *
859
+ */
860
+ get: async <TResult extends ResultType = "json">(
861
+ params: RequestType<GetKeyspaceRolloutStatusData, TResult>,
862
+ ) => {
863
+ return await this.request<
864
+ GetKeyspaceRolloutStatusResponse,
865
+ TResult
866
+ >({
867
+ method: "GET",
868
+ path: "/organizations/{organization}/databases/{database}/branches/{branch}/keyspaces/{name}/rollout-status",
869
+ params,
870
+ });
871
+ },
872
+ },
873
+ resizes: {
874
+ /**
875
+ * List keyspace resizes
876
+ *
877
+ */
878
+ list: async <TResult extends ResultType = "json">(
879
+ params: RequestType<ListKeyspaceResizesData, TResult>,
880
+ ) => {
881
+ return await this.request<
882
+ PaginatedKeyspaceResizeRequest,
883
+ TResult
884
+ >({
885
+ method: "GET",
886
+ path: "/organizations/{organization}/databases/{database}/branches/{branch}/keyspaces/{name}/resizes",
887
+ params,
888
+ });
889
+ },
890
+ },
891
+ },
892
+ parameters: {
893
+ /**
894
+ * List cluster parameters
895
+ *
896
+ * @description ### Authorization
897
+ * A service token or OAuth token must have at least one of the following access or scopes in order to use this API endpoint:
898
+ *
899
+ * **Service Token Accesses**
900
+ * `read_branch`, `delete_branch`, `create_branch`, `connect_production_branch`, `connect_branch`
901
+ *
902
+ * **OAuth Scopes**
903
+ *
904
+ * | Resource | Scopes |
905
+ * | :------- | :---------- |
906
+ * | Organization | `read_branches` |
907
+ * | Database | `read_branches` |
908
+ * | Branch | `read_branch` |
909
+ */
910
+ list: async <TResult extends ResultType = "json">(
911
+ params: RequestType<ListParametersData, TResult>,
912
+ ) => {
913
+ return await this.request<ListParametersResponse, TResult>({
914
+ method: "GET",
915
+ path: "/organizations/{organization}/databases/{database}/branches/{branch}/parameters",
916
+ params,
917
+ });
918
+ },
919
+ },
920
+ passwords: {
921
+ /**
922
+ * List passwords
923
+ *
924
+ * @description ### Authorization
925
+ * A service token or OAuth token must have at least one of the following access or scopes in order to use this API endpoint:
926
+ *
927
+ * **Service Token Accesses**
928
+ * `read_branch`, `delete_branch`, `create_branch`, `connect_production_branch`, `connect_branch`
929
+ *
930
+ * **OAuth Scopes**
931
+ *
932
+ * | Resource | Scopes |
933
+ * | :------- | :---------- |
934
+ * | Organization | `manage_passwords`, `manage_production_branch_passwords` |
935
+ * | Database | `manage_passwords`, `manage_production_branch_passwords` |
936
+ * | Branch | `manage_passwords` |
937
+ */
938
+ list: async <TResult extends ResultType = "json">(
939
+ params: RequestType<ListPasswordsData, TResult>,
940
+ ) => {
941
+ return await this.request<PaginatedDatabaseBranchPassword, TResult>(
942
+ {
943
+ method: "GET",
944
+ path: "/organizations/{organization}/databases/{database}/branches/{branch}/passwords",
945
+ params,
946
+ },
947
+ );
948
+ },
949
+ /**
950
+ * Create a password
951
+ *
952
+ * @description ### Authorization
953
+ * A service token or OAuth token must have at least one of the following access or scopes in order to use this API endpoint:
954
+ *
955
+ * **Service Token Accesses**
956
+ * `connect_production_branch`, `connect_branch`
957
+ *
958
+ * **OAuth Scopes**
959
+ *
960
+ * | Resource | Scopes |
961
+ * | :------- | :---------- |
962
+ * | Organization | `manage_passwords`, `manage_production_branch_passwords` |
963
+ * | Database | `manage_passwords`, `manage_production_branch_passwords` |
964
+ * | Branch | `manage_passwords` |
965
+ */
966
+ post: async <TResult extends ResultType = "json">(
967
+ params: RequestType<CreatePasswordData, TResult>,
968
+ ) => {
969
+ return await this.request<DatabaseBranchPassword, TResult>({
970
+ method: "POST",
971
+ path: "/organizations/{organization}/databases/{database}/branches/{branch}/passwords",
972
+ params,
973
+ });
974
+ },
975
+ /**
976
+ * Get a password
977
+ *
978
+ * @description ### Authorization
979
+ * A service token or OAuth token must have at least one of the following access or scopes in order to use this API endpoint:
980
+ *
981
+ * **Service Token Accesses**
982
+ * `read_branch`, `delete_branch`, `create_branch`, `connect_production_branch`, `connect_branch`
983
+ *
984
+ * **OAuth Scopes**
985
+ *
986
+ * | Resource | Scopes |
987
+ * | :------- | :---------- |
988
+ * | Organization | `manage_passwords`, `manage_production_branch_passwords` |
989
+ * | Database | `manage_passwords`, `manage_production_branch_passwords` |
990
+ * | Branch | `manage_passwords` |
991
+ */
992
+ get: async <TResult extends ResultType = "json">(
993
+ params: RequestType<GetPasswordData, TResult>,
994
+ ) => {
995
+ return await this.request<DatabaseBranchPassword, TResult>({
996
+ method: "GET",
997
+ path: "/organizations/{organization}/databases/{database}/branches/{branch}/passwords/{id}",
998
+ params,
999
+ });
1000
+ },
1001
+ /**
1002
+ * Update a password
1003
+ *
1004
+ * @description ### Authorization
1005
+ * A service token or OAuth token must have at least one of the following access or scopes in order to use this API endpoint:
1006
+ *
1007
+ * **Service Token Accesses**
1008
+ * `connect_production_branch`, `connect_branch`
1009
+ *
1010
+ * **OAuth Scopes**
1011
+ *
1012
+ * | Resource | Scopes |
1013
+ * | :------- | :---------- |
1014
+ * | Organization | `manage_passwords`, `manage_production_branch_passwords` |
1015
+ * | Database | `manage_passwords`, `manage_production_branch_passwords` |
1016
+ * | Branch | `manage_passwords` |
1017
+ */
1018
+ patch: async <TResult extends ResultType = "json">(
1019
+ params: RequestType<UpdatePasswordData, TResult>,
1020
+ ) => {
1021
+ return await this.request<DatabaseBranchPassword, TResult>({
1022
+ method: "PATCH",
1023
+ path: "/organizations/{organization}/databases/{database}/branches/{branch}/passwords/{id}",
1024
+ params,
1025
+ });
1026
+ },
1027
+ /**
1028
+ * Delete a password
1029
+ *
1030
+ * @description ### Authorization
1031
+ * A service token or OAuth token must have at least one of the following access or scopes in order to use this API endpoint:
1032
+ *
1033
+ * **Service Token Accesses**
1034
+ * `delete_production_branch_password`, `delete_branch_password`
1035
+ *
1036
+ * **OAuth Scopes**
1037
+ *
1038
+ * | Resource | Scopes |
1039
+ * | :------- | :---------- |
1040
+ * | Organization | `manage_passwords`, `manage_production_branch_passwords` |
1041
+ * | Database | `manage_passwords`, `manage_production_branch_passwords` |
1042
+ * | Branch | `manage_passwords` |
1043
+ */
1044
+ delete: async <TResult extends ResultType = "json">(
1045
+ params: RequestType<DeletePasswordData, TResult>,
1046
+ ) => {
1047
+ return await this.request<unknown, TResult>({
1048
+ method: "DELETE",
1049
+ path: "/organizations/{organization}/databases/{database}/branches/{branch}/passwords/{id}",
1050
+ params,
1051
+ });
1052
+ },
1053
+ renew: {
1054
+ /**
1055
+ * Renew a password
1056
+ *
1057
+ * @description ### Authorization
1058
+ * A service token or OAuth token must have at least one of the following access or scopes in order to use this API endpoint:
1059
+ *
1060
+ * **Service Token Accesses**
1061
+ * `connect_production_branch`, `connect_branch`
1062
+ *
1063
+ * **OAuth Scopes**
1064
+ *
1065
+ * | Resource | Scopes |
1066
+ * | :------- | :---------- |
1067
+ * | Organization | `manage_passwords`, `manage_production_branch_passwords` |
1068
+ * | Database | `manage_passwords`, `manage_production_branch_passwords` |
1069
+ * | Branch | `manage_passwords` |
1070
+ */
1071
+ post: async <TResult extends ResultType = "json">(
1072
+ params: RequestType<RenewPasswordData, TResult>,
1073
+ ) => {
1074
+ return await this.request<DatabaseBranchPassword, TResult>({
1075
+ method: "POST",
1076
+ path: "/organizations/{organization}/databases/{database}/branches/{branch}/passwords/{id}/renew",
1077
+ params,
1078
+ });
1079
+ },
1080
+ },
1081
+ },
1082
+ queryPatterns: {
1083
+ /**
1084
+ * List generated query patterns reports
1085
+ *
1086
+ * @description ### Authorization
1087
+ * A service token or OAuth token must have at least one of the following access or scopes in order to use this API endpoint:
1088
+ *
1089
+ * **Service Token Accesses**
1090
+ * `read_branch`
1091
+ *
1092
+ * **OAuth Scopes**
1093
+ *
1094
+ * | Resource | Scopes |
1095
+ * | :------- | :---------- |
1096
+ * | Organization | `read_branches` |
1097
+ * | Database | `read_branches` |
1098
+ * | Branch | `read_branch` |
1099
+ */
1100
+ list: async <TResult extends ResultType = "json">(
1101
+ params: RequestType<ListGeneratedQueryPatternsReportsData, TResult>,
1102
+ ) => {
1103
+ return await this.request<PaginatedQueryPatternsDownload, TResult>({
1104
+ method: "GET",
1105
+ path: "/organizations/{organization}/databases/{database}/branches/{branch}/query-patterns",
1106
+ params,
1107
+ });
1108
+ },
1109
+ /**
1110
+ * Create a new query patterns report
1111
+ *
1112
+ * @description ### Authorization
1113
+ * A service token or OAuth token must have at least one of the following access or scopes in order to use this API endpoint:
1114
+ *
1115
+ * **Service Token Accesses**
1116
+ * `read_branch`
1117
+ *
1118
+ * **OAuth Scopes**
1119
+ *
1120
+ * | Resource | Scopes |
1121
+ * | :------- | :---------- |
1122
+ * | Organization | `read_branches` |
1123
+ * | Database | `read_branches` |
1124
+ * | Branch | `read_branch` |
1125
+ */
1126
+ post: async <TResult extends ResultType = "json">(
1127
+ params: RequestType<CreateQueryPatternsReportData, TResult>,
1128
+ ) => {
1129
+ return await this.request<QueryPatternsDownload, TResult>({
1130
+ method: "POST",
1131
+ path: "/organizations/{organization}/databases/{database}/branches/{branch}/query-patterns",
1132
+ params,
1133
+ });
1134
+ },
1135
+ /**
1136
+ * Show the status of a query patterns report
1137
+ *
1138
+ * @description ### Authorization
1139
+ * A service token or OAuth token must have at least one of the following access or scopes in order to use this API endpoint:
1140
+ *
1141
+ * **Service Token Accesses**
1142
+ * `read_branch`
1143
+ *
1144
+ * **OAuth Scopes**
1145
+ *
1146
+ * | Resource | Scopes |
1147
+ * | :------- | :---------- |
1148
+ * | Organization | `read_branches` |
1149
+ * | Database | `read_branches` |
1150
+ * | Branch | `read_branch` |
1151
+ */
1152
+ get: async <TResult extends ResultType = "json">(
1153
+ params: RequestType<GetQueryPatternsReportStatusData, TResult>,
1154
+ ) => {
1155
+ return await this.request<QueryPatternsDownload, TResult>({
1156
+ method: "GET",
1157
+ path: "/organizations/{organization}/databases/{database}/branches/{branch}/query-patterns/{id}",
1158
+ params,
1159
+ });
1160
+ },
1161
+ /**
1162
+ * Delete a query patterns report
1163
+ *
1164
+ * @description ### Authorization
1165
+ * A service token or OAuth token must have at least one of the following access or scopes in order to use this API endpoint:
1166
+ *
1167
+ * **Service Token Accesses**
1168
+ * `read_branch`
1169
+ *
1170
+ * **OAuth Scopes**
1171
+ *
1172
+ * | Resource | Scopes |
1173
+ * | :------- | :---------- |
1174
+ * | Organization | `read_branches` |
1175
+ * | Database | `read_branches` |
1176
+ * | Branch | `read_branch` |
1177
+ */
1178
+ delete: async <TResult extends ResultType = "json">(
1179
+ params: RequestType<DeleteQueryPatternsReportData, TResult>,
1180
+ ) => {
1181
+ return await this.request<unknown, TResult>({
1182
+ method: "DELETE",
1183
+ path: "/organizations/{organization}/databases/{database}/branches/{branch}/query-patterns/{id}",
1184
+ params,
1185
+ });
1186
+ },
1187
+ download: {
1188
+ /**
1189
+ * Download a finished query patterns report
1190
+ *
1191
+ * @description ### Authorization
1192
+ * A service token or OAuth token must have at least one of the following access or scopes in order to use this API endpoint:
1193
+ *
1194
+ * **Service Token Accesses**
1195
+ * `read_branch`
1196
+ *
1197
+ * **OAuth Scopes**
1198
+ *
1199
+ * | Resource | Scopes |
1200
+ * | :------- | :---------- |
1201
+ * | Organization | `read_branches` |
1202
+ * | Database | `read_branches` |
1203
+ * | Branch | `read_branch` |
1204
+ */
1205
+ get: async <TResult extends ResultType = "json">(
1206
+ params: RequestType<GetQueryPatternsReportData, TResult>,
1207
+ ) => {
1208
+ return await this.request<QueryPatternsDownload, TResult>({
1209
+ method: "GET",
1210
+ path: "/organizations/{organization}/databases/{database}/branches/{branch}/query-patterns/{id}/download",
1211
+ params,
1212
+ });
1213
+ },
1214
+ },
1215
+ },
1216
+ resizes: {
1217
+ /**
1218
+ * Cancel a change request
1219
+ *
1220
+ * @description ### Authorization
1221
+ * A service token or OAuth token must have at least one of the following access or scopes in order to use this API endpoint:
1222
+ *
1223
+ * **Service Token Accesses**
1224
+ * `write_database`
1225
+ *
1226
+ * **OAuth Scopes**
1227
+ *
1228
+ * | Resource | Scopes |
1229
+ * | :------- | :---------- |
1230
+ * | Organization | `write_databases` |
1231
+ * | Database | `write_database` |
1232
+ */
1233
+ delete: async <TResult extends ResultType = "json">(
1234
+ params: RequestType<CancelBranchChangeRequestData, TResult>,
1235
+ ) => {
1236
+ return await this.request<unknown, TResult>({
1237
+ method: "DELETE",
1238
+ path: "/organizations/{organization}/databases/{database}/branches/{branch}/resizes",
1239
+ params,
1240
+ });
1241
+ },
1242
+ },
1243
+ roles: {
1244
+ /**
1245
+ * List roles
1246
+ *
1247
+ * @description ### Authorization
1248
+ * A service token or OAuth token must have at least one of the following access or scopes in order to use this API endpoint:
1249
+ *
1250
+ * **Service Token Accesses**
1251
+ * `read_branch`, `delete_branch`, `create_branch`, `connect_production_branch`, `connect_branch`
1252
+ *
1253
+ * **OAuth Scopes**
1254
+ *
1255
+ * | Resource | Scopes |
1256
+ * | :------- | :---------- |
1257
+ * | Organization | `manage_passwords`, `manage_production_branch_passwords` |
1258
+ * | Database | `manage_passwords`, `manage_production_branch_passwords` |
1259
+ * | Branch | `manage_passwords` |
1260
+ */
1261
+ list: async <TResult extends ResultType = "json">(
1262
+ params: RequestType<ListRolesData, TResult>,
1263
+ ) => {
1264
+ return await this.request<PaginatedPostgresRole, TResult>({
1265
+ method: "GET",
1266
+ path: "/organizations/{organization}/databases/{database}/branches/{branch}/roles",
1267
+ params,
1268
+ });
1269
+ },
1270
+ /**
1271
+ * Create role credentials
1272
+ *
1273
+ * @description ### Authorization
1274
+ * A service token or OAuth token must have at least one of the following access or scopes in order to use this API endpoint:
1275
+ *
1276
+ * **Service Token Accesses**
1277
+ * `create_production_branch_password`, `create_branch_password`
1278
+ *
1279
+ * **OAuth Scopes**
1280
+ *
1281
+ * | Resource | Scopes |
1282
+ * | :------- | :---------- |
1283
+ * | Organization | `manage_passwords`, `manage_production_branch_passwords` |
1284
+ * | Database | `manage_passwords`, `manage_production_branch_passwords` |
1285
+ * | Branch | `manage_passwords` |
1286
+ */
1287
+ post: async <TResult extends ResultType = "json">(
1288
+ params: RequestType<CreateRoleData, TResult>,
1289
+ ) => {
1290
+ return await this.request<PostgresRole, TResult>({
1291
+ method: "POST",
1292
+ path: "/organizations/{organization}/databases/{database}/branches/{branch}/roles",
1293
+ params,
1294
+ });
1295
+ },
1296
+ /**
1297
+ * Get a role
1298
+ *
1299
+ * @description ### Authorization
1300
+ * A service token or OAuth token must have at least one of the following access or scopes in order to use this API endpoint:
1301
+ *
1302
+ * **Service Token Accesses**
1303
+ * `read_branch`, `delete_branch`, `create_branch`, `connect_production_branch`, `connect_branch`
1304
+ *
1305
+ * **OAuth Scopes**
1306
+ *
1307
+ * | Resource | Scopes |
1308
+ * | :------- | :---------- |
1309
+ * | Organization | `manage_passwords`, `manage_production_branch_passwords` |
1310
+ * | Database | `manage_passwords`, `manage_production_branch_passwords` |
1311
+ * | Branch | `manage_passwords` |
1312
+ */
1313
+ get: async <TResult extends ResultType = "json">(
1314
+ params: RequestType<GetRoleData, TResult>,
1315
+ ) => {
1316
+ return await this.request<PostgresRole, TResult>({
1317
+ method: "GET",
1318
+ path: "/organizations/{organization}/databases/{database}/branches/{branch}/roles/{id}",
1319
+ params,
1320
+ });
1321
+ },
1322
+ /**
1323
+ * Update role name
1324
+ *
1325
+ * @description ### Authorization
1326
+ * A service token or OAuth token must have at least one of the following access or scopes in order to use this API endpoint:
1327
+ *
1328
+ * **Service Token Accesses**
1329
+ * `create_production_branch_password`, `create_branch_password`
1330
+ *
1331
+ * **OAuth Scopes**
1332
+ *
1333
+ * | Resource | Scopes |
1334
+ * | :------- | :---------- |
1335
+ * | Organization | `manage_passwords`, `manage_production_branch_passwords` |
1336
+ * | Database | `manage_passwords`, `manage_production_branch_passwords` |
1337
+ * | Branch | `manage_passwords` |
1338
+ */
1339
+ patch: async <TResult extends ResultType = "json">(
1340
+ params: RequestType<UpdateRoleData, TResult>,
1341
+ ) => {
1342
+ return await this.request<PostgresRole, TResult>({
1343
+ method: "PATCH",
1344
+ path: "/organizations/{organization}/databases/{database}/branches/{branch}/roles/{id}",
1345
+ params,
1346
+ });
1347
+ },
1348
+ /**
1349
+ * Delete role credentials
1350
+ *
1351
+ * @description ### Authorization
1352
+ * A service token or OAuth token must have at least one of the following access or scopes in order to use this API endpoint:
1353
+ *
1354
+ * **Service Token Accesses**
1355
+ * `delete_production_branch_password`, `delete_branch_password`
1356
+ *
1357
+ * **OAuth Scopes**
1358
+ *
1359
+ * | Resource | Scopes |
1360
+ * | :------- | :---------- |
1361
+ * | Organization | `manage_passwords`, `manage_production_branch_passwords` |
1362
+ * | Database | `manage_passwords`, `manage_production_branch_passwords` |
1363
+ * | Branch | `manage_passwords` |
1364
+ */
1365
+ delete: async <TResult extends ResultType = "json">(
1366
+ params: RequestType<DeleteRoleData, TResult>,
1367
+ ) => {
1368
+ return await this.request<unknown, TResult>({
1369
+ method: "DELETE",
1370
+ path: "/organizations/{organization}/databases/{database}/branches/{branch}/roles/{id}",
1371
+ params,
1372
+ });
1373
+ },
1374
+ renew: {
1375
+ /**
1376
+ * Renew role expiration
1377
+ *
1378
+ * @description ### Authorization
1379
+ * A service token or OAuth token must have at least one of the following access or scopes in order to use this API endpoint:
1380
+ *
1381
+ * **Service Token Accesses**
1382
+ * `create_production_branch_password`, `create_branch_password`
1383
+ *
1384
+ * **OAuth Scopes**
1385
+ *
1386
+ * | Resource | Scopes |
1387
+ * | :------- | :---------- |
1388
+ * | Organization | `manage_passwords`, `manage_production_branch_passwords` |
1389
+ * | Database | `manage_passwords`, `manage_production_branch_passwords` |
1390
+ * | Branch | `manage_passwords` |
1391
+ */
1392
+ post: async <TResult extends ResultType = "json">(
1393
+ params: RequestType<RenewRoleData, TResult>,
1394
+ ) => {
1395
+ return await this.request<PostgresRole, TResult>({
1396
+ method: "POST",
1397
+ path: "/organizations/{organization}/databases/{database}/branches/{branch}/roles/{id}/renew",
1398
+ params,
1399
+ });
1400
+ },
1401
+ },
1402
+ },
1403
+ /**
1404
+ * Get a branch
1405
+ *
1406
+ * @description ### Authorization
1407
+ * A service token or OAuth token must have at least one of the following access or scopes in order to use this API endpoint:
1408
+ *
1409
+ * **Service Token Accesses**
1410
+ * `read_branch`, `delete_branch`, `create_branch`, `connect_production_branch`, `connect_branch`
1411
+ *
1412
+ * **OAuth Scopes**
1413
+ *
1414
+ * | Resource | Scopes |
1415
+ * | :------- | :---------- |
1416
+ * | Organization | `read_branches` |
1417
+ * | Database | `read_branches` |
1418
+ * | Branch | `read_branch` |
1419
+ */
1420
+ get: async <TResult extends ResultType = "json">(
1421
+ params: RequestType<GetBranchData, TResult>,
1422
+ ) => {
1423
+ return await this.request<DatabaseBranch, TResult>({
1424
+ method: "GET",
1425
+ path: "/organizations/{organization}/databases/{database}/branches/{name}",
1426
+ params,
1427
+ });
1428
+ },
1429
+ /**
1430
+ * Delete a branch
1431
+ *
1432
+ * @description ### Authorization
1433
+ * A service token or OAuth token must have at least one of the following access or scopes in order to use this API endpoint:
1434
+ *
1435
+ * **Service Token Accesses**
1436
+ * `delete_branch`
1437
+ *
1438
+ * **OAuth Scopes**
1439
+ *
1440
+ * | Resource | Scopes |
1441
+ * | :------- | :---------- |
1442
+ * | Organization | `delete_branches`, `delete_production_branches` |
1443
+ * | Database | `delete_branches`, `delete_production_branches` |
1444
+ * | Branch | `delete_branch` |
1445
+ */
1446
+ delete: async <TResult extends ResultType = "json">(
1447
+ params: RequestType<DeleteBranchData, TResult>,
1448
+ ) => {
1449
+ return await this.request<unknown, TResult>({
1450
+ method: "DELETE",
1451
+ path: "/organizations/{organization}/databases/{database}/branches/{name}",
1452
+ params,
1453
+ });
1454
+ },
1455
+ cluster: {
1456
+ /**
1457
+ * Change a branch cluster configuration
1458
+ *
1459
+ * @description ### Authorization
1460
+ * A service token must have at least one of the following access in order to use this API endpoint:
1461
+ *
1462
+ * **Service Token Accesses**
1463
+ * `write_database`
1464
+ */
1465
+ patch: async <TResult extends ResultType = "json">(
1466
+ params: RequestType<UpdateBranchClusterConfigData, TResult>,
1467
+ ) => {
1468
+ return await this.request<unknown, TResult>({
1469
+ method: "PATCH",
1470
+ path: "/organizations/{organization}/databases/{database}/branches/{name}/cluster",
1471
+ params,
1472
+ });
1473
+ },
1474
+ },
1475
+ demote: {
1476
+ /**
1477
+ * Demote a branch
1478
+ *
1479
+ * @description Demotes a branch from production to development
1480
+ * ### Authorization
1481
+ * A service token or OAuth token must have at least one of the following access or scopes in order to use this API endpoint:
1482
+ *
1483
+ * **Service Token Accesses**
1484
+ * `connect_production_branch`, `demote_branches`
1485
+ *
1486
+ * **OAuth Scopes**
1487
+ *
1488
+ * | Resource | Scopes |
1489
+ * | :------- | :---------- |
1490
+ * | Organization | `demote_branches` |
1491
+ * | Database | `demote_branches` |
1492
+ */
1493
+ post: async <TResult extends ResultType = "json">(
1494
+ params: RequestType<DemoteBranchData, TResult>,
1495
+ ) => {
1496
+ return await this.request<DatabaseBranch, TResult>({
1497
+ method: "POST",
1498
+ path: "/organizations/{organization}/databases/{database}/branches/{name}/demote",
1499
+ params,
1500
+ });
1501
+ },
1502
+ },
1503
+ promote: {
1504
+ /**
1505
+ * Promote a branch
1506
+ *
1507
+ * @description Promotes a branch from development to production
1508
+ * ### Authorization
1509
+ * A service token or OAuth token must have at least one of the following access or scopes in order to use this API endpoint:
1510
+ *
1511
+ * **Service Token Accesses**
1512
+ * `connect_production_branch`, `promote_branches`
1513
+ *
1514
+ * **OAuth Scopes**
1515
+ *
1516
+ * | Resource | Scopes |
1517
+ * | :------- | :---------- |
1518
+ * | Organization | `promote_branches` |
1519
+ * | Database | `promote_branches` |
1520
+ */
1521
+ post: async <TResult extends ResultType = "json">(
1522
+ params: RequestType<PromoteBranchData, TResult>,
1523
+ ) => {
1524
+ return await this.request<DatabaseBranch, TResult>({
1525
+ method: "POST",
1526
+ path: "/organizations/{organization}/databases/{database}/branches/{name}/promote",
1527
+ params,
1528
+ });
1529
+ },
1530
+ },
1531
+ safeMigrations: {
1532
+ /**
1533
+ * Enable safe migrations for a branch
1534
+ *
1535
+ */
1536
+ post: async <TResult extends ResultType = "json">(
1537
+ params: RequestType<EnableSafeMigrationsData, TResult>,
1538
+ ) => {
1539
+ return await this.request<DatabaseBranch, TResult>({
1540
+ method: "POST",
1541
+ path: "/organizations/{organization}/databases/{database}/branches/{name}/safe-migrations",
1542
+ params,
1543
+ });
1544
+ },
1545
+ /**
1546
+ * Disable safe migrations for a branch
1547
+ *
1548
+ */
1549
+ delete: async <TResult extends ResultType = "json">(
1550
+ params: RequestType<DisableSafeMigrationsData, TResult>,
1551
+ ) => {
1552
+ return await this.request<DatabaseBranch, TResult>({
1553
+ method: "DELETE",
1554
+ path: "/organizations/{organization}/databases/{database}/branches/{name}/safe-migrations",
1555
+ params,
1556
+ });
1557
+ },
1558
+ },
1559
+ schema: {
1560
+ /**
1561
+ * Get a branch schema
1562
+ *
1563
+ * @description ### Authorization
1564
+ * A service token or OAuth token must have at least one of the following access or scopes in order to use this API endpoint:
1565
+ *
1566
+ * **Service Token Accesses**
1567
+ * `read_branch`, `delete_branch`, `create_branch`, `connect_production_branch`, `connect_branch`
1568
+ *
1569
+ * **OAuth Scopes**
1570
+ *
1571
+ * | Resource | Scopes |
1572
+ * | :------- | :---------- |
1573
+ * | Organization | `read_branches` |
1574
+ * | Database | `read_branches` |
1575
+ * | Branch | `read_branch` |
1576
+ */
1577
+ get: async <TResult extends ResultType = "json">(
1578
+ params: RequestType<GetBranchSchemaData, TResult>,
1579
+ ) => {
1580
+ return await this.request<GetBranchSchemaResponse, TResult>({
1581
+ method: "GET",
1582
+ path: "/organizations/{organization}/databases/{database}/branches/{name}/schema",
1583
+ params,
1584
+ });
1585
+ },
1586
+ lint: {
1587
+ /**
1588
+ * Lint a branch schema
1589
+ *
1590
+ * @description ### Authorization
1591
+ * A service token or OAuth token must have at least one of the following access or scopes in order to use this API endpoint:
1592
+ *
1593
+ * **Service Token Accesses**
1594
+ * `read_branch`, `delete_branch`, `create_branch`, `connect_production_branch`, `connect_branch`
1595
+ *
1596
+ * **OAuth Scopes**
1597
+ *
1598
+ * | Resource | Scopes |
1599
+ * | :------- | :---------- |
1600
+ * | Organization | `read_branches` |
1601
+ * | Database | `read_branches` |
1602
+ * | Branch | `read_branch` |
1603
+ */
1604
+ get: async <TResult extends ResultType = "json">(
1605
+ params: RequestType<LintBranchSchemaData, TResult>,
1606
+ ) => {
1607
+ return await this.request<PaginatedSchemaLintError, TResult>({
1608
+ method: "GET",
1609
+ path: "/organizations/{organization}/databases/{database}/branches/{name}/schema/lint",
1610
+ params,
1611
+ });
1612
+ },
1613
+ },
1614
+ },
1615
+ },
1616
+ deployQueue: {
1617
+ /**
1618
+ * Get the deploy queue
1619
+ *
1620
+ * @description The deploy queue returns the current list of deploy requests in the order they will be deployed.
1621
+ */
1622
+ get: async <TResult extends ResultType = "json">(
1623
+ params: RequestType<GetDeployQueueData, TResult>,
1624
+ ) => {
1625
+ return await this.request<PaginatedDeployment, TResult>({
1626
+ method: "GET",
1627
+ path: "/organizations/{organization}/databases/{database}/deploy-queue",
1628
+ params,
1629
+ });
1630
+ },
1631
+ },
1632
+ deployRequests: {
1633
+ /**
1634
+ * List deploy requests
1635
+ *
1636
+ * @description List deploy requests for a database
1637
+ * ### Authorization
1638
+ * A service token or OAuth token must have at least one of the following access or scopes in order to use this API endpoint:
1639
+ *
1640
+ * **Service Token Accesses**
1641
+ * `read_deploy_request`
1642
+ *
1643
+ * **OAuth Scopes**
1644
+ *
1645
+ * | Resource | Scopes |
1646
+ * | :------- | :---------- |
1647
+ * | Organization | `read_deploy_requests` |
1648
+ * | Database | `read_deploy_requests` |
1649
+ */
1650
+ list: async <TResult extends ResultType = "json">(
1651
+ params: RequestType<ListDeployRequestsData, TResult>,
1652
+ ) => {
1653
+ return await this.request<PaginatedDatabaseDeployRequest, TResult>({
1654
+ method: "GET",
1655
+ path: "/organizations/{organization}/databases/{database}/deploy-requests",
1656
+ params,
1657
+ });
1658
+ },
1659
+ /**
1660
+ * Create a deploy request
1661
+ *
1662
+ * @description ### Authorization
1663
+ * A service token or OAuth token must have at least one of the following access or scopes in order to use this API endpoint:
1664
+ *
1665
+ * **Service Token Accesses**
1666
+ * `read_deploy_request`, `create_deploy_requests`
1667
+ *
1668
+ * **OAuth Scopes**
1669
+ *
1670
+ * | Resource | Scopes |
1671
+ * | :------- | :---------- |
1672
+ * | Organization | `write_deploy_requests` |
1673
+ * | Database | `write_deploy_requests` |
1674
+ */
1675
+ post: async <TResult extends ResultType = "json">(
1676
+ params: RequestType<CreateDeployRequestData, TResult>,
1677
+ ) => {
1678
+ return await this.request<DatabaseDeployRequest, TResult>({
1679
+ method: "POST",
1680
+ path: "/organizations/{organization}/databases/{database}/deploy-requests",
1681
+ params,
1682
+ });
1683
+ },
1684
+ /**
1685
+ * Get a deploy request
1686
+ *
1687
+ * @description ### Authorization
1688
+ * A service token or OAuth token must have at least one of the following access or scopes in order to use this API endpoint:
1689
+ *
1690
+ * **Service Token Accesses**
1691
+ * `read_deploy_request`
1692
+ *
1693
+ * **OAuth Scopes**
1694
+ *
1695
+ * | Resource | Scopes |
1696
+ * | :------- | :---------- |
1697
+ * | Organization | `read_deploy_requests` |
1698
+ * | Database | `read_deploy_requests` |
1699
+ */
1700
+ get: async <TResult extends ResultType = "json">(
1701
+ params: RequestType<GetDeployRequestData, TResult>,
1702
+ ) => {
1703
+ return await this.request<DatabaseDeployRequest, TResult>({
1704
+ method: "GET",
1705
+ path: "/organizations/{organization}/databases/{database}/deploy-requests/{number}",
1706
+ params,
1707
+ });
1708
+ },
1709
+ /**
1710
+ * Close a deploy request
1711
+ *
1712
+ * @description ### Authorization
1713
+ * A service token or OAuth token must have at least one of the following access or scopes in order to use this API endpoint:
1714
+ *
1715
+ * **Service Token Accesses**
1716
+ * `read_deploy_request`
1717
+ *
1718
+ * **OAuth Scopes**
1719
+ *
1720
+ * | Resource | Scopes |
1721
+ * | :------- | :---------- |
1722
+ * | Organization | `write_deploy_requests` |
1723
+ * | Database | `write_deploy_requests` |
1724
+ */
1725
+ patch: async <TResult extends ResultType = "json">(
1726
+ params: RequestType<CloseDeployRequestData, TResult>,
1727
+ ) => {
1728
+ return await this.request<DatabaseDeployRequest, TResult>({
1729
+ method: "PATCH",
1730
+ path: "/organizations/{organization}/databases/{database}/deploy-requests/{number}",
1731
+ params,
1732
+ });
1733
+ },
1734
+ applyDeploy: {
1735
+ /**
1736
+ * Complete a gated deploy request
1737
+ *
1738
+ * @description ### Authorization
1739
+ * A service token or OAuth token must have at least one of the following access or scopes in order to use this API endpoint:
1740
+ *
1741
+ * **Service Token Accesses**
1742
+ * `read_deploy_request`, `create_deploy_request`
1743
+ *
1744
+ * **OAuth Scopes**
1745
+ *
1746
+ * | Resource | Scopes |
1747
+ * | :------- | :---------- |
1748
+ * | Organization | `deploy_deploy_requests` |
1749
+ * | Database | `deploy_deploy_requests` |
1750
+ */
1751
+ post: async <TResult extends ResultType = "json">(
1752
+ params: RequestType<CompleteGatedDeployRequestData, TResult>,
1753
+ ) => {
1754
+ return await this.request<DatabaseDeployRequest, TResult>({
1755
+ method: "POST",
1756
+ path: "/organizations/{organization}/databases/{database}/deploy-requests/{number}/apply-deploy",
1757
+ params,
1758
+ });
1759
+ },
1760
+ },
1761
+ autoApply: {
1762
+ /**
1763
+ * Update auto-apply for deploy request
1764
+ *
1765
+ * @description Enables or disabled the auto-apply setting for a deploy request
1766
+ * ### Authorization
1767
+ * A service token or OAuth token must have at least one of the following access or scopes in order to use this API endpoint:
1768
+ *
1769
+ * **Service Token Accesses**
1770
+ * `read_deploy_request`, `create_deploy_request`
1771
+ *
1772
+ * **OAuth Scopes**
1773
+ *
1774
+ * | Resource | Scopes |
1775
+ * | :------- | :---------- |
1776
+ * | Organization | `deploy_deploy_requests` |
1777
+ * | Database | `deploy_deploy_requests` |
1778
+ */
1779
+ put: async <TResult extends ResultType = "json">(
1780
+ params: RequestType<UpdateAutoApplyData, TResult>,
1781
+ ) => {
1782
+ return await this.request<DatabaseDeployRequest, TResult>({
1783
+ method: "PUT",
1784
+ path: "/organizations/{organization}/databases/{database}/deploy-requests/{number}/auto-apply",
1785
+ params,
1786
+ });
1787
+ },
1788
+ },
1789
+ cancel: {
1790
+ /**
1791
+ * Cancel a queued deploy request
1792
+ *
1793
+ * @description ### Authorization
1794
+ * A service token or OAuth token must have at least one of the following access or scopes in order to use this API endpoint:
1795
+ *
1796
+ * **Service Token Accesses**
1797
+ * `read_deploy_request`, `create_deploy_request`
1798
+ *
1799
+ * **OAuth Scopes**
1800
+ *
1801
+ * | Resource | Scopes |
1802
+ * | :------- | :---------- |
1803
+ * | Organization | `deploy_deploy_requests` |
1804
+ * | Database | `deploy_deploy_requests` |
1805
+ */
1806
+ post: async <TResult extends ResultType = "json">(
1807
+ params: RequestType<CancelDeployRequestData, TResult>,
1808
+ ) => {
1809
+ return await this.request<DatabaseDeployRequest, TResult>({
1810
+ method: "POST",
1811
+ path: "/organizations/{organization}/databases/{database}/deploy-requests/{number}/cancel",
1812
+ params,
1813
+ });
1814
+ },
1815
+ },
1816
+ completeDeploy: {
1817
+ /**
1818
+ * Complete an errored deploy
1819
+ *
1820
+ * @description ### Authorization
1821
+ * A service token or OAuth token must have at least one of the following access or scopes in order to use this API endpoint:
1822
+ *
1823
+ * **Service Token Accesses**
1824
+ * `read_deploy_request`, `create_deploy_request`
1825
+ *
1826
+ * **OAuth Scopes**
1827
+ *
1828
+ * | Resource | Scopes |
1829
+ * | :------- | :---------- |
1830
+ * | Organization | `deploy_deploy_requests` |
1831
+ * | Database | `deploy_deploy_requests` |
1832
+ */
1833
+ post: async <TResult extends ResultType = "json">(
1834
+ params: RequestType<CompleteErroredDeployData, TResult>,
1835
+ ) => {
1836
+ return await this.request<DatabaseDeployRequest, TResult>({
1837
+ method: "POST",
1838
+ path: "/organizations/{organization}/databases/{database}/deploy-requests/{number}/complete-deploy",
1839
+ params,
1840
+ });
1841
+ },
1842
+ },
1843
+ deploy: {
1844
+ /**
1845
+ * Queue a deploy request
1846
+ *
1847
+ * @description ### Authorization
1848
+ * A service token or OAuth token must have at least one of the following access or scopes in order to use this API endpoint:
1849
+ *
1850
+ * **Service Token Accesses**
1851
+ * `read_deploy_request`, `create_deploy_request`
1852
+ *
1853
+ * **OAuth Scopes**
1854
+ *
1855
+ * | Resource | Scopes |
1856
+ * | :------- | :---------- |
1857
+ * | Organization | `deploy_deploy_requests` |
1858
+ * | Database | `deploy_deploy_requests` |
1859
+ */
1860
+ post: async <TResult extends ResultType = "json">(
1861
+ params: RequestType<QueueDeployRequestData, TResult>,
1862
+ ) => {
1863
+ return await this.request<DatabaseDeployRequest, TResult>({
1864
+ method: "POST",
1865
+ path: "/organizations/{organization}/databases/{database}/deploy-requests/{number}/deploy",
1866
+ params,
1867
+ });
1868
+ },
1869
+ },
1870
+ deployment: {
1871
+ /**
1872
+ * Get a deployment
1873
+ *
1874
+ * @description Get the deployment for a deploy request
1875
+ * ### Authorization
1876
+ * A service token or OAuth token must have at least one of the following access or scopes in order to use this API endpoint:
1877
+ *
1878
+ * **Service Token Accesses**
1879
+ * `read_deploy_request`
1880
+ *
1881
+ * **OAuth Scopes**
1882
+ *
1883
+ * | Resource | Scopes |
1884
+ * | :------- | :---------- |
1885
+ * | Organization | `read_deploy_requests` |
1886
+ * | Database | `read_deploy_requests` |
1887
+ */
1888
+ get: async <TResult extends ResultType = "json">(
1889
+ params: RequestType<GetDeploymentData, TResult>,
1890
+ ) => {
1891
+ return await this.request<Deployment, TResult>({
1892
+ method: "GET",
1893
+ path: "/organizations/{organization}/databases/{database}/deploy-requests/{number}/deployment",
1894
+ params,
1895
+ });
1896
+ },
1897
+ },
1898
+ operations: {
1899
+ /**
1900
+ * List deploy operations
1901
+ *
1902
+ * @description List deploy operations for a deploy request
1903
+ * ### Authorization
1904
+ * A service token or OAuth token must have at least one of the following access or scopes in order to use this API endpoint:
1905
+ *
1906
+ * **Service Token Accesses**
1907
+ * `read_deploy_request`
1908
+ *
1909
+ * **OAuth Scopes**
1910
+ *
1911
+ * | Resource | Scopes |
1912
+ * | :------- | :---------- |
1913
+ * | Organization | `read_deploy_requests` |
1914
+ * | Database | `read_deploy_requests` |
1915
+ */
1916
+ list: async <TResult extends ResultType = "json">(
1917
+ params: RequestType<ListDeployOperationsData, TResult>,
1918
+ ) => {
1919
+ return await this.request<PaginatedDeployOperation, TResult>({
1920
+ method: "GET",
1921
+ path: "/organizations/{organization}/databases/{database}/deploy-requests/{number}/operations",
1922
+ params,
1923
+ });
1924
+ },
1925
+ },
1926
+ revert: {
1927
+ /**
1928
+ * Complete a revert
1929
+ *
1930
+ * @description ### Authorization
1931
+ * A service token or OAuth token must have at least one of the following access or scopes in order to use this API endpoint:
1932
+ *
1933
+ * **Service Token Accesses**
1934
+ * `read_deploy_request`, `create_deploy_request`
1935
+ *
1936
+ * **OAuth Scopes**
1937
+ *
1938
+ * | Resource | Scopes |
1939
+ * | :------- | :---------- |
1940
+ * | Organization | `deploy_deploy_requests` |
1941
+ * | Database | `deploy_deploy_requests` |
1942
+ */
1943
+ post: async <TResult extends ResultType = "json">(
1944
+ params: RequestType<CompleteRevertData, TResult>,
1945
+ ) => {
1946
+ return await this.request<DatabaseDeployRequest, TResult>({
1947
+ method: "POST",
1948
+ path: "/organizations/{organization}/databases/{database}/deploy-requests/{number}/revert",
1949
+ params,
1950
+ });
1951
+ },
1952
+ },
1953
+ reviews: {
1954
+ /**
1955
+ * List deploy request reviews
1956
+ *
1957
+ * @description ### Authorization
1958
+ * A service token or OAuth token must have at least one of the following access or scopes in order to use this API endpoint:
1959
+ *
1960
+ * **Service Token Accesses**
1961
+ * `read_deploy_request`
1962
+ *
1963
+ * **OAuth Scopes**
1964
+ *
1965
+ * | Resource | Scopes |
1966
+ * | :------- | :---------- |
1967
+ * | Organization | `read_deploy_requests` |
1968
+ * | Database | `read_deploy_requests` |
1969
+ */
1970
+ list: async <TResult extends ResultType = "json">(
1971
+ params: RequestType<ListDeployRequestReviewsData, TResult>,
1972
+ ) => {
1973
+ return await this.request<PaginatedDeployRequestReview, TResult>({
1974
+ method: "GET",
1975
+ path: "/organizations/{organization}/databases/{database}/deploy-requests/{number}/reviews",
1976
+ params,
1977
+ });
1978
+ },
1979
+ /**
1980
+ * Review a deploy request
1981
+ *
1982
+ * @description Review a deploy request by either approving or commenting on the deploy request
1983
+ * ### Authorization
1984
+ * A service token or OAuth token must have at least one of the following access or scopes in order to use this API endpoint:
1985
+ *
1986
+ * **Service Token Accesses**
1987
+ * `approve_deploy_request`, `review_deploy_request`
1988
+ *
1989
+ * **OAuth Scopes**
1990
+ *
1991
+ * | Resource | Scopes |
1992
+ * | :------- | :---------- |
1993
+ * | Organization | `approve_deploy_requests` |
1994
+ * | Database | `approve_deploy_requests` |
1995
+ */
1996
+ post: async <TResult extends ResultType = "json">(
1997
+ params: RequestType<ReviewDeployRequestData, TResult>,
1998
+ ) => {
1999
+ return await this.request<DeployRequestReview, TResult>({
2000
+ method: "POST",
2001
+ path: "/organizations/{organization}/databases/{database}/deploy-requests/{number}/reviews",
2002
+ params,
2003
+ });
2004
+ },
2005
+ },
2006
+ skipRevert: {
2007
+ /**
2008
+ * Skip revert period
2009
+ *
2010
+ * @description Skips the revert period for a deploy request
2011
+ * ### Authorization
2012
+ * A service token or OAuth token must have at least one of the following access or scopes in order to use this API endpoint:
2013
+ *
2014
+ * **Service Token Accesses**
2015
+ * `read_deploy_request`, `create_deploy_request`
2016
+ *
2017
+ * **OAuth Scopes**
2018
+ *
2019
+ * | Resource | Scopes |
2020
+ * | :------- | :---------- |
2021
+ * | Organization | `deploy_deploy_requests` |
2022
+ * | Database | `deploy_deploy_requests` |
2023
+ */
2024
+ post: async <TResult extends ResultType = "json">(
2025
+ params: RequestType<SkipRevertPeriodData, TResult>,
2026
+ ) => {
2027
+ return await this.request<DatabaseDeployRequest, TResult>({
2028
+ method: "POST",
2029
+ path: "/organizations/{organization}/databases/{database}/deploy-requests/{number}/skip-revert",
2030
+ params,
2031
+ });
2032
+ },
2033
+ },
2034
+ throttler: {
2035
+ /**
2036
+ * Get deploy request throttler configurations
2037
+ *
2038
+ * @description ### Authorization
2039
+ * A service token or OAuth token must have at least one of the following access or scopes in order to use this API endpoint:
2040
+ *
2041
+ * **Service Token Accesses**
2042
+ * `read_deploy_request`
2043
+ *
2044
+ * **OAuth Scopes**
2045
+ *
2046
+ * | Resource | Scopes |
2047
+ * | :------- | :---------- |
2048
+ * | Organization | `read_deploy_requests` |
2049
+ * | Database | `read_deploy_requests` |
2050
+ */
2051
+ get: async <TResult extends ResultType = "json">(
2052
+ params: RequestType<GetDeployRequestThrottlerData, TResult>,
2053
+ ) => {
2054
+ return await this.request<ThrottlerConfigurations, TResult>({
2055
+ method: "GET",
2056
+ path: "/organizations/{organization}/databases/{database}/deploy-requests/{number}/throttler",
2057
+ params,
2058
+ });
2059
+ },
2060
+ /**
2061
+ * Update deploy request throttler configurations
2062
+ *
2063
+ * @description ### Authorization
2064
+ * A service token or OAuth token must have at least one of the following access or scopes in order to use this API endpoint:
2065
+ *
2066
+ * **Service Token Accesses**
2067
+ * `read_deploy_request`, `create_deploy_request`
2068
+ *
2069
+ * **OAuth Scopes**
2070
+ *
2071
+ * | Resource | Scopes |
2072
+ * | :------- | :---------- |
2073
+ * | Organization | `deploy_deploy_requests` |
2074
+ * | Database | `deploy_deploy_requests` |
2075
+ */
2076
+ patch: async <TResult extends ResultType = "json">(
2077
+ params: RequestType<UpdateDeployRequestThrottlerData, TResult>,
2078
+ ) => {
2079
+ return await this.request<ThrottlerConfigurations, TResult>({
2080
+ method: "PATCH",
2081
+ path: "/organizations/{organization}/databases/{database}/deploy-requests/{number}/throttler",
2082
+ params,
2083
+ });
2084
+ },
2085
+ },
2086
+ },
2087
+ throttler: {
2088
+ /**
2089
+ * Get database throttler configurations
2090
+ *
2091
+ * @description ### Authorization
2092
+ * A service token or OAuth token must have at least one of the following access or scopes in order to use this API endpoint:
2093
+ *
2094
+ * **Service Token Accesses**
2095
+ * `read_deploy_request`, `create_deploy_request`
2096
+ *
2097
+ * **OAuth Scopes**
2098
+ *
2099
+ * | Resource | Scopes |
2100
+ * | :------- | :---------- |
2101
+ * | Organization | `read_databases` |
2102
+ * | Database | `read_database` |
2103
+ */
2104
+ get: async <TResult extends ResultType = "json">(
2105
+ params: RequestType<GetDatabaseThrottlerData, TResult>,
2106
+ ) => {
2107
+ return await this.request<ThrottlerConfigurations, TResult>({
2108
+ method: "GET",
2109
+ path: "/organizations/{organization}/databases/{database}/throttler",
2110
+ params,
2111
+ });
2112
+ },
2113
+ /**
2114
+ * Update database throttler configurations
2115
+ *
2116
+ * @description ### Authorization
2117
+ * A service token or OAuth token must have at least one of the following access or scopes in order to use this API endpoint:
2118
+ *
2119
+ * **Service Token Accesses**
2120
+ * `read_deploy_request`, `create_deploy_request`
2121
+ *
2122
+ * **OAuth Scopes**
2123
+ *
2124
+ * | Resource | Scopes |
2125
+ * | :------- | :---------- |
2126
+ * | Organization | `deploy_deploy_requests` |
2127
+ * | Database | `deploy_deploy_requests` |
2128
+ */
2129
+ patch: async <TResult extends ResultType = "json">(
2130
+ params: RequestType<UpdateDatabaseThrottlerData, TResult>,
2131
+ ) => {
2132
+ return await this.request<ThrottlerConfigurations, TResult>({
2133
+ method: "PATCH",
2134
+ path: "/organizations/{organization}/databases/{database}/throttler",
2135
+ params,
2136
+ });
2137
+ },
2138
+ },
2139
+ webhooks: {
2140
+ /**
2141
+ * List webhooks
2142
+ *
2143
+ * @description List webhooks for a database
2144
+ * ### Authorization
2145
+ * A service token or OAuth token must have at least one of the following access or scopes in order to use this API endpoint:
2146
+ *
2147
+ * **Service Token Accesses**
2148
+ * `read_database`
2149
+ *
2150
+ * **OAuth Scopes**
2151
+ *
2152
+ * | Resource | Scopes |
2153
+ * | :------- | :---------- |
2154
+ * | Organization | `read_databases` |
2155
+ * | Database | `read_database` |
2156
+ */
2157
+ list: async <TResult extends ResultType = "json">(
2158
+ params: RequestType<ListWebhooksData, TResult>,
2159
+ ) => {
2160
+ return await this.request<PaginatedDatabaseWebhook, TResult>({
2161
+ method: "GET",
2162
+ path: "/organizations/{organization}/databases/{database}/webhooks",
2163
+ params,
2164
+ });
2165
+ },
2166
+ /**
2167
+ * Create a webhook
2168
+ *
2169
+ * @description ### Authorization
2170
+ * A service token or OAuth token must have at least one of the following access or scopes in order to use this API endpoint:
2171
+ *
2172
+ * **Service Token Accesses**
2173
+ * `write_database`
2174
+ *
2175
+ * **OAuth Scopes**
2176
+ *
2177
+ * | Resource | Scopes |
2178
+ * | :------- | :---------- |
2179
+ * | Organization | `write_databases` |
2180
+ * | Database | `write_database` |
2181
+ */
2182
+ post: async <TResult extends ResultType = "json">(
2183
+ params: RequestType<CreateWebhookData, TResult>,
2184
+ ) => {
2185
+ return await this.request<DatabaseWebhook, TResult>({
2186
+ method: "POST",
2187
+ path: "/organizations/{organization}/databases/{database}/webhooks",
2188
+ params,
2189
+ });
2190
+ },
2191
+ /**
2192
+ * Get a webhook
2193
+ *
2194
+ * @description ### Authorization
2195
+ * A service token or OAuth token must have at least one of the following access or scopes in order to use this API endpoint:
2196
+ *
2197
+ * **Service Token Accesses**
2198
+ * `read_database`
2199
+ *
2200
+ * **OAuth Scopes**
2201
+ *
2202
+ * | Resource | Scopes |
2203
+ * | :------- | :---------- |
2204
+ * | Organization | `read_databases` |
2205
+ * | Database | `read_database` |
2206
+ */
2207
+ get: async <TResult extends ResultType = "json">(
2208
+ params: RequestType<GetWebhookData, TResult>,
2209
+ ) => {
2210
+ return await this.request<DatabaseWebhook, TResult>({
2211
+ method: "GET",
2212
+ path: "/organizations/{organization}/databases/{database}/webhooks/{id}",
2213
+ params,
2214
+ });
2215
+ },
2216
+ /**
2217
+ * Update a webhook
2218
+ *
2219
+ * @description ### Authorization
2220
+ * A service token or OAuth token must have at least one of the following access or scopes in order to use this API endpoint:
2221
+ *
2222
+ * **Service Token Accesses**
2223
+ * `write_database`
2224
+ *
2225
+ * **OAuth Scopes**
2226
+ *
2227
+ * | Resource | Scopes |
2228
+ * | :------- | :---------- |
2229
+ * | Organization | `write_databases` |
2230
+ * | Database | `write_database` |
2231
+ */
2232
+ patch: async <TResult extends ResultType = "json">(
2233
+ params: RequestType<UpdateWebhookData, TResult>,
2234
+ ) => {
2235
+ return await this.request<DatabaseWebhook, TResult>({
2236
+ method: "PATCH",
2237
+ path: "/organizations/{organization}/databases/{database}/webhooks/{id}",
2238
+ params,
2239
+ });
2240
+ },
2241
+ /**
2242
+ * Delete a webhook
2243
+ *
2244
+ * @description ### Authorization
2245
+ * A service token or OAuth token must have at least one of the following access or scopes in order to use this API endpoint:
2246
+ *
2247
+ * **Service Token Accesses**
2248
+ * `write_database`
2249
+ *
2250
+ * **OAuth Scopes**
2251
+ *
2252
+ * | Resource | Scopes |
2253
+ * | :------- | :---------- |
2254
+ * | Organization | `write_databases` |
2255
+ * | Database | `write_database` |
2256
+ */
2257
+ delete: async <TResult extends ResultType = "json">(
2258
+ params: RequestType<DeleteWebhookData, TResult>,
2259
+ ) => {
2260
+ return await this.request<unknown, TResult>({
2261
+ method: "DELETE",
2262
+ path: "/organizations/{organization}/databases/{database}/webhooks/{id}",
2263
+ params,
2264
+ });
2265
+ },
2266
+ test: {
2267
+ /**
2268
+ * Test a webhook
2269
+ *
2270
+ * @description Sends a test event to the webhook
2271
+ * ### Authorization
2272
+ * A service token or OAuth token must have at least one of the following access or scopes in order to use this API endpoint:
2273
+ *
2274
+ * **Service Token Accesses**
2275
+ * `write_database`
2276
+ *
2277
+ * **OAuth Scopes**
2278
+ *
2279
+ * | Resource | Scopes |
2280
+ * | :------- | :---------- |
2281
+ * | Organization | `write_databases` |
2282
+ * | Database | `write_database` |
2283
+ */
2284
+ post: async <TResult extends ResultType = "json">(
2285
+ params: RequestType<TestWebhookData, TResult>,
2286
+ ) => {
2287
+ return await this.request<unknown, TResult>({
2288
+ method: "POST",
2289
+ path: "/organizations/{organization}/databases/{database}/webhooks/{id}/test",
2290
+ params,
2291
+ });
2292
+ },
2293
+ },
2294
+ },
2295
+ workflows: {
2296
+ /**
2297
+ * List workflows
2298
+ *
2299
+ */
2300
+ list: async <TResult extends ResultType = "json">(
2301
+ params: RequestType<ListWorkflowsData, TResult>,
2302
+ ) => {
2303
+ return await this.request<PaginatedWorkflow, TResult>({
2304
+ method: "GET",
2305
+ path: "/organizations/{organization}/databases/{database}/workflows",
2306
+ params,
2307
+ });
2308
+ },
2309
+ /**
2310
+ * Create a workflow
2311
+ *
2312
+ */
2313
+ post: async <TResult extends ResultType = "json">(
2314
+ params: RequestType<CreateWorkflowData, TResult>,
2315
+ ) => {
2316
+ return await this.request<Workflow, TResult>({
2317
+ method: "POST",
2318
+ path: "/organizations/{organization}/databases/{database}/workflows",
2319
+ params,
2320
+ });
2321
+ },
2322
+ /**
2323
+ * Get a workflow
2324
+ *
2325
+ */
2326
+ get: async <TResult extends ResultType = "json">(
2327
+ params: RequestType<GetWorkflowData, TResult>,
2328
+ ) => {
2329
+ return await this.request<Workflow, TResult>({
2330
+ method: "GET",
2331
+ path: "/organizations/{organization}/databases/{database}/workflows/{number}",
2332
+ params,
2333
+ });
2334
+ },
2335
+ /**
2336
+ * Cancel a workflow
2337
+ *
2338
+ */
2339
+ delete: async <TResult extends ResultType = "json">(
2340
+ params: RequestType<WorkflowCancelData, TResult>,
2341
+ ) => {
2342
+ return await this.request<Workflow, TResult>({
2343
+ method: "DELETE",
2344
+ path: "/organizations/{organization}/databases/{database}/workflows/{number}",
2345
+ params,
2346
+ });
2347
+ },
2348
+ complete: {
2349
+ /**
2350
+ * Complete a workflow
2351
+ *
2352
+ */
2353
+ patch: async <TResult extends ResultType = "json">(
2354
+ params: RequestType<WorkflowCompleteData, TResult>,
2355
+ ) => {
2356
+ return await this.request<Workflow, TResult>({
2357
+ method: "PATCH",
2358
+ path: "/organizations/{organization}/databases/{database}/workflows/{number}/complete",
2359
+ params,
2360
+ });
2361
+ },
2362
+ },
2363
+ cutover: {
2364
+ /**
2365
+ * Cutover traffic
2366
+ *
2367
+ */
2368
+ patch: async <TResult extends ResultType = "json">(
2369
+ params: RequestType<WorkflowCutoverData, TResult>,
2370
+ ) => {
2371
+ return await this.request<Workflow, TResult>({
2372
+ method: "PATCH",
2373
+ path: "/organizations/{organization}/databases/{database}/workflows/{number}/cutover",
2374
+ params,
2375
+ });
2376
+ },
2377
+ },
2378
+ retry: {
2379
+ /**
2380
+ * Retry a failed workflow
2381
+ *
2382
+ */
2383
+ patch: async <TResult extends ResultType = "json">(
2384
+ params: RequestType<WorkflowRetryData, TResult>,
2385
+ ) => {
2386
+ return await this.request<Workflow, TResult>({
2387
+ method: "PATCH",
2388
+ path: "/organizations/{organization}/databases/{database}/workflows/{number}/retry",
2389
+ params,
2390
+ });
2391
+ },
2392
+ },
2393
+ reverseCutover: {
2394
+ /**
2395
+ * Reverse traffic cutover
2396
+ *
2397
+ */
2398
+ patch: async <TResult extends ResultType = "json">(
2399
+ params: RequestType<WorkflowReverseCutoverData, TResult>,
2400
+ ) => {
2401
+ return await this.request<Workflow, TResult>({
2402
+ method: "PATCH",
2403
+ path: "/organizations/{organization}/databases/{database}/workflows/{number}/reverse-cutover",
2404
+ params,
2405
+ });
2406
+ },
2407
+ },
2408
+ reverseTraffic: {
2409
+ /**
2410
+ * Reverse traffic
2411
+ *
2412
+ */
2413
+ patch: async <TResult extends ResultType = "json">(
2414
+ params: RequestType<WorkflowReverseTrafficData, TResult>,
2415
+ ) => {
2416
+ return await this.request<Workflow, TResult>({
2417
+ method: "PATCH",
2418
+ path: "/organizations/{organization}/databases/{database}/workflows/{number}/reverse-traffic",
2419
+ params,
2420
+ });
2421
+ },
2422
+ },
2423
+ switchPrimaries: {
2424
+ /**
2425
+ * Switch primary traffic
2426
+ *
2427
+ */
2428
+ patch: async <TResult extends ResultType = "json">(
2429
+ params: RequestType<WorkflowSwitchPrimariesData, TResult>,
2430
+ ) => {
2431
+ return await this.request<Workflow, TResult>({
2432
+ method: "PATCH",
2433
+ path: "/organizations/{organization}/databases/{database}/workflows/{number}/switch-primaries",
2434
+ params,
2435
+ });
2436
+ },
2437
+ },
2438
+ switchReplicas: {
2439
+ /**
2440
+ * Switch replica traffic
2441
+ *
2442
+ */
2443
+ patch: async <TResult extends ResultType = "json">(
2444
+ params: RequestType<WorkflowSwitchReplicasData, TResult>,
2445
+ ) => {
2446
+ return await this.request<Workflow, TResult>({
2447
+ method: "PATCH",
2448
+ path: "/organizations/{organization}/databases/{database}/workflows/{number}/switch-replicas",
2449
+ params,
2450
+ });
2451
+ },
2452
+ },
2453
+ verifyData: {
2454
+ /**
2455
+ * Verify workflow data
2456
+ *
2457
+ */
2458
+ patch: async <TResult extends ResultType = "json">(
2459
+ params: RequestType<VerifyWorkflowData, TResult>,
2460
+ ) => {
2461
+ return await this.request<Workflow, TResult>({
2462
+ method: "PATCH",
2463
+ path: "/organizations/{organization}/databases/{database}/workflows/{number}/verify-data",
2464
+ params,
2465
+ });
2466
+ },
2467
+ },
2468
+ },
2469
+ /**
2470
+ * Get a database
2471
+ *
2472
+ * @description ### Authorization
2473
+ * A service token or OAuth token must have at least one of the following access or scopes in order to use this API endpoint:
2474
+ *
2475
+ * **Service Token Accesses**
2476
+ * `read_database`, `delete_database`, `write_database`, `read_branch`, `delete_branch`, `create_branch`, `delete_production_branch`, `connect_branch`, `connect_production_branch`, `delete_branch_password`, `delete_production_branch_password`, `read_deploy_request`, `create_deploy_request`, `approve_deploy_request`, `read_schema_recommendations`, `close_schema_recommendations`, `read_comment`, `create_comment`, `restore_backup`, `restore_production_branch_backup`, `read_backups`, `write_backups`, `delete_backups`, `delete_production_branch_backups`, `write_branch_vschema`, `write_production_branch_vschema`
2477
+ *
2478
+ * **OAuth Scopes**
2479
+ *
2480
+ * | Resource | Scopes |
2481
+ * | :------- | :---------- |
2482
+ * | Organization | `read_databases` |
2483
+ * | Database | `read_database` |
2484
+ */
2485
+ get: async <TResult extends ResultType = "json">(
2486
+ params: RequestType<GetDatabaseData, TResult>,
2487
+ ) => {
2488
+ return await this.request<Database, TResult>({
2489
+ method: "GET",
2490
+ path: "/organizations/{organization}/databases/{name}",
2491
+ params,
2492
+ });
2493
+ },
2494
+ /**
2495
+ * Update database settings
2496
+ *
2497
+ * @description ### Authorization
2498
+ * A service token or OAuth token must have at least one of the following access or scopes in order to use this API endpoint:
2499
+ *
2500
+ * **Service Token Accesses**
2501
+ * `write_database`
2502
+ *
2503
+ * **OAuth Scopes**
2504
+ *
2505
+ * | Resource | Scopes |
2506
+ * | :------- | :---------- |
2507
+ * | Organization | `write_databases` |
2508
+ * | Database | `write_database` |
2509
+ */
2510
+ patch: async <TResult extends ResultType = "json">(
2511
+ params: RequestType<UpdateDatabaseSettingsData, TResult>,
2512
+ ) => {
2513
+ return await this.request<Database, TResult>({
2514
+ method: "PATCH",
2515
+ path: "/organizations/{organization}/databases/{name}",
2516
+ params,
2517
+ });
2518
+ },
2519
+ /**
2520
+ * Delete a database
2521
+ *
2522
+ * @description ### Authorization
2523
+ * A service token or OAuth token must have at least one of the following access or scopes in order to use this API endpoint:
2524
+ *
2525
+ * **Service Token Accesses**
2526
+ * `delete_database`
2527
+ *
2528
+ * **OAuth Scopes**
2529
+ *
2530
+ * | Resource | Scopes |
2531
+ * | :------- | :---------- |
2532
+ * | Organization | `delete_databases` |
2533
+ * | Database | `delete_database` |
2534
+ */
2535
+ delete: async <TResult extends ResultType = "json">(
2536
+ params: RequestType<DeleteDatabaseData, TResult>,
2537
+ ) => {
2538
+ return await this.request<unknown, TResult>({
2539
+ method: "DELETE",
2540
+ path: "/organizations/{organization}/databases/{name}",
2541
+ params,
2542
+ });
2543
+ },
2544
+ readOnlyRegions: {
2545
+ /**
2546
+ * List read-only regions
2547
+ *
2548
+ * @description List read-only regions for the database's default branch
2549
+ * ### Authorization
2550
+ * A service token or OAuth token must have at least one of the following access or scopes in order to use this API endpoint:
2551
+ *
2552
+ * **Service Token Accesses**
2553
+ * `read_database`, `delete_database`, `write_database`, `read_branch`, `delete_branch`, `create_branch`, `delete_production_branch`, `connect_branch`, `connect_production_branch`, `delete_branch_password`, `delete_production_branch_password`, `read_deploy_request`, `create_deploy_request`, `approve_deploy_request`, `read_schema_recommendations`, `close_schema_recommendations`, `read_comment`, `create_comment`, `restore_backup`, `restore_production_branch_backup`, `read_backups`, `write_backups`, `delete_backups`, `delete_production_branch_backups`, `write_branch_vschema`, `write_production_branch_vschema`
2554
+ *
2555
+ * **OAuth Scopes**
2556
+ *
2557
+ * | Resource | Scopes |
2558
+ * | :------- | :---------- |
2559
+ * | Organization | `read_branches` |
2560
+ * | Database | `read_branches` |
2561
+ */
2562
+ list: async <TResult extends ResultType = "json">(
2563
+ params: RequestType<ListReadOnlyRegionsData, TResult>,
2564
+ ) => {
2565
+ return await this.request<
2566
+ PaginatedDatabaseBranchReadOnlyRegion,
2567
+ TResult
2568
+ >({
2569
+ method: "GET",
2570
+ path: "/organizations/{organization}/databases/{name}/read-only-regions",
2571
+ params,
2572
+ });
2573
+ },
2574
+ },
2575
+ regions: {
2576
+ /**
2577
+ * List database regions
2578
+ *
2579
+ * @description ### Authorization
2580
+ * A service token or OAuth token must have at least one of the following access or scopes in order to use this API endpoint:
2581
+ *
2582
+ * **Service Token Accesses**
2583
+ * `read_database`, `delete_database`, `write_database`, `read_branch`, `delete_branch`, `create_branch`, `delete_production_branch`, `connect_branch`, `connect_production_branch`, `delete_branch_password`, `delete_production_branch_password`, `read_deploy_request`, `create_deploy_request`, `approve_deploy_request`, `read_schema_recommendations`, `close_schema_recommendations`, `read_comment`, `create_comment`, `restore_backup`, `restore_production_branch_backup`, `read_backups`, `write_backups`, `delete_backups`, `delete_production_branch_backups`, `write_branch_vschema`, `write_production_branch_vschema`
2584
+ *
2585
+ * **OAuth Scopes**
2586
+ *
2587
+ * | Resource | Scopes |
2588
+ * | :------- | :---------- |
2589
+ * | Organization | `read_databases` |
2590
+ * | Database | `read_database` |
2591
+ */
2592
+ list: async <TResult extends ResultType = "json">(
2593
+ params: RequestType<ListDatabaseRegionsData, TResult>,
2594
+ ) => {
2595
+ return await this.request<PaginatedPlanetscaleRegion, TResult>({
2596
+ method: "GET",
2597
+ path: "/organizations/{organization}/databases/{name}/regions",
2598
+ params,
2599
+ });
2600
+ },
2601
+ },
2602
+ },
2603
+ invoices: {
2604
+ /**
2605
+ * Get invoices
2606
+ *
2607
+ * @description Get the invoices for an organization
2608
+ * ### Authorization
2609
+ * A service token or OAuth token must have at least one of the following access or scopes in order to use this API endpoint:
2610
+ *
2611
+ * **Service Token Accesses**
2612
+ * `read_invoices`
2613
+ *
2614
+ * **OAuth Scopes**
2615
+ *
2616
+ * | Resource | Scopes |
2617
+ * | :------- | :---------- |
2618
+ * | Organization | `read_invoices` |
2619
+ */
2620
+ list: async <TResult extends ResultType = "json">(
2621
+ params: RequestType<ListInvoicesData, TResult>,
2622
+ ) => {
2623
+ return await this.request<PaginatedInvoice, TResult>({
2624
+ method: "GET",
2625
+ path: "/organizations/{organization}/invoices",
2626
+ params,
2627
+ });
2628
+ },
2629
+ /**
2630
+ * Get an invoice
2631
+ *
2632
+ * @description ### Authorization
2633
+ * A service token or OAuth token must have at least one of the following access or scopes in order to use this API endpoint:
2634
+ *
2635
+ * **Service Token Accesses**
2636
+ * `read_invoices`
2637
+ *
2638
+ * **OAuth Scopes**
2639
+ *
2640
+ * | Resource | Scopes |
2641
+ * | :------- | :---------- |
2642
+ * | Organization | `read_invoices` |
2643
+ */
2644
+ get: async <TResult extends ResultType = "json">(
2645
+ params: RequestType<GetInvoiceData, TResult>,
2646
+ ) => {
2647
+ return await this.request<Invoice, TResult>({
2648
+ method: "GET",
2649
+ path: "/organizations/{organization}/invoices/{id}",
2650
+ params,
2651
+ });
2652
+ },
2653
+ lineItems: {
2654
+ /**
2655
+ * Get invoice line items
2656
+ *
2657
+ * @description Get the line items for an invoice
2658
+ * ### Authorization
2659
+ * A service token or OAuth token must have at least one of the following access or scopes in order to use this API endpoint:
2660
+ *
2661
+ * **Service Token Accesses**
2662
+ * `read_invoices`
2663
+ *
2664
+ * **OAuth Scopes**
2665
+ *
2666
+ * | Resource | Scopes |
2667
+ * | :------- | :---------- |
2668
+ * | Organization | `read_invoices` |
2669
+ */
2670
+ get: async <TResult extends ResultType = "json">(
2671
+ params: RequestType<GetInvoiceLineItemsData, TResult>,
2672
+ ) => {
2673
+ return await this.request<PaginatedLineItem, TResult>({
2674
+ method: "GET",
2675
+ path: "/organizations/{organization}/invoices/{id}/line-items",
2676
+ params,
2677
+ });
2678
+ },
2679
+ },
2680
+ },
2681
+ members: {
2682
+ /**
2683
+ * List organization members
2684
+ *
2685
+ * @description ### Authorization
2686
+ * A service token must have at least one of the following access in order to use this API endpoint:
2687
+ *
2688
+ * **Service Token Accesses**
2689
+ * `read_organization`
2690
+ */
2691
+ list: async <TResult extends ResultType = "json">(
2692
+ params: RequestType<ListOrganizationMembersData, TResult>,
2693
+ ) => {
2694
+ return await this.request<PaginatedOrganizationMembership, TResult>({
2695
+ method: "GET",
2696
+ path: "/organizations/{organization}/members",
2697
+ params,
2698
+ });
2699
+ },
2700
+ },
2701
+ oauthApplications: {
2702
+ /**
2703
+ * List OAuth applications
2704
+ *
2705
+ * @description ### Authorization
2706
+ * A service token must have at least one of the following access in order to use this API endpoint:
2707
+ *
2708
+ * **Service Token Accesses**
2709
+ * `read_oauth_applications`
2710
+ */
2711
+ list: async <TResult extends ResultType = "json">(
2712
+ params: RequestType<ListOauthApplicationsData, TResult>,
2713
+ ) => {
2714
+ return await this.request<PaginatedOauthApplication, TResult>({
2715
+ method: "GET",
2716
+ path: "/organizations/{organization}/oauth-applications",
2717
+ params,
2718
+ });
2719
+ },
2720
+ /**
2721
+ * Get an OAuth application
2722
+ *
2723
+ * @description ### Authorization
2724
+ * A service token must have at least one of the following access in order to use this API endpoint:
2725
+ *
2726
+ * **Service Token Accesses**
2727
+ * `read_oauth_applications`
2728
+ */
2729
+ get: async <TResult extends ResultType = "json">(
2730
+ params: RequestType<GetOauthApplicationData, TResult>,
2731
+ ) => {
2732
+ return await this.request<OauthApplication, TResult>({
2733
+ method: "GET",
2734
+ path: "/organizations/{organization}/oauth-applications/{application_id}",
2735
+ params,
2736
+ });
2737
+ },
2738
+ tokens: {
2739
+ /**
2740
+ * List OAuth tokens
2741
+ *
2742
+ * @description List OAuth tokens created by an OAuth application
2743
+ * ### Authorization
2744
+ * A service token must have at least one of the following access in order to use this API endpoint:
2745
+ *
2746
+ * **Service Token Accesses**
2747
+ * `read_oauth_tokens`
2748
+ */
2749
+ list: async <TResult extends ResultType = "json">(
2750
+ params: RequestType<ListOauthTokensData, TResult>,
2751
+ ) => {
2752
+ return await this.request<PaginatedServiceToken, TResult>({
2753
+ method: "GET",
2754
+ path: "/organizations/{organization}/oauth-applications/{application_id}/tokens",
2755
+ params,
2756
+ });
2757
+ },
2758
+ /**
2759
+ * Get an OAuth token
2760
+ *
2761
+ * @description ### Authorization
2762
+ * A service token must have at least one of the following access in order to use this API endpoint:
2763
+ *
2764
+ * **Service Token Accesses**
2765
+ * `read_oauth_tokens`
2766
+ */
2767
+ get: async <TResult extends ResultType = "json">(
2768
+ params: RequestType<GetOauthTokenData, TResult>,
2769
+ ) => {
2770
+ return await this.request<ServiceToken, TResult>({
2771
+ method: "GET",
2772
+ path: "/organizations/{organization}/oauth-applications/{application_id}/tokens/{token_id}",
2773
+ params,
2774
+ });
2775
+ },
2776
+ /**
2777
+ * Delete an OAuth token
2778
+ *
2779
+ * @description ### Authorization
2780
+ * A service token must have at least one of the following access in order to use this API endpoint:
2781
+ *
2782
+ * **Service Token Accesses**
2783
+ * `delete_oauth_tokens`
2784
+ */
2785
+ delete: async <TResult extends ResultType = "json">(
2786
+ params: RequestType<DeleteOauthTokenData, TResult>,
2787
+ ) => {
2788
+ return await this.request<unknown, TResult>({
2789
+ method: "DELETE",
2790
+ path: "/organizations/{organization}/oauth-applications/{application_id}/tokens/{token_id}",
2791
+ params,
2792
+ });
2793
+ },
2794
+ },
2795
+ token: {
2796
+ /**
2797
+ * Create or renew an OAuth token
2798
+ *
2799
+ * @description Create an OAuth token from an authorization grant code, or refresh an OAuth token from a refresh token
2800
+ * ### Authorization
2801
+ * A service token must have at least one of the following access in order to use this API endpoint:
2802
+ *
2803
+ * **Service Token Accesses**
2804
+ * `write_oauth_tokens`
2805
+ */
2806
+ post: async <TResult extends ResultType = "json">(
2807
+ params: RequestType<CreateOauthTokenData, TResult>,
2808
+ ) => {
2809
+ return await this.request<ServiceToken, TResult>({
2810
+ method: "POST",
2811
+ path: "/organizations/{organization}/oauth-applications/{id}/token",
2812
+ params,
2813
+ });
2814
+ },
2815
+ },
2816
+ },
2817
+ };
2818
+ regions = {
2819
+ /**
2820
+ * List public regions
2821
+ *
2822
+ * @description Endpoint is available without authentication.
2823
+ */
2824
+ list: async <TResult extends ResultType = "json">(
2825
+ params?: RequestType<ListPublicRegionsData, TResult>,
2826
+ ) => {
2827
+ return await this.request<
2828
+ PaginatedPublicPlanetscaleRegionSerializer,
2829
+ TResult
2830
+ >({
2831
+ method: "GET",
2832
+ path: "/regions",
2833
+ params,
2834
+ });
2835
+ },
2836
+ };
2837
+ user = {
2838
+ /**
2839
+ * Get current user
2840
+ *
2841
+ * @description Get the user associated with this service token
2842
+ * ### Authorization
2843
+ * A OAuth token must have at least one of the following scopes in order to use this API endpoint:
2844
+ *
2845
+ * **OAuth Scopes**
2846
+ *
2847
+ * | Resource | Scopes |
2848
+ * | :------- | :---------- |
2849
+ * | User | `read_user` |
2850
+ */
2851
+ get: async <TResult extends ResultType = "json">(
2852
+ params?: RequestType<GetCurrentUserData, TResult>,
2853
+ ) => {
2854
+ return await this.request<User, TResult>({
2855
+ method: "GET",
2856
+ path: "/user",
2857
+ params,
2858
+ });
2859
+ },
2860
+ };
2861
+ }
2862
+
2863
+ const formatURL = (input: {
2864
+ url: string;
2865
+ path?: Record<string, string>;
2866
+ query?: Record<string, string | number | boolean>;
2867
+ }) => {
2868
+ const url = new URL(
2869
+ input.url.replaceAll(/{(\w+)}/g, (_, key) => {
2870
+ if (!input.path?.[key]) {
2871
+ throw new Error(`Missing required parameter: ${key}`);
2872
+ }
2873
+ return input.path[key];
2874
+ }),
2875
+ );
2876
+ if (input.query) {
2877
+ for (const [key, value] of Object.entries(input.query)) {
2878
+ url.searchParams.set(key, value.toString());
2879
+ }
2880
+ }
2881
+ return url.toString();
2882
+ };