@databricks/sdk-uc-functions 0.27.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.
- package/dist/package.js +7 -0
- package/dist/package.js.map +1 -0
- package/dist/v1/client.d.ts +63 -59
- package/dist/v1/client.d.ts.map +1 -1
- package/dist/v1/client.js +195 -244
- package/dist/v1/client.js.map +1 -1
- package/dist/v1/index.d.ts +3 -7
- package/dist/v1/index.js +4 -7
- package/dist/v1/model.d.ts +361 -358
- package/dist/v1/model.d.ts.map +1 -1
- package/dist/v1/model.js +344 -471
- package/dist/v1/model.js.map +1 -1
- package/dist/v1/transport.d.ts +21 -17
- package/dist/v1/transport.d.ts.map +1 -1
- package/dist/v1/transport.js +60 -69
- package/dist/v1/transport.js.map +1 -1
- package/dist/v1/utils.d.ts +18 -14
- package/dist/v1/utils.d.ts.map +1 -1
- package/dist/v1/utils.js +76 -103
- package/dist/v1/utils.js.map +1 -1
- package/package.json +5 -5
- package/dist/v1/index.d.ts.map +0 -1
- package/dist/v1/index.js.map +0 -1
package/dist/package.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"package.js","names":[],"sources":["../package.json"],"sourcesContent":[""],"mappings":""}
|
package/dist/v1/client.d.ts
CHANGED
|
@@ -1,61 +1,65 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
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
|
package/dist/v1/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","
|
|
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
|
-
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import
|
|
8
|
-
|
|
9
|
-
|
|
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
|
-
|
|
12
|
-
|
|
11
|
+
key: "sdk-js-" + name.replace(/^@[^/]+\/sdk-/, ""),
|
|
12
|
+
value: version
|
|
13
13
|
};
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
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
|