@databricks/sdk-scim 0.0.0-dev → 0.1.0-dev.2

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