@databricks/sdk-uc-abacpolicies 0.1.0-dev.2 → 0.1.0-dev.4

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,267 +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 type {
20
- CreatePolicyRequest,
21
- DeletePolicyRequest,
22
- DeletePolicyRequest_Response,
23
- GetPolicyRequest,
24
- ListPoliciesRequest,
25
- ListPoliciesRequest_Response,
26
- PolicyInfo,
27
- UpdatePolicyRequest,
28
- } from './model';
29
- import {
30
- marshalPolicyInfoSchema,
31
- unmarshalDeletePolicyRequest_ResponseSchema,
32
- unmarshalListPoliciesRequest_ResponseSchema,
33
- unmarshalPolicyInfoSchema,
34
- } from './model';
35
-
36
- // Package identity segment for this client to be used in the User-Agent header.
37
- const PACKAGE_SEGMENT = {
38
- key: 'sdk-js-' + pkgJson.name.replace(/^@[^/]+\/sdk-/, ''),
39
- value: pkgJson.version,
40
- };
41
-
42
- export class AbacPoliciesClient {
43
- private readonly host: string;
44
- // Workspace ID used to route workspace-level calls on unified hosts (SPOG).
45
- // When set, workspace-level methods send X-Databricks-Org-Id on every
46
- // request.
47
- private readonly workspaceId: string | undefined;
48
- private readonly httpClient: HttpClient;
49
- private readonly logger: Logger;
50
- // User-Agent header value. Composed once at construction from
51
- // createDefault() merged with this package's identity and the active
52
- // credential's name.
53
- private readonly userAgent: string;
54
-
55
- constructor(options: ClientOptions) {
56
- if (options.host === undefined) {
57
- throw new Error('Host is required.');
58
- }
59
- this.host = options.host.replace(/\/$/, '');
60
- this.workspaceId = options.workspaceId;
61
- this.logger = options.logger ?? new NoOpLogger();
62
- const info = createDefault()
63
- .with(PACKAGE_SEGMENT)
64
- .with({key: 'sdk-js-auth', value: AUTH_VERSION})
65
- .with({key: 'auth', value: options.credentials?.name() ?? 'default'});
66
- this.userAgent = info.toString();
67
- this.httpClient = newHttpClient(options);
68
- }
69
-
70
- /**
71
- * Creates a new policy on a securable.
72
- * The new policy applies to the securable and all its descendants.
73
- */
74
- async createPolicy(
75
- req: CreatePolicyRequest,
76
- options?: CallOptions
77
- ): Promise<PolicyInfo> {
78
- const url = `${this.host}/api/2.1/unity-catalog/policies`;
79
- const body = marshalRequest(req.policyInfo, marshalPolicyInfoSchema);
80
- let resp: PolicyInfo | undefined;
81
- const call = async (callSignal?: AbortSignal): Promise<void> => {
82
- const headers = new Headers({'Content-Type': 'application/json'});
83
- if (this.workspaceId !== undefined) {
84
- headers.set('X-Databricks-Org-Id', this.workspaceId);
85
- }
86
- headers.set('User-Agent', this.userAgent);
87
- const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
88
- const respBody = await executeHttpCall({
89
- request: httpReq,
90
- httpClient: this.httpClient,
91
- logger: this.logger,
92
- });
93
- resp = parseResponse(respBody, unmarshalPolicyInfoSchema);
94
- };
95
- await executeCall(call, options);
96
- if (resp === undefined) {
97
- throw new Error('operation completed without a result.');
98
- }
99
- return resp;
100
- }
101
-
102
- /** Delete an ABAC policy defined on a securable. */
103
- async deletePolicy(
104
- req: DeletePolicyRequest,
105
- options?: CallOptions
106
- ): Promise<DeletePolicyRequest_Response> {
107
- const url = `${this.host}/api/2.1/unity-catalog/policies/${req.onSecurableType ?? ''}/${req.onSecurableFullname ?? ''}/${req.name ?? ''}`;
108
- let resp: DeletePolicyRequest_Response | undefined;
109
- const call = async (callSignal?: AbortSignal): Promise<void> => {
110
- const headers = new Headers();
111
- if (this.workspaceId !== undefined) {
112
- headers.set('X-Databricks-Org-Id', this.workspaceId);
113
- }
114
- headers.set('User-Agent', this.userAgent);
115
- const httpReq = buildHttpRequest('DELETE', url, headers, callSignal);
116
- const respBody = await executeHttpCall({
117
- request: httpReq,
118
- httpClient: this.httpClient,
119
- logger: this.logger,
120
- });
121
- resp = parseResponse(
122
- respBody,
123
- unmarshalDeletePolicyRequest_ResponseSchema
124
- );
125
- };
126
- await executeCall(call, options);
127
- if (resp === undefined) {
128
- throw new Error('operation completed without a result.');
129
- }
130
- return resp;
131
- }
132
-
133
- /** Get the policy definition on a securable */
134
- async getPolicy(
135
- req: GetPolicyRequest,
136
- options?: CallOptions
137
- ): Promise<PolicyInfo> {
138
- const url = `${this.host}/api/2.1/unity-catalog/policies/${req.onSecurableType ?? ''}/${req.onSecurableFullname ?? ''}/${req.name ?? ''}`;
139
- let resp: PolicyInfo | undefined;
140
- const call = async (callSignal?: AbortSignal): Promise<void> => {
141
- const headers = new Headers();
142
- if (this.workspaceId !== undefined) {
143
- headers.set('X-Databricks-Org-Id', this.workspaceId);
144
- }
145
- headers.set('User-Agent', this.userAgent);
146
- const httpReq = buildHttpRequest('GET', url, headers, callSignal);
147
- const respBody = await executeHttpCall({
148
- request: httpReq,
149
- httpClient: this.httpClient,
150
- logger: this.logger,
151
- });
152
- resp = parseResponse(respBody, unmarshalPolicyInfoSchema);
153
- };
154
- await executeCall(call, options);
155
- if (resp === undefined) {
156
- throw new Error('operation completed without a result.');
157
- }
158
- return resp;
159
- }
160
-
161
- /**
162
- * List all policies defined on a securable.
163
- * Optionally, the list can include inherited policies defined on the securable's parent schema or catalog.
164
- *
165
- * PAGINATION BEHAVIOR: The API is by default paginated, a page may contain zero results while still providing a next_page_token.
166
- * Clients must continue reading pages until next_page_token is absent, which is the only indication that the end of results has been reached.
167
- */
168
- async listPolicies(
169
- req: ListPoliciesRequest,
170
- options?: CallOptions
171
- ): Promise<ListPoliciesRequest_Response> {
172
- const url = `${this.host}/api/2.1/unity-catalog/policies/${req.onSecurableType ?? ''}/${req.onSecurableFullname ?? ''}`;
173
- const params = new URLSearchParams();
174
- if (req.includeInherited !== undefined) {
175
- params.append('include_inherited', String(req.includeInherited));
176
- }
177
- if (req.maxResults !== undefined) {
178
- params.append('max_results', String(req.maxResults));
179
- }
180
- if (req.pageToken !== undefined) {
181
- params.append('page_token', req.pageToken);
182
- }
183
- const query = params.toString();
184
- const fullUrl = query !== '' ? `${url}?${query}` : url;
185
- let resp: ListPoliciesRequest_Response | undefined;
186
- const call = async (callSignal?: AbortSignal): Promise<void> => {
187
- const headers = new Headers();
188
- if (this.workspaceId !== undefined) {
189
- headers.set('X-Databricks-Org-Id', this.workspaceId);
190
- }
191
- headers.set('User-Agent', this.userAgent);
192
- const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
193
- const respBody = await executeHttpCall({
194
- request: httpReq,
195
- httpClient: this.httpClient,
196
- logger: this.logger,
197
- });
198
- resp = parseResponse(
199
- respBody,
200
- unmarshalListPoliciesRequest_ResponseSchema
201
- );
202
- };
203
- await executeCall(call, options);
204
- if (resp === undefined) {
205
- throw new Error('operation completed without a result.');
206
- }
207
- return resp;
208
- }
209
-
210
- async *listPoliciesIter(
211
- req: ListPoliciesRequest,
212
- options?: CallOptions
213
- ): AsyncGenerator<PolicyInfo> {
214
- const pageReq: ListPoliciesRequest = {...req};
215
- for (;;) {
216
- const resp = await this.listPolicies(pageReq, options);
217
- for (const item of resp.policies ?? []) {
218
- yield item;
219
- }
220
- if (resp.nextPageToken === undefined || resp.nextPageToken === '') {
221
- return;
222
- }
223
- pageReq.pageToken = resp.nextPageToken;
224
- }
225
- }
226
-
227
- /** Update an ABAC policy on a securable. */
228
- async updatePolicy(
229
- req: UpdatePolicyRequest,
230
- options?: CallOptions
231
- ): Promise<PolicyInfo> {
232
- const url = `${this.host}/api/2.1/unity-catalog/policies/${req.onSecurableType ?? ''}/${req.onSecurableFullname ?? ''}/${req.name ?? ''}`;
233
- const params = new URLSearchParams();
234
- if (req.updateMask !== undefined) {
235
- params.append('update_mask', req.updateMask.toString());
236
- }
237
- const query = params.toString();
238
- const fullUrl = query !== '' ? `${url}?${query}` : url;
239
- const body = marshalRequest(req.policyInfo, marshalPolicyInfoSchema);
240
- let resp: PolicyInfo | undefined;
241
- const call = async (callSignal?: AbortSignal): Promise<void> => {
242
- const headers = new Headers({'Content-Type': 'application/json'});
243
- if (this.workspaceId !== undefined) {
244
- headers.set('X-Databricks-Org-Id', this.workspaceId);
245
- }
246
- headers.set('User-Agent', this.userAgent);
247
- const httpReq = buildHttpRequest(
248
- 'PATCH',
249
- fullUrl,
250
- headers,
251
- callSignal,
252
- body
253
- );
254
- const respBody = await executeHttpCall({
255
- request: httpReq,
256
- httpClient: this.httpClient,
257
- logger: this.logger,
258
- });
259
- resp = parseResponse(respBody, unmarshalPolicyInfoSchema);
260
- };
261
- await executeCall(call, options);
262
- if (resp === undefined) {
263
- throw new Error('operation completed without a result.');
264
- }
265
- return resp;
266
- }
267
- }
package/src/v1/index.ts DELETED
@@ -1,22 +0,0 @@
1
- // Code generated from API definition by Databricks SDK Generator. DO NOT EDIT.
2
-
3
- export {AbacPoliciesClient} from './client';
4
-
5
- export {PolicyType, SecurableType} from './model';
6
-
7
- export type {
8
- ColumnMaskOptions,
9
- CreatePolicyRequest,
10
- DeletePolicyRequest,
11
- DeletePolicyRequest_Response,
12
- FunctionArgument,
13
- GetPolicyRequest,
14
- ListPoliciesRequest,
15
- ListPoliciesRequest_Response,
16
- MatchColumn,
17
- PolicyInfo,
18
- RowFilterOptions,
19
- UpdatePolicyRequest,
20
- } from './model';
21
-
22
- export {policyInfoFieldMask} from './model';