@databricks/sdk-oauth 0.0.0-dev → 0.1.0-dev.1

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.
@@ -0,0 +1,113 @@
1
+ // Code generated from API definition by Databricks SDK Generator. DO NOT EDIT.
2
+ import { execute } from '@databricks/sdk-core/api';
3
+ import { ApiError } from '@databricks/sdk-core/apierror';
4
+ import JSONBig from 'json-bigint';
5
+ // JSON codec that preserves int64 precision. On the way in, large integer
6
+ // literals come back as bigint instead of being rounded to JS Number. On the
7
+ // way out, bigint values are emitted as raw JSON number digits.
8
+ const jsonBigint = JSONBig({ useNativeBigInt: true });
9
+ /**
10
+ * Translates public CallOptions to the internal Options shape accepted by
11
+ * execute(). Even though the shapes match today, this isolates the public
12
+ * API from the executor's internal type so they can diverge.
13
+ */
14
+ export async function executeCall(call, options) {
15
+ const opts = {
16
+ ...(options?.retrier !== undefined && { retrier: options.retrier }),
17
+ ...(options?.rateLimiter !== undefined && {
18
+ rateLimiter: options.rateLimiter,
19
+ }),
20
+ ...(options?.timeout !== undefined && { timeout: options.timeout }),
21
+ };
22
+ return execute(options?.signal, call, opts);
23
+ }
24
+ async function readAll(body) {
25
+ if (body === null) {
26
+ return new Uint8Array(0);
27
+ }
28
+ const reader = body.getReader();
29
+ const chunks = [];
30
+ for (;;) {
31
+ const { done, value } = await reader.read();
32
+ if (done) {
33
+ break;
34
+ }
35
+ chunks.push(value);
36
+ }
37
+ const totalLength = chunks.reduce((acc, chunk) => acc + chunk.length, 0);
38
+ const result = new Uint8Array(totalLength);
39
+ let offset = 0;
40
+ for (const chunk of chunks) {
41
+ result.set(chunk, offset);
42
+ offset += chunk.length;
43
+ }
44
+ return result;
45
+ }
46
+ export async function executeHttpCall(opts) {
47
+ opts.logger.debug('HTTP request', {
48
+ method: opts.request.method,
49
+ url: opts.request.url,
50
+ });
51
+ let resp;
52
+ try {
53
+ resp = await opts.httpClient.send(opts.request);
54
+ }
55
+ catch (e) {
56
+ opts.logger.debug('HTTP request failed');
57
+ throw e;
58
+ }
59
+ const body = await readAll(resp.body);
60
+ opts.logger.debug('HTTP response', {
61
+ statusCode: resp.statusCode,
62
+ body: new TextDecoder().decode(body),
63
+ });
64
+ const apiErr = ApiError.fromHttpError(resp.statusCode, resp.headers, body);
65
+ if (apiErr !== undefined) {
66
+ throw apiErr;
67
+ }
68
+ return body;
69
+ }
70
+ export function buildHttpRequest(method, url, headers, signal, body) {
71
+ const req = { url, method, headers };
72
+ if (body !== undefined) {
73
+ req.body = body;
74
+ }
75
+ if (signal !== undefined) {
76
+ req.signal = signal;
77
+ }
78
+ return req;
79
+ }
80
+ export function parseResponse(body, schema) {
81
+ const text = new TextDecoder().decode(body);
82
+ const parsed = jsonBigint.parse(text);
83
+ return schema.parse(parsed);
84
+ }
85
+ export function marshalRequest(data, schema) {
86
+ return jsonBigint.stringify(schema.parse(data));
87
+ }
88
+ export function flattenQueryParams(prefix, value, params) {
89
+ if (value === null || value === undefined) {
90
+ return;
91
+ }
92
+ if (Array.isArray(value)) {
93
+ // arrays of objects are not yet supported
94
+ for (const item of value) {
95
+ params.append(prefix, String(item));
96
+ }
97
+ }
98
+ else if (typeof value === 'object') {
99
+ for (const [key, val] of Object.entries(value)) {
100
+ flattenQueryParams(`${prefix}.${key}`, val, params);
101
+ }
102
+ }
103
+ else if (typeof value === 'string' ||
104
+ typeof value === 'number' ||
105
+ typeof value === 'boolean' ||
106
+ typeof value === 'bigint') {
107
+ params.append(prefix, String(value));
108
+ }
109
+ else {
110
+ throw new Error(`Unsupported query parameter type: ${typeof value}`);
111
+ }
112
+ }
113
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/v1/utils.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAG/E,OAAO,EAAC,OAAO,EAAC,MAAM,0BAA0B,CAAC;AACjD,OAAO,EAAC,QAAQ,EAAC,MAAM,+BAA+B,CAAC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M,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QACrC,KAAK,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAgC,CAAC,EAAE,CAAC;YAC1E,kBAAkB,CAAC,GAAG,MAAM,IAAI,GAAG,EAAE,EAAE,GAAG,EAAE,MAAM,CAAC,CAAC;QACtD,CAAC;IACH,CAAC;SAAM,IACL,OAAO,KAAK,KAAK,QAAQ;QACzB,OAAO,KAAK,KAAK,QAAQ;QACzB,OAAO,KAAK,KAAK,SAAS;QAC1B,OAAO,KAAK,KAAK,QAAQ,EACzB,CAAC;QACD,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;IACvC,CAAC;SAAM,CAAC;QACN,MAAM,IAAI,KAAK,CAAC,qCAAqC,OAAO,KAAK,EAAE,CAAC,CAAC;IACvE,CAAC;AACH,CAAC"}
package/package.json CHANGED
@@ -1,7 +1,41 @@
1
1
  {
2
2
  "name": "@databricks/sdk-oauth",
3
- "version": "0.0.0-dev",
4
- "description": "Bootstrap placeholder; real contents in a later release.",
5
- "main": "index.js",
6
- "license": "Apache-2.0"
3
+ "version": "0.1.0-dev.1",
4
+ "description": "",
5
+ "type": "module",
6
+ "exports": {
7
+ "./v1": {
8
+ "types": "./dist/v1/index.d.ts",
9
+ "import": "./dist/v1/index.js"
10
+ }
11
+ },
12
+ "files": [
13
+ "dist",
14
+ "src",
15
+ "LICENSE"
16
+ ],
17
+ "scripts": {
18
+ "build": "tsc -b",
19
+ "lint": "eslint src --ext .ts",
20
+ "lint:fix": "eslint src --ext .ts --fix",
21
+ "format": "prettier --write \"src/**/*.ts\"",
22
+ "format:check": "prettier --check \"src/**/*.ts\"",
23
+ "typecheck": "tsc --noEmit",
24
+ "clean": "rm -rf dist tsconfig.tsbuildinfo",
25
+ "test": "echo 'no tests'",
26
+ "test:browser": "echo 'no tests'"
27
+ },
28
+ "author": "Databricks",
29
+ "license": "Apache-2.0",
30
+ "dependencies": {
31
+ "@databricks/sdk-auth": ">=0.1.0-dev.2 <1.0.0",
32
+ "@databricks/sdk-core": ">=0.1.0-dev.3 <1.0.0",
33
+ "@databricks/sdk-options": ">=0.1.0-dev.2 <1.0.0",
34
+ "@js-temporal/polyfill": "^0.5.0",
35
+ "json-bigint": "^1.0.0",
36
+ "zod": "^4.3.6"
37
+ },
38
+ "engines": {
39
+ "node": ">=22.0.0"
40
+ }
7
41
  }
@@ -0,0 +1,523 @@
1
+ // Code generated from API definition by Databricks SDK Generator. DO NOT EDIT.
2
+
3
+ import {VERSION as AUTH_VERSION} from '@databricks/sdk-auth';
4
+ import type {Call} from '@databricks/sdk-core/api';
5
+ import {createDefault} from '@databricks/sdk-core/clientinfo';
6
+ import type {Logger} from '@databricks/sdk-core/logger';
7
+ import {NoOpLogger} from '@databricks/sdk-core/logger';
8
+ import type {CallOptions} from '@databricks/sdk-options/call';
9
+ import type {ClientOptions} from '@databricks/sdk-options/client';
10
+ import type {HttpClient} from '@databricks/sdk-core/http';
11
+ import {newHttpClient} from './transport';
12
+ import {
13
+ buildHttpRequest,
14
+ executeCall,
15
+ executeHttpCall,
16
+ marshalRequest,
17
+ parseResponse,
18
+ } from './utils';
19
+ import pkgJson from '../../package.json' with {type: 'json'};
20
+ import type {
21
+ CreateCustomOAuthAppIntegrationRequest,
22
+ CreatePublishedOAuthAppIntegrationRequest,
23
+ CreatePublishedOAuthAppIntegrationRequest_Response,
24
+ CustomOAuthAppIntegration,
25
+ CustomOAuthAppIntegrationSecret,
26
+ DeleteCustomOAuthAppIntegrationRequest,
27
+ DeleteCustomOAuthAppIntegrationRequest_Response,
28
+ DeletePublishedOAuthAppIntegrationRequest,
29
+ DeletePublishedOAuthAppIntegrationRequest_Response,
30
+ GetCustomOAuthAppIntegrationRequest,
31
+ GetPublishedOAuthAppIntegrationRequest,
32
+ ListCustomOAuthAppIntegrationsRequest,
33
+ ListCustomOAuthAppIntegrationsRequest_Response,
34
+ ListPublishedOAuthAppIntegrationsRequest,
35
+ ListPublishedOAuthAppIntegrationsRequest_Response,
36
+ ListPublishedOAuthAppsRequest,
37
+ ListPublishedOAuthAppsRequest_Response,
38
+ PublishedOAuthApp,
39
+ PublishedOAuthAppIntegration,
40
+ UpdateCustomOAuthAppIntegrationRequest,
41
+ UpdateCustomOAuthAppIntegrationRequest_Response,
42
+ UpdatePublishedOAuthAppIntegrationRequest,
43
+ UpdatePublishedOAuthAppIntegrationRequest_Response,
44
+ } from './model';
45
+ import {
46
+ marshalCreateCustomOAuthAppIntegrationRequestSchema,
47
+ marshalCreatePublishedOAuthAppIntegrationRequestSchema,
48
+ marshalUpdateCustomOAuthAppIntegrationRequestSchema,
49
+ marshalUpdatePublishedOAuthAppIntegrationRequestSchema,
50
+ unmarshalCreatePublishedOAuthAppIntegrationRequest_ResponseSchema,
51
+ unmarshalCustomOAuthAppIntegrationSchema,
52
+ unmarshalCustomOAuthAppIntegrationSecretSchema,
53
+ unmarshalDeleteCustomOAuthAppIntegrationRequest_ResponseSchema,
54
+ unmarshalDeletePublishedOAuthAppIntegrationRequest_ResponseSchema,
55
+ unmarshalListCustomOAuthAppIntegrationsRequest_ResponseSchema,
56
+ unmarshalListPublishedOAuthAppIntegrationsRequest_ResponseSchema,
57
+ unmarshalListPublishedOAuthAppsRequest_ResponseSchema,
58
+ unmarshalPublishedOAuthAppIntegrationSchema,
59
+ unmarshalUpdateCustomOAuthAppIntegrationRequest_ResponseSchema,
60
+ unmarshalUpdatePublishedOAuthAppIntegrationRequest_ResponseSchema,
61
+ } from './model';
62
+
63
+ // Package identity segment for this client to be used in the User-Agent header.
64
+ const PACKAGE_SEGMENT = {
65
+ key: 'sdk-js-' + pkgJson.name.replace(/^@[^/]+\/sdk-/, ''),
66
+ value: pkgJson.version,
67
+ };
68
+
69
+ export class OauthClient {
70
+ private readonly host: string;
71
+ // Fallback for endpoints whose path contains {account_id}. If the request
72
+ // already carries an accountId, that value wins.
73
+ private readonly accountId: string | undefined;
74
+ private readonly httpClient: HttpClient;
75
+ private readonly logger: Logger;
76
+ // User-Agent header value. Composed once at construction from
77
+ // createDefault() merged with this package's identity and the active
78
+ // credential's name.
79
+ private readonly userAgent: string;
80
+
81
+ constructor(options: ClientOptions) {
82
+ if (options.host === undefined) {
83
+ throw new Error('Host is required.');
84
+ }
85
+ this.host = options.host.replace(/\/$/, '');
86
+ this.accountId = options.accountId;
87
+ this.logger = options.logger ?? new NoOpLogger();
88
+ const info = createDefault()
89
+ .with(PACKAGE_SEGMENT)
90
+ .with({key: 'sdk-js-auth', value: AUTH_VERSION})
91
+ .with({key: 'auth', value: options.credentials?.name() ?? 'default'});
92
+ this.userAgent = info.toString();
93
+ this.httpClient = newHttpClient(options);
94
+ }
95
+
96
+ /**
97
+ * Create Custom OAuth App Integration.
98
+ *
99
+ * You can retrieve the custom OAuth app integration via :method:CustomAppIntegration/get.
100
+ */
101
+ async createCustomOAuthAppIntegration(
102
+ req: CreateCustomOAuthAppIntegrationRequest,
103
+ options?: CallOptions
104
+ ): Promise<CustomOAuthAppIntegrationSecret> {
105
+ const url = `${this.host}/api/2.0/accounts/${req.accountId ?? this.accountId ?? ''}/oauth2/custom-app-integrations`;
106
+ const body = marshalRequest(
107
+ req,
108
+ marshalCreateCustomOAuthAppIntegrationRequestSchema
109
+ );
110
+ let resp: CustomOAuthAppIntegrationSecret | undefined;
111
+ const call: Call = async (callSignal?: AbortSignal): Promise<void> => {
112
+ const headers = new Headers({'Content-Type': 'application/json'});
113
+ headers.set('User-Agent', this.userAgent);
114
+ const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
115
+ const respBody = await executeHttpCall({
116
+ request: httpReq,
117
+ httpClient: this.httpClient,
118
+ logger: this.logger,
119
+ });
120
+ resp = parseResponse(
121
+ respBody,
122
+ unmarshalCustomOAuthAppIntegrationSecretSchema
123
+ );
124
+ };
125
+ await executeCall(call, options);
126
+ if (resp === undefined) {
127
+ throw new Error('API call completed without a result.');
128
+ }
129
+ return resp;
130
+ }
131
+
132
+ /**
133
+ * Create Published OAuth App Integration.
134
+ *
135
+ * You can retrieve the published OAuth app integration via :method:PublishedAppIntegration/get.
136
+ */
137
+ async createPublishedOAuthAppIntegration(
138
+ req: CreatePublishedOAuthAppIntegrationRequest,
139
+ options?: CallOptions
140
+ ): Promise<CreatePublishedOAuthAppIntegrationRequest_Response> {
141
+ const url = `${this.host}/api/2.0/accounts/${req.accountId ?? this.accountId ?? ''}/oauth2/published-app-integrations`;
142
+ const body = marshalRequest(
143
+ req,
144
+ marshalCreatePublishedOAuthAppIntegrationRequestSchema
145
+ );
146
+ let resp: CreatePublishedOAuthAppIntegrationRequest_Response | undefined;
147
+ const call: Call = async (callSignal?: AbortSignal): Promise<void> => {
148
+ const headers = new Headers({'Content-Type': 'application/json'});
149
+ headers.set('User-Agent', this.userAgent);
150
+ const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
151
+ const respBody = await executeHttpCall({
152
+ request: httpReq,
153
+ httpClient: this.httpClient,
154
+ logger: this.logger,
155
+ });
156
+ resp = parseResponse(
157
+ respBody,
158
+ unmarshalCreatePublishedOAuthAppIntegrationRequest_ResponseSchema
159
+ );
160
+ };
161
+ await executeCall(call, options);
162
+ if (resp === undefined) {
163
+ throw new Error('API call completed without a result.');
164
+ }
165
+ return resp;
166
+ }
167
+
168
+ /**
169
+ * Delete an existing Custom OAuth App Integration.
170
+ * You can retrieve the custom OAuth app integration via :method:CustomAppIntegration/get.
171
+ */
172
+ async deleteCustomOAuthAppIntegration(
173
+ req: DeleteCustomOAuthAppIntegrationRequest,
174
+ options?: CallOptions
175
+ ): Promise<DeleteCustomOAuthAppIntegrationRequest_Response> {
176
+ const url = `${this.host}/api/2.0/accounts/${req.accountId ?? this.accountId ?? ''}/oauth2/custom-app-integrations/${req.integrationId ?? ''}`;
177
+ let resp: DeleteCustomOAuthAppIntegrationRequest_Response | undefined;
178
+ const call: Call = async (callSignal?: AbortSignal): Promise<void> => {
179
+ const headers = new Headers();
180
+ headers.set('User-Agent', this.userAgent);
181
+ const httpReq = buildHttpRequest('DELETE', url, headers, callSignal);
182
+ const respBody = await executeHttpCall({
183
+ request: httpReq,
184
+ httpClient: this.httpClient,
185
+ logger: this.logger,
186
+ });
187
+ resp = parseResponse(
188
+ respBody,
189
+ unmarshalDeleteCustomOAuthAppIntegrationRequest_ResponseSchema
190
+ );
191
+ };
192
+ await executeCall(call, options);
193
+ if (resp === undefined) {
194
+ throw new Error('API call completed without a result.');
195
+ }
196
+ return resp;
197
+ }
198
+
199
+ /**
200
+ * Delete an existing Published OAuth App Integration.
201
+ * You can retrieve the published OAuth app integration via :method:PublishedAppIntegration/get.
202
+ */
203
+ async deletePublishedOAuthAppIntegration(
204
+ req: DeletePublishedOAuthAppIntegrationRequest,
205
+ options?: CallOptions
206
+ ): Promise<DeletePublishedOAuthAppIntegrationRequest_Response> {
207
+ const url = `${this.host}/api/2.0/accounts/${req.accountId ?? this.accountId ?? ''}/oauth2/published-app-integrations/${req.integrationId ?? ''}`;
208
+ let resp: DeletePublishedOAuthAppIntegrationRequest_Response | undefined;
209
+ const call: Call = async (callSignal?: AbortSignal): Promise<void> => {
210
+ const headers = new Headers();
211
+ headers.set('User-Agent', this.userAgent);
212
+ const httpReq = buildHttpRequest('DELETE', url, headers, callSignal);
213
+ const respBody = await executeHttpCall({
214
+ request: httpReq,
215
+ httpClient: this.httpClient,
216
+ logger: this.logger,
217
+ });
218
+ resp = parseResponse(
219
+ respBody,
220
+ unmarshalDeletePublishedOAuthAppIntegrationRequest_ResponseSchema
221
+ );
222
+ };
223
+ await executeCall(call, options);
224
+ if (resp === undefined) {
225
+ throw new Error('API call completed without a result.');
226
+ }
227
+ return resp;
228
+ }
229
+
230
+ /** Gets the Custom OAuth App Integration for the given integration id. */
231
+ async getCustomOAuthAppIntegration(
232
+ req: GetCustomOAuthAppIntegrationRequest,
233
+ options?: CallOptions
234
+ ): Promise<CustomOAuthAppIntegration> {
235
+ const url = `${this.host}/api/2.0/accounts/${req.accountId ?? this.accountId ?? ''}/oauth2/custom-app-integrations/${req.integrationId ?? ''}`;
236
+ let resp: CustomOAuthAppIntegration | undefined;
237
+ const call: Call = async (callSignal?: AbortSignal): Promise<void> => {
238
+ const headers = new Headers();
239
+ headers.set('User-Agent', this.userAgent);
240
+ const httpReq = buildHttpRequest('GET', url, headers, callSignal);
241
+ const respBody = await executeHttpCall({
242
+ request: httpReq,
243
+ httpClient: this.httpClient,
244
+ logger: this.logger,
245
+ });
246
+ resp = parseResponse(respBody, unmarshalCustomOAuthAppIntegrationSchema);
247
+ };
248
+ await executeCall(call, options);
249
+ if (resp === undefined) {
250
+ throw new Error('API call completed without a result.');
251
+ }
252
+ return resp;
253
+ }
254
+
255
+ /** Gets the Published OAuth App Integration for the given integration id. */
256
+ async getPublishedOAuthAppIntegration(
257
+ req: GetPublishedOAuthAppIntegrationRequest,
258
+ options?: CallOptions
259
+ ): Promise<PublishedOAuthAppIntegration> {
260
+ const url = `${this.host}/api/2.0/accounts/${req.accountId ?? this.accountId ?? ''}/oauth2/published-app-integrations/${req.integrationId ?? ''}`;
261
+ let resp: PublishedOAuthAppIntegration | undefined;
262
+ const call: Call = async (callSignal?: AbortSignal): Promise<void> => {
263
+ const headers = new Headers();
264
+ headers.set('User-Agent', this.userAgent);
265
+ const httpReq = buildHttpRequest('GET', url, headers, callSignal);
266
+ const respBody = await executeHttpCall({
267
+ request: httpReq,
268
+ httpClient: this.httpClient,
269
+ logger: this.logger,
270
+ });
271
+ resp = parseResponse(
272
+ respBody,
273
+ unmarshalPublishedOAuthAppIntegrationSchema
274
+ );
275
+ };
276
+ await executeCall(call, options);
277
+ if (resp === undefined) {
278
+ throw new Error('API call completed without a result.');
279
+ }
280
+ return resp;
281
+ }
282
+
283
+ /** Get the list of custom OAuth app integrations for the specified <Account> */
284
+ async listCustomOAuthAppIntegrations(
285
+ req: ListCustomOAuthAppIntegrationsRequest,
286
+ options?: CallOptions
287
+ ): Promise<ListCustomOAuthAppIntegrationsRequest_Response> {
288
+ const url = `${this.host}/api/2.0/accounts/${req.accountId ?? this.accountId ?? ''}/oauth2/custom-app-integrations`;
289
+ const params = new URLSearchParams();
290
+ if (req.pageToken !== undefined) {
291
+ params.append('page_token', req.pageToken);
292
+ }
293
+ if (req.pageSize !== undefined) {
294
+ params.append('page_size', String(req.pageSize));
295
+ }
296
+ if (req.includeCreatorUsername !== undefined) {
297
+ params.append(
298
+ 'include_creator_username',
299
+ String(req.includeCreatorUsername)
300
+ );
301
+ }
302
+ const query = params.toString();
303
+ const fullUrl = query !== '' ? `${url}?${query}` : url;
304
+ let resp: ListCustomOAuthAppIntegrationsRequest_Response | undefined;
305
+ const call: Call = async (callSignal?: AbortSignal): Promise<void> => {
306
+ const headers = new Headers();
307
+ headers.set('User-Agent', this.userAgent);
308
+ const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
309
+ const respBody = await executeHttpCall({
310
+ request: httpReq,
311
+ httpClient: this.httpClient,
312
+ logger: this.logger,
313
+ });
314
+ resp = parseResponse(
315
+ respBody,
316
+ unmarshalListCustomOAuthAppIntegrationsRequest_ResponseSchema
317
+ );
318
+ };
319
+ await executeCall(call, options);
320
+ if (resp === undefined) {
321
+ throw new Error('API call completed without a result.');
322
+ }
323
+ return resp;
324
+ }
325
+
326
+ async *listCustomOAuthAppIntegrationsIter(
327
+ req: ListCustomOAuthAppIntegrationsRequest,
328
+ options?: CallOptions
329
+ ): AsyncGenerator<CustomOAuthAppIntegration> {
330
+ const pageReq: ListCustomOAuthAppIntegrationsRequest = {...req};
331
+ for (;;) {
332
+ const resp = await this.listCustomOAuthAppIntegrations(pageReq, options);
333
+ for (const item of resp.apps ?? []) {
334
+ yield item;
335
+ }
336
+ if (resp.nextPageToken === undefined || resp.nextPageToken === '') {
337
+ return;
338
+ }
339
+ pageReq.pageToken = resp.nextPageToken;
340
+ }
341
+ }
342
+
343
+ /** Get the list of published OAuth app integrations for the specified <Account> */
344
+ async listPublishedOAuthAppIntegrations(
345
+ req: ListPublishedOAuthAppIntegrationsRequest,
346
+ options?: CallOptions
347
+ ): Promise<ListPublishedOAuthAppIntegrationsRequest_Response> {
348
+ const url = `${this.host}/api/2.0/accounts/${req.accountId ?? this.accountId ?? ''}/oauth2/published-app-integrations`;
349
+ const params = new URLSearchParams();
350
+ if (req.pageToken !== undefined) {
351
+ params.append('page_token', req.pageToken);
352
+ }
353
+ if (req.pageSize !== undefined) {
354
+ params.append('page_size', String(req.pageSize));
355
+ }
356
+ const query = params.toString();
357
+ const fullUrl = query !== '' ? `${url}?${query}` : url;
358
+ let resp: ListPublishedOAuthAppIntegrationsRequest_Response | undefined;
359
+ const call: Call = async (callSignal?: AbortSignal): Promise<void> => {
360
+ const headers = new Headers();
361
+ headers.set('User-Agent', this.userAgent);
362
+ const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
363
+ const respBody = await executeHttpCall({
364
+ request: httpReq,
365
+ httpClient: this.httpClient,
366
+ logger: this.logger,
367
+ });
368
+ resp = parseResponse(
369
+ respBody,
370
+ unmarshalListPublishedOAuthAppIntegrationsRequest_ResponseSchema
371
+ );
372
+ };
373
+ await executeCall(call, options);
374
+ if (resp === undefined) {
375
+ throw new Error('API call completed without a result.');
376
+ }
377
+ return resp;
378
+ }
379
+
380
+ async *listPublishedOAuthAppIntegrationsIter(
381
+ req: ListPublishedOAuthAppIntegrationsRequest,
382
+ options?: CallOptions
383
+ ): AsyncGenerator<PublishedOAuthAppIntegration> {
384
+ const pageReq: ListPublishedOAuthAppIntegrationsRequest = {...req};
385
+ for (;;) {
386
+ const resp = await this.listPublishedOAuthAppIntegrations(
387
+ pageReq,
388
+ options
389
+ );
390
+ for (const item of resp.apps ?? []) {
391
+ yield item;
392
+ }
393
+ if (resp.nextPageToken === undefined || resp.nextPageToken === '') {
394
+ return;
395
+ }
396
+ pageReq.pageToken = resp.nextPageToken;
397
+ }
398
+ }
399
+
400
+ /** Get all the available published OAuth apps in <Databricks>. */
401
+ async listPublishedOAuthApps(
402
+ req: ListPublishedOAuthAppsRequest,
403
+ options?: CallOptions
404
+ ): Promise<ListPublishedOAuthAppsRequest_Response> {
405
+ const url = `${this.host}/api/2.0/accounts/${req.accountId ?? this.accountId ?? ''}/oauth2/published-apps`;
406
+ const params = new URLSearchParams();
407
+ if (req.pageToken !== undefined) {
408
+ params.append('page_token', req.pageToken);
409
+ }
410
+ if (req.pageSize !== undefined) {
411
+ params.append('page_size', String(req.pageSize));
412
+ }
413
+ const query = params.toString();
414
+ const fullUrl = query !== '' ? `${url}?${query}` : url;
415
+ let resp: ListPublishedOAuthAppsRequest_Response | undefined;
416
+ const call: Call = async (callSignal?: AbortSignal): Promise<void> => {
417
+ const headers = new Headers();
418
+ headers.set('User-Agent', this.userAgent);
419
+ const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
420
+ const respBody = await executeHttpCall({
421
+ request: httpReq,
422
+ httpClient: this.httpClient,
423
+ logger: this.logger,
424
+ });
425
+ resp = parseResponse(
426
+ respBody,
427
+ unmarshalListPublishedOAuthAppsRequest_ResponseSchema
428
+ );
429
+ };
430
+ await executeCall(call, options);
431
+ if (resp === undefined) {
432
+ throw new Error('API call completed without a result.');
433
+ }
434
+ return resp;
435
+ }
436
+
437
+ async *listPublishedOAuthAppsIter(
438
+ req: ListPublishedOAuthAppsRequest,
439
+ options?: CallOptions
440
+ ): AsyncGenerator<PublishedOAuthApp> {
441
+ const pageReq: ListPublishedOAuthAppsRequest = {...req};
442
+ for (;;) {
443
+ const resp = await this.listPublishedOAuthApps(pageReq, options);
444
+ for (const item of resp.apps ?? []) {
445
+ yield item;
446
+ }
447
+ if (resp.nextPageToken === undefined || resp.nextPageToken === '') {
448
+ return;
449
+ }
450
+ pageReq.pageToken = resp.nextPageToken;
451
+ }
452
+ }
453
+
454
+ /**
455
+ * Updates an existing custom OAuth App Integration.
456
+ * You can retrieve the custom OAuth app integration via :method:CustomAppIntegration/get.
457
+ */
458
+ async updateCustomOAuthAppIntegration(
459
+ req: UpdateCustomOAuthAppIntegrationRequest,
460
+ options?: CallOptions
461
+ ): Promise<UpdateCustomOAuthAppIntegrationRequest_Response> {
462
+ const url = `${this.host}/api/2.0/accounts/${req.accountId ?? this.accountId ?? ''}/oauth2/custom-app-integrations/${req.integrationId ?? ''}`;
463
+ const body = marshalRequest(
464
+ req,
465
+ marshalUpdateCustomOAuthAppIntegrationRequestSchema
466
+ );
467
+ let resp: UpdateCustomOAuthAppIntegrationRequest_Response | undefined;
468
+ const call: Call = async (callSignal?: AbortSignal): Promise<void> => {
469
+ const headers = new Headers({'Content-Type': 'application/json'});
470
+ headers.set('User-Agent', this.userAgent);
471
+ const httpReq = buildHttpRequest('PATCH', url, headers, callSignal, body);
472
+ const respBody = await executeHttpCall({
473
+ request: httpReq,
474
+ httpClient: this.httpClient,
475
+ logger: this.logger,
476
+ });
477
+ resp = parseResponse(
478
+ respBody,
479
+ unmarshalUpdateCustomOAuthAppIntegrationRequest_ResponseSchema
480
+ );
481
+ };
482
+ await executeCall(call, options);
483
+ if (resp === undefined) {
484
+ throw new Error('API call completed without a result.');
485
+ }
486
+ return resp;
487
+ }
488
+
489
+ /**
490
+ * Updates an existing published OAuth App Integration.
491
+ * You can retrieve the published OAuth app integration via :method:PublishedAppIntegration/get.
492
+ */
493
+ async updatePublishedOAuthAppIntegration(
494
+ req: UpdatePublishedOAuthAppIntegrationRequest,
495
+ options?: CallOptions
496
+ ): Promise<UpdatePublishedOAuthAppIntegrationRequest_Response> {
497
+ const url = `${this.host}/api/2.0/accounts/${req.accountId ?? this.accountId ?? ''}/oauth2/published-app-integrations/${req.integrationId ?? ''}`;
498
+ const body = marshalRequest(
499
+ req,
500
+ marshalUpdatePublishedOAuthAppIntegrationRequestSchema
501
+ );
502
+ let resp: UpdatePublishedOAuthAppIntegrationRequest_Response | undefined;
503
+ const call: Call = async (callSignal?: AbortSignal): Promise<void> => {
504
+ const headers = new Headers({'Content-Type': 'application/json'});
505
+ headers.set('User-Agent', this.userAgent);
506
+ const httpReq = buildHttpRequest('PATCH', url, headers, callSignal, body);
507
+ const respBody = await executeHttpCall({
508
+ request: httpReq,
509
+ httpClient: this.httpClient,
510
+ logger: this.logger,
511
+ });
512
+ resp = parseResponse(
513
+ respBody,
514
+ unmarshalUpdatePublishedOAuthAppIntegrationRequest_ResponseSchema
515
+ );
516
+ };
517
+ await executeCall(call, options);
518
+ if (resp === undefined) {
519
+ throw new Error('API call completed without a result.');
520
+ }
521
+ return resp;
522
+ }
523
+ }