@databricks/sdk-uc-functions 0.0.0-dev → 0.1.0-dev.2
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/LICENSE +203 -0
- package/dist/v1/client.d.ts +61 -0
- package/dist/v1/client.d.ts.map +1 -0
- package/dist/v1/client.js +244 -0
- package/dist/v1/client.js.map +1 -0
- package/dist/v1/index.d.ts +4 -0
- package/dist/v1/index.d.ts.map +1 -0
- package/dist/v1/index.js +4 -0
- package/dist/v1/index.js.map +1 -0
- package/dist/v1/model.d.ts +384 -0
- package/dist/v1/model.d.ts.map +1 -0
- package/dist/v1/model.js +489 -0
- package/dist/v1/model.js.map +1 -0
- package/dist/v1/transport.d.ts +5 -0
- package/dist/v1/transport.d.ts.map +1 -0
- package/dist/v1/transport.js +57 -0
- package/dist/v1/transport.js.map +1 -0
- package/dist/v1/utils.d.ts +21 -0
- package/dist/v1/utils.d.ts.map +1 -0
- package/dist/v1/utils.js +113 -0
- package/dist/v1/utils.js.map +1 -0
- package/package.json +38 -4
- package/src/v1/client.ts +303 -0
- package/src/v1/index.ts +33 -0
- package/src/v1/model.ts +836 -0
- package/src/v1/transport.ts +73 -0
- package/src/v1/utils.ts +156 -0
- package/README.md +0 -1
- package/index.js +0 -1
package/dist/v1/utils.js
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
// Code generated from API definition by Databricks SDK Generator. DO NOT EDIT.
|
|
2
|
+
import { execute } from '@databricks/sdk-core/ops';
|
|
3
|
+
import { ApiError } from '@databricks/sdk-core/apierror';
|
|
4
|
+
import JSONBig from 'json-bigint';
|
|
5
|
+
// JSON codec that preserves int64 precision. On the way in, large integer
|
|
6
|
+
// literals come back as bigint instead of being rounded to JS Number. On the
|
|
7
|
+
// way out, bigint values are emitted as raw JSON number digits.
|
|
8
|
+
const jsonBigint = JSONBig({ useNativeBigInt: true });
|
|
9
|
+
/**
|
|
10
|
+
* Translates public CallOptions to the internal Options shape accepted by
|
|
11
|
+
* execute(). Even though the shapes match today, this isolates the public
|
|
12
|
+
* API from the executor's internal type so they can diverge.
|
|
13
|
+
*/
|
|
14
|
+
export async function executeCall(call, options) {
|
|
15
|
+
const opts = {
|
|
16
|
+
...(options?.retrier !== undefined && { retrier: options.retrier }),
|
|
17
|
+
...(options?.rateLimiter !== undefined && {
|
|
18
|
+
rateLimiter: options.rateLimiter,
|
|
19
|
+
}),
|
|
20
|
+
...(options?.timeout !== undefined && { timeout: options.timeout }),
|
|
21
|
+
};
|
|
22
|
+
return execute(options?.signal, call, opts);
|
|
23
|
+
}
|
|
24
|
+
async function readAll(body) {
|
|
25
|
+
if (body === null) {
|
|
26
|
+
return new Uint8Array(0);
|
|
27
|
+
}
|
|
28
|
+
const reader = body.getReader();
|
|
29
|
+
const chunks = [];
|
|
30
|
+
for (;;) {
|
|
31
|
+
const { done, value } = await reader.read();
|
|
32
|
+
if (done) {
|
|
33
|
+
break;
|
|
34
|
+
}
|
|
35
|
+
chunks.push(value);
|
|
36
|
+
}
|
|
37
|
+
const totalLength = chunks.reduce((acc, chunk) => acc + chunk.length, 0);
|
|
38
|
+
const result = new Uint8Array(totalLength);
|
|
39
|
+
let offset = 0;
|
|
40
|
+
for (const chunk of chunks) {
|
|
41
|
+
result.set(chunk, offset);
|
|
42
|
+
offset += chunk.length;
|
|
43
|
+
}
|
|
44
|
+
return result;
|
|
45
|
+
}
|
|
46
|
+
export async function executeHttpCall(opts) {
|
|
47
|
+
opts.logger.debug('HTTP request', {
|
|
48
|
+
method: opts.request.method,
|
|
49
|
+
url: opts.request.url,
|
|
50
|
+
});
|
|
51
|
+
let resp;
|
|
52
|
+
try {
|
|
53
|
+
resp = await opts.httpClient.send(opts.request);
|
|
54
|
+
}
|
|
55
|
+
catch (e) {
|
|
56
|
+
opts.logger.debug('HTTP request failed');
|
|
57
|
+
throw e;
|
|
58
|
+
}
|
|
59
|
+
const body = await readAll(resp.body);
|
|
60
|
+
opts.logger.debug('HTTP response', {
|
|
61
|
+
statusCode: resp.statusCode,
|
|
62
|
+
body: new TextDecoder().decode(body),
|
|
63
|
+
});
|
|
64
|
+
const apiErr = ApiError.fromHttpError(resp.statusCode, resp.headers, body);
|
|
65
|
+
if (apiErr !== undefined) {
|
|
66
|
+
throw apiErr;
|
|
67
|
+
}
|
|
68
|
+
return body;
|
|
69
|
+
}
|
|
70
|
+
export function buildHttpRequest(method, url, headers, signal, body) {
|
|
71
|
+
const req = { url, method, headers };
|
|
72
|
+
if (body !== undefined) {
|
|
73
|
+
req.body = body;
|
|
74
|
+
}
|
|
75
|
+
if (signal !== undefined) {
|
|
76
|
+
req.signal = signal;
|
|
77
|
+
}
|
|
78
|
+
return req;
|
|
79
|
+
}
|
|
80
|
+
export function parseResponse(body, schema) {
|
|
81
|
+
const text = new TextDecoder().decode(body);
|
|
82
|
+
const parsed = jsonBigint.parse(text);
|
|
83
|
+
return schema.parse(parsed);
|
|
84
|
+
}
|
|
85
|
+
export function marshalRequest(data, schema) {
|
|
86
|
+
return jsonBigint.stringify(schema.parse(data));
|
|
87
|
+
}
|
|
88
|
+
export function flattenQueryParams(prefix, value, params) {
|
|
89
|
+
if (value === null || value === undefined) {
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
if (Array.isArray(value)) {
|
|
93
|
+
// arrays of objects are not yet supported
|
|
94
|
+
for (const item of value) {
|
|
95
|
+
params.append(prefix, String(item));
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
else if (typeof value === 'object') {
|
|
99
|
+
for (const [key, val] of Object.entries(value)) {
|
|
100
|
+
flattenQueryParams(`${prefix}.${key}`, val, params);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
else if (typeof value === 'string' ||
|
|
104
|
+
typeof value === 'number' ||
|
|
105
|
+
typeof value === 'boolean' ||
|
|
106
|
+
typeof value === 'bigint') {
|
|
107
|
+
params.append(prefix, String(value));
|
|
108
|
+
}
|
|
109
|
+
else {
|
|
110
|
+
throw new Error(`Unsupported query parameter type: ${typeof value}`);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/v1/utils.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAG/E,OAAO,EAAC,OAAO,EAAC,MAAM,0BAA0B,CAAC;AACjD,OAAO,EAAC,QAAQ,EAAC,MAAM,+BAA+B,CAAC;AAQvD,OAAO,OAAO,MAAM,aAAa,CAAC;AAGlC,0EAA0E;AAC1E,6EAA6E;AAC7E,gEAAgE;AAChE,MAAM,UAAU,GAAG,OAAO,CAAC,EAAC,eAAe,EAAE,IAAI,EAAC,CAAC,CAAC;AAQpD;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAC/B,IAA6C,EAC7C,OAAqB;IAErB,MAAM,IAAI,GAAY;QACpB,GAAG,CAAC,OAAO,EAAE,OAAO,KAAK,SAAS,IAAI,EAAC,OAAO,EAAE,OAAO,CAAC,OAAO,EAAC,CAAC;QACjE,GAAG,CAAC,OAAO,EAAE,WAAW,KAAK,SAAS,IAAI;YACxC,WAAW,EAAE,OAAO,CAAC,WAAW;SACjC,CAAC;QACF,GAAG,CAAC,OAAO,EAAE,OAAO,KAAK,SAAS,IAAI,EAAC,OAAO,EAAE,OAAO,CAAC,OAAO,EAAC,CAAC;KAClE,CAAC;IACF,OAAO,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;AAC9C,CAAC;AAED,KAAK,UAAU,OAAO,CACpB,IAAuC;IAEvC,IAAI,IAAI,KAAK,IAAI,EAAE,CAAC;QAClB,OAAO,IAAI,UAAU,CAAC,CAAC,CAAC,CAAC;IAC3B,CAAC;IACD,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,EAAE,CAAC;IAChC,MAAM,MAAM,GAAiB,EAAE,CAAC;IAChC,SAAS,CAAC;QACR,MA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AK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QAC1C,OAAO;IACT,CAAC;IACD,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACzB,0CAA0C;QAC1C,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;YACzB,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;QACtC,CAAC;IACH,CAAC;SAAM,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QACrC,KAAK,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAgC,CAAC,EAAE,CAAC;YAC1E,kBAAkB,CAAC,GAAG,MAAM,IAAI,GAAG,EAAE,EAAE,GAAG,EAAE,MAAM,CAAC,CAAC;QACtD,CAAC;IACH,CAAC;SAAM,IACL,OAAO,KAAK,KAAK,QAAQ;QACzB,OAAO,KAAK,KAAK,QAAQ;QACzB,OAAO,KAAK,KAAK,SAAS;QAC1B,OAAO,KAAK,KAAK,QAAQ,EACzB,CAAC;QACD,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;IACvC,CAAC;SAAM,CAAC;QACN,MAAM,IAAI,KAAK,CAAC,qCAAqC,OAAO,KAAK,EAAE,CAAC,CAAC;IACvE,CAAC;AACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,41 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@databricks/sdk-uc-functions",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "
|
|
5
|
-
"
|
|
6
|
-
"
|
|
3
|
+
"version": "0.1.0-dev.2",
|
|
4
|
+
"description": "",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"exports": {
|
|
7
|
+
"./v1": {
|
|
8
|
+
"types": "./dist/v1/index.d.ts",
|
|
9
|
+
"import": "./dist/v1/index.js"
|
|
10
|
+
}
|
|
11
|
+
},
|
|
12
|
+
"files": [
|
|
13
|
+
"dist",
|
|
14
|
+
"src",
|
|
15
|
+
"LICENSE"
|
|
16
|
+
],
|
|
17
|
+
"scripts": {
|
|
18
|
+
"build": "tsc -b",
|
|
19
|
+
"lint": "eslint src --ext .ts",
|
|
20
|
+
"lint:fix": "eslint src --ext .ts --fix",
|
|
21
|
+
"format": "prettier --write \"src/**/*.ts\"",
|
|
22
|
+
"format:check": "prettier --check \"src/**/*.ts\"",
|
|
23
|
+
"typecheck": "tsc --noEmit",
|
|
24
|
+
"clean": "rm -rf dist tsconfig.tsbuildinfo",
|
|
25
|
+
"test": "echo 'no tests'",
|
|
26
|
+
"test:browser": "echo 'no tests'"
|
|
27
|
+
},
|
|
28
|
+
"author": "Databricks",
|
|
29
|
+
"license": "Apache-2.0",
|
|
30
|
+
"dependencies": {
|
|
31
|
+
"@databricks/sdk-auth": ">=0.1.0-dev.3 <1.0.0",
|
|
32
|
+
"@databricks/sdk-core": ">=0.1.0-dev.4 <1.0.0",
|
|
33
|
+
"@databricks/sdk-options": ">=0.1.0-dev.3 <1.0.0",
|
|
34
|
+
"@js-temporal/polyfill": "^0.5.0",
|
|
35
|
+
"json-bigint": "^1.0.0",
|
|
36
|
+
"zod": "^4.3.6"
|
|
37
|
+
},
|
|
38
|
+
"engines": {
|
|
39
|
+
"node": ">=22.0.0"
|
|
40
|
+
}
|
|
7
41
|
}
|
package/src/v1/client.ts
ADDED
|
@@ -0,0 +1,303 @@
|
|
|
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
|
+
DeleteFunctionRequest_Response,
|
|
23
|
+
FunctionInfo,
|
|
24
|
+
GetFunctionRequest,
|
|
25
|
+
ListFunctionsRequest,
|
|
26
|
+
ListFunctionsRequest_Response,
|
|
27
|
+
UpdateFunctionRequest,
|
|
28
|
+
} from './model';
|
|
29
|
+
import {
|
|
30
|
+
marshalCreateFunctionRequestSchema,
|
|
31
|
+
marshalUpdateFunctionRequestSchema,
|
|
32
|
+
unmarshalDeleteFunctionRequest_ResponseSchema,
|
|
33
|
+
unmarshalFunctionInfoSchema,
|
|
34
|
+
unmarshalListFunctionsRequest_ResponseSchema,
|
|
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<DeleteFunctionRequest_Response> {
|
|
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: DeleteFunctionRequest_Response | 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(
|
|
140
|
+
respBody,
|
|
141
|
+
unmarshalDeleteFunctionRequest_ResponseSchema
|
|
142
|
+
);
|
|
143
|
+
};
|
|
144
|
+
await executeCall(call, options);
|
|
145
|
+
if (resp === undefined) {
|
|
146
|
+
throw new Error('operation completed without a result.');
|
|
147
|
+
}
|
|
148
|
+
return resp;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Gets a function from within a parent catalog and schema.
|
|
153
|
+
* For the fetch to succeed, the user must satisfy one of the following requirements:
|
|
154
|
+
* - Is a metastore admin
|
|
155
|
+
* - Is an owner of the function's parent catalog
|
|
156
|
+
* - Have the **USE_CATALOG** privilege on the function's parent catalog and be the owner of the function
|
|
157
|
+
* - 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
|
|
158
|
+
*/
|
|
159
|
+
async getFunction(
|
|
160
|
+
req: GetFunctionRequest,
|
|
161
|
+
options?: CallOptions
|
|
162
|
+
): Promise<FunctionInfo> {
|
|
163
|
+
const url = `${this.host}/api/2.1/unity-catalog/functions/${req.fullNameArg ?? ''}`;
|
|
164
|
+
const params = new URLSearchParams();
|
|
165
|
+
if (req.includeBrowse !== undefined) {
|
|
166
|
+
params.append('include_browse', String(req.includeBrowse));
|
|
167
|
+
}
|
|
168
|
+
const query = params.toString();
|
|
169
|
+
const fullUrl = query !== '' ? `${url}?${query}` : url;
|
|
170
|
+
let resp: FunctionInfo | undefined;
|
|
171
|
+
const call = async (callSignal?: AbortSignal): Promise<void> => {
|
|
172
|
+
const headers = new Headers();
|
|
173
|
+
if (this.workspaceId !== undefined) {
|
|
174
|
+
headers.set('X-Databricks-Org-Id', this.workspaceId);
|
|
175
|
+
}
|
|
176
|
+
headers.set('User-Agent', this.userAgent);
|
|
177
|
+
const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
|
|
178
|
+
const respBody = await executeHttpCall({
|
|
179
|
+
request: httpReq,
|
|
180
|
+
httpClient: this.httpClient,
|
|
181
|
+
logger: this.logger,
|
|
182
|
+
});
|
|
183
|
+
resp = parseResponse(respBody, unmarshalFunctionInfoSchema);
|
|
184
|
+
};
|
|
185
|
+
await executeCall(call, options);
|
|
186
|
+
if (resp === undefined) {
|
|
187
|
+
throw new Error('operation completed without a result.');
|
|
188
|
+
}
|
|
189
|
+
return resp;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* List functions within the specified parent catalog and schema.
|
|
194
|
+
* If the user is a metastore admin, all functions are returned in the output list.
|
|
195
|
+
* 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.
|
|
196
|
+
* There is no guarantee of a specific ordering of the elements in the array.
|
|
197
|
+
*
|
|
198
|
+
* NOTE: we recommend using max_results=0 to use the paginated version of this API. Unpaginated calls will be deprecated soon.
|
|
199
|
+
*
|
|
200
|
+
* PAGINATION BEHAVIOR: When using pagination (max_results >= 0), a page may contain zero results while still providing a next_page_token.
|
|
201
|
+
* Clients must continue reading pages until next_page_token is absent, which is the only indication that the end of results has been reached.
|
|
202
|
+
*/
|
|
203
|
+
async listFunctions(
|
|
204
|
+
req: ListFunctionsRequest,
|
|
205
|
+
options?: CallOptions
|
|
206
|
+
): Promise<ListFunctionsRequest_Response> {
|
|
207
|
+
const url = `${this.host}/api/2.1/unity-catalog/functions`;
|
|
208
|
+
const params = new URLSearchParams();
|
|
209
|
+
if (req.catalogName !== undefined) {
|
|
210
|
+
params.append('catalog_name', req.catalogName);
|
|
211
|
+
}
|
|
212
|
+
if (req.schemaName !== undefined) {
|
|
213
|
+
params.append('schema_name', req.schemaName);
|
|
214
|
+
}
|
|
215
|
+
if (req.includeBrowse !== undefined) {
|
|
216
|
+
params.append('include_browse', String(req.includeBrowse));
|
|
217
|
+
}
|
|
218
|
+
if (req.maxResults !== undefined) {
|
|
219
|
+
params.append('max_results', String(req.maxResults));
|
|
220
|
+
}
|
|
221
|
+
if (req.pageToken !== undefined) {
|
|
222
|
+
params.append('page_token', req.pageToken);
|
|
223
|
+
}
|
|
224
|
+
const query = params.toString();
|
|
225
|
+
const fullUrl = query !== '' ? `${url}?${query}` : url;
|
|
226
|
+
let resp: ListFunctionsRequest_Response | undefined;
|
|
227
|
+
const call = async (callSignal?: AbortSignal): Promise<void> => {
|
|
228
|
+
const headers = new Headers();
|
|
229
|
+
if (this.workspaceId !== undefined) {
|
|
230
|
+
headers.set('X-Databricks-Org-Id', this.workspaceId);
|
|
231
|
+
}
|
|
232
|
+
headers.set('User-Agent', this.userAgent);
|
|
233
|
+
const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
|
|
234
|
+
const respBody = await executeHttpCall({
|
|
235
|
+
request: httpReq,
|
|
236
|
+
httpClient: this.httpClient,
|
|
237
|
+
logger: this.logger,
|
|
238
|
+
});
|
|
239
|
+
resp = parseResponse(
|
|
240
|
+
respBody,
|
|
241
|
+
unmarshalListFunctionsRequest_ResponseSchema
|
|
242
|
+
);
|
|
243
|
+
};
|
|
244
|
+
await executeCall(call, options);
|
|
245
|
+
if (resp === undefined) {
|
|
246
|
+
throw new Error('operation completed without a result.');
|
|
247
|
+
}
|
|
248
|
+
return resp;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
async *listFunctionsIter(
|
|
252
|
+
req: ListFunctionsRequest,
|
|
253
|
+
options?: CallOptions
|
|
254
|
+
): AsyncGenerator<FunctionInfo> {
|
|
255
|
+
const pageReq: ListFunctionsRequest = {...req};
|
|
256
|
+
for (;;) {
|
|
257
|
+
const resp = await this.listFunctions(pageReq, options);
|
|
258
|
+
for (const item of resp.functions ?? []) {
|
|
259
|
+
yield item;
|
|
260
|
+
}
|
|
261
|
+
if (resp.nextPageToken === undefined || resp.nextPageToken === '') {
|
|
262
|
+
return;
|
|
263
|
+
}
|
|
264
|
+
pageReq.pageToken = resp.nextPageToken;
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
/**
|
|
269
|
+
* Updates the function that matches the supplied name.
|
|
270
|
+
* 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.
|
|
271
|
+
* - Is a metastore admin
|
|
272
|
+
* - Is the owner of the function's parent catalog
|
|
273
|
+
* - Is the owner of the function's parent schema and has the **USE_CATALOG** privilege on its parent catalog
|
|
274
|
+
* - 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.
|
|
275
|
+
*/
|
|
276
|
+
async updateFunction(
|
|
277
|
+
req: UpdateFunctionRequest,
|
|
278
|
+
options?: CallOptions
|
|
279
|
+
): Promise<FunctionInfo> {
|
|
280
|
+
const url = `${this.host}/api/2.1/unity-catalog/functions/${req.fullNameArg ?? ''}`;
|
|
281
|
+
const body = marshalRequest(req, marshalUpdateFunctionRequestSchema);
|
|
282
|
+
let resp: FunctionInfo | undefined;
|
|
283
|
+
const call = async (callSignal?: AbortSignal): Promise<void> => {
|
|
284
|
+
const headers = new Headers({'Content-Type': 'application/json'});
|
|
285
|
+
if (this.workspaceId !== undefined) {
|
|
286
|
+
headers.set('X-Databricks-Org-Id', this.workspaceId);
|
|
287
|
+
}
|
|
288
|
+
headers.set('User-Agent', this.userAgent);
|
|
289
|
+
const httpReq = buildHttpRequest('PATCH', url, headers, callSignal, body);
|
|
290
|
+
const respBody = await executeHttpCall({
|
|
291
|
+
request: httpReq,
|
|
292
|
+
httpClient: this.httpClient,
|
|
293
|
+
logger: this.logger,
|
|
294
|
+
});
|
|
295
|
+
resp = parseResponse(respBody, unmarshalFunctionInfoSchema);
|
|
296
|
+
};
|
|
297
|
+
await executeCall(call, options);
|
|
298
|
+
if (resp === undefined) {
|
|
299
|
+
throw new Error('operation completed without a result.');
|
|
300
|
+
}
|
|
301
|
+
return resp;
|
|
302
|
+
}
|
|
303
|
+
}
|
package/src/v1/index.ts
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
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
|
+
DeleteFunctionRequest_Response,
|
|
22
|
+
Dependency,
|
|
23
|
+
DependencyList,
|
|
24
|
+
FunctionDependency,
|
|
25
|
+
FunctionInfo,
|
|
26
|
+
FunctionParameterInfo,
|
|
27
|
+
FunctionParameterInfos,
|
|
28
|
+
GetFunctionRequest,
|
|
29
|
+
ListFunctionsRequest,
|
|
30
|
+
ListFunctionsRequest_Response,
|
|
31
|
+
TableDependency,
|
|
32
|
+
UpdateFunctionRequest,
|
|
33
|
+
} from './model';
|