@databricks/sdk-uc-functions 0.1.0-dev.3 → 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/dist/v1/model.d.ts +55 -48
- package/dist/v1/model.d.ts.map +1 -1
- package/dist/v1/model.js +76 -80
- package/dist/v1/model.js.map +1 -1
- package/dist/v1/utils.d.ts.map +1 -1
- package/dist/v1/utils.js +2 -1
- package/dist/v1/utils.js.map +1 -1
- package/package.json +4 -5
- package/src/v1/client.ts +0 -297
- package/src/v1/index.ts +0 -33
- package/src/v1/model.ts +0 -833
- package/src/v1/transport.ts +0 -73
- package/src/v1/utils.ts +0 -156
package/src/v1/client.ts
DELETED
|
@@ -1,297 +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
|
-
CreateFunctionRequest,
|
|
21
|
-
DeleteFunctionRequest,
|
|
22
|
-
DeleteFunctionResponse,
|
|
23
|
-
FunctionInfo,
|
|
24
|
-
GetFunctionRequest,
|
|
25
|
-
ListFunctionsRequest,
|
|
26
|
-
ListFunctionsResponse,
|
|
27
|
-
UpdateFunctionRequest,
|
|
28
|
-
} from './model';
|
|
29
|
-
import {
|
|
30
|
-
marshalCreateFunctionRequestSchema,
|
|
31
|
-
marshalUpdateFunctionRequestSchema,
|
|
32
|
-
unmarshalDeleteFunctionResponseSchema,
|
|
33
|
-
unmarshalFunctionInfoSchema,
|
|
34
|
-
unmarshalListFunctionsResponseSchema,
|
|
35
|
-
} from './model';
|
|
36
|
-
|
|
37
|
-
// Package identity segment for this client to be used in the User-Agent header.
|
|
38
|
-
const PACKAGE_SEGMENT = {
|
|
39
|
-
key: 'sdk-js-' + pkgJson.name.replace(/^@[^/]+\/sdk-/, ''),
|
|
40
|
-
value: pkgJson.version,
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
export class FunctionsClient {
|
|
44
|
-
private readonly host: string;
|
|
45
|
-
// Workspace ID used to route workspace-level calls on unified hosts (SPOG).
|
|
46
|
-
// When set, workspace-level methods send X-Databricks-Org-Id on every
|
|
47
|
-
// request.
|
|
48
|
-
private readonly workspaceId: string | undefined;
|
|
49
|
-
private readonly httpClient: HttpClient;
|
|
50
|
-
private readonly logger: Logger;
|
|
51
|
-
// User-Agent header value. Composed once at construction from
|
|
52
|
-
// createDefault() merged with this package's identity and the active
|
|
53
|
-
// credential's name.
|
|
54
|
-
private readonly userAgent: string;
|
|
55
|
-
|
|
56
|
-
constructor(options: ClientOptions) {
|
|
57
|
-
if (options.host === undefined) {
|
|
58
|
-
throw new Error('Host is required.');
|
|
59
|
-
}
|
|
60
|
-
this.host = options.host.replace(/\/$/, '');
|
|
61
|
-
this.workspaceId = options.workspaceId;
|
|
62
|
-
this.logger = options.logger ?? new NoOpLogger();
|
|
63
|
-
const info = createDefault()
|
|
64
|
-
.with(PACKAGE_SEGMENT)
|
|
65
|
-
.with({key: 'sdk-js-auth', value: AUTH_VERSION})
|
|
66
|
-
.with({key: 'auth', value: options.credentials?.name() ?? 'default'});
|
|
67
|
-
this.userAgent = info.toString();
|
|
68
|
-
this.httpClient = newHttpClient(options);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
* **WARNING: This API is experimental and will change in future versions**
|
|
73
|
-
*
|
|
74
|
-
* Creates a new function
|
|
75
|
-
*
|
|
76
|
-
* The user must have the following permissions in order for the function to be created:
|
|
77
|
-
* - **USE_CATALOG** on the function's parent catalog
|
|
78
|
-
* - **USE_SCHEMA** and **CREATE_FUNCTION** on the function's parent schema
|
|
79
|
-
*/
|
|
80
|
-
async createFunction(
|
|
81
|
-
req: CreateFunctionRequest,
|
|
82
|
-
options?: CallOptions
|
|
83
|
-
): Promise<FunctionInfo> {
|
|
84
|
-
const url = `${this.host}/api/2.1/unity-catalog/functions`;
|
|
85
|
-
const body = marshalRequest(req, marshalCreateFunctionRequestSchema);
|
|
86
|
-
let resp: FunctionInfo | undefined;
|
|
87
|
-
const call = async (callSignal?: AbortSignal): Promise<void> => {
|
|
88
|
-
const headers = new Headers({'Content-Type': 'application/json'});
|
|
89
|
-
if (this.workspaceId !== undefined) {
|
|
90
|
-
headers.set('X-Databricks-Org-Id', this.workspaceId);
|
|
91
|
-
}
|
|
92
|
-
headers.set('User-Agent', this.userAgent);
|
|
93
|
-
const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
|
|
94
|
-
const respBody = await executeHttpCall({
|
|
95
|
-
request: httpReq,
|
|
96
|
-
httpClient: this.httpClient,
|
|
97
|
-
logger: this.logger,
|
|
98
|
-
});
|
|
99
|
-
resp = parseResponse(respBody, unmarshalFunctionInfoSchema);
|
|
100
|
-
};
|
|
101
|
-
await executeCall(call, options);
|
|
102
|
-
if (resp === undefined) {
|
|
103
|
-
throw new Error('operation completed without a result.');
|
|
104
|
-
}
|
|
105
|
-
return resp;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
/**
|
|
109
|
-
* Deletes the function that matches the supplied name.
|
|
110
|
-
* For the deletion to succeed, the user must satisfy one of the following conditions:
|
|
111
|
-
* - Is the owner of the function's parent catalog
|
|
112
|
-
* - Is the owner of the function's parent schema and have the **USE_CATALOG** privilege on its parent catalog
|
|
113
|
-
* - 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
|
|
114
|
-
*/
|
|
115
|
-
async deleteFunction(
|
|
116
|
-
req: DeleteFunctionRequest,
|
|
117
|
-
options?: CallOptions
|
|
118
|
-
): Promise<DeleteFunctionResponse> {
|
|
119
|
-
const url = `${this.host}/api/2.1/unity-catalog/functions/${req.fullNameArg ?? ''}`;
|
|
120
|
-
const params = new URLSearchParams();
|
|
121
|
-
if (req.force !== undefined) {
|
|
122
|
-
params.append('force', String(req.force));
|
|
123
|
-
}
|
|
124
|
-
const query = params.toString();
|
|
125
|
-
const fullUrl = query !== '' ? `${url}?${query}` : url;
|
|
126
|
-
let resp: DeleteFunctionResponse | undefined;
|
|
127
|
-
const call = async (callSignal?: AbortSignal): Promise<void> => {
|
|
128
|
-
const headers = new Headers();
|
|
129
|
-
if (this.workspaceId !== undefined) {
|
|
130
|
-
headers.set('X-Databricks-Org-Id', this.workspaceId);
|
|
131
|
-
}
|
|
132
|
-
headers.set('User-Agent', this.userAgent);
|
|
133
|
-
const httpReq = buildHttpRequest('DELETE', fullUrl, headers, callSignal);
|
|
134
|
-
const respBody = await executeHttpCall({
|
|
135
|
-
request: httpReq,
|
|
136
|
-
httpClient: this.httpClient,
|
|
137
|
-
logger: this.logger,
|
|
138
|
-
});
|
|
139
|
-
resp = parseResponse(respBody, unmarshalDeleteFunctionResponseSchema);
|
|
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
|
-
/**
|
|
149
|
-
* Gets a function from within a parent catalog and schema.
|
|
150
|
-
* For the fetch to succeed, the user must satisfy one of the following requirements:
|
|
151
|
-
* - Is a metastore admin
|
|
152
|
-
* - Is an owner of the function's parent catalog
|
|
153
|
-
* - Have the **USE_CATALOG** privilege on the function's parent catalog and be the owner of the function
|
|
154
|
-
* - 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
|
|
155
|
-
*/
|
|
156
|
-
async getFunction(
|
|
157
|
-
req: GetFunctionRequest,
|
|
158
|
-
options?: CallOptions
|
|
159
|
-
): Promise<FunctionInfo> {
|
|
160
|
-
const url = `${this.host}/api/2.1/unity-catalog/functions/${req.fullNameArg ?? ''}`;
|
|
161
|
-
const params = new URLSearchParams();
|
|
162
|
-
if (req.includeBrowse !== undefined) {
|
|
163
|
-
params.append('include_browse', String(req.includeBrowse));
|
|
164
|
-
}
|
|
165
|
-
const query = params.toString();
|
|
166
|
-
const fullUrl = query !== '' ? `${url}?${query}` : url;
|
|
167
|
-
let resp: FunctionInfo | undefined;
|
|
168
|
-
const call = async (callSignal?: AbortSignal): Promise<void> => {
|
|
169
|
-
const headers = new Headers();
|
|
170
|
-
if (this.workspaceId !== undefined) {
|
|
171
|
-
headers.set('X-Databricks-Org-Id', this.workspaceId);
|
|
172
|
-
}
|
|
173
|
-
headers.set('User-Agent', this.userAgent);
|
|
174
|
-
const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
|
|
175
|
-
const respBody = await executeHttpCall({
|
|
176
|
-
request: httpReq,
|
|
177
|
-
httpClient: this.httpClient,
|
|
178
|
-
logger: this.logger,
|
|
179
|
-
});
|
|
180
|
-
resp = parseResponse(respBody, unmarshalFunctionInfoSchema);
|
|
181
|
-
};
|
|
182
|
-
await executeCall(call, options);
|
|
183
|
-
if (resp === undefined) {
|
|
184
|
-
throw new Error('operation completed without a result.');
|
|
185
|
-
}
|
|
186
|
-
return resp;
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
/**
|
|
190
|
-
* List functions within the specified parent catalog and schema.
|
|
191
|
-
* If the user is a metastore admin, all functions are returned in the output list.
|
|
192
|
-
* 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.
|
|
193
|
-
* There is no guarantee of a specific ordering of the elements in the array.
|
|
194
|
-
*
|
|
195
|
-
* NOTE: we recommend using max_results=0 to use the paginated version of this API. Unpaginated calls will be deprecated soon.
|
|
196
|
-
*
|
|
197
|
-
* PAGINATION BEHAVIOR: When using pagination (max_results >= 0), a page may contain zero results while still providing a next_page_token.
|
|
198
|
-
* Clients must continue reading pages until next_page_token is absent, which is the only indication that the end of results has been reached.
|
|
199
|
-
*/
|
|
200
|
-
async listFunctions(
|
|
201
|
-
req: ListFunctionsRequest,
|
|
202
|
-
options?: CallOptions
|
|
203
|
-
): Promise<ListFunctionsResponse> {
|
|
204
|
-
const url = `${this.host}/api/2.1/unity-catalog/functions`;
|
|
205
|
-
const params = new URLSearchParams();
|
|
206
|
-
if (req.catalogName !== undefined) {
|
|
207
|
-
params.append('catalog_name', req.catalogName);
|
|
208
|
-
}
|
|
209
|
-
if (req.schemaName !== undefined) {
|
|
210
|
-
params.append('schema_name', req.schemaName);
|
|
211
|
-
}
|
|
212
|
-
if (req.includeBrowse !== undefined) {
|
|
213
|
-
params.append('include_browse', String(req.includeBrowse));
|
|
214
|
-
}
|
|
215
|
-
if (req.maxResults !== undefined) {
|
|
216
|
-
params.append('max_results', String(req.maxResults));
|
|
217
|
-
}
|
|
218
|
-
if (req.pageToken !== undefined) {
|
|
219
|
-
params.append('page_token', req.pageToken);
|
|
220
|
-
}
|
|
221
|
-
const query = params.toString();
|
|
222
|
-
const fullUrl = query !== '' ? `${url}?${query}` : url;
|
|
223
|
-
let resp: ListFunctionsResponse | undefined;
|
|
224
|
-
const call = async (callSignal?: AbortSignal): Promise<void> => {
|
|
225
|
-
const headers = new Headers();
|
|
226
|
-
if (this.workspaceId !== undefined) {
|
|
227
|
-
headers.set('X-Databricks-Org-Id', this.workspaceId);
|
|
228
|
-
}
|
|
229
|
-
headers.set('User-Agent', this.userAgent);
|
|
230
|
-
const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
|
|
231
|
-
const respBody = await executeHttpCall({
|
|
232
|
-
request: httpReq,
|
|
233
|
-
httpClient: this.httpClient,
|
|
234
|
-
logger: this.logger,
|
|
235
|
-
});
|
|
236
|
-
resp = parseResponse(respBody, unmarshalListFunctionsResponseSchema);
|
|
237
|
-
};
|
|
238
|
-
await executeCall(call, options);
|
|
239
|
-
if (resp === undefined) {
|
|
240
|
-
throw new Error('operation completed without a result.');
|
|
241
|
-
}
|
|
242
|
-
return resp;
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
async *listFunctionsIter(
|
|
246
|
-
req: ListFunctionsRequest,
|
|
247
|
-
options?: CallOptions
|
|
248
|
-
): AsyncGenerator<FunctionInfo> {
|
|
249
|
-
const pageReq: ListFunctionsRequest = {...req};
|
|
250
|
-
for (;;) {
|
|
251
|
-
const resp = await this.listFunctions(pageReq, options);
|
|
252
|
-
for (const item of resp.functions ?? []) {
|
|
253
|
-
yield item;
|
|
254
|
-
}
|
|
255
|
-
if (resp.nextPageToken === undefined || resp.nextPageToken === '') {
|
|
256
|
-
return;
|
|
257
|
-
}
|
|
258
|
-
pageReq.pageToken = resp.nextPageToken;
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
/**
|
|
263
|
-
* Updates the function that matches the supplied name.
|
|
264
|
-
* 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.
|
|
265
|
-
* - Is a metastore admin
|
|
266
|
-
* - Is the owner of the function's parent catalog
|
|
267
|
-
* - Is the owner of the function's parent schema and has the **USE_CATALOG** privilege on its parent catalog
|
|
268
|
-
* - 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.
|
|
269
|
-
*/
|
|
270
|
-
async updateFunction(
|
|
271
|
-
req: UpdateFunctionRequest,
|
|
272
|
-
options?: CallOptions
|
|
273
|
-
): Promise<FunctionInfo> {
|
|
274
|
-
const url = `${this.host}/api/2.1/unity-catalog/functions/${req.fullNameArg ?? ''}`;
|
|
275
|
-
const body = marshalRequest(req, marshalUpdateFunctionRequestSchema);
|
|
276
|
-
let resp: FunctionInfo | undefined;
|
|
277
|
-
const call = async (callSignal?: AbortSignal): Promise<void> => {
|
|
278
|
-
const headers = new Headers({'Content-Type': 'application/json'});
|
|
279
|
-
if (this.workspaceId !== undefined) {
|
|
280
|
-
headers.set('X-Databricks-Org-Id', this.workspaceId);
|
|
281
|
-
}
|
|
282
|
-
headers.set('User-Agent', this.userAgent);
|
|
283
|
-
const httpReq = buildHttpRequest('PATCH', url, headers, callSignal, body);
|
|
284
|
-
const respBody = await executeHttpCall({
|
|
285
|
-
request: httpReq,
|
|
286
|
-
httpClient: this.httpClient,
|
|
287
|
-
logger: this.logger,
|
|
288
|
-
});
|
|
289
|
-
resp = parseResponse(respBody, unmarshalFunctionInfoSchema);
|
|
290
|
-
};
|
|
291
|
-
await executeCall(call, options);
|
|
292
|
-
if (resp === undefined) {
|
|
293
|
-
throw new Error('operation completed without a result.');
|
|
294
|
-
}
|
|
295
|
-
return resp;
|
|
296
|
-
}
|
|
297
|
-
}
|
package/src/v1/index.ts
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
// Code generated from API definition by Databricks SDK Generator. DO NOT EDIT.
|
|
2
|
-
|
|
3
|
-
export {FunctionsClient} from './client';
|
|
4
|
-
|
|
5
|
-
export {
|
|
6
|
-
ColumnTypeName,
|
|
7
|
-
FunctionParameterMode,
|
|
8
|
-
FunctionParameterType,
|
|
9
|
-
FunctionInfo_ParameterStyle,
|
|
10
|
-
FunctionInfo_RoutineBody,
|
|
11
|
-
FunctionInfo_SecurityType,
|
|
12
|
-
FunctionInfo_SqlDataAccess,
|
|
13
|
-
} from './model';
|
|
14
|
-
|
|
15
|
-
export type {
|
|
16
|
-
ConnectionDependency,
|
|
17
|
-
CreateFunction,
|
|
18
|
-
CreateFunctionRequest,
|
|
19
|
-
CredentialDependency,
|
|
20
|
-
DeleteFunctionRequest,
|
|
21
|
-
DeleteFunctionResponse,
|
|
22
|
-
Dependency,
|
|
23
|
-
DependencyList,
|
|
24
|
-
FunctionDependency,
|
|
25
|
-
FunctionInfo,
|
|
26
|
-
FunctionParameterInfo,
|
|
27
|
-
FunctionParameterInfos,
|
|
28
|
-
GetFunctionRequest,
|
|
29
|
-
ListFunctionsRequest,
|
|
30
|
-
ListFunctionsResponse,
|
|
31
|
-
TableDependency,
|
|
32
|
-
UpdateFunctionRequest,
|
|
33
|
-
} from './model';
|