@databricks/sdk-uc-functions 0.34.0 → 0.35.0

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,7 @@
1
+ //#region package.json
2
+ var name = "@databricks/sdk-uc-functions";
3
+ var version = "0.35.0";
4
+
5
+ //#endregion
6
+ export { name, version };
7
+ //# sourceMappingURL=package.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"package.js","names":[],"sources":["../package.json"],"sourcesContent":[""],"mappings":""}
@@ -1,61 +1,65 @@
1
- import type { CallOptions } from '@databricks/sdk-options/call';
2
- import type { ClientOptions } from '@databricks/sdk-options/client';
3
- import type { CreateFunctionRequest, DeleteFunctionRequest, DeleteFunctionResponse, FunctionInfo, GetFunctionRequest, ListFunctionsRequest, ListFunctionsResponse, UpdateFunctionRequest } from './model';
4
- export declare class FunctionsClient {
5
- private readonly options;
6
- private readonly logger;
7
- private readonly userAgent;
8
- private config;
9
- constructor(options: ClientOptions);
10
- private resolveConfig;
11
- /**
12
- * **WARNING: This API is experimental and will change in future versions**
13
- *
14
- * Creates a new function
15
- *
16
- * The user must have the following permissions in order for the function to be created:
17
- * - **USE_CATALOG** on the function's parent catalog
18
- * - **USE_SCHEMA** and **CREATE_FUNCTION** on the function's parent schema
19
- */
20
- createFunction(req: CreateFunctionRequest, options?: CallOptions): Promise<FunctionInfo>;
21
- /**
22
- * Deletes the function that matches the supplied name.
23
- * For the deletion to succeed, the user must satisfy one of the following conditions:
24
- * - Is the owner of the function's parent catalog
25
- * - Is the owner of the function's parent schema and have the **USE_CATALOG** privilege on its parent catalog
26
- * - Is the owner of the function itself and have both the **USE_CATALOG** privilege on its parent catalog and the **USE_SCHEMA** privilege on its parent schema
27
- */
28
- deleteFunction(req: DeleteFunctionRequest, options?: CallOptions): Promise<DeleteFunctionResponse>;
29
- /**
30
- * Gets a function from within a parent catalog and schema.
31
- * For the fetch to succeed, the user must satisfy one of the following requirements:
32
- * - Is a metastore admin
33
- * - Is an owner of the function's parent catalog
34
- * - Have the **USE_CATALOG** privilege on the function's parent catalog and be the owner of the function
35
- * - Have the **USE_CATALOG** privilege on the function's parent catalog, the **USE_SCHEMA** privilege on the function's parent schema, and the **EXECUTE** privilege on the function itself
36
- */
37
- getFunction(req: GetFunctionRequest, options?: CallOptions): Promise<FunctionInfo>;
38
- /**
39
- * List functions within the specified parent catalog and schema.
40
- * If the user is a metastore admin, all functions are returned in the output list.
41
- * Otherwise, the user must have the **USE_CATALOG** privilege on the catalog and the **USE_SCHEMA** privilege on the schema, and the output list contains only functions for which either the user has the **EXECUTE** privilege or the user is the owner.
42
- * There is no guarantee of a specific ordering of the elements in the array.
43
- *
44
- * NOTE: we recommend using max_results=0 to use the paginated version of this API. Unpaginated calls will be deprecated soon.
45
- *
46
- * PAGINATION BEHAVIOR: When using pagination (max_results >= 0), a page may contain zero results while still providing a next_page_token.
47
- * Clients must continue reading pages until next_page_token is absent, which is the only indication that the end of results has been reached.
48
- */
49
- listFunctions(req: ListFunctionsRequest, options?: CallOptions): Promise<ListFunctionsResponse>;
50
- listFunctionsIter(req: ListFunctionsRequest, options?: CallOptions): AsyncGenerator<FunctionInfo>;
51
- /**
52
- * Updates the function that matches the supplied name.
53
- * Only the owner of the function can be updated. If the user is not a metastore admin, the user must be a member of the group that is the new function owner.
54
- * - Is a metastore admin
55
- * - Is the owner of the function's parent catalog
56
- * - Is the owner of the function's parent schema and has the **USE_CATALOG** privilege on its parent catalog
57
- * - Is the owner of the function itself and has the **USE_CATALOG** privilege on its parent catalog as well as the **USE_SCHEMA** privilege on the function's parent schema.
58
- */
59
- updateFunction(req: UpdateFunctionRequest, options?: CallOptions): Promise<FunctionInfo>;
1
+ import { CreateFunctionRequest, DeleteFunctionRequest, DeleteFunctionResponse, FunctionInfo, GetFunctionRequest, ListFunctionsRequest, ListFunctionsResponse, UpdateFunctionRequest } from "./model.js";
2
+ import { CallOptions } from "@databricks/sdk-options/call";
3
+ import { ClientOptions } from "@databricks/sdk-options/client";
4
+
5
+ //#region src/v1/client.d.ts
6
+ declare class FunctionsClient {
7
+ private readonly options;
8
+ private readonly logger;
9
+ private readonly userAgent;
10
+ private config;
11
+ constructor(options: ClientOptions);
12
+ private resolveConfig;
13
+ /**
14
+ * **WARNING: This API is experimental and will change in future versions**
15
+ *
16
+ * Creates a new function
17
+ *
18
+ * The user must have the following permissions in order for the function to be created:
19
+ * - **USE_CATALOG** on the function's parent catalog
20
+ * - **USE_SCHEMA** and **CREATE_FUNCTION** on the function's parent schema
21
+ */
22
+ createFunction(req: CreateFunctionRequest, options?: CallOptions): Promise<FunctionInfo>;
23
+ /**
24
+ * Deletes the function that matches the supplied name.
25
+ * For the deletion to succeed, the user must satisfy one of the following conditions:
26
+ * - Is the owner of the function's parent catalog
27
+ * - Is the owner of the function's parent schema and have the **USE_CATALOG** privilege on its parent catalog
28
+ * - Is the owner of the function itself and have both the **USE_CATALOG** privilege on its parent catalog and the **USE_SCHEMA** privilege on its parent schema
29
+ */
30
+ deleteFunction(req: DeleteFunctionRequest, options?: CallOptions): Promise<DeleteFunctionResponse>;
31
+ /**
32
+ * Gets a function from within a parent catalog and schema.
33
+ * For the fetch to succeed, the user must satisfy one of the following requirements:
34
+ * - Is a metastore admin
35
+ * - Is an owner of the function's parent catalog
36
+ * - Have the **USE_CATALOG** privilege on the function's parent catalog and be the owner of the function
37
+ * - Have the **USE_CATALOG** privilege on the function's parent catalog, the **USE_SCHEMA** privilege on the function's parent schema, and the **EXECUTE** privilege on the function itself
38
+ */
39
+ getFunction(req: GetFunctionRequest, options?: CallOptions): Promise<FunctionInfo>;
40
+ /**
41
+ * List functions within the specified parent catalog and schema.
42
+ * If the user is a metastore admin, all functions are returned in the output list.
43
+ * Otherwise, the user must have the **USE_CATALOG** privilege on the catalog and the **USE_SCHEMA** privilege on the schema, and the output list contains only functions for which either the user has the **EXECUTE** privilege or the user is the owner.
44
+ * There is no guarantee of a specific ordering of the elements in the array.
45
+ *
46
+ * NOTE: we recommend using max_results=0 to use the paginated version of this API. Unpaginated calls will be deprecated soon.
47
+ *
48
+ * PAGINATION BEHAVIOR: When using pagination (max_results >= 0), a page may contain zero results while still providing a next_page_token.
49
+ * Clients must continue reading pages until next_page_token is absent, which is the only indication that the end of results has been reached.
50
+ */
51
+ listFunctions(req: ListFunctionsRequest, options?: CallOptions): Promise<ListFunctionsResponse>;
52
+ listFunctionsIter(req: ListFunctionsRequest, options?: CallOptions): AsyncGenerator<FunctionInfo>;
53
+ /**
54
+ * Updates the function that matches the supplied name.
55
+ * Only the owner of the function can be updated. If the user is not a metastore admin, the user must be a member of the group that is the new function owner.
56
+ * - Is a metastore admin
57
+ * - Is the owner of the function's parent catalog
58
+ * - Is the owner of the function's parent schema and has the **USE_CATALOG** privilege on its parent catalog
59
+ * - Is the owner of the function itself and has the **USE_CATALOG** privilege on its parent catalog as well as the **USE_SCHEMA** privilege on the function's parent schema.
60
+ */
61
+ updateFunction(req: UpdateFunctionRequest, options?: CallOptions): Promise<FunctionInfo>;
60
62
  }
63
+ //#endregion
64
+ export { FunctionsClient };
61
65
  //# sourceMappingURL=client.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/v1/client.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,8BAA8B,CAAC;AAC9D,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,gCAAgC,CAAC;AAWlE,OAAO,KAAK,EACV,qBAAqB,EACrB,qBAAqB,EACrB,sBAAsB,EACtB,YAAY,EACZ,kBAAkB,EAClB,oBAAoB,EACpB,qBAAqB,EACrB,qBAAqB,EACtB,MAAM,SAAS,CAAC;AAejB,qBAAa,eAAe;IAC1B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAgB;IACxC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAIhC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAS;IAInC,OAAO,CAAC,MAAM,CAA4C;gBAE9C,OAAO,EAAE,aAAa;IAUlC,OAAO,CAAC,aAAa;IAKrB;;;;;;;;OAQG;IACG,cAAc,CAClB,GAAG,EAAE,qBAAqB,EAC1B,OAAO,CAAC,EAAE,WAAW,GACpB,OAAO,CAAC,YAAY,CAAC;IA0BxB;;;;;;OAMG;IACG,cAAc,CAClB,GAAG,EAAE,qBAAqB,EAC1B,OAAO,CAAC,EAAE,WAAW,GACpB,OAAO,CAAC,sBAAsB,CAAC;IA+BlC;;;;;;;OAOG;IACG,WAAW,CACf,GAAG,EAAE,kBAAkB,EACvB,OAAO,CAAC,EAAE,WAAW,GACpB,OAAO,CAAC,YAAY,CAAC;IA+BxB;;;;;;;;;;OAUG;IACG,aAAa,CACjB,GAAG,EAAE,oBAAoB,EACzB,OAAO,CAAC,EAAE,WAAW,GACpB,OAAO,CAAC,qBAAqB,CAAC;IA2C1B,iBAAiB,CACtB,GAAG,EAAE,oBAAoB,EACzB,OAAO,CAAC,EAAE,WAAW,GACpB,cAAc,CAAC,YAAY,CAAC;IAc/B;;;;;;;OAOG;IACG,cAAc,CAClB,GAAG,EAAE,qBAAqB,EAC1B,OAAO,CAAC,EAAE,WAAW,GACpB,OAAO,CAAC,YAAY,CAAC;CAyBzB"}
1
+ {"version":3,"file":"client.d.ts","names":[],"sources":["../../src/v1/client.ts"],"mappings":";;;;;cA0Ca,eAAA;EAAA,iBACM,OAAA;EAAA,iBACA,MAAA;EAAA,iBAIA,SAAA;EAAA,QAIT,MAAA;cAEI,OAAA,EAAS,aAAA;EAAA,QAUb,aAAA;EAgBI;;;;;;;;;EAFN,cAAA,CACJ,GAAA,EAAK,qBAAA,EACL,OAAA,GAAU,WAAA,GACT,OAAA,CAAQ,YAAA;EA8ER;;;;;;;EA7CG,cAAA,CACJ,GAAA,EAAK,qBAAA,EACL,OAAA,GAAU,WAAA,GACT,OAAA,CAAQ,sBAAA;EAqIR;;;;;;;;EA9FG,WAAA,CACJ,GAAA,EAAK,kBAAA,EACL,OAAA,GAAU,WAAA,GACT,OAAA,CAAQ,YAAA;EA/GM;;;;;;;;;;;EAyJX,aAAA,CACJ,GAAA,EAAK,oBAAA,EACL,OAAA,GAAU,WAAA,GACT,OAAA,CAAQ,qBAAA;EA2CJ,iBAAA,CACL,GAAA,EAAK,oBAAA,EACL,OAAA,GAAU,WAAA,GACT,cAAA,CAAe,YAAA;EAxIZ;;;;;;;;EA8JA,cAAA,CACJ,GAAA,EAAK,qBAAA,EACL,OAAA,GAAU,WAAA,GACT,OAAA,CAAQ,YAAA;AAAA"}
package/dist/v1/client.js CHANGED
@@ -1,247 +1,198 @@
1
- // Code generated from API definition by Databricks SDK Generator. DO NOT EDIT.
2
- import { VERSION as AUTH_VERSION } from '@databricks/sdk-auth';
3
- import { createDefault } from '@databricks/sdk-core/clientinfo';
4
- import { NoOpLogger } from '@databricks/sdk-core/logger';
5
- import { resolveClientConfig } from './transport';
6
- import { buildHttpRequest, executeCall, executeHttpCall, marshalRequest, parseResponse, } from './utils';
7
- import pkgJson from '../../package.json' with { type: 'json' };
8
- import { marshalCreateFunctionRequestSchema, marshalUpdateFunctionRequestSchema, unmarshalDeleteFunctionResponseSchema, unmarshalFunctionInfoSchema, unmarshalListFunctionsResponseSchema, } from './model';
9
- // Package identity segment for this client to be used in the User-Agent header.
1
+ import { resolveClientConfig } from "./transport.js";
2
+ import { buildHttpRequest, executeCall, executeHttpCall, marshalRequest, parseResponse } from "./utils.js";
3
+ import { name, version } from "../package.js";
4
+ import { marshalCreateFunctionRequestSchema, marshalUpdateFunctionRequestSchema, unmarshalDeleteFunctionResponseSchema, unmarshalFunctionInfoSchema, unmarshalListFunctionsResponseSchema } from "./model.js";
5
+ import { VERSION } from "@databricks/sdk-auth";
6
+ import { createDefault } from "@databricks/sdk-core/clientinfo";
7
+ import { NoOpLogger } from "@databricks/sdk-core/logger";
8
+
9
+ //#region src/v1/client.ts
10
10
  const PACKAGE_SEGMENT = {
11
- key: 'sdk-js-' + pkgJson.name.replace(/^@[^/]+\/sdk-/, ''),
12
- value: pkgJson.version,
11
+ key: "sdk-js-" + name.replace(/^@[^/]+\/sdk-/, ""),
12
+ value: version
13
13
  };
14
- export class FunctionsClient {
15
- options;
16
- logger;
17
- // User-Agent header value. Composed once at construction from
18
- // createDefault() merged with this package's identity and the active
19
- // credential's name.
20
- userAgent;
21
- // Memoized configuration. The profile is resolved once, lazily, on the first
22
- // request, then reused; host, workspaceId/accountId, and credentials are
23
- // filled from it when not set explicitly on the options.
24
- config;
25
- constructor(options) {
26
- this.options = options;
27
- this.logger = options.logger ?? new NoOpLogger();
28
- const info = createDefault()
29
- .with(PACKAGE_SEGMENT)
30
- .with({ key: 'sdk-js-auth', value: AUTH_VERSION })
31
- .with({ key: 'auth', value: options.credentials?.name() ?? 'default' });
32
- this.userAgent = info.toString();
33
- }
34
- resolveConfig() {
35
- this.config ??= resolveClientConfig(this.options);
36
- return this.config;
37
- }
38
- /**
39
- * **WARNING: This API is experimental and will change in future versions**
40
- *
41
- * Creates a new function
42
- *
43
- * The user must have the following permissions in order for the function to be created:
44
- * - **USE_CATALOG** on the function's parent catalog
45
- * - **USE_SCHEMA** and **CREATE_FUNCTION** on the function's parent schema
46
- */
47
- async createFunction(req, options) {
48
- const { host, workspaceId, httpClient } = await this.resolveConfig();
49
- const url = `${host}/api/2.1/unity-catalog/functions`;
50
- const body = marshalRequest(req, marshalCreateFunctionRequestSchema);
51
- let resp;
52
- const call = async (callSignal) => {
53
- const headers = new Headers({ 'Content-Type': 'application/json' });
54
- if (workspaceId !== undefined) {
55
- headers.set('X-Databricks-Workspace-Id', workspaceId);
56
- }
57
- headers.set('User-Agent', this.userAgent);
58
- const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
59
- const respBody = await executeHttpCall({
60
- request: httpReq,
61
- httpClient,
62
- logger: this.logger,
63
- });
64
- resp = parseResponse(respBody, unmarshalFunctionInfoSchema);
65
- };
66
- await executeCall(call, options);
67
- if (resp === undefined) {
68
- throw new Error('operation completed without a result.');
69
- }
70
- return resp;
71
- }
72
- /**
73
- * Deletes the function that matches the supplied name.
74
- * For the deletion to succeed, the user must satisfy one of the following conditions:
75
- * - Is the owner of the function's parent catalog
76
- * - Is the owner of the function's parent schema and have the **USE_CATALOG** privilege on its parent catalog
77
- * - Is the owner of the function itself and have both the **USE_CATALOG** privilege on its parent catalog and the **USE_SCHEMA** privilege on its parent schema
78
- */
79
- async deleteFunction(req, options) {
80
- const { host, workspaceId, httpClient } = await this.resolveConfig();
81
- const url = `${host}/api/2.1/unity-catalog/functions/${req.fullNameArg ?? ''}`;
82
- const params = new URLSearchParams();
83
- if (req.force !== undefined) {
84
- params.append('force', String(req.force));
85
- }
86
- const query = params.toString();
87
- const fullUrl = query !== '' ? `${url}?${query}` : url;
88
- let resp;
89
- const call = async (callSignal) => {
90
- const headers = new Headers();
91
- if (workspaceId !== undefined) {
92
- headers.set('X-Databricks-Workspace-Id', workspaceId);
93
- }
94
- headers.set('User-Agent', this.userAgent);
95
- const httpReq = buildHttpRequest('DELETE', fullUrl, headers, callSignal);
96
- const respBody = await executeHttpCall({
97
- request: httpReq,
98
- httpClient,
99
- logger: this.logger,
100
- });
101
- resp = parseResponse(respBody, unmarshalDeleteFunctionResponseSchema);
102
- };
103
- await executeCall(call, options);
104
- if (resp === undefined) {
105
- throw new Error('operation completed without a result.');
106
- }
107
- return resp;
108
- }
109
- /**
110
- * Gets a function from within a parent catalog and schema.
111
- * For the fetch to succeed, the user must satisfy one of the following requirements:
112
- * - Is a metastore admin
113
- * - Is an owner of the function's parent catalog
114
- * - Have the **USE_CATALOG** privilege on the function's parent catalog and be the owner of the function
115
- * - Have the **USE_CATALOG** privilege on the function's parent catalog, the **USE_SCHEMA** privilege on the function's parent schema, and the **EXECUTE** privilege on the function itself
116
- */
117
- async getFunction(req, options) {
118
- const { host, workspaceId, httpClient } = await this.resolveConfig();
119
- const url = `${host}/api/2.1/unity-catalog/functions/${req.fullNameArg ?? ''}`;
120
- const params = new URLSearchParams();
121
- if (req.includeBrowse !== undefined) {
122
- params.append('include_browse', String(req.includeBrowse));
123
- }
124
- const query = params.toString();
125
- const fullUrl = query !== '' ? `${url}?${query}` : url;
126
- let resp;
127
- const call = async (callSignal) => {
128
- const headers = new Headers();
129
- if (workspaceId !== undefined) {
130
- headers.set('X-Databricks-Workspace-Id', workspaceId);
131
- }
132
- headers.set('User-Agent', this.userAgent);
133
- const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
134
- const respBody = await executeHttpCall({
135
- request: httpReq,
136
- httpClient,
137
- logger: this.logger,
138
- });
139
- resp = parseResponse(respBody, unmarshalFunctionInfoSchema);
140
- };
141
- await executeCall(call, options);
142
- if (resp === undefined) {
143
- throw new Error('operation completed without a result.');
144
- }
145
- return resp;
146
- }
147
- /**
148
- * List functions within the specified parent catalog and schema.
149
- * If the user is a metastore admin, all functions are returned in the output list.
150
- * Otherwise, the user must have the **USE_CATALOG** privilege on the catalog and the **USE_SCHEMA** privilege on the schema, and the output list contains only functions for which either the user has the **EXECUTE** privilege or the user is the owner.
151
- * There is no guarantee of a specific ordering of the elements in the array.
152
- *
153
- * NOTE: we recommend using max_results=0 to use the paginated version of this API. Unpaginated calls will be deprecated soon.
154
- *
155
- * PAGINATION BEHAVIOR: When using pagination (max_results >= 0), a page may contain zero results while still providing a next_page_token.
156
- * Clients must continue reading pages until next_page_token is absent, which is the only indication that the end of results has been reached.
157
- */
158
- async listFunctions(req, options) {
159
- const { host, workspaceId, httpClient } = await this.resolveConfig();
160
- const url = `${host}/api/2.1/unity-catalog/functions`;
161
- const params = new URLSearchParams();
162
- if (req.catalogName !== undefined) {
163
- params.append('catalog_name', req.catalogName);
164
- }
165
- if (req.schemaName !== undefined) {
166
- params.append('schema_name', req.schemaName);
167
- }
168
- if (req.includeBrowse !== undefined) {
169
- params.append('include_browse', String(req.includeBrowse));
170
- }
171
- if (req.maxResults !== undefined) {
172
- params.append('max_results', String(req.maxResults));
173
- }
174
- if (req.pageToken !== undefined) {
175
- params.append('page_token', req.pageToken);
176
- }
177
- const query = params.toString();
178
- const fullUrl = query !== '' ? `${url}?${query}` : url;
179
- let resp;
180
- const call = async (callSignal) => {
181
- const headers = new Headers();
182
- if (workspaceId !== undefined) {
183
- headers.set('X-Databricks-Workspace-Id', workspaceId);
184
- }
185
- headers.set('User-Agent', this.userAgent);
186
- const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
187
- const respBody = await executeHttpCall({
188
- request: httpReq,
189
- httpClient,
190
- logger: this.logger,
191
- });
192
- resp = parseResponse(respBody, unmarshalListFunctionsResponseSchema);
193
- };
194
- await executeCall(call, options);
195
- if (resp === undefined) {
196
- throw new Error('operation completed without a result.');
197
- }
198
- return resp;
199
- }
200
- async *listFunctionsIter(req, options) {
201
- const pageReq = { ...req };
202
- for (;;) {
203
- const resp = await this.listFunctions(pageReq, options);
204
- for (const item of resp.functions ?? []) {
205
- yield item;
206
- }
207
- if (resp.nextPageToken === undefined || resp.nextPageToken === '') {
208
- return;
209
- }
210
- pageReq.pageToken = resp.nextPageToken;
211
- }
212
- }
213
- /**
214
- * Updates the function that matches the supplied name.
215
- * Only the owner of the function can be updated. If the user is not a metastore admin, the user must be a member of the group that is the new function owner.
216
- * - Is a metastore admin
217
- * - Is the owner of the function's parent catalog
218
- * - Is the owner of the function's parent schema and has the **USE_CATALOG** privilege on its parent catalog
219
- * - Is the owner of the function itself and has the **USE_CATALOG** privilege on its parent catalog as well as the **USE_SCHEMA** privilege on the function's parent schema.
220
- */
221
- async updateFunction(req, options) {
222
- const { host, workspaceId, httpClient } = await this.resolveConfig();
223
- const url = `${host}/api/2.1/unity-catalog/functions/${req.fullNameArg ?? ''}`;
224
- const body = marshalRequest(req, marshalUpdateFunctionRequestSchema);
225
- let resp;
226
- const call = async (callSignal) => {
227
- const headers = new Headers({ 'Content-Type': 'application/json' });
228
- if (workspaceId !== undefined) {
229
- headers.set('X-Databricks-Workspace-Id', workspaceId);
230
- }
231
- headers.set('User-Agent', this.userAgent);
232
- const httpReq = buildHttpRequest('PATCH', url, headers, callSignal, body);
233
- const respBody = await executeHttpCall({
234
- request: httpReq,
235
- httpClient,
236
- logger: this.logger,
237
- });
238
- resp = parseResponse(respBody, unmarshalFunctionInfoSchema);
239
- };
240
- await executeCall(call, options);
241
- if (resp === undefined) {
242
- throw new Error('operation completed without a result.');
243
- }
244
- return resp;
245
- }
246
- }
14
+ var FunctionsClient = class {
15
+ options;
16
+ logger;
17
+ userAgent;
18
+ config;
19
+ constructor(options) {
20
+ this.options = options;
21
+ this.logger = options.logger ?? new NoOpLogger();
22
+ this.userAgent = createDefault().with(PACKAGE_SEGMENT).with({
23
+ key: "sdk-js-auth",
24
+ value: VERSION
25
+ }).with({
26
+ key: "auth",
27
+ value: options.credentials?.name() ?? "default"
28
+ }).toString();
29
+ }
30
+ resolveConfig() {
31
+ this.config ??= resolveClientConfig(this.options);
32
+ return this.config;
33
+ }
34
+ /**
35
+ * **WARNING: This API is experimental and will change in future versions**
36
+ *
37
+ * Creates a new function
38
+ *
39
+ * The user must have the following permissions in order for the function to be created:
40
+ * - **USE_CATALOG** on the function's parent catalog
41
+ * - **USE_SCHEMA** and **CREATE_FUNCTION** on the function's parent schema
42
+ */
43
+ async createFunction(req, options) {
44
+ const { host, workspaceId, httpClient } = await this.resolveConfig();
45
+ const url = `${host}/api/2.1/unity-catalog/functions`;
46
+ const body = marshalRequest(req, marshalCreateFunctionRequestSchema);
47
+ let resp;
48
+ const call = async (callSignal) => {
49
+ const headers = new Headers({ "Content-Type": "application/json" });
50
+ if (workspaceId !== void 0) headers.set("X-Databricks-Workspace-Id", workspaceId);
51
+ headers.set("User-Agent", this.userAgent);
52
+ resp = parseResponse(await executeHttpCall({
53
+ request: buildHttpRequest("POST", url, headers, callSignal, body),
54
+ httpClient,
55
+ logger: this.logger
56
+ }), unmarshalFunctionInfoSchema);
57
+ };
58
+ await executeCall(call, options);
59
+ if (resp === void 0) throw new Error("operation completed without a result.");
60
+ return resp;
61
+ }
62
+ /**
63
+ * Deletes the function that matches the supplied name.
64
+ * For the deletion to succeed, the user must satisfy one of the following conditions:
65
+ * - Is the owner of the function's parent catalog
66
+ * - Is the owner of the function's parent schema and have the **USE_CATALOG** privilege on its parent catalog
67
+ * - Is the owner of the function itself and have both the **USE_CATALOG** privilege on its parent catalog and the **USE_SCHEMA** privilege on its parent schema
68
+ */
69
+ async deleteFunction(req, options) {
70
+ const { host, workspaceId, httpClient } = await this.resolveConfig();
71
+ const url = `${host}/api/2.1/unity-catalog/functions/${req.fullNameArg ?? ""}`;
72
+ const params = new URLSearchParams();
73
+ if (req.force !== void 0) params.append("force", String(req.force));
74
+ const query = params.toString();
75
+ const fullUrl = query !== "" ? `${url}?${query}` : url;
76
+ let resp;
77
+ const call = async (callSignal) => {
78
+ const headers = new Headers();
79
+ if (workspaceId !== void 0) headers.set("X-Databricks-Workspace-Id", workspaceId);
80
+ headers.set("User-Agent", this.userAgent);
81
+ resp = parseResponse(await executeHttpCall({
82
+ request: buildHttpRequest("DELETE", fullUrl, headers, callSignal),
83
+ httpClient,
84
+ logger: this.logger
85
+ }), unmarshalDeleteFunctionResponseSchema);
86
+ };
87
+ await executeCall(call, options);
88
+ if (resp === void 0) throw new Error("operation completed without a result.");
89
+ return resp;
90
+ }
91
+ /**
92
+ * Gets a function from within a parent catalog and schema.
93
+ * For the fetch to succeed, the user must satisfy one of the following requirements:
94
+ * - Is a metastore admin
95
+ * - Is an owner of the function's parent catalog
96
+ * - Have the **USE_CATALOG** privilege on the function's parent catalog and be the owner of the function
97
+ * - Have the **USE_CATALOG** privilege on the function's parent catalog, the **USE_SCHEMA** privilege on the function's parent schema, and the **EXECUTE** privilege on the function itself
98
+ */
99
+ async getFunction(req, options) {
100
+ const { host, workspaceId, httpClient } = await this.resolveConfig();
101
+ const url = `${host}/api/2.1/unity-catalog/functions/${req.fullNameArg ?? ""}`;
102
+ const params = new URLSearchParams();
103
+ if (req.includeBrowse !== void 0) params.append("include_browse", String(req.includeBrowse));
104
+ const query = params.toString();
105
+ const fullUrl = query !== "" ? `${url}?${query}` : url;
106
+ let resp;
107
+ const call = async (callSignal) => {
108
+ const headers = new Headers();
109
+ if (workspaceId !== void 0) headers.set("X-Databricks-Workspace-Id", workspaceId);
110
+ headers.set("User-Agent", this.userAgent);
111
+ resp = parseResponse(await executeHttpCall({
112
+ request: buildHttpRequest("GET", fullUrl, headers, callSignal),
113
+ httpClient,
114
+ logger: this.logger
115
+ }), unmarshalFunctionInfoSchema);
116
+ };
117
+ await executeCall(call, options);
118
+ if (resp === void 0) throw new Error("operation completed without a result.");
119
+ return resp;
120
+ }
121
+ /**
122
+ * List functions within the specified parent catalog and schema.
123
+ * If the user is a metastore admin, all functions are returned in the output list.
124
+ * Otherwise, the user must have the **USE_CATALOG** privilege on the catalog and the **USE_SCHEMA** privilege on the schema, and the output list contains only functions for which either the user has the **EXECUTE** privilege or the user is the owner.
125
+ * There is no guarantee of a specific ordering of the elements in the array.
126
+ *
127
+ * NOTE: we recommend using max_results=0 to use the paginated version of this API. Unpaginated calls will be deprecated soon.
128
+ *
129
+ * PAGINATION BEHAVIOR: When using pagination (max_results >= 0), a page may contain zero results while still providing a next_page_token.
130
+ * Clients must continue reading pages until next_page_token is absent, which is the only indication that the end of results has been reached.
131
+ */
132
+ async listFunctions(req, options) {
133
+ const { host, workspaceId, httpClient } = await this.resolveConfig();
134
+ const url = `${host}/api/2.1/unity-catalog/functions`;
135
+ const params = new URLSearchParams();
136
+ if (req.catalogName !== void 0) params.append("catalog_name", req.catalogName);
137
+ if (req.schemaName !== void 0) params.append("schema_name", req.schemaName);
138
+ if (req.includeBrowse !== void 0) params.append("include_browse", String(req.includeBrowse));
139
+ if (req.maxResults !== void 0) params.append("max_results", String(req.maxResults));
140
+ if (req.pageToken !== void 0) params.append("page_token", req.pageToken);
141
+ const query = params.toString();
142
+ const fullUrl = query !== "" ? `${url}?${query}` : url;
143
+ let resp;
144
+ const call = async (callSignal) => {
145
+ const headers = new Headers();
146
+ if (workspaceId !== void 0) headers.set("X-Databricks-Workspace-Id", workspaceId);
147
+ headers.set("User-Agent", this.userAgent);
148
+ resp = parseResponse(await executeHttpCall({
149
+ request: buildHttpRequest("GET", fullUrl, headers, callSignal),
150
+ httpClient,
151
+ logger: this.logger
152
+ }), unmarshalListFunctionsResponseSchema);
153
+ };
154
+ await executeCall(call, options);
155
+ if (resp === void 0) throw new Error("operation completed without a result.");
156
+ return resp;
157
+ }
158
+ async *listFunctionsIter(req, options) {
159
+ const pageReq = { ...req };
160
+ for (;;) {
161
+ const resp = await this.listFunctions(pageReq, options);
162
+ for (const item of resp.functions ?? []) yield item;
163
+ if (resp.nextPageToken === void 0 || resp.nextPageToken === "") return;
164
+ pageReq.pageToken = resp.nextPageToken;
165
+ }
166
+ }
167
+ /**
168
+ * Updates the function that matches the supplied name.
169
+ * Only the owner of the function can be updated. If the user is not a metastore admin, the user must be a member of the group that is the new function owner.
170
+ * - Is a metastore admin
171
+ * - Is the owner of the function's parent catalog
172
+ * - Is the owner of the function's parent schema and has the **USE_CATALOG** privilege on its parent catalog
173
+ * - Is the owner of the function itself and has the **USE_CATALOG** privilege on its parent catalog as well as the **USE_SCHEMA** privilege on the function's parent schema.
174
+ */
175
+ async updateFunction(req, options) {
176
+ const { host, workspaceId, httpClient } = await this.resolveConfig();
177
+ const url = `${host}/api/2.1/unity-catalog/functions/${req.fullNameArg ?? ""}`;
178
+ const body = marshalRequest(req, marshalUpdateFunctionRequestSchema);
179
+ let resp;
180
+ const call = async (callSignal) => {
181
+ const headers = new Headers({ "Content-Type": "application/json" });
182
+ if (workspaceId !== void 0) headers.set("X-Databricks-Workspace-Id", workspaceId);
183
+ headers.set("User-Agent", this.userAgent);
184
+ resp = parseResponse(await executeHttpCall({
185
+ request: buildHttpRequest("PATCH", url, headers, callSignal, body),
186
+ httpClient,
187
+ logger: this.logger
188
+ }), unmarshalFunctionInfoSchema);
189
+ };
190
+ await executeCall(call, options);
191
+ if (resp === void 0) throw new Error("operation completed without a result.");
192
+ return resp;
193
+ }
194
+ };
195
+
196
+ //#endregion
197
+ export { FunctionsClient };
247
198
  //# sourceMappingURL=client.js.map