@databricks/sdk-networking 0.1.0-dev.3 → 0.1.0-dev.5

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.
package/src/v1/client.ts DELETED
@@ -1,1695 +0,0 @@
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 {z} from 'zod';
20
- import type {
21
- AccountNetworkPolicy,
22
- CreateAccountIpAccessListRequest,
23
- CreateAccountIpAccessListResponse,
24
- CreateEndpointRequest,
25
- CreateIpAccessList,
26
- CreateIpAccessListResponse,
27
- CreateNccPrivateEndpointRuleRequest,
28
- CreateNetworkConnectivityConfigRequest,
29
- CreateNetworkPolicyRequest,
30
- CreateNetworkRequest,
31
- CreatePrivateAccessSettingsRequest,
32
- CreateVpcEndpointRequest,
33
- CustomerFacingNetworkConnectivityConfig,
34
- CustomerFacingPrivateAccessSettings,
35
- CustomerFacingVpcEndpoint,
36
- DeleteAccountIpAccessListRequest,
37
- DeleteAccountIpAccessListResponse,
38
- DeleteEndpointRequest,
39
- DeleteIpAccessList,
40
- DeleteIpAccessListResponse,
41
- DeleteNccPrivateEndpointRuleRequest,
42
- DeleteNetworkConnectivityConfigRequest,
43
- DeleteNetworkPolicyRequest,
44
- DeleteNetworkRequest,
45
- DeletePrivateAccessSettingsRequest,
46
- DeleteVpcEndpointRequest,
47
- Endpoint,
48
- GetAccountIpAccessListRequest,
49
- GetAccountIpAccessListResponse,
50
- GetEndpointRequest,
51
- GetIpAccessList,
52
- GetIpAccessListResponse,
53
- GetNccPrivateEndpointRuleRequest,
54
- GetNetworkConnectivityConfigRequest,
55
- GetNetworkPolicyRequest,
56
- GetNetworkRequest,
57
- GetPrivateAccessSettingsRequest,
58
- GetVpcEndpointRequest,
59
- GetWorkspaceNetworkOptionRequest,
60
- ListAccountIpAccessListsRequest,
61
- ListAccountIpAccessListsResponse,
62
- ListEndpointsRequest,
63
- ListEndpointsResponse,
64
- ListIpAccessLists,
65
- ListIpAccessListsResponse,
66
- ListNccPrivateEndpointRulesRequest,
67
- ListNccPrivateEndpointRulesResponse,
68
- ListNetworkConnectivityConfigsRequest,
69
- ListNetworkConnectivityConfigsResponse,
70
- ListNetworkPoliciesRequest,
71
- ListNetworkPoliciesResponse,
72
- ListNetworkRequest,
73
- ListNetworkResponse,
74
- ListPrivateAccessSettingsRequest,
75
- ListPrivateAccessSettingsResponse,
76
- ListVpcEndpointRequest,
77
- ListVpcEndpointResponse,
78
- NccPrivateEndpointRule,
79
- Network,
80
- ReplaceAccountIpAccessListRequest,
81
- ReplaceAccountIpAccessListResponse,
82
- ReplaceIpAccessList,
83
- ReplaceIpAccessListResponse,
84
- UpdateAccountIpAccessListRequest,
85
- UpdateAccountIpAccessListResponse,
86
- UpdateIpAccessList,
87
- UpdateIpAccessListResponse,
88
- UpdateNccPrivateEndpointRuleRequest,
89
- UpdateNetworkPolicyRequest,
90
- UpdatePrivateAccessSettingsRequest,
91
- UpdateWorkspaceNetworkOptionRequest,
92
- WorkspaceNetworkOption,
93
- } from './model';
94
- import {
95
- marshalAccountNetworkPolicySchema,
96
- marshalCreateAccountIpAccessListRequestSchema,
97
- marshalCreateIpAccessListSchema,
98
- marshalCreateNetworkConnectivityConfigurationSchema,
99
- marshalCreateNetworkRequestSchema,
100
- marshalCreatePrivateAccessSettingsRequestSchema,
101
- marshalCreatePrivateEndpointRuleSchema,
102
- marshalCreateVpcEndpointRequestSchema,
103
- marshalCustomerFacingPrivateAccessSettingsSchema,
104
- marshalEndpointSchema,
105
- marshalReplaceAccountIpAccessListRequestSchema,
106
- marshalReplaceIpAccessListSchema,
107
- marshalUpdateAccountIpAccessListRequestSchema,
108
- marshalUpdateIpAccessListSchema,
109
- marshalUpdatePrivateEndpointRuleSchema,
110
- marshalWorkspaceNetworkOptionSchema,
111
- unmarshalAccountNetworkPolicySchema,
112
- unmarshalCreateAccountIpAccessListResponseSchema,
113
- unmarshalCreateIpAccessListResponseSchema,
114
- unmarshalCustomerFacingNetworkConnectivityConfigSchema,
115
- unmarshalCustomerFacingPrivateAccessSettingsSchema,
116
- unmarshalCustomerFacingVpcEndpointSchema,
117
- unmarshalDeleteAccountIpAccessListResponseSchema,
118
- unmarshalDeleteIpAccessListResponseSchema,
119
- unmarshalEndpointSchema,
120
- unmarshalGetAccountIpAccessListResponseSchema,
121
- unmarshalGetIpAccessListResponseSchema,
122
- unmarshalListAccountIpAccessListsResponseSchema,
123
- unmarshalListEndpointsResponseSchema,
124
- unmarshalListIpAccessListsResponseSchema,
125
- unmarshalListNccPrivateEndpointRulesResponseSchema,
126
- unmarshalListNetworkConnectivityConfigsResponseSchema,
127
- unmarshalListNetworkPoliciesResponseSchema,
128
- unmarshalNccPrivateEndpointRuleSchema,
129
- unmarshalNetworkSchema,
130
- unmarshalReplaceAccountIpAccessListResponseSchema,
131
- unmarshalReplaceIpAccessListResponseSchema,
132
- unmarshalUpdateAccountIpAccessListResponseSchema,
133
- unmarshalUpdateIpAccessListResponseSchema,
134
- unmarshalWorkspaceNetworkOptionSchema,
135
- } from './model';
136
-
137
- // Package identity segment for this client to be used in the User-Agent header.
138
- const PACKAGE_SEGMENT = {
139
- key: 'sdk-js-' + pkgJson.name.replace(/^@[^/]+\/sdk-/, ''),
140
- value: pkgJson.version,
141
- };
142
-
143
- export class NetworkingClient {
144
- private readonly host: string;
145
- // Fallback for endpoints whose path contains {account_id}. If the request
146
- // already carries an accountId, that value wins.
147
- private readonly accountId: string | undefined;
148
- // Workspace ID used to route workspace-level calls on unified hosts (SPOG).
149
- // When set, workspace-level methods send X-Databricks-Org-Id on every
150
- // request.
151
- private readonly workspaceId: string | undefined;
152
- private readonly httpClient: HttpClient;
153
- private readonly logger: Logger;
154
- // User-Agent header value. Composed once at construction from
155
- // createDefault() merged with this package's identity and the active
156
- // credential's name.
157
- private readonly userAgent: string;
158
-
159
- constructor(options: ClientOptions) {
160
- if (options.host === undefined) {
161
- throw new Error('Host is required.');
162
- }
163
- this.host = options.host.replace(/\/$/, '');
164
- this.accountId = options.accountId;
165
- this.workspaceId = options.workspaceId;
166
- this.logger = options.logger ?? new NoOpLogger();
167
- const info = createDefault()
168
- .with(PACKAGE_SEGMENT)
169
- .with({key: 'sdk-js-auth', value: AUTH_VERSION})
170
- .with({key: 'auth', value: options.credentials?.name() ?? 'default'});
171
- this.userAgent = info.toString();
172
- this.httpClient = newHttpClient(options);
173
- }
174
-
175
- /**
176
- * Creates an IP access list for the account.
177
- *
178
- * A list can be an allow list or a block list. See the top of this file for a description of
179
- * how the server treats allow lists and block lists at runtime.
180
- *
181
- * When creating or updating an IP access list:
182
- *
183
- * * For all allow lists and block lists combined, the API supports a maximum of 1000
184
- * IP/CIDR values, where one CIDR counts as a single value. Attempts to exceed that number
185
- * return error 400 with `error_code` value `QUOTA_EXCEEDED`.
186
- * * If the new list would block the calling user's current IP, error 400 is returned with
187
- * `error_code` value `INVALID_STATE`.
188
- *
189
- * It can take a few minutes for the changes to take effect.
190
- */
191
- async createAccountIpAccessList(
192
- req: CreateAccountIpAccessListRequest,
193
- options?: CallOptions
194
- ): Promise<CreateAccountIpAccessListResponse> {
195
- const url = `${this.host}/api/2.0/accounts/${req.accountId ?? this.accountId ?? ''}/ip-access-lists`;
196
- const body = marshalRequest(
197
- req,
198
- marshalCreateAccountIpAccessListRequestSchema
199
- );
200
- let resp: CreateAccountIpAccessListResponse | undefined;
201
- const call = async (callSignal?: AbortSignal): Promise<void> => {
202
- const headers = new Headers({'Content-Type': 'application/json'});
203
- headers.set('User-Agent', this.userAgent);
204
- const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
205
- const respBody = await executeHttpCall({
206
- request: httpReq,
207
- httpClient: this.httpClient,
208
- logger: this.logger,
209
- });
210
- resp = parseResponse(
211
- respBody,
212
- unmarshalCreateAccountIpAccessListResponseSchema
213
- );
214
- };
215
- await executeCall(call, options);
216
- if (resp === undefined) {
217
- throw new Error('operation completed without a result.');
218
- }
219
- return resp;
220
- }
221
-
222
- /** Deletes an IP access list, specified by its list ID. */
223
- async deleteAccountIpAccessList(
224
- req: DeleteAccountIpAccessListRequest,
225
- options?: CallOptions
226
- ): Promise<DeleteAccountIpAccessListResponse> {
227
- const url = `${this.host}/api/2.0/accounts/${req.accountId ?? this.accountId ?? ''}/ip-access-lists/${req.listId ?? ''}`;
228
- let resp: DeleteAccountIpAccessListResponse | undefined;
229
- const call = async (callSignal?: AbortSignal): Promise<void> => {
230
- const headers = new Headers();
231
- headers.set('User-Agent', this.userAgent);
232
- const httpReq = buildHttpRequest('DELETE', url, headers, callSignal);
233
- const respBody = await executeHttpCall({
234
- request: httpReq,
235
- httpClient: this.httpClient,
236
- logger: this.logger,
237
- });
238
- resp = parseResponse(
239
- respBody,
240
- unmarshalDeleteAccountIpAccessListResponseSchema
241
- );
242
- };
243
- await executeCall(call, options);
244
- if (resp === undefined) {
245
- throw new Error('operation completed without a result.');
246
- }
247
- return resp;
248
- }
249
-
250
- /** Gets an IP access list, specified by its list ID. */
251
- async getAccountIpAccessList(
252
- req: GetAccountIpAccessListRequest,
253
- options?: CallOptions
254
- ): Promise<GetAccountIpAccessListResponse> {
255
- const url = `${this.host}/api/2.0/accounts/${req.accountId ?? this.accountId ?? ''}/ip-access-lists/${req.listId ?? ''}`;
256
- let resp: GetAccountIpAccessListResponse | undefined;
257
- const call = async (callSignal?: AbortSignal): Promise<void> => {
258
- const headers = new Headers();
259
- headers.set('User-Agent', this.userAgent);
260
- const httpReq = buildHttpRequest('GET', url, headers, callSignal);
261
- const respBody = await executeHttpCall({
262
- request: httpReq,
263
- httpClient: this.httpClient,
264
- logger: this.logger,
265
- });
266
- resp = parseResponse(
267
- respBody,
268
- unmarshalGetAccountIpAccessListResponseSchema
269
- );
270
- };
271
- await executeCall(call, options);
272
- if (resp === undefined) {
273
- throw new Error('operation completed without a result.');
274
- }
275
- return resp;
276
- }
277
-
278
- /** Gets all IP access lists for the specified account. */
279
- async listAccountIpAccessLists(
280
- req: ListAccountIpAccessListsRequest,
281
- options?: CallOptions
282
- ): Promise<ListAccountIpAccessListsResponse> {
283
- const url = `${this.host}/api/2.0/accounts/${req.accountId ?? this.accountId ?? ''}/ip-access-lists`;
284
- let resp: ListAccountIpAccessListsResponse | undefined;
285
- const call = async (callSignal?: AbortSignal): Promise<void> => {
286
- const headers = new Headers();
287
- headers.set('User-Agent', this.userAgent);
288
- const httpReq = buildHttpRequest('GET', url, headers, callSignal);
289
- const respBody = await executeHttpCall({
290
- request: httpReq,
291
- httpClient: this.httpClient,
292
- logger: this.logger,
293
- });
294
- resp = parseResponse(
295
- respBody,
296
- unmarshalListAccountIpAccessListsResponseSchema
297
- );
298
- };
299
- await executeCall(call, options);
300
- if (resp === undefined) {
301
- throw new Error('operation completed without a result.');
302
- }
303
- return resp;
304
- }
305
-
306
- /**
307
- * Replaces an IP access list, specified by its ID.
308
- *
309
- * A list can include allow lists and block lists. See the top of this file for a description
310
- * of how the server treats allow lists and block lists at run time. When replacing an IP
311
- * access list:
312
- * * For all allow lists and block lists combined, the API supports a maximum of 1000 IP/CIDR values,
313
- * where one CIDR counts as a single value. Attempts to exceed that number return error 400 with `error_code`
314
- * value `QUOTA_EXCEEDED`.
315
- * * If the resulting list would block the calling user's current IP, error 400 is returned with `error_code`
316
- * value `INVALID_STATE`.
317
- * It can take a few minutes for the changes to take effect.
318
- */
319
- async replaceAccountIpAccessList(
320
- req: ReplaceAccountIpAccessListRequest,
321
- options?: CallOptions
322
- ): Promise<ReplaceAccountIpAccessListResponse> {
323
- const url = `${this.host}/api/2.0/accounts/${req.accountId ?? this.accountId ?? ''}/ip-access-lists/${req.listId ?? ''}`;
324
- const body = marshalRequest(
325
- req,
326
- marshalReplaceAccountIpAccessListRequestSchema
327
- );
328
- let resp: ReplaceAccountIpAccessListResponse | undefined;
329
- const call = async (callSignal?: AbortSignal): Promise<void> => {
330
- const headers = new Headers({'Content-Type': 'application/json'});
331
- headers.set('User-Agent', this.userAgent);
332
- const httpReq = buildHttpRequest('PUT', url, headers, callSignal, body);
333
- const respBody = await executeHttpCall({
334
- request: httpReq,
335
- httpClient: this.httpClient,
336
- logger: this.logger,
337
- });
338
- resp = parseResponse(
339
- respBody,
340
- unmarshalReplaceAccountIpAccessListResponseSchema
341
- );
342
- };
343
- await executeCall(call, options);
344
- if (resp === undefined) {
345
- throw new Error('operation completed without a result.');
346
- }
347
- return resp;
348
- }
349
-
350
- /**
351
- * Updates an existing IP access list, specified by its ID.
352
- *
353
- * A list can include allow lists and block lists. See the top of this file for a description
354
- * of how the server treats allow lists and block lists at run time.
355
- *
356
- * When updating an IP access list:
357
- *
358
- * * For all allow lists and block lists combined, the API supports a maximum of 1000
359
- * IP/CIDR values, where one CIDR counts as a single value. Attempts to exceed that number
360
- * return error 400 with `error_code` value `QUOTA_EXCEEDED`.
361
- * * If the updated list would block the calling user's current IP, error 400 is returned
362
- * with `error_code` value `INVALID_STATE`.
363
- *
364
- * It can take a few minutes for the changes to take effect.
365
- */
366
- async updateAccountIpAccessList(
367
- req: UpdateAccountIpAccessListRequest,
368
- options?: CallOptions
369
- ): Promise<UpdateAccountIpAccessListResponse> {
370
- const url = `${this.host}/api/2.0/accounts/${req.accountId ?? this.accountId ?? ''}/ip-access-lists/${req.listId ?? ''}`;
371
- const body = marshalRequest(
372
- req,
373
- marshalUpdateAccountIpAccessListRequestSchema
374
- );
375
- let resp: UpdateAccountIpAccessListResponse | undefined;
376
- const call = async (callSignal?: AbortSignal): Promise<void> => {
377
- const headers = new Headers({'Content-Type': 'application/json'});
378
- headers.set('User-Agent', this.userAgent);
379
- const httpReq = buildHttpRequest('PATCH', url, headers, callSignal, body);
380
- const respBody = await executeHttpCall({
381
- request: httpReq,
382
- httpClient: this.httpClient,
383
- logger: this.logger,
384
- });
385
- resp = parseResponse(
386
- respBody,
387
- unmarshalUpdateAccountIpAccessListResponseSchema
388
- );
389
- };
390
- await executeCall(call, options);
391
- if (resp === undefined) {
392
- throw new Error('operation completed without a result.');
393
- }
394
- return resp;
395
- }
396
-
397
- /**
398
- * Creates a new network connectivity endpoint that enables private connectivity
399
- * between your network resources and <Databricks> services.
400
- *
401
- * After creation, the endpoint is initially in the PENDING state. The <Databricks>
402
- * endpoint service automatically reviews and approves the endpoint within a few
403
- * minutes. Use the GET method to retrieve the latest endpoint state.
404
- *
405
- * An endpoint can be used only after it reaches the APPROVED state.
406
- */
407
- async createEndpoint(
408
- req: CreateEndpointRequest,
409
- options?: CallOptions
410
- ): Promise<Endpoint> {
411
- const url = `${this.host}/api/networking/v1/${req.parent ?? ''}/endpoints`;
412
- const body = marshalRequest(req.endpoint, marshalEndpointSchema);
413
- let resp: Endpoint | undefined;
414
- const call = async (callSignal?: AbortSignal): Promise<void> => {
415
- const headers = new Headers({'Content-Type': 'application/json'});
416
- if (this.workspaceId !== undefined) {
417
- headers.set('X-Databricks-Org-Id', this.workspaceId);
418
- }
419
- headers.set('User-Agent', this.userAgent);
420
- const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
421
- const respBody = await executeHttpCall({
422
- request: httpReq,
423
- httpClient: this.httpClient,
424
- logger: this.logger,
425
- });
426
- resp = parseResponse(respBody, unmarshalEndpointSchema);
427
- };
428
- await executeCall(call, options);
429
- if (resp === undefined) {
430
- throw new Error('operation completed without a result.');
431
- }
432
- return resp;
433
- }
434
-
435
- /**
436
- * Deletes a network endpoint. This will remove the endpoint configuration from <Databricks>.
437
- * Depending on the endpoint type and use case, you may also need to delete corresponding network resources
438
- * in your cloud provider account.
439
- */
440
- async deleteEndpoint(
441
- req: DeleteEndpointRequest,
442
- options?: CallOptions
443
- ): Promise<void> {
444
- const url = `${this.host}/api/networking/v1/${req.name ?? ''}`;
445
- const call = async (callSignal?: AbortSignal): Promise<void> => {
446
- const headers = new Headers();
447
- if (this.workspaceId !== undefined) {
448
- headers.set('X-Databricks-Org-Id', this.workspaceId);
449
- }
450
- headers.set('User-Agent', this.userAgent);
451
- const httpReq = buildHttpRequest('DELETE', url, headers, callSignal);
452
- await executeHttpCall({
453
- request: httpReq,
454
- httpClient: this.httpClient,
455
- logger: this.logger,
456
- });
457
- };
458
- await executeCall(call, options);
459
- }
460
-
461
- /** Gets details of a specific network endpoint. */
462
- async getEndpoint(
463
- req: GetEndpointRequest,
464
- options?: CallOptions
465
- ): Promise<Endpoint> {
466
- const url = `${this.host}/api/networking/v1/${req.name ?? ''}`;
467
- let resp: Endpoint | undefined;
468
- const call = async (callSignal?: AbortSignal): Promise<void> => {
469
- const headers = new Headers();
470
- if (this.workspaceId !== undefined) {
471
- headers.set('X-Databricks-Org-Id', this.workspaceId);
472
- }
473
- headers.set('User-Agent', this.userAgent);
474
- const httpReq = buildHttpRequest('GET', url, headers, callSignal);
475
- const respBody = await executeHttpCall({
476
- request: httpReq,
477
- httpClient: this.httpClient,
478
- logger: this.logger,
479
- });
480
- resp = parseResponse(respBody, unmarshalEndpointSchema);
481
- };
482
- await executeCall(call, options);
483
- if (resp === undefined) {
484
- throw new Error('operation completed without a result.');
485
- }
486
- return resp;
487
- }
488
-
489
- /** Lists all network connectivity endpoints for the account. */
490
- async listEndpoints(
491
- req: ListEndpointsRequest,
492
- options?: CallOptions
493
- ): Promise<ListEndpointsResponse> {
494
- const url = `${this.host}/api/networking/v1/${req.parent ?? ''}/endpoints`;
495
- const params = new URLSearchParams();
496
- if (req.pageToken !== undefined) {
497
- params.append('page_token', req.pageToken);
498
- }
499
- if (req.pageSize !== undefined) {
500
- params.append('page_size', String(req.pageSize));
501
- }
502
- const query = params.toString();
503
- const fullUrl = query !== '' ? `${url}?${query}` : url;
504
- let resp: ListEndpointsResponse | undefined;
505
- const call = async (callSignal?: AbortSignal): Promise<void> => {
506
- const headers = new Headers();
507
- if (this.workspaceId !== undefined) {
508
- headers.set('X-Databricks-Org-Id', this.workspaceId);
509
- }
510
- headers.set('User-Agent', this.userAgent);
511
- const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
512
- const respBody = await executeHttpCall({
513
- request: httpReq,
514
- httpClient: this.httpClient,
515
- logger: this.logger,
516
- });
517
- resp = parseResponse(respBody, unmarshalListEndpointsResponseSchema);
518
- };
519
- await executeCall(call, options);
520
- if (resp === undefined) {
521
- throw new Error('operation completed without a result.');
522
- }
523
- return resp;
524
- }
525
-
526
- async *listEndpointsIter(
527
- req: ListEndpointsRequest,
528
- options?: CallOptions
529
- ): AsyncGenerator<Endpoint> {
530
- const pageReq: ListEndpointsRequest = {...req};
531
- for (;;) {
532
- const resp = await this.listEndpoints(pageReq, options);
533
- for (const item of resp.items ?? []) {
534
- yield item;
535
- }
536
- if (resp.nextPageToken === undefined || resp.nextPageToken === '') {
537
- return;
538
- }
539
- pageReq.pageToken = resp.nextPageToken;
540
- }
541
- }
542
-
543
- /**
544
- * Creates an IP access list for this workspace.
545
- *
546
- * A list can be an allow list or a block list.
547
- * See the top of this file for a description of how the server treats allow lists and block lists at runtime.
548
- *
549
- * When creating or updating an IP access list:
550
- *
551
- * * For all allow lists and block lists combined, the API supports a maximum of 1000 IP/CIDR values,
552
- * where one CIDR counts as a single value. Attempts to exceed that number return error 400 with `error_code` value `QUOTA_EXCEEDED`.
553
- * * If the new list would block the calling user's current IP, error 400 is returned with `error_code` value `INVALID_STATE`.
554
- *
555
- * It can take a few minutes for the changes to take effect. **Note**: Your new IP access list has no effect until you enable the feature. See :method:workspaceconf/setStatus
556
- */
557
- async createIpAccessList(
558
- req: CreateIpAccessList,
559
- options?: CallOptions
560
- ): Promise<CreateIpAccessListResponse> {
561
- const url = `${this.host}/api/2.0/ip-access-lists`;
562
- const body = marshalRequest(req, marshalCreateIpAccessListSchema);
563
- let resp: CreateIpAccessListResponse | undefined;
564
- const call = async (callSignal?: AbortSignal): Promise<void> => {
565
- const headers = new Headers({'Content-Type': 'application/json'});
566
- if (this.workspaceId !== undefined) {
567
- headers.set('X-Databricks-Org-Id', this.workspaceId);
568
- }
569
- headers.set('User-Agent', this.userAgent);
570
- const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
571
- const respBody = await executeHttpCall({
572
- request: httpReq,
573
- httpClient: this.httpClient,
574
- logger: this.logger,
575
- });
576
- resp = parseResponse(respBody, unmarshalCreateIpAccessListResponseSchema);
577
- };
578
- await executeCall(call, options);
579
- if (resp === undefined) {
580
- throw new Error('operation completed without a result.');
581
- }
582
- return resp;
583
- }
584
-
585
- /** Deletes an IP access list, specified by its list ID. */
586
- async deleteIpAccessList(
587
- req: DeleteIpAccessList,
588
- options?: CallOptions
589
- ): Promise<DeleteIpAccessListResponse> {
590
- const url = `${this.host}/api/2.0/ip-access-lists/${req.listId ?? ''}`;
591
- let resp: DeleteIpAccessListResponse | undefined;
592
- const call = async (callSignal?: AbortSignal): Promise<void> => {
593
- const headers = new Headers();
594
- if (this.workspaceId !== undefined) {
595
- headers.set('X-Databricks-Org-Id', this.workspaceId);
596
- }
597
- headers.set('User-Agent', this.userAgent);
598
- const httpReq = buildHttpRequest('DELETE', url, headers, callSignal);
599
- const respBody = await executeHttpCall({
600
- request: httpReq,
601
- httpClient: this.httpClient,
602
- logger: this.logger,
603
- });
604
- resp = parseResponse(respBody, unmarshalDeleteIpAccessListResponseSchema);
605
- };
606
- await executeCall(call, options);
607
- if (resp === undefined) {
608
- throw new Error('operation completed without a result.');
609
- }
610
- return resp;
611
- }
612
-
613
- /** Gets an IP access list, specified by its list ID. */
614
- async getIpAccessList(
615
- req: GetIpAccessList,
616
- options?: CallOptions
617
- ): Promise<GetIpAccessListResponse> {
618
- const url = `${this.host}/api/2.0/ip-access-lists/${req.listId ?? ''}`;
619
- let resp: GetIpAccessListResponse | undefined;
620
- const call = async (callSignal?: AbortSignal): Promise<void> => {
621
- const headers = new Headers();
622
- if (this.workspaceId !== undefined) {
623
- headers.set('X-Databricks-Org-Id', this.workspaceId);
624
- }
625
- headers.set('User-Agent', this.userAgent);
626
- const httpReq = buildHttpRequest('GET', url, headers, callSignal);
627
- const respBody = await executeHttpCall({
628
- request: httpReq,
629
- httpClient: this.httpClient,
630
- logger: this.logger,
631
- });
632
- resp = parseResponse(respBody, unmarshalGetIpAccessListResponseSchema);
633
- };
634
- await executeCall(call, options);
635
- if (resp === undefined) {
636
- throw new Error('operation completed without a result.');
637
- }
638
- return resp;
639
- }
640
-
641
- /** Gets all IP access lists for the specified workspace. */
642
- async listIpAccessLists(
643
- _req: ListIpAccessLists,
644
- options?: CallOptions
645
- ): Promise<ListIpAccessListsResponse> {
646
- const url = `${this.host}/api/2.0/ip-access-lists`;
647
- let resp: ListIpAccessListsResponse | undefined;
648
- const call = async (callSignal?: AbortSignal): Promise<void> => {
649
- const headers = new Headers();
650
- if (this.workspaceId !== undefined) {
651
- headers.set('X-Databricks-Org-Id', this.workspaceId);
652
- }
653
- headers.set('User-Agent', this.userAgent);
654
- const httpReq = buildHttpRequest('GET', url, headers, callSignal);
655
- const respBody = await executeHttpCall({
656
- request: httpReq,
657
- httpClient: this.httpClient,
658
- logger: this.logger,
659
- });
660
- resp = parseResponse(respBody, unmarshalListIpAccessListsResponseSchema);
661
- };
662
- await executeCall(call, options);
663
- if (resp === undefined) {
664
- throw new Error('operation completed without a result.');
665
- }
666
- return resp;
667
- }
668
-
669
- /**
670
- * Replaces an IP access list, specified by its ID.
671
- *
672
- * A list can include allow lists and block lists. See the top
673
- * of this file for a description of how the server treats allow lists and block lists at run time. When
674
- * replacing an IP access list:
675
- * * For all allow lists and block lists combined, the API supports a maximum of 1000 IP/CIDR values,
676
- * where one CIDR counts as a single value. Attempts to exceed that number return error 400 with `error_code`
677
- * value `QUOTA_EXCEEDED`.
678
- * * If the resulting list would block the calling user's current IP, error 400 is returned with `error_code`
679
- * value `INVALID_STATE`.
680
- * It can take a few minutes for the changes to take effect. Note that your resulting IP access list has no
681
- * effect until you enable the feature. See :method:workspaceconf/setStatus.
682
- */
683
- async replaceIpAccessList(
684
- req: ReplaceIpAccessList,
685
- options?: CallOptions
686
- ): Promise<ReplaceIpAccessListResponse> {
687
- const url = `${this.host}/api/2.0/ip-access-lists/${req.listId ?? ''}`;
688
- const body = marshalRequest(req, marshalReplaceIpAccessListSchema);
689
- let resp: ReplaceIpAccessListResponse | undefined;
690
- const call = async (callSignal?: AbortSignal): Promise<void> => {
691
- const headers = new Headers({'Content-Type': 'application/json'});
692
- if (this.workspaceId !== undefined) {
693
- headers.set('X-Databricks-Org-Id', this.workspaceId);
694
- }
695
- headers.set('User-Agent', this.userAgent);
696
- const httpReq = buildHttpRequest('PUT', url, headers, callSignal, body);
697
- const respBody = await executeHttpCall({
698
- request: httpReq,
699
- httpClient: this.httpClient,
700
- logger: this.logger,
701
- });
702
- resp = parseResponse(
703
- respBody,
704
- unmarshalReplaceIpAccessListResponseSchema
705
- );
706
- };
707
- await executeCall(call, options);
708
- if (resp === undefined) {
709
- throw new Error('operation completed without a result.');
710
- }
711
- return resp;
712
- }
713
-
714
- /**
715
- * Updates an existing IP access list, specified by its ID.
716
- *
717
- * A list can include allow lists and block lists.
718
- * See the top of this file for a description of how the server treats allow lists and block lists at run time.
719
- *
720
- * When updating an IP access list:
721
- *
722
- * * For all allow lists and block lists combined, the API supports a maximum of 1000 IP/CIDR values,
723
- * where one CIDR counts as a single value. Attempts to exceed that number return error 400 with `error_code` value `QUOTA_EXCEEDED`.
724
- * * If the updated list would block the calling user's current IP, error 400 is returned with `error_code` value `INVALID_STATE`.
725
- *
726
- * It can take a few minutes for the changes to take effect. Note that your resulting IP access list has no effect until you enable
727
- * the feature. See :method:workspaceconf/setStatus.
728
- */
729
- async updateIpAccessList(
730
- req: UpdateIpAccessList,
731
- options?: CallOptions
732
- ): Promise<UpdateIpAccessListResponse> {
733
- const url = `${this.host}/api/2.0/ip-access-lists/${req.listId ?? ''}`;
734
- const body = marshalRequest(req, marshalUpdateIpAccessListSchema);
735
- let resp: UpdateIpAccessListResponse | undefined;
736
- const call = async (callSignal?: AbortSignal): Promise<void> => {
737
- const headers = new Headers({'Content-Type': 'application/json'});
738
- if (this.workspaceId !== undefined) {
739
- headers.set('X-Databricks-Org-Id', this.workspaceId);
740
- }
741
- headers.set('User-Agent', this.userAgent);
742
- const httpReq = buildHttpRequest('PATCH', url, headers, callSignal, body);
743
- const respBody = await executeHttpCall({
744
- request: httpReq,
745
- httpClient: this.httpClient,
746
- logger: this.logger,
747
- });
748
- resp = parseResponse(respBody, unmarshalUpdateIpAccessListResponseSchema);
749
- };
750
- await executeCall(call, options);
751
- if (resp === undefined) {
752
- throw new Error('operation completed without a result.');
753
- }
754
- return resp;
755
- }
756
-
757
- /**
758
- * Creates a network connectivity configuration (NCC), which provides stable Azure service
759
- * subnets when accessing your Azure Storage accounts. You can also use a network connectivity configuration to create
760
- * <Databricks> managed private endpoints so that <Databricks> serverless compute resources privately access your
761
- * resources.
762
- *
763
- * **IMPORTANT**: After you create the network connectivity configuration, you must assign one or more workspaces to the new network connectivity configuration.
764
- * You can share one network connectivity configuration with multiple workspaces from the same Azure region within
765
- * the same <Databricks> account.
766
- * See [configure serverless secure connectivity](https://learn.microsoft.com/azure/databricks/security/network/serverless-network-security).
767
- */
768
- async createNetworkConnectivityConfigPublic(
769
- req: CreateNetworkConnectivityConfigRequest,
770
- options?: CallOptions
771
- ): Promise<CustomerFacingNetworkConnectivityConfig> {
772
- const url = `${this.host}/api/2.0/accounts/${req.accountId ?? this.accountId ?? ''}/network-connectivity-configs`;
773
- const body = marshalRequest(
774
- req.networkConnectivityConfig,
775
- marshalCreateNetworkConnectivityConfigurationSchema
776
- );
777
- let resp: CustomerFacingNetworkConnectivityConfig | undefined;
778
- const call = async (callSignal?: AbortSignal): Promise<void> => {
779
- const headers = new Headers({'Content-Type': 'application/json'});
780
- headers.set('User-Agent', this.userAgent);
781
- const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
782
- const respBody = await executeHttpCall({
783
- request: httpReq,
784
- httpClient: this.httpClient,
785
- logger: this.logger,
786
- });
787
- resp = parseResponse(
788
- respBody,
789
- unmarshalCustomerFacingNetworkConnectivityConfigSchema
790
- );
791
- };
792
- await executeCall(call, options);
793
- if (resp === undefined) {
794
- throw new Error('operation completed without a result.');
795
- }
796
- return resp;
797
- }
798
-
799
- /** Deletes a network connectivity configuration. */
800
- async deleteNetworkConnectivityConfigPublic(
801
- req: DeleteNetworkConnectivityConfigRequest,
802
- options?: CallOptions
803
- ): Promise<void> {
804
- const url = `${this.host}/api/2.0/accounts/${req.accountId ?? this.accountId ?? ''}/network-connectivity-configs/${req.networkConnectivityConfigId ?? ''}`;
805
- const call = async (callSignal?: AbortSignal): Promise<void> => {
806
- const headers = new Headers();
807
- headers.set('User-Agent', this.userAgent);
808
- const httpReq = buildHttpRequest('DELETE', url, headers, callSignal);
809
- await executeHttpCall({
810
- request: httpReq,
811
- httpClient: this.httpClient,
812
- logger: this.logger,
813
- });
814
- };
815
- await executeCall(call, options);
816
- }
817
-
818
- /** Gets a network connectivity configuration. */
819
- async getNetworkConnectivityConfigPublic(
820
- req: GetNetworkConnectivityConfigRequest,
821
- options?: CallOptions
822
- ): Promise<CustomerFacingNetworkConnectivityConfig> {
823
- const url = `${this.host}/api/2.0/accounts/${req.accountId ?? this.accountId ?? ''}/network-connectivity-configs/${req.networkConnectivityConfigId ?? ''}`;
824
- let resp: CustomerFacingNetworkConnectivityConfig | undefined;
825
- const call = async (callSignal?: AbortSignal): Promise<void> => {
826
- const headers = new Headers();
827
- headers.set('User-Agent', this.userAgent);
828
- const httpReq = buildHttpRequest('GET', url, headers, callSignal);
829
- const respBody = await executeHttpCall({
830
- request: httpReq,
831
- httpClient: this.httpClient,
832
- logger: this.logger,
833
- });
834
- resp = parseResponse(
835
- respBody,
836
- unmarshalCustomerFacingNetworkConnectivityConfigSchema
837
- );
838
- };
839
- await executeCall(call, options);
840
- if (resp === undefined) {
841
- throw new Error('operation completed without a result.');
842
- }
843
- return resp;
844
- }
845
-
846
- /** Gets an array of network connectivity configurations. */
847
- async listNetworkConnectivityConfigsPublic(
848
- req: ListNetworkConnectivityConfigsRequest,
849
- options?: CallOptions
850
- ): Promise<ListNetworkConnectivityConfigsResponse> {
851
- const url = `${this.host}/api/2.0/accounts/${req.accountId ?? this.accountId ?? ''}/network-connectivity-configs`;
852
- const params = new URLSearchParams();
853
- if (req.pageToken !== undefined) {
854
- params.append('page_token', req.pageToken);
855
- }
856
- const query = params.toString();
857
- const fullUrl = query !== '' ? `${url}?${query}` : url;
858
- let resp: ListNetworkConnectivityConfigsResponse | undefined;
859
- const call = async (callSignal?: AbortSignal): Promise<void> => {
860
- const headers = new Headers();
861
- headers.set('User-Agent', this.userAgent);
862
- const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
863
- const respBody = await executeHttpCall({
864
- request: httpReq,
865
- httpClient: this.httpClient,
866
- logger: this.logger,
867
- });
868
- resp = parseResponse(
869
- respBody,
870
- unmarshalListNetworkConnectivityConfigsResponseSchema
871
- );
872
- };
873
- await executeCall(call, options);
874
- if (resp === undefined) {
875
- throw new Error('operation completed without a result.');
876
- }
877
- return resp;
878
- }
879
-
880
- async *listNetworkConnectivityConfigsPublicIter(
881
- req: ListNetworkConnectivityConfigsRequest,
882
- options?: CallOptions
883
- ): AsyncGenerator<CustomerFacingNetworkConnectivityConfig> {
884
- const pageReq: ListNetworkConnectivityConfigsRequest = {...req};
885
- for (;;) {
886
- const resp = await this.listNetworkConnectivityConfigsPublic(
887
- pageReq,
888
- options
889
- );
890
- for (const item of resp.items ?? []) {
891
- yield item;
892
- }
893
- if (resp.nextPageToken === undefined || resp.nextPageToken === '') {
894
- return;
895
- }
896
- pageReq.pageToken = resp.nextPageToken;
897
- }
898
- }
899
-
900
- /**
901
- * Create a private endpoint rule for the specified network connectivity config object.
902
- * Once the object is created, <Databricks> asynchronously provisions a new Azure private endpoint to your
903
- * specified Azure resource.
904
- *
905
- * **IMPORTANT**: You must use Azure portal or other Azure tools to approve the private endpoint to complete the
906
- * connection. To get the information of the private endpoint created, make a `GET` request on the new private
907
- * endpoint rule. See [serverless private link](https://learn.microsoft.com/azure/databricks/security/network/serverless-network-security/serverless-private-link).
908
- */
909
- async createNccPrivateEndpointRule(
910
- req: CreateNccPrivateEndpointRuleRequest,
911
- options?: CallOptions
912
- ): Promise<NccPrivateEndpointRule> {
913
- const url = `${this.host}/api/2.0/accounts/${req.accountId ?? this.accountId ?? ''}/network-connectivity-configs/${req.networkConnectivityConfigId ?? ''}/private-endpoint-rules`;
914
- const body = marshalRequest(
915
- req.privateEndpointRule,
916
- marshalCreatePrivateEndpointRuleSchema
917
- );
918
- let resp: NccPrivateEndpointRule | undefined;
919
- const call = async (callSignal?: AbortSignal): Promise<void> => {
920
- const headers = new Headers({'Content-Type': 'application/json'});
921
- headers.set('User-Agent', this.userAgent);
922
- const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
923
- const respBody = await executeHttpCall({
924
- request: httpReq,
925
- httpClient: this.httpClient,
926
- logger: this.logger,
927
- });
928
- resp = parseResponse(respBody, unmarshalNccPrivateEndpointRuleSchema);
929
- };
930
- await executeCall(call, options);
931
- if (resp === undefined) {
932
- throw new Error('operation completed without a result.');
933
- }
934
- return resp;
935
- }
936
-
937
- /**
938
- * Initiates deleting a private endpoint rule. If the connection state is PENDING or EXPIRED,
939
- * the private endpoint is immediately deleted. Otherwise, the private endpoint is deactivated
940
- * and will be deleted after one day of deactivation. When a private endpoint is deactivated,
941
- * the `deactivated` field is set to `true` and the private endpoint is not
942
- * available to your serverless compute resources.
943
- */
944
- async deleteNccPrivateEndpointRule(
945
- req: DeleteNccPrivateEndpointRuleRequest,
946
- options?: CallOptions
947
- ): Promise<NccPrivateEndpointRule> {
948
- const url = `${this.host}/api/2.0/accounts/${req.accountId ?? this.accountId ?? ''}/network-connectivity-configs/${req.networkConnectivityConfigId ?? ''}/private-endpoint-rules/${req.privateEndpointRuleId ?? ''}`;
949
- let resp: NccPrivateEndpointRule | undefined;
950
- const call = async (callSignal?: AbortSignal): Promise<void> => {
951
- const headers = new Headers();
952
- headers.set('User-Agent', this.userAgent);
953
- const httpReq = buildHttpRequest('DELETE', url, headers, callSignal);
954
- const respBody = await executeHttpCall({
955
- request: httpReq,
956
- httpClient: this.httpClient,
957
- logger: this.logger,
958
- });
959
- resp = parseResponse(respBody, unmarshalNccPrivateEndpointRuleSchema);
960
- };
961
- await executeCall(call, options);
962
- if (resp === undefined) {
963
- throw new Error('operation completed without a result.');
964
- }
965
- return resp;
966
- }
967
-
968
- /** Gets the private endpoint rule. */
969
- async getNccPrivateEndpointRule(
970
- req: GetNccPrivateEndpointRuleRequest,
971
- options?: CallOptions
972
- ): Promise<NccPrivateEndpointRule> {
973
- const url = `${this.host}/api/2.0/accounts/${req.accountId ?? this.accountId ?? ''}/network-connectivity-configs/${req.networkConnectivityConfigId ?? ''}/private-endpoint-rules/${req.privateEndpointRuleId ?? ''}`;
974
- let resp: NccPrivateEndpointRule | undefined;
975
- const call = async (callSignal?: AbortSignal): Promise<void> => {
976
- const headers = new Headers();
977
- headers.set('User-Agent', this.userAgent);
978
- const httpReq = buildHttpRequest('GET', url, headers, callSignal);
979
- const respBody = await executeHttpCall({
980
- request: httpReq,
981
- httpClient: this.httpClient,
982
- logger: this.logger,
983
- });
984
- resp = parseResponse(respBody, unmarshalNccPrivateEndpointRuleSchema);
985
- };
986
- await executeCall(call, options);
987
- if (resp === undefined) {
988
- throw new Error('operation completed without a result.');
989
- }
990
- return resp;
991
- }
992
-
993
- /** Gets an array of private endpoint rules. */
994
- async listNccPrivateEndpointRules(
995
- req: ListNccPrivateEndpointRulesRequest,
996
- options?: CallOptions
997
- ): Promise<ListNccPrivateEndpointRulesResponse> {
998
- const url = `${this.host}/api/2.0/accounts/${req.accountId ?? this.accountId ?? ''}/network-connectivity-configs/${req.networkConnectivityConfigId ?? ''}/private-endpoint-rules`;
999
- const params = new URLSearchParams();
1000
- if (req.pageToken !== undefined) {
1001
- params.append('page_token', req.pageToken);
1002
- }
1003
- const query = params.toString();
1004
- const fullUrl = query !== '' ? `${url}?${query}` : url;
1005
- let resp: ListNccPrivateEndpointRulesResponse | undefined;
1006
- const call = async (callSignal?: AbortSignal): Promise<void> => {
1007
- const headers = new Headers();
1008
- headers.set('User-Agent', this.userAgent);
1009
- const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
1010
- const respBody = await executeHttpCall({
1011
- request: httpReq,
1012
- httpClient: this.httpClient,
1013
- logger: this.logger,
1014
- });
1015
- resp = parseResponse(
1016
- respBody,
1017
- unmarshalListNccPrivateEndpointRulesResponseSchema
1018
- );
1019
- };
1020
- await executeCall(call, options);
1021
- if (resp === undefined) {
1022
- throw new Error('operation completed without a result.');
1023
- }
1024
- return resp;
1025
- }
1026
-
1027
- async *listNccPrivateEndpointRulesIter(
1028
- req: ListNccPrivateEndpointRulesRequest,
1029
- options?: CallOptions
1030
- ): AsyncGenerator<NccPrivateEndpointRule> {
1031
- const pageReq: ListNccPrivateEndpointRulesRequest = {...req};
1032
- for (;;) {
1033
- const resp = await this.listNccPrivateEndpointRules(pageReq, options);
1034
- for (const item of resp.items ?? []) {
1035
- yield item;
1036
- }
1037
- if (resp.nextPageToken === undefined || resp.nextPageToken === '') {
1038
- return;
1039
- }
1040
- pageReq.pageToken = resp.nextPageToken;
1041
- }
1042
- }
1043
-
1044
- /** Updates a private endpoint rule. Currently only a private endpoint rule to customer-managed resources is allowed to be updated. */
1045
- async updateNccPrivateEndpointRule(
1046
- req: UpdateNccPrivateEndpointRuleRequest,
1047
- options?: CallOptions
1048
- ): Promise<NccPrivateEndpointRule> {
1049
- const url = `${this.host}/api/2.0/accounts/${req.accountId ?? this.accountId ?? ''}/network-connectivity-configs/${req.networkConnectivityConfigId ?? ''}/private-endpoint-rules/${req.privateEndpointRuleId ?? ''}`;
1050
- const params = new URLSearchParams();
1051
- if (req.updateMask !== undefined) {
1052
- params.append('update_mask', req.updateMask.toString());
1053
- }
1054
- const query = params.toString();
1055
- const fullUrl = query !== '' ? `${url}?${query}` : url;
1056
- const body = marshalRequest(
1057
- req.privateEndpointRule,
1058
- marshalUpdatePrivateEndpointRuleSchema
1059
- );
1060
- let resp: NccPrivateEndpointRule | undefined;
1061
- const call = async (callSignal?: AbortSignal): Promise<void> => {
1062
- const headers = new Headers({'Content-Type': 'application/json'});
1063
- headers.set('User-Agent', this.userAgent);
1064
- const httpReq = buildHttpRequest(
1065
- 'PATCH',
1066
- fullUrl,
1067
- headers,
1068
- callSignal,
1069
- body
1070
- );
1071
- const respBody = await executeHttpCall({
1072
- request: httpReq,
1073
- httpClient: this.httpClient,
1074
- logger: this.logger,
1075
- });
1076
- resp = parseResponse(respBody, unmarshalNccPrivateEndpointRuleSchema);
1077
- };
1078
- await executeCall(call, options);
1079
- if (resp === undefined) {
1080
- throw new Error('operation completed without a result.');
1081
- }
1082
- return resp;
1083
- }
1084
-
1085
- /**
1086
- * Creates a new network policy to manage which network destinations can be accessed from the <Databricks>
1087
- * environment.
1088
- */
1089
- async createNetworkPolicyRpc(
1090
- req: CreateNetworkPolicyRequest,
1091
- options?: CallOptions
1092
- ): Promise<AccountNetworkPolicy> {
1093
- const url = `${this.host}/api/2.0/accounts/${req.accountId ?? this.accountId ?? ''}/network-policies`;
1094
- const body = marshalRequest(
1095
- req.networkPolicy,
1096
- marshalAccountNetworkPolicySchema
1097
- );
1098
- let resp: AccountNetworkPolicy | undefined;
1099
- const call = async (callSignal?: AbortSignal): Promise<void> => {
1100
- const headers = new Headers({'Content-Type': 'application/json'});
1101
- headers.set('User-Agent', this.userAgent);
1102
- const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
1103
- const respBody = await executeHttpCall({
1104
- request: httpReq,
1105
- httpClient: this.httpClient,
1106
- logger: this.logger,
1107
- });
1108
- resp = parseResponse(respBody, unmarshalAccountNetworkPolicySchema);
1109
- };
1110
- await executeCall(call, options);
1111
- if (resp === undefined) {
1112
- throw new Error('operation completed without a result.');
1113
- }
1114
- return resp;
1115
- }
1116
-
1117
- /** Deletes a network policy. Cannot be called on 'default-policy'. */
1118
- async deleteNetworkPolicyRpc(
1119
- req: DeleteNetworkPolicyRequest,
1120
- options?: CallOptions
1121
- ): Promise<void> {
1122
- const url = `${this.host}/api/2.0/accounts/${req.accountId ?? this.accountId ?? ''}/network-policies/${req.networkPolicyId ?? ''}`;
1123
- const call = async (callSignal?: AbortSignal): Promise<void> => {
1124
- const headers = new Headers();
1125
- headers.set('User-Agent', this.userAgent);
1126
- const httpReq = buildHttpRequest('DELETE', url, headers, callSignal);
1127
- await executeHttpCall({
1128
- request: httpReq,
1129
- httpClient: this.httpClient,
1130
- logger: this.logger,
1131
- });
1132
- };
1133
- await executeCall(call, options);
1134
- }
1135
-
1136
- /** Gets a network policy. */
1137
- async getNetworkPolicyRpc(
1138
- req: GetNetworkPolicyRequest,
1139
- options?: CallOptions
1140
- ): Promise<AccountNetworkPolicy> {
1141
- const url = `${this.host}/api/2.0/accounts/${req.accountId ?? this.accountId ?? ''}/network-policies/${req.networkPolicyId ?? ''}`;
1142
- let resp: AccountNetworkPolicy | undefined;
1143
- const call = async (callSignal?: AbortSignal): Promise<void> => {
1144
- const headers = new Headers();
1145
- headers.set('User-Agent', this.userAgent);
1146
- const httpReq = buildHttpRequest('GET', url, headers, callSignal);
1147
- const respBody = await executeHttpCall({
1148
- request: httpReq,
1149
- httpClient: this.httpClient,
1150
- logger: this.logger,
1151
- });
1152
- resp = parseResponse(respBody, unmarshalAccountNetworkPolicySchema);
1153
- };
1154
- await executeCall(call, options);
1155
- if (resp === undefined) {
1156
- throw new Error('operation completed without a result.');
1157
- }
1158
- return resp;
1159
- }
1160
-
1161
- /** Gets an array of network policies. */
1162
- async listNetworkPoliciesRpc(
1163
- req: ListNetworkPoliciesRequest,
1164
- options?: CallOptions
1165
- ): Promise<ListNetworkPoliciesResponse> {
1166
- const url = `${this.host}/api/2.0/accounts/${req.accountId ?? this.accountId ?? ''}/network-policies`;
1167
- const params = new URLSearchParams();
1168
- if (req.pageToken !== undefined) {
1169
- params.append('page_token', req.pageToken);
1170
- }
1171
- const query = params.toString();
1172
- const fullUrl = query !== '' ? `${url}?${query}` : url;
1173
- let resp: ListNetworkPoliciesResponse | undefined;
1174
- const call = async (callSignal?: AbortSignal): Promise<void> => {
1175
- const headers = new Headers();
1176
- headers.set('User-Agent', this.userAgent);
1177
- const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
1178
- const respBody = await executeHttpCall({
1179
- request: httpReq,
1180
- httpClient: this.httpClient,
1181
- logger: this.logger,
1182
- });
1183
- resp = parseResponse(
1184
- respBody,
1185
- unmarshalListNetworkPoliciesResponseSchema
1186
- );
1187
- };
1188
- await executeCall(call, options);
1189
- if (resp === undefined) {
1190
- throw new Error('operation completed without a result.');
1191
- }
1192
- return resp;
1193
- }
1194
-
1195
- async *listNetworkPoliciesRpcIter(
1196
- req: ListNetworkPoliciesRequest,
1197
- options?: CallOptions
1198
- ): AsyncGenerator<AccountNetworkPolicy> {
1199
- const pageReq: ListNetworkPoliciesRequest = {...req};
1200
- for (;;) {
1201
- const resp = await this.listNetworkPoliciesRpc(pageReq, options);
1202
- for (const item of resp.items ?? []) {
1203
- yield item;
1204
- }
1205
- if (resp.nextPageToken === undefined || resp.nextPageToken === '') {
1206
- return;
1207
- }
1208
- pageReq.pageToken = resp.nextPageToken;
1209
- }
1210
- }
1211
-
1212
- /** Updates a network policy. This allows you to modify the configuration of a network policy. */
1213
- async updateNetworkPolicyRpc(
1214
- req: UpdateNetworkPolicyRequest,
1215
- options?: CallOptions
1216
- ): Promise<AccountNetworkPolicy> {
1217
- const url = `${this.host}/api/2.0/accounts/${req.accountId ?? this.accountId ?? ''}/network-policies/${req.networkPolicyId ?? ''}`;
1218
- const body = marshalRequest(
1219
- req.networkPolicy,
1220
- marshalAccountNetworkPolicySchema
1221
- );
1222
- let resp: AccountNetworkPolicy | undefined;
1223
- const call = async (callSignal?: AbortSignal): Promise<void> => {
1224
- const headers = new Headers({'Content-Type': 'application/json'});
1225
- headers.set('User-Agent', this.userAgent);
1226
- const httpReq = buildHttpRequest('PUT', url, headers, callSignal, body);
1227
- const respBody = await executeHttpCall({
1228
- request: httpReq,
1229
- httpClient: this.httpClient,
1230
- logger: this.logger,
1231
- });
1232
- resp = parseResponse(respBody, unmarshalAccountNetworkPolicySchema);
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
- /** Creates a <Databricks> network configuration that represents an VPC and its resources. The VPC will be used for new <Databricks> clusters. This requires a pre-existing VPC and subnets. */
1242
- async createNetworkPublic(
1243
- req: CreateNetworkRequest,
1244
- options?: CallOptions
1245
- ): Promise<Network> {
1246
- const url = `${this.host}/api/2.0/accounts/${req.accountId ?? this.accountId ?? ''}/networks`;
1247
- const body = marshalRequest(req, marshalCreateNetworkRequestSchema);
1248
- let resp: Network | undefined;
1249
- const call = async (callSignal?: AbortSignal): Promise<void> => {
1250
- const headers = new Headers({'Content-Type': 'application/json'});
1251
- headers.set('User-Agent', this.userAgent);
1252
- const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
1253
- const respBody = await executeHttpCall({
1254
- request: httpReq,
1255
- httpClient: this.httpClient,
1256
- logger: this.logger,
1257
- });
1258
- resp = parseResponse(respBody, unmarshalNetworkSchema);
1259
- };
1260
- await executeCall(call, options);
1261
- if (resp === undefined) {
1262
- throw new Error('operation completed without a result.');
1263
- }
1264
- return resp;
1265
- }
1266
-
1267
- /**
1268
- * Creates a private access settings configuration, which represents
1269
- * network access restrictions for workspace resources. Private access
1270
- * settings configure whether workspaces can be accessed from the public
1271
- * internet or only from private endpoints.
1272
- */
1273
- async createPrivateAccessSettingsPublic(
1274
- req: CreatePrivateAccessSettingsRequest,
1275
- options?: CallOptions
1276
- ): Promise<CustomerFacingPrivateAccessSettings> {
1277
- const url = `${this.host}/api/2.0/accounts/${req.accountId ?? this.accountId ?? ''}/private-access-settings`;
1278
- const body = marshalRequest(
1279
- req,
1280
- marshalCreatePrivateAccessSettingsRequestSchema
1281
- );
1282
- let resp: CustomerFacingPrivateAccessSettings | undefined;
1283
- const call = async (callSignal?: AbortSignal): Promise<void> => {
1284
- const headers = new Headers({'Content-Type': 'application/json'});
1285
- headers.set('User-Agent', this.userAgent);
1286
- const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
1287
- const respBody = await executeHttpCall({
1288
- request: httpReq,
1289
- httpClient: this.httpClient,
1290
- logger: this.logger,
1291
- });
1292
- resp = parseResponse(
1293
- respBody,
1294
- unmarshalCustomerFacingPrivateAccessSettingsSchema
1295
- );
1296
- };
1297
- await executeCall(call, options);
1298
- if (resp === undefined) {
1299
- throw new Error('operation completed without a result.');
1300
- }
1301
- return resp;
1302
- }
1303
-
1304
- /**
1305
- * Creates a VPC endpoint configuration, which represents a
1306
- * [VPC endpoint](https://docs.aws.amazon.com/vpc/latest/privatelink/vpc-endpoints.html)
1307
- * object in AWS used to communicate privately with <Databricks> over
1308
- * [AWS PrivateLink](https://aws.amazon.com/privatelink).
1309
- *
1310
- * After you create the VPC endpoint configuration, the <Databricks>
1311
- * [endpoint service](https://docs.aws.amazon.com/vpc/latest/privatelink/privatelink-share-your-services.html)
1312
- * automatically accepts the VPC endpoint.
1313
- *
1314
- * Before configuring PrivateLink, read the
1315
- * [<Databricks> article about PrivateLink](https://docs.databricks.com/administration-guide/cloud-configurations/aws/privatelink.html).
1316
- */
1317
- async createVpcEndpointPublic(
1318
- req: CreateVpcEndpointRequest,
1319
- options?: CallOptions
1320
- ): Promise<CustomerFacingVpcEndpoint> {
1321
- const url = `${this.host}/api/2.0/accounts/${req.accountId ?? this.accountId ?? ''}/vpc-endpoints`;
1322
- const body = marshalRequest(req, marshalCreateVpcEndpointRequestSchema);
1323
- let resp: CustomerFacingVpcEndpoint | undefined;
1324
- const call = async (callSignal?: AbortSignal): Promise<void> => {
1325
- const headers = new Headers({'Content-Type': 'application/json'});
1326
- headers.set('User-Agent', this.userAgent);
1327
- const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
1328
- const respBody = await executeHttpCall({
1329
- request: httpReq,
1330
- httpClient: this.httpClient,
1331
- logger: this.logger,
1332
- });
1333
- resp = parseResponse(respBody, unmarshalCustomerFacingVpcEndpointSchema);
1334
- };
1335
- await executeCall(call, options);
1336
- if (resp === undefined) {
1337
- throw new Error('operation completed without a result.');
1338
- }
1339
- return resp;
1340
- }
1341
-
1342
- /**
1343
- * Deletes a <Databricks> network configuration, which represents a cloud VPC and its resources. You cannot delete a network that is associated with a workspace.
1344
- *
1345
- * This operation is available only if your account is on the E2 version of the platform.
1346
- */
1347
- async deleteNetworkPublic(
1348
- req: DeleteNetworkRequest,
1349
- options?: CallOptions
1350
- ): Promise<Network> {
1351
- const url = `${this.host}/api/2.0/accounts/${req.accountId ?? this.accountId ?? ''}/networks/${req.networkId ?? ''}`;
1352
- let resp: Network | undefined;
1353
- const call = async (callSignal?: AbortSignal): Promise<void> => {
1354
- const headers = new Headers();
1355
- headers.set('User-Agent', this.userAgent);
1356
- const httpReq = buildHttpRequest('DELETE', url, headers, callSignal);
1357
- const respBody = await executeHttpCall({
1358
- request: httpReq,
1359
- httpClient: this.httpClient,
1360
- logger: this.logger,
1361
- });
1362
- resp = parseResponse(respBody, unmarshalNetworkSchema);
1363
- };
1364
- await executeCall(call, options);
1365
- if (resp === undefined) {
1366
- throw new Error('operation completed without a result.');
1367
- }
1368
- return resp;
1369
- }
1370
-
1371
- /** Deletes a <Databricks> private access settings configuration, both specified by ID. */
1372
- async deletePrivateAccessSettingsPublic(
1373
- req: DeletePrivateAccessSettingsRequest,
1374
- options?: CallOptions
1375
- ): Promise<CustomerFacingPrivateAccessSettings> {
1376
- const url = `${this.host}/api/2.0/accounts/${req.accountId ?? this.accountId ?? ''}/private-access-settings/${req.privateAccessSettingsId ?? ''}`;
1377
- let resp: CustomerFacingPrivateAccessSettings | undefined;
1378
- const call = async (callSignal?: AbortSignal): Promise<void> => {
1379
- const headers = new Headers();
1380
- headers.set('User-Agent', this.userAgent);
1381
- const httpReq = buildHttpRequest('DELETE', url, headers, callSignal);
1382
- const respBody = await executeHttpCall({
1383
- request: httpReq,
1384
- httpClient: this.httpClient,
1385
- logger: this.logger,
1386
- });
1387
- resp = parseResponse(
1388
- respBody,
1389
- unmarshalCustomerFacingPrivateAccessSettingsSchema
1390
- );
1391
- };
1392
- await executeCall(call, options);
1393
- if (resp === undefined) {
1394
- throw new Error('operation completed without a result.');
1395
- }
1396
- return resp;
1397
- }
1398
-
1399
- /** Deletes a Databricks VPC endpoint configuration. You cannot delete a VPC endpoint configuration that is associated with any workspace. */
1400
- async deleteVpcEndpointPublic(
1401
- req: DeleteVpcEndpointRequest,
1402
- options?: CallOptions
1403
- ): Promise<CustomerFacingVpcEndpoint> {
1404
- const url = `${this.host}/api/2.0/accounts/${req.accountId ?? this.accountId ?? ''}/vpc-endpoints/${req.vpcEndpointId ?? ''}`;
1405
- let resp: CustomerFacingVpcEndpoint | undefined;
1406
- const call = async (callSignal?: AbortSignal): Promise<void> => {
1407
- const headers = new Headers();
1408
- headers.set('User-Agent', this.userAgent);
1409
- const httpReq = buildHttpRequest('DELETE', url, headers, callSignal);
1410
- const respBody = await executeHttpCall({
1411
- request: httpReq,
1412
- httpClient: this.httpClient,
1413
- logger: this.logger,
1414
- });
1415
- resp = parseResponse(respBody, unmarshalCustomerFacingVpcEndpointSchema);
1416
- };
1417
- await executeCall(call, options);
1418
- if (resp === undefined) {
1419
- throw new Error('operation completed without a result.');
1420
- }
1421
- return resp;
1422
- }
1423
-
1424
- /** Gets a <Databricks> network configuration, which represents a cloud VPC and its resources. */
1425
- async getNetworkPublic(
1426
- req: GetNetworkRequest,
1427
- options?: CallOptions
1428
- ): Promise<Network> {
1429
- const url = `${this.host}/api/2.0/accounts/${req.accountId ?? this.accountId ?? ''}/networks/${req.networkId ?? ''}`;
1430
- let resp: Network | undefined;
1431
- const call = async (callSignal?: AbortSignal): Promise<void> => {
1432
- const headers = new Headers();
1433
- headers.set('User-Agent', this.userAgent);
1434
- const httpReq = buildHttpRequest('GET', url, headers, callSignal);
1435
- const respBody = await executeHttpCall({
1436
- request: httpReq,
1437
- httpClient: this.httpClient,
1438
- logger: this.logger,
1439
- });
1440
- resp = parseResponse(respBody, unmarshalNetworkSchema);
1441
- };
1442
- await executeCall(call, options);
1443
- if (resp === undefined) {
1444
- throw new Error('operation completed without a result.');
1445
- }
1446
- return resp;
1447
- }
1448
-
1449
- /** Gets a <Databricks> private access settings configuration, both specified by ID. */
1450
- async getPrivateAccessSettingsPublic(
1451
- req: GetPrivateAccessSettingsRequest,
1452
- options?: CallOptions
1453
- ): Promise<CustomerFacingPrivateAccessSettings> {
1454
- const url = `${this.host}/api/2.0/accounts/${req.accountId ?? this.accountId ?? ''}/private-access-settings/${req.privateAccessSettingsId ?? ''}`;
1455
- let resp: CustomerFacingPrivateAccessSettings | undefined;
1456
- const call = async (callSignal?: AbortSignal): Promise<void> => {
1457
- const headers = new Headers();
1458
- headers.set('User-Agent', this.userAgent);
1459
- const httpReq = buildHttpRequest('GET', url, headers, callSignal);
1460
- const respBody = await executeHttpCall({
1461
- request: httpReq,
1462
- httpClient: this.httpClient,
1463
- logger: this.logger,
1464
- });
1465
- resp = parseResponse(
1466
- respBody,
1467
- unmarshalCustomerFacingPrivateAccessSettingsSchema
1468
- );
1469
- };
1470
- await executeCall(call, options);
1471
- if (resp === undefined) {
1472
- throw new Error('operation completed without a result.');
1473
- }
1474
- return resp;
1475
- }
1476
-
1477
- /**
1478
- * Gets a VPC endpoint configuration, which represents
1479
- * a [VPC endpoint](https://docs.aws.amazon.com/vpc/latest/privatelink/concepts.html)
1480
- * object in AWS used to communicate privately with <Databricks> over
1481
- * [AWS PrivateLink](https://aws.amazon.com/privatelink).
1482
- */
1483
- async getVpcEndpointPublic(
1484
- req: GetVpcEndpointRequest,
1485
- options?: CallOptions
1486
- ): Promise<CustomerFacingVpcEndpoint> {
1487
- const url = `${this.host}/api/2.0/accounts/${req.accountId ?? this.accountId ?? ''}/vpc-endpoints/${req.vpcEndpointId ?? ''}`;
1488
- let resp: CustomerFacingVpcEndpoint | undefined;
1489
- const call = async (callSignal?: AbortSignal): Promise<void> => {
1490
- const headers = new Headers();
1491
- headers.set('User-Agent', this.userAgent);
1492
- const httpReq = buildHttpRequest('GET', url, headers, callSignal);
1493
- const respBody = await executeHttpCall({
1494
- request: httpReq,
1495
- httpClient: this.httpClient,
1496
- logger: this.logger,
1497
- });
1498
- resp = parseResponse(respBody, unmarshalCustomerFacingVpcEndpointSchema);
1499
- };
1500
- await executeCall(call, options);
1501
- if (resp === undefined) {
1502
- throw new Error('operation completed without a result.');
1503
- }
1504
- return resp;
1505
- }
1506
-
1507
- /** Lists <Databricks> network configurations for an account. */
1508
- async listNetworkPublic(
1509
- req: ListNetworkRequest,
1510
- options?: CallOptions
1511
- ): Promise<ListNetworkResponse> {
1512
- const url = `${this.host}/api/2.0/accounts/${req.accountId ?? this.accountId ?? ''}/networks`;
1513
- let resp: ListNetworkResponse | undefined;
1514
- const call = async (callSignal?: AbortSignal): Promise<void> => {
1515
- const headers = new Headers();
1516
- headers.set('User-Agent', this.userAgent);
1517
- const httpReq = buildHttpRequest('GET', url, headers, callSignal);
1518
- const respBody = await executeHttpCall({
1519
- request: httpReq,
1520
- httpClient: this.httpClient,
1521
- logger: this.logger,
1522
- });
1523
- resp = {
1524
- networks: parseResponse(
1525
- respBody,
1526
- z.array(z.lazy(() => unmarshalNetworkSchema))
1527
- ),
1528
- };
1529
- };
1530
- await executeCall(call, options);
1531
- if (resp === undefined) {
1532
- throw new Error('operation completed without a result.');
1533
- }
1534
- return resp;
1535
- }
1536
-
1537
- /** Lists <Databricks> private access settings for an account. */
1538
- async listPrivateAccessSettingsPublic(
1539
- req: ListPrivateAccessSettingsRequest,
1540
- options?: CallOptions
1541
- ): Promise<ListPrivateAccessSettingsResponse> {
1542
- const url = `${this.host}/api/2.0/accounts/${req.accountId ?? this.accountId ?? ''}/private-access-settings`;
1543
- let resp: ListPrivateAccessSettingsResponse | undefined;
1544
- const call = async (callSignal?: AbortSignal): Promise<void> => {
1545
- const headers = new Headers();
1546
- headers.set('User-Agent', this.userAgent);
1547
- const httpReq = buildHttpRequest('GET', url, headers, callSignal);
1548
- const respBody = await executeHttpCall({
1549
- request: httpReq,
1550
- httpClient: this.httpClient,
1551
- logger: this.logger,
1552
- });
1553
- resp = {
1554
- privateAccessSettings: parseResponse(
1555
- respBody,
1556
- z.array(
1557
- z.lazy(() => unmarshalCustomerFacingPrivateAccessSettingsSchema)
1558
- )
1559
- ),
1560
- };
1561
- };
1562
- await executeCall(call, options);
1563
- if (resp === undefined) {
1564
- throw new Error('operation completed without a result.');
1565
- }
1566
- return resp;
1567
- }
1568
-
1569
- /** Lists Databricks VPC endpoint configurations for an account. */
1570
- async listVpcEndpointPublic(
1571
- req: ListVpcEndpointRequest,
1572
- options?: CallOptions
1573
- ): Promise<ListVpcEndpointResponse> {
1574
- const url = `${this.host}/api/2.0/accounts/${req.accountId ?? this.accountId ?? ''}/vpc-endpoints`;
1575
- let resp: ListVpcEndpointResponse | undefined;
1576
- const call = async (callSignal?: AbortSignal): Promise<void> => {
1577
- const headers = new Headers();
1578
- headers.set('User-Agent', this.userAgent);
1579
- const httpReq = buildHttpRequest('GET', url, headers, callSignal);
1580
- const respBody = await executeHttpCall({
1581
- request: httpReq,
1582
- httpClient: this.httpClient,
1583
- logger: this.logger,
1584
- });
1585
- resp = {
1586
- vpcEndpoints: parseResponse(
1587
- respBody,
1588
- z.array(z.lazy(() => unmarshalCustomerFacingVpcEndpointSchema))
1589
- ),
1590
- };
1591
- };
1592
- await executeCall(call, options);
1593
- if (resp === undefined) {
1594
- throw new Error('operation completed without a result.');
1595
- }
1596
- return resp;
1597
- }
1598
-
1599
- /**
1600
- * Updates an existing private access settings object, which specifies how your workspace is accessed over AWS PrivateLink. To use AWS PrivateLink, a workspace must have a private access settings object referenced by ID in the workspace's private_access_settings_id property.
1601
- * This operation completely overwrites your existing private access settings object attached to your workspaces. All workspaces attached to the private access settings are affected by any change. If public_access_enabled, private_access_level, or allowed_vpc_endpoint_ids are updated, effects of these changes might take several minutes to propagate to the workspace API.
1602
- * You can share one private access settings object with multiple workspaces in a single account. However, private access settings are specific to AWS regions, so only workspaces in the same AWS region can use a given private access settings object.
1603
- * Before configuring PrivateLink, read the <Databricks> article about PrivateLink.
1604
- */
1605
- async updatePrivateAccessSettingsPublic(
1606
- req: UpdatePrivateAccessSettingsRequest,
1607
- options?: CallOptions
1608
- ): Promise<CustomerFacingPrivateAccessSettings> {
1609
- const url = `${this.host}/api/2.0/accounts/${req.customerFacingPrivateAccessSettings?.accountId ?? this.accountId ?? ''}/private-access-settings/${req.customerFacingPrivateAccessSettings?.privateAccessSettingsId ?? ''}`;
1610
- const body = marshalRequest(
1611
- req.customerFacingPrivateAccessSettings,
1612
- marshalCustomerFacingPrivateAccessSettingsSchema
1613
- );
1614
- let resp: CustomerFacingPrivateAccessSettings | undefined;
1615
- const call = async (callSignal?: AbortSignal): Promise<void> => {
1616
- const headers = new Headers({'Content-Type': 'application/json'});
1617
- headers.set('User-Agent', this.userAgent);
1618
- const httpReq = buildHttpRequest('PUT', url, headers, callSignal, body);
1619
- const respBody = await executeHttpCall({
1620
- request: httpReq,
1621
- httpClient: this.httpClient,
1622
- logger: this.logger,
1623
- });
1624
- resp = parseResponse(
1625
- respBody,
1626
- unmarshalCustomerFacingPrivateAccessSettingsSchema
1627
- );
1628
- };
1629
- await executeCall(call, options);
1630
- if (resp === undefined) {
1631
- throw new Error('operation completed without a result.');
1632
- }
1633
- return resp;
1634
- }
1635
-
1636
- /**
1637
- * Gets the network option for a workspace. Every workspace has exactly one network policy binding,
1638
- * with 'default-policy' used if no explicit assignment exists.
1639
- */
1640
- async getWorkspaceNetworkOptionRpc(
1641
- req: GetWorkspaceNetworkOptionRequest,
1642
- options?: CallOptions
1643
- ): Promise<WorkspaceNetworkOption> {
1644
- const url = `${this.host}/api/2.0/accounts/${req.accountId ?? this.accountId ?? ''}/workspaces/${String(req.workspaceId ?? '')}/network`;
1645
- let resp: WorkspaceNetworkOption | undefined;
1646
- const call = async (callSignal?: AbortSignal): Promise<void> => {
1647
- const headers = new Headers();
1648
- headers.set('User-Agent', this.userAgent);
1649
- const httpReq = buildHttpRequest('GET', url, headers, callSignal);
1650
- const respBody = await executeHttpCall({
1651
- request: httpReq,
1652
- httpClient: this.httpClient,
1653
- logger: this.logger,
1654
- });
1655
- resp = parseResponse(respBody, unmarshalWorkspaceNetworkOptionSchema);
1656
- };
1657
- await executeCall(call, options);
1658
- if (resp === undefined) {
1659
- throw new Error('operation completed without a result.');
1660
- }
1661
- return resp;
1662
- }
1663
-
1664
- /**
1665
- * Updates the network option for a workspace. This operation associates the workspace with the specified network policy.
1666
- * To revert to the default policy, specify 'default-policy' as the network_policy_id.
1667
- */
1668
- async updateWorkspaceNetworkOptionRpc(
1669
- req: UpdateWorkspaceNetworkOptionRequest,
1670
- options?: CallOptions
1671
- ): Promise<WorkspaceNetworkOption> {
1672
- const url = `${this.host}/api/2.0/accounts/${req.accountId ?? this.accountId ?? ''}/workspaces/${String(req.workspaceId ?? '')}/network`;
1673
- const body = marshalRequest(
1674
- req.workspaceNetworkOption,
1675
- marshalWorkspaceNetworkOptionSchema
1676
- );
1677
- let resp: WorkspaceNetworkOption | undefined;
1678
- const call = async (callSignal?: AbortSignal): Promise<void> => {
1679
- const headers = new Headers({'Content-Type': 'application/json'});
1680
- headers.set('User-Agent', this.userAgent);
1681
- const httpReq = buildHttpRequest('PUT', url, headers, callSignal, body);
1682
- const respBody = await executeHttpCall({
1683
- request: httpReq,
1684
- httpClient: this.httpClient,
1685
- logger: this.logger,
1686
- });
1687
- resp = parseResponse(respBody, unmarshalWorkspaceNetworkOptionSchema);
1688
- };
1689
- await executeCall(call, options);
1690
- if (resp === undefined) {
1691
- throw new Error('operation completed without a result.');
1692
- }
1693
- return resp;
1694
- }
1695
- }