@databricks/sdk-scim 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,1489 @@
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
+ AccountGroup,
22
+ AccountServicePrincipal,
23
+ AccountUser,
24
+ CreateAccountGroupRequest,
25
+ CreateAccountServicePrincipalRequest,
26
+ CreateAccountUserRequest,
27
+ CreateGroupRequest,
28
+ CreateServicePrincipalRequest,
29
+ CreateUserRequest,
30
+ DeleteAccountGroupRequest,
31
+ DeleteAccountServicePrincipalRequest,
32
+ DeleteAccountUserRequest,
33
+ DeleteGroupRequest,
34
+ DeleteServicePrincipalRequest,
35
+ DeleteUserRequest,
36
+ GetAccountGroupRequest,
37
+ GetAccountServicePrincipalRequest,
38
+ GetAccountUserRequest,
39
+ GetGroupRequest,
40
+ GetPasswordPermissionLevelsRequest,
41
+ GetPasswordPermissionLevelsResponse,
42
+ GetPasswordPermissionsRequest,
43
+ GetServicePrincipalRequest,
44
+ GetUserRequest,
45
+ Group,
46
+ ListAccountGroupsRequest,
47
+ ListAccountGroupsResponse,
48
+ ListAccountServicePrincipalsRequest,
49
+ ListAccountServicePrincipalsResponse,
50
+ ListAccountUsersRequest,
51
+ ListAccountUsersResponse,
52
+ ListGroupsRequest,
53
+ ListGroupsResponse,
54
+ ListServicePrincipalResponse,
55
+ ListServicePrincipalsRequest,
56
+ ListUsersRequest,
57
+ ListUsersResponse,
58
+ MeRequest,
59
+ PasswordPermissions,
60
+ PasswordPermissionsRequest,
61
+ PatchAccountGroupRequest,
62
+ PatchAccountServicePrincipalRequest,
63
+ PatchAccountUserRequest,
64
+ PatchGroupRequest,
65
+ PatchServicePrincipalRequest,
66
+ PatchUserRequest,
67
+ ServicePrincipal,
68
+ UpdateAccountGroupRequest,
69
+ UpdateAccountServicePrincipalRequest,
70
+ UpdateAccountUserRequest,
71
+ UpdateGroupRequest,
72
+ UpdateServicePrincipalRequest,
73
+ UpdateUserRequest,
74
+ User,
75
+ } from './model';
76
+ import {
77
+ marshalCreateAccountGroupRequestSchema,
78
+ marshalCreateAccountServicePrincipalRequestSchema,
79
+ marshalCreateAccountUserRequestSchema,
80
+ marshalCreateGroupRequestSchema,
81
+ marshalCreateServicePrincipalRequestSchema,
82
+ marshalCreateUserRequestSchema,
83
+ marshalPasswordPermissionsRequestSchema,
84
+ marshalPatchAccountGroupRequestSchema,
85
+ marshalPatchAccountServicePrincipalRequestSchema,
86
+ marshalPatchAccountUserRequestSchema,
87
+ marshalPatchGroupRequestSchema,
88
+ marshalPatchServicePrincipalRequestSchema,
89
+ marshalPatchUserRequestSchema,
90
+ marshalUpdateAccountGroupRequestSchema,
91
+ marshalUpdateAccountServicePrincipalRequestSchema,
92
+ marshalUpdateAccountUserRequestSchema,
93
+ marshalUpdateGroupRequestSchema,
94
+ marshalUpdateServicePrincipalRequestSchema,
95
+ marshalUpdateUserRequestSchema,
96
+ unmarshalAccountGroupSchema,
97
+ unmarshalAccountServicePrincipalSchema,
98
+ unmarshalAccountUserSchema,
99
+ unmarshalGetPasswordPermissionLevelsResponseSchema,
100
+ unmarshalGroupSchema,
101
+ unmarshalListAccountGroupsResponseSchema,
102
+ unmarshalListAccountServicePrincipalsResponseSchema,
103
+ unmarshalListAccountUsersResponseSchema,
104
+ unmarshalListGroupsResponseSchema,
105
+ unmarshalListServicePrincipalResponseSchema,
106
+ unmarshalListUsersResponseSchema,
107
+ unmarshalPasswordPermissionsSchema,
108
+ unmarshalServicePrincipalSchema,
109
+ unmarshalUserSchema,
110
+ } from './model';
111
+
112
+ // Package identity segment for this client to be used in the User-Agent header.
113
+ const PACKAGE_SEGMENT = {
114
+ key: 'sdk-js-' + pkgJson.name.replace(/^@[^/]+\/sdk-/, ''),
115
+ value: pkgJson.version,
116
+ };
117
+
118
+ export class ScimClient {
119
+ private readonly host: string;
120
+ // Fallback for endpoints whose path contains {account_id}. If the request
121
+ // already carries an accountId, that value wins.
122
+ private readonly accountId: string | undefined;
123
+ // Workspace ID used to route workspace-level calls on unified hosts (SPOG).
124
+ // When set, workspace-level methods send X-Databricks-Org-Id on every
125
+ // request.
126
+ private readonly workspaceId: string | undefined;
127
+ private readonly httpClient: HttpClient;
128
+ private readonly logger: Logger;
129
+ // User-Agent header value. Composed once at construction from
130
+ // createDefault() merged with this package's identity and the active
131
+ // credential's name.
132
+ private readonly userAgent: string;
133
+
134
+ constructor(options: ClientOptions) {
135
+ if (options.host === undefined) {
136
+ throw new Error('Host is required.');
137
+ }
138
+ this.host = options.host.replace(/\/$/, '');
139
+ this.accountId = options.accountId;
140
+ this.workspaceId = options.workspaceId;
141
+ this.logger = options.logger ?? new NoOpLogger();
142
+ const info = createDefault()
143
+ .with(PACKAGE_SEGMENT)
144
+ .with({key: 'sdk-js-auth', value: AUTH_VERSION})
145
+ .with({key: 'auth', value: options.credentials?.name() ?? 'default'});
146
+ this.userAgent = info.toString();
147
+ this.httpClient = newHttpClient(options);
148
+ }
149
+
150
+ /** Creates a group in the <Databricks> account with a unique name, using the supplied group details. */
151
+ async createAccountGroup(
152
+ req: CreateAccountGroupRequest,
153
+ options?: CallOptions
154
+ ): Promise<AccountGroup> {
155
+ const url = `${this.host}/api/2.0/accounts/${req.accountId ?? this.accountId ?? ''}/scim/v2/Groups`;
156
+ const body = marshalRequest(req, marshalCreateAccountGroupRequestSchema);
157
+ let resp: AccountGroup | undefined;
158
+ const call: Call = async (callSignal?: AbortSignal): Promise<void> => {
159
+ const headers = new Headers({'Content-Type': 'application/json'});
160
+ headers.set('User-Agent', this.userAgent);
161
+ const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
162
+ const respBody = await executeHttpCall({
163
+ request: httpReq,
164
+ httpClient: this.httpClient,
165
+ logger: this.logger,
166
+ });
167
+ resp = parseResponse(respBody, unmarshalAccountGroupSchema);
168
+ };
169
+ await executeCall(call, options);
170
+ if (resp === undefined) {
171
+ throw new Error('API call completed without a result.');
172
+ }
173
+ return resp;
174
+ }
175
+
176
+ /** Deletes a group from the <Databricks> account. */
177
+ async deleteAccountGroup(
178
+ req: DeleteAccountGroupRequest,
179
+ options?: CallOptions
180
+ ): Promise<void> {
181
+ const url = `${this.host}/api/2.0/accounts/${req.accountId ?? this.accountId ?? ''}/scim/v2/Groups/${req.id ?? ''}`;
182
+ const call: Call = async (callSignal?: AbortSignal): Promise<void> => {
183
+ const headers = new Headers();
184
+ headers.set('User-Agent', this.userAgent);
185
+ const httpReq = buildHttpRequest('DELETE', url, headers, callSignal);
186
+ await executeHttpCall({
187
+ request: httpReq,
188
+ httpClient: this.httpClient,
189
+ logger: this.logger,
190
+ });
191
+ };
192
+ await executeCall(call, options);
193
+ }
194
+
195
+ /** Gets the information for a specific group in the <Databricks> account. */
196
+ async getAccountGroup(
197
+ req: GetAccountGroupRequest,
198
+ options?: CallOptions
199
+ ): Promise<AccountGroup> {
200
+ const url = `${this.host}/api/2.0/accounts/${req.accountId ?? this.accountId ?? ''}/scim/v2/Groups/${req.id ?? ''}`;
201
+ let resp: AccountGroup | undefined;
202
+ const call: Call = async (callSignal?: AbortSignal): Promise<void> => {
203
+ const headers = new Headers();
204
+ headers.set('User-Agent', this.userAgent);
205
+ const httpReq = buildHttpRequest('GET', url, headers, callSignal);
206
+ const respBody = await executeHttpCall({
207
+ request: httpReq,
208
+ httpClient: this.httpClient,
209
+ logger: this.logger,
210
+ });
211
+ resp = parseResponse(respBody, unmarshalAccountGroupSchema);
212
+ };
213
+ await executeCall(call, options);
214
+ if (resp === undefined) {
215
+ throw new Error('API call completed without a result.');
216
+ }
217
+ return resp;
218
+ }
219
+
220
+ /**
221
+ * Gets all details of the groups associated with the <Databricks> account. As of 08/22/2025,
222
+ * this endpoint will no longer return members. Instead, members should be retrieved by
223
+ * iterating through `Get group details`. Existing accounts that rely on this attribute
224
+ * will not be impacted and will continue receiving member data as before.
225
+ */
226
+ async listAccountGroups(
227
+ req: ListAccountGroupsRequest,
228
+ options?: CallOptions
229
+ ): Promise<ListAccountGroupsResponse> {
230
+ const url = `${this.host}/api/2.0/accounts/${req.accountId ?? this.accountId ?? ''}/scim/v2/Groups`;
231
+ const params = new URLSearchParams();
232
+ if (req.filter !== undefined) {
233
+ params.append('filter', req.filter);
234
+ }
235
+ if (req.attributes !== undefined) {
236
+ params.append('attributes', req.attributes);
237
+ }
238
+ if (req.excludedAttributes !== undefined) {
239
+ params.append('excludedAttributes', req.excludedAttributes);
240
+ }
241
+ if (req.startIndex !== undefined) {
242
+ params.append('startIndex', String(req.startIndex));
243
+ }
244
+ if (req.count !== undefined) {
245
+ params.append('count', String(req.count));
246
+ }
247
+ if (req.sortBy !== undefined) {
248
+ params.append('sortBy', req.sortBy);
249
+ }
250
+ if (req.sortOrder !== undefined) {
251
+ params.append('sortOrder', req.sortOrder);
252
+ }
253
+ const query = params.toString();
254
+ const fullUrl = query !== '' ? `${url}?${query}` : url;
255
+ let resp: ListAccountGroupsResponse | undefined;
256
+ const call: Call = async (callSignal?: AbortSignal): Promise<void> => {
257
+ const headers = new Headers();
258
+ headers.set('User-Agent', this.userAgent);
259
+ const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
260
+ const respBody = await executeHttpCall({
261
+ request: httpReq,
262
+ httpClient: this.httpClient,
263
+ logger: this.logger,
264
+ });
265
+ resp = parseResponse(respBody, unmarshalListAccountGroupsResponseSchema);
266
+ };
267
+ await executeCall(call, options);
268
+ if (resp === undefined) {
269
+ throw new Error('API call completed without a result.');
270
+ }
271
+ return resp;
272
+ }
273
+
274
+ async *listAccountGroupsIter(
275
+ req: ListAccountGroupsRequest,
276
+ options?: CallOptions
277
+ ): AsyncGenerator<AccountGroup> {
278
+ const pageReq: ListAccountGroupsRequest = {...req};
279
+ for (;;) {
280
+ const resp = await this.listAccountGroups(pageReq, options);
281
+ const items = resp.resources ?? [];
282
+ for (const item of items) {
283
+ yield item;
284
+ }
285
+ if (items.length === 0) {
286
+ return;
287
+ }
288
+ pageReq.startIndex = (resp.startIndex ?? 0n) + BigInt(items.length);
289
+ }
290
+ }
291
+
292
+ /** Partially updates the details of a group. */
293
+ async patchAccountGroup(
294
+ req: PatchAccountGroupRequest,
295
+ options?: CallOptions
296
+ ): Promise<void> {
297
+ const url = `${this.host}/api/2.0/accounts/${req.accountId ?? this.accountId ?? ''}/scim/v2/Groups/${req.id ?? ''}`;
298
+ const body = marshalRequest(req, marshalPatchAccountGroupRequestSchema);
299
+ const call: Call = async (callSignal?: AbortSignal): Promise<void> => {
300
+ const headers = new Headers({'Content-Type': 'application/json'});
301
+ headers.set('User-Agent', this.userAgent);
302
+ const httpReq = buildHttpRequest('PATCH', url, headers, callSignal, body);
303
+ await executeHttpCall({
304
+ request: httpReq,
305
+ httpClient: this.httpClient,
306
+ logger: this.logger,
307
+ });
308
+ };
309
+ await executeCall(call, options);
310
+ }
311
+
312
+ /** Updates the details of a group by replacing the entire group entity. */
313
+ async updateAccountGroup(
314
+ req: UpdateAccountGroupRequest,
315
+ options?: CallOptions
316
+ ): Promise<void> {
317
+ const url = `${this.host}/api/2.0/accounts/${req.accountId ?? this.accountId ?? ''}/scim/v2/Groups/${req.id ?? ''}`;
318
+ const body = marshalRequest(req, marshalUpdateAccountGroupRequestSchema);
319
+ const call: Call = async (callSignal?: AbortSignal): Promise<void> => {
320
+ const headers = new Headers({'Content-Type': 'application/json'});
321
+ headers.set('User-Agent', this.userAgent);
322
+ const httpReq = buildHttpRequest('PUT', url, headers, callSignal, body);
323
+ await executeHttpCall({
324
+ request: httpReq,
325
+ httpClient: this.httpClient,
326
+ logger: this.logger,
327
+ });
328
+ };
329
+ await executeCall(call, options);
330
+ }
331
+
332
+ /** Creates a new service principal in the <Databricks> account. */
333
+ async createAccountServicePrincipal(
334
+ req: CreateAccountServicePrincipalRequest,
335
+ options?: CallOptions
336
+ ): Promise<AccountServicePrincipal> {
337
+ const url = `${this.host}/api/2.0/accounts/${req.accountId ?? this.accountId ?? ''}/scim/v2/ServicePrincipals`;
338
+ const body = marshalRequest(
339
+ req,
340
+ marshalCreateAccountServicePrincipalRequestSchema
341
+ );
342
+ let resp: AccountServicePrincipal | undefined;
343
+ const call: Call = async (callSignal?: AbortSignal): Promise<void> => {
344
+ const headers = new Headers({'Content-Type': 'application/json'});
345
+ headers.set('User-Agent', this.userAgent);
346
+ const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
347
+ const respBody = await executeHttpCall({
348
+ request: httpReq,
349
+ httpClient: this.httpClient,
350
+ logger: this.logger,
351
+ });
352
+ resp = parseResponse(respBody, unmarshalAccountServicePrincipalSchema);
353
+ };
354
+ await executeCall(call, options);
355
+ if (resp === undefined) {
356
+ throw new Error('API call completed without a result.');
357
+ }
358
+ return resp;
359
+ }
360
+
361
+ /** Delete a single service principal in the <Databricks> account. */
362
+ async deleteAccountServicePrincipal(
363
+ req: DeleteAccountServicePrincipalRequest,
364
+ options?: CallOptions
365
+ ): Promise<void> {
366
+ const url = `${this.host}/api/2.0/accounts/${req.accountId ?? this.accountId ?? ''}/scim/v2/ServicePrincipals/${req.id ?? ''}`;
367
+ const call: Call = async (callSignal?: AbortSignal): Promise<void> => {
368
+ const headers = new Headers();
369
+ headers.set('User-Agent', this.userAgent);
370
+ const httpReq = buildHttpRequest('DELETE', url, headers, callSignal);
371
+ await executeHttpCall({
372
+ request: httpReq,
373
+ httpClient: this.httpClient,
374
+ logger: this.logger,
375
+ });
376
+ };
377
+ await executeCall(call, options);
378
+ }
379
+
380
+ /** Gets the details for a single service principal define in the <Databricks> account. */
381
+ async getAccountServicePrincipal(
382
+ req: GetAccountServicePrincipalRequest,
383
+ options?: CallOptions
384
+ ): Promise<AccountServicePrincipal> {
385
+ const url = `${this.host}/api/2.0/accounts/${req.accountId ?? this.accountId ?? ''}/scim/v2/ServicePrincipals/${req.id ?? ''}`;
386
+ let resp: AccountServicePrincipal | undefined;
387
+ const call: Call = async (callSignal?: AbortSignal): Promise<void> => {
388
+ const headers = new Headers();
389
+ headers.set('User-Agent', this.userAgent);
390
+ const httpReq = buildHttpRequest('GET', url, headers, callSignal);
391
+ const respBody = await executeHttpCall({
392
+ request: httpReq,
393
+ httpClient: this.httpClient,
394
+ logger: this.logger,
395
+ });
396
+ resp = parseResponse(respBody, unmarshalAccountServicePrincipalSchema);
397
+ };
398
+ await executeCall(call, options);
399
+ if (resp === undefined) {
400
+ throw new Error('API call completed without a result.');
401
+ }
402
+ return resp;
403
+ }
404
+
405
+ /** Gets the set of service principals associated with a <Databricks> account. */
406
+ async listAccountServicePrincipals(
407
+ req: ListAccountServicePrincipalsRequest,
408
+ options?: CallOptions
409
+ ): Promise<ListAccountServicePrincipalsResponse> {
410
+ const url = `${this.host}/api/2.0/accounts/${req.accountId ?? this.accountId ?? ''}/scim/v2/ServicePrincipals`;
411
+ const params = new URLSearchParams();
412
+ if (req.attributes !== undefined) {
413
+ params.append('attributes', req.attributes);
414
+ }
415
+ if (req.count !== undefined) {
416
+ params.append('count', String(req.count));
417
+ }
418
+ if (req.excludedAttributes !== undefined) {
419
+ params.append('excludedAttributes', req.excludedAttributes);
420
+ }
421
+ if (req.filter !== undefined) {
422
+ params.append('filter', req.filter);
423
+ }
424
+ if (req.sortBy !== undefined) {
425
+ params.append('sortBy', req.sortBy);
426
+ }
427
+ if (req.sortOrder !== undefined) {
428
+ params.append('sortOrder', req.sortOrder);
429
+ }
430
+ if (req.startIndex !== undefined) {
431
+ params.append('startIndex', String(req.startIndex));
432
+ }
433
+ const query = params.toString();
434
+ const fullUrl = query !== '' ? `${url}?${query}` : url;
435
+ let resp: ListAccountServicePrincipalsResponse | undefined;
436
+ const call: Call = async (callSignal?: AbortSignal): Promise<void> => {
437
+ const headers = new Headers();
438
+ headers.set('User-Agent', this.userAgent);
439
+ const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
440
+ const respBody = await executeHttpCall({
441
+ request: httpReq,
442
+ httpClient: this.httpClient,
443
+ logger: this.logger,
444
+ });
445
+ resp = parseResponse(
446
+ respBody,
447
+ unmarshalListAccountServicePrincipalsResponseSchema
448
+ );
449
+ };
450
+ await executeCall(call, options);
451
+ if (resp === undefined) {
452
+ throw new Error('API call completed without a result.');
453
+ }
454
+ return resp;
455
+ }
456
+
457
+ async *listAccountServicePrincipalsIter(
458
+ req: ListAccountServicePrincipalsRequest,
459
+ options?: CallOptions
460
+ ): AsyncGenerator<AccountServicePrincipal> {
461
+ const pageReq: ListAccountServicePrincipalsRequest = {...req};
462
+ for (;;) {
463
+ const resp = await this.listAccountServicePrincipals(pageReq, options);
464
+ const items = resp.resources ?? [];
465
+ for (const item of items) {
466
+ yield item;
467
+ }
468
+ if (items.length === 0) {
469
+ return;
470
+ }
471
+ pageReq.startIndex = (resp.startIndex ?? 0n) + BigInt(items.length);
472
+ }
473
+ }
474
+
475
+ /** Partially updates the details of a single service principal in the <Databricks> account. */
476
+ async patchAccountServicePrincipal(
477
+ req: PatchAccountServicePrincipalRequest,
478
+ options?: CallOptions
479
+ ): Promise<void> {
480
+ const url = `${this.host}/api/2.0/accounts/${req.accountId ?? this.accountId ?? ''}/scim/v2/ServicePrincipals/${req.id ?? ''}`;
481
+ const body = marshalRequest(
482
+ req,
483
+ marshalPatchAccountServicePrincipalRequestSchema
484
+ );
485
+ const call: Call = async (callSignal?: AbortSignal): Promise<void> => {
486
+ const headers = new Headers({'Content-Type': 'application/json'});
487
+ headers.set('User-Agent', this.userAgent);
488
+ const httpReq = buildHttpRequest('PATCH', url, headers, callSignal, body);
489
+ await executeHttpCall({
490
+ request: httpReq,
491
+ httpClient: this.httpClient,
492
+ logger: this.logger,
493
+ });
494
+ };
495
+ await executeCall(call, options);
496
+ }
497
+
498
+ /**
499
+ * Updates the details of a single service principal.
500
+ *
501
+ * This action replaces the existing service principal with the same name.
502
+ */
503
+ async updateAccountServicePrincipal(
504
+ req: UpdateAccountServicePrincipalRequest,
505
+ options?: CallOptions
506
+ ): Promise<void> {
507
+ const url = `${this.host}/api/2.0/accounts/${req.accountId ?? this.accountId ?? ''}/scim/v2/ServicePrincipals/${req.id ?? ''}`;
508
+ const body = marshalRequest(
509
+ req,
510
+ marshalUpdateAccountServicePrincipalRequestSchema
511
+ );
512
+ const call: Call = async (callSignal?: AbortSignal): Promise<void> => {
513
+ const headers = new Headers({'Content-Type': 'application/json'});
514
+ headers.set('User-Agent', this.userAgent);
515
+ const httpReq = buildHttpRequest('PUT', url, headers, callSignal, body);
516
+ await executeHttpCall({
517
+ request: httpReq,
518
+ httpClient: this.httpClient,
519
+ logger: this.logger,
520
+ });
521
+ };
522
+ await executeCall(call, options);
523
+ }
524
+
525
+ /** Creates a new user in the <Databricks> account. This new user will also be added to the <Databricks> account. */
526
+ async createAccountUser(
527
+ req: CreateAccountUserRequest,
528
+ options?: CallOptions
529
+ ): Promise<AccountUser> {
530
+ const url = `${this.host}/api/2.0/accounts/${req.accountId ?? this.accountId ?? ''}/scim/v2/Users`;
531
+ const body = marshalRequest(req, marshalCreateAccountUserRequestSchema);
532
+ let resp: AccountUser | undefined;
533
+ const call: Call = async (callSignal?: AbortSignal): Promise<void> => {
534
+ const headers = new Headers({'Content-Type': 'application/json'});
535
+ headers.set('User-Agent', this.userAgent);
536
+ const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
537
+ const respBody = await executeHttpCall({
538
+ request: httpReq,
539
+ httpClient: this.httpClient,
540
+ logger: this.logger,
541
+ });
542
+ resp = parseResponse(respBody, unmarshalAccountUserSchema);
543
+ };
544
+ await executeCall(call, options);
545
+ if (resp === undefined) {
546
+ throw new Error('API call completed without a result.');
547
+ }
548
+ return resp;
549
+ }
550
+
551
+ /** Deletes a user. Deleting a user from a <Databricks> account also removes objects associated with the user. */
552
+ async deleteAccountUser(
553
+ req: DeleteAccountUserRequest,
554
+ options?: CallOptions
555
+ ): Promise<void> {
556
+ const url = `${this.host}/api/2.0/accounts/${req.accountId ?? this.accountId ?? ''}/scim/v2/Users/${req.id ?? ''}`;
557
+ const call: Call = async (callSignal?: AbortSignal): Promise<void> => {
558
+ const headers = new Headers();
559
+ headers.set('User-Agent', this.userAgent);
560
+ const httpReq = buildHttpRequest('DELETE', url, headers, callSignal);
561
+ await executeHttpCall({
562
+ request: httpReq,
563
+ httpClient: this.httpClient,
564
+ logger: this.logger,
565
+ });
566
+ };
567
+ await executeCall(call, options);
568
+ }
569
+
570
+ /** Gets information for a specific user in <Databricks> account. */
571
+ async getAccountUser(
572
+ req: GetAccountUserRequest,
573
+ options?: CallOptions
574
+ ): Promise<AccountUser> {
575
+ const url = `${this.host}/api/2.0/accounts/${req.accountId ?? this.accountId ?? ''}/scim/v2/Users/${req.id ?? ''}`;
576
+ const params = new URLSearchParams();
577
+ if (req.attributes !== undefined) {
578
+ params.append('attributes', req.attributes);
579
+ }
580
+ if (req.count !== undefined) {
581
+ params.append('count', String(req.count));
582
+ }
583
+ if (req.excludedAttributes !== undefined) {
584
+ params.append('excludedAttributes', req.excludedAttributes);
585
+ }
586
+ if (req.filter !== undefined) {
587
+ params.append('filter', req.filter);
588
+ }
589
+ if (req.sortBy !== undefined) {
590
+ params.append('sortBy', req.sortBy);
591
+ }
592
+ if (req.sortOrder !== undefined) {
593
+ params.append('sortOrder', req.sortOrder);
594
+ }
595
+ if (req.startIndex !== undefined) {
596
+ params.append('startIndex', String(req.startIndex));
597
+ }
598
+ const query = params.toString();
599
+ const fullUrl = query !== '' ? `${url}?${query}` : url;
600
+ let resp: AccountUser | undefined;
601
+ const call: Call = async (callSignal?: AbortSignal): Promise<void> => {
602
+ const headers = new Headers();
603
+ headers.set('User-Agent', this.userAgent);
604
+ const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
605
+ const respBody = await executeHttpCall({
606
+ request: httpReq,
607
+ httpClient: this.httpClient,
608
+ logger: this.logger,
609
+ });
610
+ resp = parseResponse(respBody, unmarshalAccountUserSchema);
611
+ };
612
+ await executeCall(call, options);
613
+ if (resp === undefined) {
614
+ throw new Error('API call completed without a result.');
615
+ }
616
+ return resp;
617
+ }
618
+
619
+ /** Gets details for all the users associated with a <Databricks> account. */
620
+ async listAccountUsers(
621
+ req: ListAccountUsersRequest,
622
+ options?: CallOptions
623
+ ): Promise<ListAccountUsersResponse> {
624
+ const url = `${this.host}/api/2.0/accounts/${req.accountId ?? this.accountId ?? ''}/scim/v2/Users`;
625
+ const params = new URLSearchParams();
626
+ if (req.attributes !== undefined) {
627
+ params.append('attributes', req.attributes);
628
+ }
629
+ if (req.count !== undefined) {
630
+ params.append('count', String(req.count));
631
+ }
632
+ if (req.excludedAttributes !== undefined) {
633
+ params.append('excludedAttributes', req.excludedAttributes);
634
+ }
635
+ if (req.filter !== undefined) {
636
+ params.append('filter', req.filter);
637
+ }
638
+ if (req.sortBy !== undefined) {
639
+ params.append('sortBy', req.sortBy);
640
+ }
641
+ if (req.sortOrder !== undefined) {
642
+ params.append('sortOrder', req.sortOrder);
643
+ }
644
+ if (req.startIndex !== undefined) {
645
+ params.append('startIndex', String(req.startIndex));
646
+ }
647
+ const query = params.toString();
648
+ const fullUrl = query !== '' ? `${url}?${query}` : url;
649
+ let resp: ListAccountUsersResponse | undefined;
650
+ const call: Call = async (callSignal?: AbortSignal): Promise<void> => {
651
+ const headers = new Headers();
652
+ headers.set('User-Agent', this.userAgent);
653
+ const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
654
+ const respBody = await executeHttpCall({
655
+ request: httpReq,
656
+ httpClient: this.httpClient,
657
+ logger: this.logger,
658
+ });
659
+ resp = parseResponse(respBody, unmarshalListAccountUsersResponseSchema);
660
+ };
661
+ await executeCall(call, options);
662
+ if (resp === undefined) {
663
+ throw new Error('API call completed without a result.');
664
+ }
665
+ return resp;
666
+ }
667
+
668
+ async *listAccountUsersIter(
669
+ req: ListAccountUsersRequest,
670
+ options?: CallOptions
671
+ ): AsyncGenerator<AccountUser> {
672
+ const pageReq: ListAccountUsersRequest = {...req};
673
+ for (;;) {
674
+ const resp = await this.listAccountUsers(pageReq, options);
675
+ const items = resp.resources ?? [];
676
+ for (const item of items) {
677
+ yield item;
678
+ }
679
+ if (items.length === 0) {
680
+ return;
681
+ }
682
+ pageReq.startIndex = (resp.startIndex ?? 0n) + BigInt(items.length);
683
+ }
684
+ }
685
+
686
+ /** Partially updates a user resource by applying the supplied operations on specific user attributes. */
687
+ async patchAccountUser(
688
+ req: PatchAccountUserRequest,
689
+ options?: CallOptions
690
+ ): Promise<void> {
691
+ const url = `${this.host}/api/2.0/accounts/${req.accountId ?? this.accountId ?? ''}/scim/v2/Users/${req.id ?? ''}`;
692
+ const body = marshalRequest(req, marshalPatchAccountUserRequestSchema);
693
+ const call: Call = async (callSignal?: AbortSignal): Promise<void> => {
694
+ const headers = new Headers({'Content-Type': 'application/json'});
695
+ headers.set('User-Agent', this.userAgent);
696
+ const httpReq = buildHttpRequest('PATCH', url, headers, callSignal, body);
697
+ await executeHttpCall({
698
+ request: httpReq,
699
+ httpClient: this.httpClient,
700
+ logger: this.logger,
701
+ });
702
+ };
703
+ await executeCall(call, options);
704
+ }
705
+
706
+ /** Replaces a user's information with the data supplied in request. */
707
+ async updateAccountUser(
708
+ req: UpdateAccountUserRequest,
709
+ options?: CallOptions
710
+ ): Promise<void> {
711
+ const url = `${this.host}/api/2.0/accounts/${req.accountId ?? this.accountId ?? ''}/scim/v2/Users/${req.id ?? ''}`;
712
+ const body = marshalRequest(req, marshalUpdateAccountUserRequestSchema);
713
+ const call: Call = async (callSignal?: AbortSignal): Promise<void> => {
714
+ const headers = new Headers({'Content-Type': 'application/json'});
715
+ headers.set('User-Agent', this.userAgent);
716
+ const httpReq = buildHttpRequest('PUT', url, headers, callSignal, body);
717
+ await executeHttpCall({
718
+ request: httpReq,
719
+ httpClient: this.httpClient,
720
+ logger: this.logger,
721
+ });
722
+ };
723
+ await executeCall(call, options);
724
+ }
725
+
726
+ /** Get details about the current method caller's identity. */
727
+ async me(req: MeRequest, options?: CallOptions): Promise<User> {
728
+ const url = `${this.host}/api/2.0/preview/scim/v2/Me`;
729
+ const params = new URLSearchParams();
730
+ if (req.attributes !== undefined) {
731
+ params.append('attributes', req.attributes);
732
+ }
733
+ if (req.excludedAttributes !== undefined) {
734
+ params.append('excludedAttributes', req.excludedAttributes);
735
+ }
736
+ const query = params.toString();
737
+ const fullUrl = query !== '' ? `${url}?${query}` : url;
738
+ let resp: User | undefined;
739
+ const call: Call = async (callSignal?: AbortSignal): Promise<void> => {
740
+ const headers = new Headers();
741
+ if (this.workspaceId !== undefined) {
742
+ headers.set('X-Databricks-Org-Id', this.workspaceId);
743
+ }
744
+ headers.set('User-Agent', this.userAgent);
745
+ const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
746
+ const respBody = await executeHttpCall({
747
+ request: httpReq,
748
+ httpClient: this.httpClient,
749
+ logger: this.logger,
750
+ });
751
+ resp = parseResponse(respBody, unmarshalUserSchema);
752
+ };
753
+ await executeCall(call, options);
754
+ if (resp === undefined) {
755
+ throw new Error('API call completed without a result.');
756
+ }
757
+ return resp;
758
+ }
759
+
760
+ /** Creates a group in the <Databricks> workspace with a unique name, using the supplied group details. */
761
+ async createGroup(
762
+ req: CreateGroupRequest,
763
+ options?: CallOptions
764
+ ): Promise<Group> {
765
+ const url = `${this.host}/api/2.0/preview/scim/v2/Groups`;
766
+ const body = marshalRequest(req, marshalCreateGroupRequestSchema);
767
+ let resp: Group | undefined;
768
+ const call: Call = async (callSignal?: AbortSignal): Promise<void> => {
769
+ const headers = new Headers({'Content-Type': 'application/json'});
770
+ if (this.workspaceId !== undefined) {
771
+ headers.set('X-Databricks-Org-Id', this.workspaceId);
772
+ }
773
+ headers.set('User-Agent', this.userAgent);
774
+ const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
775
+ const respBody = await executeHttpCall({
776
+ request: httpReq,
777
+ httpClient: this.httpClient,
778
+ logger: this.logger,
779
+ });
780
+ resp = parseResponse(respBody, unmarshalGroupSchema);
781
+ };
782
+ await executeCall(call, options);
783
+ if (resp === undefined) {
784
+ throw new Error('API call completed without a result.');
785
+ }
786
+ return resp;
787
+ }
788
+
789
+ /** Deletes a group from the <Databricks> workspace. */
790
+ async deleteGroup(
791
+ req: DeleteGroupRequest,
792
+ options?: CallOptions
793
+ ): Promise<void> {
794
+ const url = `${this.host}/api/2.0/preview/scim/v2/Groups/${req.id ?? ''}`;
795
+ const call: Call = async (callSignal?: AbortSignal): Promise<void> => {
796
+ const headers = new Headers();
797
+ if (this.workspaceId !== undefined) {
798
+ headers.set('X-Databricks-Org-Id', this.workspaceId);
799
+ }
800
+ headers.set('User-Agent', this.userAgent);
801
+ const httpReq = buildHttpRequest('DELETE', url, headers, callSignal);
802
+ await executeHttpCall({
803
+ request: httpReq,
804
+ httpClient: this.httpClient,
805
+ logger: this.logger,
806
+ });
807
+ };
808
+ await executeCall(call, options);
809
+ }
810
+
811
+ /** Gets the information for a specific group in the <Databricks> workspace. */
812
+ async getGroup(req: GetGroupRequest, options?: CallOptions): Promise<Group> {
813
+ const url = `${this.host}/api/2.0/preview/scim/v2/Groups/${req.id ?? ''}`;
814
+ let resp: Group | undefined;
815
+ const call: Call = async (callSignal?: AbortSignal): Promise<void> => {
816
+ const headers = new Headers();
817
+ if (this.workspaceId !== undefined) {
818
+ headers.set('X-Databricks-Org-Id', this.workspaceId);
819
+ }
820
+ headers.set('User-Agent', this.userAgent);
821
+ const httpReq = buildHttpRequest('GET', url, headers, callSignal);
822
+ const respBody = await executeHttpCall({
823
+ request: httpReq,
824
+ httpClient: this.httpClient,
825
+ logger: this.logger,
826
+ });
827
+ resp = parseResponse(respBody, unmarshalGroupSchema);
828
+ };
829
+ await executeCall(call, options);
830
+ if (resp === undefined) {
831
+ throw new Error('API call completed without a result.');
832
+ }
833
+ return resp;
834
+ }
835
+
836
+ /** Gets all details of the groups associated with the <Databricks> workspace. */
837
+ async listGroups(
838
+ req: ListGroupsRequest,
839
+ options?: CallOptions
840
+ ): Promise<ListGroupsResponse> {
841
+ const url = `${this.host}/api/2.0/preview/scim/v2/Groups`;
842
+ const params = new URLSearchParams();
843
+ if (req.filter !== undefined) {
844
+ params.append('filter', req.filter);
845
+ }
846
+ if (req.attributes !== undefined) {
847
+ params.append('attributes', req.attributes);
848
+ }
849
+ if (req.excludedAttributes !== undefined) {
850
+ params.append('excludedAttributes', req.excludedAttributes);
851
+ }
852
+ if (req.startIndex !== undefined) {
853
+ params.append('startIndex', String(req.startIndex));
854
+ }
855
+ if (req.count !== undefined) {
856
+ params.append('count', String(req.count));
857
+ }
858
+ if (req.sortBy !== undefined) {
859
+ params.append('sortBy', req.sortBy);
860
+ }
861
+ if (req.sortOrder !== undefined) {
862
+ params.append('sortOrder', req.sortOrder);
863
+ }
864
+ const query = params.toString();
865
+ const fullUrl = query !== '' ? `${url}?${query}` : url;
866
+ let resp: ListGroupsResponse | undefined;
867
+ const call: Call = async (callSignal?: AbortSignal): Promise<void> => {
868
+ const headers = new Headers();
869
+ if (this.workspaceId !== undefined) {
870
+ headers.set('X-Databricks-Org-Id', this.workspaceId);
871
+ }
872
+ headers.set('User-Agent', this.userAgent);
873
+ const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
874
+ const respBody = await executeHttpCall({
875
+ request: httpReq,
876
+ httpClient: this.httpClient,
877
+ logger: this.logger,
878
+ });
879
+ resp = parseResponse(respBody, unmarshalListGroupsResponseSchema);
880
+ };
881
+ await executeCall(call, options);
882
+ if (resp === undefined) {
883
+ throw new Error('API call completed without a result.');
884
+ }
885
+ return resp;
886
+ }
887
+
888
+ async *listGroupsIter(
889
+ req: ListGroupsRequest,
890
+ options?: CallOptions
891
+ ): AsyncGenerator<Group> {
892
+ const pageReq: ListGroupsRequest = {...req};
893
+ for (;;) {
894
+ const resp = await this.listGroups(pageReq, options);
895
+ const items = resp.resources ?? [];
896
+ for (const item of items) {
897
+ yield item;
898
+ }
899
+ if (items.length === 0) {
900
+ return;
901
+ }
902
+ pageReq.startIndex = (resp.startIndex ?? 0n) + BigInt(items.length);
903
+ }
904
+ }
905
+
906
+ /** Partially updates the details of a group. */
907
+ async patchGroup(
908
+ req: PatchGroupRequest,
909
+ options?: CallOptions
910
+ ): Promise<void> {
911
+ const url = `${this.host}/api/2.0/preview/scim/v2/Groups/${req.id ?? ''}`;
912
+ const body = marshalRequest(req, marshalPatchGroupRequestSchema);
913
+ const call: Call = async (callSignal?: AbortSignal): Promise<void> => {
914
+ const headers = new Headers({'Content-Type': 'application/json'});
915
+ if (this.workspaceId !== undefined) {
916
+ headers.set('X-Databricks-Org-Id', this.workspaceId);
917
+ }
918
+ headers.set('User-Agent', this.userAgent);
919
+ const httpReq = buildHttpRequest('PATCH', url, headers, callSignal, body);
920
+ await executeHttpCall({
921
+ request: httpReq,
922
+ httpClient: this.httpClient,
923
+ logger: this.logger,
924
+ });
925
+ };
926
+ await executeCall(call, options);
927
+ }
928
+
929
+ /** Updates the details of a group by replacing the entire group entity. */
930
+ async updateGroup(
931
+ req: UpdateGroupRequest,
932
+ options?: CallOptions
933
+ ): Promise<void> {
934
+ const url = `${this.host}/api/2.0/preview/scim/v2/Groups/${req.id ?? ''}`;
935
+ const body = marshalRequest(req, marshalUpdateGroupRequestSchema);
936
+ const call: Call = async (callSignal?: AbortSignal): Promise<void> => {
937
+ const headers = new Headers({'Content-Type': 'application/json'});
938
+ if (this.workspaceId !== undefined) {
939
+ headers.set('X-Databricks-Org-Id', this.workspaceId);
940
+ }
941
+ headers.set('User-Agent', this.userAgent);
942
+ const httpReq = buildHttpRequest('PUT', url, headers, callSignal, body);
943
+ await executeHttpCall({
944
+ request: httpReq,
945
+ httpClient: this.httpClient,
946
+ logger: this.logger,
947
+ });
948
+ };
949
+ await executeCall(call, options);
950
+ }
951
+
952
+ /** Creates a new service principal in the <Databricks> workspace. */
953
+ async createServicePrincipal(
954
+ req: CreateServicePrincipalRequest,
955
+ options?: CallOptions
956
+ ): Promise<ServicePrincipal> {
957
+ const url = `${this.host}/api/2.0/preview/scim/v2/ServicePrincipals`;
958
+ const body = marshalRequest(
959
+ req,
960
+ marshalCreateServicePrincipalRequestSchema
961
+ );
962
+ let resp: ServicePrincipal | undefined;
963
+ const call: Call = async (callSignal?: AbortSignal): Promise<void> => {
964
+ const headers = new Headers({'Content-Type': 'application/json'});
965
+ if (this.workspaceId !== undefined) {
966
+ headers.set('X-Databricks-Org-Id', this.workspaceId);
967
+ }
968
+ headers.set('User-Agent', this.userAgent);
969
+ const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
970
+ const respBody = await executeHttpCall({
971
+ request: httpReq,
972
+ httpClient: this.httpClient,
973
+ logger: this.logger,
974
+ });
975
+ resp = parseResponse(respBody, unmarshalServicePrincipalSchema);
976
+ };
977
+ await executeCall(call, options);
978
+ if (resp === undefined) {
979
+ throw new Error('API call completed without a result.');
980
+ }
981
+ return resp;
982
+ }
983
+
984
+ /** Delete a single service principal in the <Databricks> workspace. */
985
+ async deleteServicePrincipal(
986
+ req: DeleteServicePrincipalRequest,
987
+ options?: CallOptions
988
+ ): Promise<void> {
989
+ const url = `${this.host}/api/2.0/preview/scim/v2/ServicePrincipals/${req.id ?? ''}`;
990
+ const call: Call = async (callSignal?: AbortSignal): Promise<void> => {
991
+ const headers = new Headers();
992
+ if (this.workspaceId !== undefined) {
993
+ headers.set('X-Databricks-Org-Id', this.workspaceId);
994
+ }
995
+ headers.set('User-Agent', this.userAgent);
996
+ const httpReq = buildHttpRequest('DELETE', url, headers, callSignal);
997
+ await executeHttpCall({
998
+ request: httpReq,
999
+ httpClient: this.httpClient,
1000
+ logger: this.logger,
1001
+ });
1002
+ };
1003
+ await executeCall(call, options);
1004
+ }
1005
+
1006
+ /** Gets the details for a single service principal define in the <Databricks> workspace. */
1007
+ async getServicePrincipal(
1008
+ req: GetServicePrincipalRequest,
1009
+ options?: CallOptions
1010
+ ): Promise<ServicePrincipal> {
1011
+ const url = `${this.host}/api/2.0/preview/scim/v2/ServicePrincipals/${req.id ?? ''}`;
1012
+ let resp: ServicePrincipal | undefined;
1013
+ const call: Call = async (callSignal?: AbortSignal): Promise<void> => {
1014
+ const headers = new Headers();
1015
+ if (this.workspaceId !== undefined) {
1016
+ headers.set('X-Databricks-Org-Id', this.workspaceId);
1017
+ }
1018
+ headers.set('User-Agent', this.userAgent);
1019
+ const httpReq = buildHttpRequest('GET', url, headers, callSignal);
1020
+ const respBody = await executeHttpCall({
1021
+ request: httpReq,
1022
+ httpClient: this.httpClient,
1023
+ logger: this.logger,
1024
+ });
1025
+ resp = parseResponse(respBody, unmarshalServicePrincipalSchema);
1026
+ };
1027
+ await executeCall(call, options);
1028
+ if (resp === undefined) {
1029
+ throw new Error('API call completed without a result.');
1030
+ }
1031
+ return resp;
1032
+ }
1033
+
1034
+ /** Gets the set of service principals associated with a <Databricks> workspace. */
1035
+ async listServicePrincipals(
1036
+ req: ListServicePrincipalsRequest,
1037
+ options?: CallOptions
1038
+ ): Promise<ListServicePrincipalResponse> {
1039
+ const url = `${this.host}/api/2.0/preview/scim/v2/ServicePrincipals`;
1040
+ const params = new URLSearchParams();
1041
+ if (req.attributes !== undefined) {
1042
+ params.append('attributes', req.attributes);
1043
+ }
1044
+ if (req.count !== undefined) {
1045
+ params.append('count', String(req.count));
1046
+ }
1047
+ if (req.excludedAttributes !== undefined) {
1048
+ params.append('excludedAttributes', req.excludedAttributes);
1049
+ }
1050
+ if (req.filter !== undefined) {
1051
+ params.append('filter', req.filter);
1052
+ }
1053
+ if (req.sortBy !== undefined) {
1054
+ params.append('sortBy', req.sortBy);
1055
+ }
1056
+ if (req.sortOrder !== undefined) {
1057
+ params.append('sortOrder', req.sortOrder);
1058
+ }
1059
+ if (req.startIndex !== undefined) {
1060
+ params.append('startIndex', String(req.startIndex));
1061
+ }
1062
+ const query = params.toString();
1063
+ const fullUrl = query !== '' ? `${url}?${query}` : url;
1064
+ let resp: ListServicePrincipalResponse | undefined;
1065
+ const call: Call = async (callSignal?: AbortSignal): Promise<void> => {
1066
+ const headers = new Headers();
1067
+ if (this.workspaceId !== undefined) {
1068
+ headers.set('X-Databricks-Org-Id', this.workspaceId);
1069
+ }
1070
+ headers.set('User-Agent', this.userAgent);
1071
+ const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
1072
+ const respBody = await executeHttpCall({
1073
+ request: httpReq,
1074
+ httpClient: this.httpClient,
1075
+ logger: this.logger,
1076
+ });
1077
+ resp = parseResponse(
1078
+ respBody,
1079
+ unmarshalListServicePrincipalResponseSchema
1080
+ );
1081
+ };
1082
+ await executeCall(call, options);
1083
+ if (resp === undefined) {
1084
+ throw new Error('API call completed without a result.');
1085
+ }
1086
+ return resp;
1087
+ }
1088
+
1089
+ async *listServicePrincipalsIter(
1090
+ req: ListServicePrincipalsRequest,
1091
+ options?: CallOptions
1092
+ ): AsyncGenerator<ServicePrincipal> {
1093
+ const pageReq: ListServicePrincipalsRequest = {...req};
1094
+ for (;;) {
1095
+ const resp = await this.listServicePrincipals(pageReq, options);
1096
+ const items = resp.resources ?? [];
1097
+ for (const item of items) {
1098
+ yield item;
1099
+ }
1100
+ if (items.length === 0) {
1101
+ return;
1102
+ }
1103
+ pageReq.startIndex = (resp.startIndex ?? 0n) + BigInt(items.length);
1104
+ }
1105
+ }
1106
+
1107
+ /** Partially updates the details of a single service principal in the <Databricks> workspace. */
1108
+ async patchServicePrincipal(
1109
+ req: PatchServicePrincipalRequest,
1110
+ options?: CallOptions
1111
+ ): Promise<void> {
1112
+ const url = `${this.host}/api/2.0/preview/scim/v2/ServicePrincipals/${req.id ?? ''}`;
1113
+ const body = marshalRequest(req, marshalPatchServicePrincipalRequestSchema);
1114
+ const call: Call = async (callSignal?: AbortSignal): Promise<void> => {
1115
+ const headers = new Headers({'Content-Type': 'application/json'});
1116
+ if (this.workspaceId !== undefined) {
1117
+ headers.set('X-Databricks-Org-Id', this.workspaceId);
1118
+ }
1119
+ headers.set('User-Agent', this.userAgent);
1120
+ const httpReq = buildHttpRequest('PATCH', url, headers, callSignal, body);
1121
+ await executeHttpCall({
1122
+ request: httpReq,
1123
+ httpClient: this.httpClient,
1124
+ logger: this.logger,
1125
+ });
1126
+ };
1127
+ await executeCall(call, options);
1128
+ }
1129
+
1130
+ /**
1131
+ * Updates the details of a single service principal.
1132
+ *
1133
+ * This action replaces the existing service principal with the same name.
1134
+ */
1135
+ async updateServicePrincipal(
1136
+ req: UpdateServicePrincipalRequest,
1137
+ options?: CallOptions
1138
+ ): Promise<void> {
1139
+ const url = `${this.host}/api/2.0/preview/scim/v2/ServicePrincipals/${req.id ?? ''}`;
1140
+ const body = marshalRequest(
1141
+ req,
1142
+ marshalUpdateServicePrincipalRequestSchema
1143
+ );
1144
+ const call: Call = async (callSignal?: AbortSignal): Promise<void> => {
1145
+ const headers = new Headers({'Content-Type': 'application/json'});
1146
+ if (this.workspaceId !== undefined) {
1147
+ headers.set('X-Databricks-Org-Id', this.workspaceId);
1148
+ }
1149
+ headers.set('User-Agent', this.userAgent);
1150
+ const httpReq = buildHttpRequest('PUT', url, headers, callSignal, body);
1151
+ await executeHttpCall({
1152
+ request: httpReq,
1153
+ httpClient: this.httpClient,
1154
+ logger: this.logger,
1155
+ });
1156
+ };
1157
+ await executeCall(call, options);
1158
+ }
1159
+
1160
+ /** Creates a new user in the <Databricks> workspace. This new user will also be added to the <Databricks> account. */
1161
+ async createUser(
1162
+ req: CreateUserRequest,
1163
+ options?: CallOptions
1164
+ ): Promise<User> {
1165
+ const url = `${this.host}/api/2.0/preview/scim/v2/Users`;
1166
+ const body = marshalRequest(req, marshalCreateUserRequestSchema);
1167
+ let resp: User | undefined;
1168
+ const call: Call = async (callSignal?: AbortSignal): Promise<void> => {
1169
+ const headers = new Headers({'Content-Type': 'application/json'});
1170
+ if (this.workspaceId !== undefined) {
1171
+ headers.set('X-Databricks-Org-Id', this.workspaceId);
1172
+ }
1173
+ headers.set('User-Agent', this.userAgent);
1174
+ const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
1175
+ const respBody = await executeHttpCall({
1176
+ request: httpReq,
1177
+ httpClient: this.httpClient,
1178
+ logger: this.logger,
1179
+ });
1180
+ resp = parseResponse(respBody, unmarshalUserSchema);
1181
+ };
1182
+ await executeCall(call, options);
1183
+ if (resp === undefined) {
1184
+ throw new Error('API call completed without a result.');
1185
+ }
1186
+ return resp;
1187
+ }
1188
+
1189
+ /** Deletes a user. Deleting a user from a <Databricks> workspace also removes objects associated with the user. */
1190
+ async deleteUser(
1191
+ req: DeleteUserRequest,
1192
+ options?: CallOptions
1193
+ ): Promise<void> {
1194
+ const url = `${this.host}/api/2.0/preview/scim/v2/Users/${req.id ?? ''}`;
1195
+ const call: Call = async (callSignal?: AbortSignal): Promise<void> => {
1196
+ const headers = new Headers();
1197
+ if (this.workspaceId !== undefined) {
1198
+ headers.set('X-Databricks-Org-Id', this.workspaceId);
1199
+ }
1200
+ headers.set('User-Agent', this.userAgent);
1201
+ const httpReq = buildHttpRequest('DELETE', url, headers, callSignal);
1202
+ await executeHttpCall({
1203
+ request: httpReq,
1204
+ httpClient: this.httpClient,
1205
+ logger: this.logger,
1206
+ });
1207
+ };
1208
+ await executeCall(call, options);
1209
+ }
1210
+
1211
+ /** Gets the permission levels that a user can have on an object. */
1212
+ async getPermissionLevels(
1213
+ _req: GetPasswordPermissionLevelsRequest,
1214
+ options?: CallOptions
1215
+ ): Promise<GetPasswordPermissionLevelsResponse> {
1216
+ const url = `${this.host}/api/2.0/permissions/authorization/passwords/permissionLevels`;
1217
+ let resp: GetPasswordPermissionLevelsResponse | undefined;
1218
+ const call: Call = async (callSignal?: AbortSignal): Promise<void> => {
1219
+ const headers = new Headers();
1220
+ if (this.workspaceId !== undefined) {
1221
+ headers.set('X-Databricks-Org-Id', this.workspaceId);
1222
+ }
1223
+ headers.set('User-Agent', this.userAgent);
1224
+ const httpReq = buildHttpRequest('GET', url, headers, callSignal);
1225
+ const respBody = await executeHttpCall({
1226
+ request: httpReq,
1227
+ httpClient: this.httpClient,
1228
+ logger: this.logger,
1229
+ });
1230
+ resp = parseResponse(
1231
+ respBody,
1232
+ unmarshalGetPasswordPermissionLevelsResponseSchema
1233
+ );
1234
+ };
1235
+ await executeCall(call, options);
1236
+ if (resp === undefined) {
1237
+ throw new Error('API call completed without a result.');
1238
+ }
1239
+ return resp;
1240
+ }
1241
+
1242
+ /** Gets the permissions of all passwords. Passwords can inherit permissions from their root object. */
1243
+ async getPermissions(
1244
+ _req: GetPasswordPermissionsRequest,
1245
+ options?: CallOptions
1246
+ ): Promise<PasswordPermissions> {
1247
+ const url = `${this.host}/api/2.0/permissions/authorization/passwords`;
1248
+ let resp: PasswordPermissions | undefined;
1249
+ const call: Call = async (callSignal?: AbortSignal): Promise<void> => {
1250
+ const headers = new Headers();
1251
+ if (this.workspaceId !== undefined) {
1252
+ headers.set('X-Databricks-Org-Id', this.workspaceId);
1253
+ }
1254
+ headers.set('User-Agent', this.userAgent);
1255
+ const httpReq = buildHttpRequest('GET', url, headers, callSignal);
1256
+ const respBody = await executeHttpCall({
1257
+ request: httpReq,
1258
+ httpClient: this.httpClient,
1259
+ logger: this.logger,
1260
+ });
1261
+ resp = parseResponse(respBody, unmarshalPasswordPermissionsSchema);
1262
+ };
1263
+ await executeCall(call, options);
1264
+ if (resp === undefined) {
1265
+ throw new Error('API call completed without a result.');
1266
+ }
1267
+ return resp;
1268
+ }
1269
+
1270
+ /** Gets information for a specific user in <Databricks> workspace. */
1271
+ async getUser(req: GetUserRequest, options?: CallOptions): Promise<User> {
1272
+ const url = `${this.host}/api/2.0/preview/scim/v2/Users/${req.id ?? ''}`;
1273
+ const params = new URLSearchParams();
1274
+ if (req.attributes !== undefined) {
1275
+ params.append('attributes', req.attributes);
1276
+ }
1277
+ if (req.count !== undefined) {
1278
+ params.append('count', String(req.count));
1279
+ }
1280
+ if (req.excludedAttributes !== undefined) {
1281
+ params.append('excludedAttributes', req.excludedAttributes);
1282
+ }
1283
+ if (req.filter !== undefined) {
1284
+ params.append('filter', req.filter);
1285
+ }
1286
+ if (req.sortBy !== undefined) {
1287
+ params.append('sortBy', req.sortBy);
1288
+ }
1289
+ if (req.sortOrder !== undefined) {
1290
+ params.append('sortOrder', req.sortOrder);
1291
+ }
1292
+ if (req.startIndex !== undefined) {
1293
+ params.append('startIndex', String(req.startIndex));
1294
+ }
1295
+ const query = params.toString();
1296
+ const fullUrl = query !== '' ? `${url}?${query}` : url;
1297
+ let resp: User | undefined;
1298
+ const call: Call = async (callSignal?: AbortSignal): Promise<void> => {
1299
+ const headers = new Headers();
1300
+ if (this.workspaceId !== undefined) {
1301
+ headers.set('X-Databricks-Org-Id', this.workspaceId);
1302
+ }
1303
+ headers.set('User-Agent', this.userAgent);
1304
+ const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
1305
+ const respBody = await executeHttpCall({
1306
+ request: httpReq,
1307
+ httpClient: this.httpClient,
1308
+ logger: this.logger,
1309
+ });
1310
+ resp = parseResponse(respBody, unmarshalUserSchema);
1311
+ };
1312
+ await executeCall(call, options);
1313
+ if (resp === undefined) {
1314
+ throw new Error('API call completed without a result.');
1315
+ }
1316
+ return resp;
1317
+ }
1318
+
1319
+ /** Gets details for all the users associated with a <Databricks> workspace. */
1320
+ async listUsers(
1321
+ req: ListUsersRequest,
1322
+ options?: CallOptions
1323
+ ): Promise<ListUsersResponse> {
1324
+ const url = `${this.host}/api/2.0/preview/scim/v2/Users`;
1325
+ const params = new URLSearchParams();
1326
+ if (req.attributes !== undefined) {
1327
+ params.append('attributes', req.attributes);
1328
+ }
1329
+ if (req.count !== undefined) {
1330
+ params.append('count', String(req.count));
1331
+ }
1332
+ if (req.excludedAttributes !== undefined) {
1333
+ params.append('excludedAttributes', req.excludedAttributes);
1334
+ }
1335
+ if (req.filter !== undefined) {
1336
+ params.append('filter', req.filter);
1337
+ }
1338
+ if (req.sortBy !== undefined) {
1339
+ params.append('sortBy', req.sortBy);
1340
+ }
1341
+ if (req.sortOrder !== undefined) {
1342
+ params.append('sortOrder', req.sortOrder);
1343
+ }
1344
+ if (req.startIndex !== undefined) {
1345
+ params.append('startIndex', String(req.startIndex));
1346
+ }
1347
+ const query = params.toString();
1348
+ const fullUrl = query !== '' ? `${url}?${query}` : url;
1349
+ let resp: ListUsersResponse | undefined;
1350
+ const call: Call = async (callSignal?: AbortSignal): Promise<void> => {
1351
+ const headers = new Headers();
1352
+ if (this.workspaceId !== undefined) {
1353
+ headers.set('X-Databricks-Org-Id', this.workspaceId);
1354
+ }
1355
+ headers.set('User-Agent', this.userAgent);
1356
+ const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
1357
+ const respBody = await executeHttpCall({
1358
+ request: httpReq,
1359
+ httpClient: this.httpClient,
1360
+ logger: this.logger,
1361
+ });
1362
+ resp = parseResponse(respBody, unmarshalListUsersResponseSchema);
1363
+ };
1364
+ await executeCall(call, options);
1365
+ if (resp === undefined) {
1366
+ throw new Error('API call completed without a result.');
1367
+ }
1368
+ return resp;
1369
+ }
1370
+
1371
+ async *listUsersIter(
1372
+ req: ListUsersRequest,
1373
+ options?: CallOptions
1374
+ ): AsyncGenerator<User> {
1375
+ const pageReq: ListUsersRequest = {...req};
1376
+ for (;;) {
1377
+ const resp = await this.listUsers(pageReq, options);
1378
+ const items = resp.resources ?? [];
1379
+ for (const item of items) {
1380
+ yield item;
1381
+ }
1382
+ if (items.length === 0) {
1383
+ return;
1384
+ }
1385
+ pageReq.startIndex = (resp.startIndex ?? 0n) + BigInt(items.length);
1386
+ }
1387
+ }
1388
+
1389
+ /** Partially updates a user resource by applying the supplied operations on specific user attributes. */
1390
+ async patchUser(req: PatchUserRequest, options?: CallOptions): Promise<void> {
1391
+ const url = `${this.host}/api/2.0/preview/scim/v2/Users/${req.id ?? ''}`;
1392
+ const body = marshalRequest(req, marshalPatchUserRequestSchema);
1393
+ const call: Call = async (callSignal?: AbortSignal): Promise<void> => {
1394
+ const headers = new Headers({'Content-Type': 'application/json'});
1395
+ if (this.workspaceId !== undefined) {
1396
+ headers.set('X-Databricks-Org-Id', this.workspaceId);
1397
+ }
1398
+ headers.set('User-Agent', this.userAgent);
1399
+ const httpReq = buildHttpRequest('PATCH', url, headers, callSignal, body);
1400
+ await executeHttpCall({
1401
+ request: httpReq,
1402
+ httpClient: this.httpClient,
1403
+ logger: this.logger,
1404
+ });
1405
+ };
1406
+ await executeCall(call, options);
1407
+ }
1408
+
1409
+ /** Sets permissions on an object, replacing existing permissions if they exist. Deletes all direct permissions if none are specified. Objects can inherit permissions from their root object. */
1410
+ async setPermissions(
1411
+ req: PasswordPermissionsRequest,
1412
+ options?: CallOptions
1413
+ ): Promise<PasswordPermissions> {
1414
+ const url = `${this.host}/api/2.0/permissions/authorization/passwords`;
1415
+ const body = marshalRequest(req, marshalPasswordPermissionsRequestSchema);
1416
+ let resp: PasswordPermissions | undefined;
1417
+ const call: Call = async (callSignal?: AbortSignal): Promise<void> => {
1418
+ const headers = new Headers({'Content-Type': 'application/json'});
1419
+ if (this.workspaceId !== undefined) {
1420
+ headers.set('X-Databricks-Org-Id', this.workspaceId);
1421
+ }
1422
+ headers.set('User-Agent', this.userAgent);
1423
+ const httpReq = buildHttpRequest('PUT', url, headers, callSignal, body);
1424
+ const respBody = await executeHttpCall({
1425
+ request: httpReq,
1426
+ httpClient: this.httpClient,
1427
+ logger: this.logger,
1428
+ });
1429
+ resp = parseResponse(respBody, unmarshalPasswordPermissionsSchema);
1430
+ };
1431
+ await executeCall(call, options);
1432
+ if (resp === undefined) {
1433
+ throw new Error('API call completed without a result.');
1434
+ }
1435
+ return resp;
1436
+ }
1437
+
1438
+ /** Updates the permissions on all passwords. Passwords can inherit permissions from their root object. */
1439
+ async updatePermissions(
1440
+ req: PasswordPermissionsRequest,
1441
+ options?: CallOptions
1442
+ ): Promise<PasswordPermissions> {
1443
+ const url = `${this.host}/api/2.0/permissions/authorization/passwords`;
1444
+ const body = marshalRequest(req, marshalPasswordPermissionsRequestSchema);
1445
+ let resp: PasswordPermissions | undefined;
1446
+ const call: Call = async (callSignal?: AbortSignal): Promise<void> => {
1447
+ const headers = new Headers({'Content-Type': 'application/json'});
1448
+ if (this.workspaceId !== undefined) {
1449
+ headers.set('X-Databricks-Org-Id', this.workspaceId);
1450
+ }
1451
+ headers.set('User-Agent', this.userAgent);
1452
+ const httpReq = buildHttpRequest('PATCH', url, headers, callSignal, body);
1453
+ const respBody = await executeHttpCall({
1454
+ request: httpReq,
1455
+ httpClient: this.httpClient,
1456
+ logger: this.logger,
1457
+ });
1458
+ resp = parseResponse(respBody, unmarshalPasswordPermissionsSchema);
1459
+ };
1460
+ await executeCall(call, options);
1461
+ if (resp === undefined) {
1462
+ throw new Error('API call completed without a result.');
1463
+ }
1464
+ return resp;
1465
+ }
1466
+
1467
+ /** Replaces a user's information with the data supplied in request. */
1468
+ async updateUser(
1469
+ req: UpdateUserRequest,
1470
+ options?: CallOptions
1471
+ ): Promise<void> {
1472
+ const url = `${this.host}/api/2.0/preview/scim/v2/Users/${req.id ?? ''}`;
1473
+ const body = marshalRequest(req, marshalUpdateUserRequestSchema);
1474
+ const call: Call = async (callSignal?: AbortSignal): Promise<void> => {
1475
+ const headers = new Headers({'Content-Type': 'application/json'});
1476
+ if (this.workspaceId !== undefined) {
1477
+ headers.set('X-Databricks-Org-Id', this.workspaceId);
1478
+ }
1479
+ headers.set('User-Agent', this.userAgent);
1480
+ const httpReq = buildHttpRequest('PUT', url, headers, callSignal, body);
1481
+ await executeHttpCall({
1482
+ request: httpReq,
1483
+ httpClient: this.httpClient,
1484
+ logger: this.logger,
1485
+ });
1486
+ };
1487
+ await executeCall(call, options);
1488
+ }
1489
+ }