@databricks/sdk-uc-workspacebindings 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 +38 -0
- package/dist/v1/client.d.ts.map +1 -0
- package/dist/v1/client.js +178 -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 +86 -0
- package/dist/v1/model.d.ts.map +1 -0
- package/dist/v1/model.js +97 -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 +247 -0
- package/src/v1/index.ts +17 -0
- package/src/v1/model.ts +193 -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
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model.js","sourceRoot":"","sources":["../../src/v1/model.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAE/E,OAAO,EAAC,CAAC,EAAC,MAAM,KAAK,CAAC;AAEtB,oHAAoH;AACpH,MAAM,CAAN,IAAY,WAIX;AAJD,WAAY,WAAW;IACrB,oEAAqD,CAAA;IACrD,kEAAmD,CAAA;IACnD,gEAAiD,CAAA;AACnD,CAAC,EAJW,WAAW,KAAX,WAAW,QAItB;AAqFD,oGAAoG;AACpG,MAAM,CAAC,MAAM,0DAA0D,GACrE,CAAC;KACE,MAAM,CAAC;IACN,UAAU,EAAE,CAAC;S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B;CAC1C,CAAC,CAAC,CAAC;AAEN,MAAM,CAAC,MAAM,2CAA2C,GAAc,CAAC;KACpE,MAAM,CAAC;IACN,aAAa,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IACpC,iBAAiB,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IACxC,GAAG,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,iCAAiC,CAAC,CAAC,CAAC,QAAQ,EAAE;IACxE,MAAM,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,iCAAiC,CAAC,CAAC,CAAC,QAAQ,EAAE;CAC5E,CAAC;KACD,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;IACf,cAAc,EAAE,CAAC,CAAC,aAAa;IAC/B,mBAAmB,EAAE,CAAC,CAAC,iBAAiB;IACxC,GAAG,EAAE,CAAC,CAAC,GAAG;IACV,MAAM,EAAE,CAAC,CAAC,MAAM;CACjB,CAAC,CAAC,CAAC;AAEN,MAAM,CAAC,MAAM,iCAAiC,GAAc,CAAC;KAC1D,MAAM,CAAC;IACN,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAClC,WAAW,EAAE,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,QAAQ,EAAE;CAC5C,CAAC;KACD,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;IACf,YAAY,EAAE,CAAC,CAAC,WAAW;IAC3B,YAAY,EAAE,CAAC,CAAC,WAAW;CAC5B,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { HttpClient } from '@databricks/sdk-core/http';
|
|
2
|
+
import type { ClientOptions } from '@databricks/sdk-options/client';
|
|
3
|
+
/** Creates a new HTTP client with the given options. */
|
|
4
|
+
export declare function newHttpClient(options?: ClientOptions): HttpClient;
|
|
5
|
+
//# sourceMappingURL=transport.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transport.d.ts","sourceRoot":"","sources":["../../src/v1/transport.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,UAAU,EAGX,MAAM,2BAA2B,CAAC;AAEnC,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,gCAAgC,CAAC;AAElE,wDAAwD;AACxD,wBAAgB,aAAa,CAAC,OAAO,CAAC,EAAE,aAAa,GAAG,UAAU,CAwBjE"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
// Code generated from API definition by Databricks SDK Generator. DO NOT EDIT.
|
|
2
|
+
import { defaultCredentials } from '@databricks/sdk-auth/credentials';
|
|
3
|
+
import { newFetchHttpClient } from '@databricks/sdk-core/http';
|
|
4
|
+
/** Creates a new HTTP client with the given options. */
|
|
5
|
+
export function newHttpClient(options) {
|
|
6
|
+
const opts = options ?? {};
|
|
7
|
+
// If an HTTP client is provided, use it as-is. Throw if other options are
|
|
8
|
+
// also set, since they would be silently ignored.
|
|
9
|
+
if (opts.httpClient !== undefined) {
|
|
10
|
+
if (opts.credentials !== undefined || opts.timeout !== undefined) {
|
|
11
|
+
throw new Error('httpClient cannot be combined with credentials or timeout');
|
|
12
|
+
}
|
|
13
|
+
return opts.httpClient;
|
|
14
|
+
}
|
|
15
|
+
const credentials = opts.credentials ?? defaultCredentials();
|
|
16
|
+
const base = newFetchHttpClient();
|
|
17
|
+
let client = new AuthHttpClient(base, credentials);
|
|
18
|
+
if (opts.timeout !== undefined) {
|
|
19
|
+
client = new TimeoutHttpClient(client, opts.timeout);
|
|
20
|
+
}
|
|
21
|
+
return client;
|
|
22
|
+
}
|
|
23
|
+
/** Wraps an HttpClient and adds authentication headers to requests. */
|
|
24
|
+
class AuthHttpClient {
|
|
25
|
+
base;
|
|
26
|
+
credentials;
|
|
27
|
+
constructor(base, credentials) {
|
|
28
|
+
this.base = base;
|
|
29
|
+
this.credentials = credentials;
|
|
30
|
+
}
|
|
31
|
+
async send(request) {
|
|
32
|
+
const authHeaders = await this.credentials.authHeaders();
|
|
33
|
+
// Do not modify the original request.
|
|
34
|
+
const headers = new Headers(request.headers);
|
|
35
|
+
for (const h of authHeaders) {
|
|
36
|
+
headers.set(h.key, h.value);
|
|
37
|
+
}
|
|
38
|
+
return this.base.send({ ...request, headers });
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
/** Wraps an HttpClient and applies a default timeout to requests. */
|
|
42
|
+
class TimeoutHttpClient {
|
|
43
|
+
base;
|
|
44
|
+
timeout;
|
|
45
|
+
constructor(base, timeout) {
|
|
46
|
+
this.base = base;
|
|
47
|
+
this.timeout = timeout;
|
|
48
|
+
}
|
|
49
|
+
async send(request) {
|
|
50
|
+
const timeoutSignal = AbortSignal.timeout(this.timeout);
|
|
51
|
+
const signal = request.signal !== undefined
|
|
52
|
+
? AbortSignal.any([request.signal, timeoutSignal])
|
|
53
|
+
: timeoutSignal;
|
|
54
|
+
return this.base.send({ ...request, signal });
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=transport.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transport.js","sourceRoot":"","sources":["../../src/v1/transport.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAG/E,OAAO,EAAC,kBAAkB,EAAC,MAAM,kCAAkC,CAAC;AAMpE,OAAO,EAAC,kBAAkB,EAAC,MAAM,2BAA2B,CAAC;AAG7D,wDAAwD;AACxD,MAAM,UAAU,aAAa,CAAC,OAAuB;IACnD,MAAM,IAAI,GAAG,OAAO,IAAI,EAAE,CAAC;IAE3B,0EAA0E;IAC1E,kDAAkD;IAClD,IAAI,IAAI,CAAC,UAAU,KAAK,SAAS,EAAE,CAAC;QAClC,IAAI,IAAI,CAAC,WAAW,KAAK,SAAS,IAAI,IAAI,CAAC,OAAO,KAAK,SAAS,EAAE,CAAC;YACjE,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C;IAEJ,KAAK,CAAC,IAAI,CAAC,OAAoB;QAC7B,MAAM,aAAa,GAAG,WAAW,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACxD,MAAM,MAAM,GACV,OAAO,CAAC,MAAM,KAAK,SAAS;YAC1B,CAAC,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;YAClD,CAAC,CAAC,aAAa,CAAC;QACpB,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,EAAC,GAAG,OAAO,EAAE,MAAM,EAAC,CAAC,CAAC;IAC9C,CAAC;CACF"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { HttpClient, HttpRequest } from '@databricks/sdk-core/http';
|
|
2
|
+
import type { Logger } from '@databricks/sdk-core/logger';
|
|
3
|
+
import type { CallOptions } from '@databricks/sdk-options/call';
|
|
4
|
+
import type { z } from 'zod';
|
|
5
|
+
export interface HttpCallOptions {
|
|
6
|
+
readonly request: HttpRequest;
|
|
7
|
+
readonly httpClient: HttpClient;
|
|
8
|
+
readonly logger: Logger;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Translates public CallOptions to the internal Options shape accepted by
|
|
12
|
+
* execute(). Even though the shapes match today, this isolates the public
|
|
13
|
+
* API from the executor's internal type so they can diverge.
|
|
14
|
+
*/
|
|
15
|
+
export declare function executeCall(call: (signal?: AbortSignal) => Promise<void>, options?: CallOptions): Promise<void>;
|
|
16
|
+
export declare function executeHttpCall(opts: HttpCallOptions): Promise<Uint8Array>;
|
|
17
|
+
export declare function buildHttpRequest(method: string, url: string, headers: Headers, signal?: AbortSignal, body?: string | ReadableStream<Uint8Array>): HttpRequest;
|
|
18
|
+
export declare function parseResponse<T>(body: Uint8Array, schema: z.ZodType<T>): T;
|
|
19
|
+
export declare function marshalRequest(data: unknown, schema: z.ZodType): string;
|
|
20
|
+
export declare function flattenQueryParams(prefix: string, value: unknown, params: URLSearchParams): void;
|
|
21
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/v1/utils.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,UAAU,EACV,WAAW,EAEZ,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,6BAA6B,CAAC;AACxD,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,8BAA8B,CAAC;AAE9D,OAAO,KAAK,EAAC,CAAC,EAAC,MAAM,KAAK,CAAC;AAO3B,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAC;IAC9B,QAAQ,CAAC,UAAU,EAAE,UAAU,CAAC;IAChC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAED;;;;GAIG;AACH,wBAAsB,WAAW,CAC/B,IAAI,EAAE,CAAC,MAAM,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC,IAAI,CAAC,EAC7C,OAAO,CAAC,EAAE,WAAW,GACpB,OAAO,CAAC,IAAI,CAAC,CASf;AA2BD,wBAAsB,eAAe,CACnC,IAAI,EAAE,eAAe,GACpB,OAAO,CAAC,UAAU,CAAC,CA2BrB;AAED,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,OAAO,EAChB,MAAM,CAAC,EAAE,WAAW,EACpB,IAAI,CAAC,EAAE,MAAM,GAAG,cAAc,CAAC,UAAU,CAAC,GACzC,WAAW,CASb;AAED,wBAAgB,aAAa,CAAC,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAI1E;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,CAAC,OAAO,GAAG,MAAM,CAEvE;AAED,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,OAAO,EACd,MAAM,EAAE,eAAe,GACtB,IAAI,CAuBN"}
|
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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AAO,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-workspacebindings",
|
|
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,247 @@
|
|
|
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
|
+
GetCatalogWorkspaceBindingsRequest,
|
|
21
|
+
GetCatalogWorkspaceBindingsRequest_Response,
|
|
22
|
+
GetWorkspaceBindingsRequest,
|
|
23
|
+
GetWorkspaceBindingsRequest_Response,
|
|
24
|
+
UpdateCatalogWorkspaceBindingsRequest,
|
|
25
|
+
UpdateCatalogWorkspaceBindingsRequest_Response,
|
|
26
|
+
UpdateWorkspaceBindingsRequest,
|
|
27
|
+
UpdateWorkspaceBindingsRequest_Response,
|
|
28
|
+
WorkspaceBindingInfo,
|
|
29
|
+
} from './model';
|
|
30
|
+
import {
|
|
31
|
+
marshalUpdateCatalogWorkspaceBindingsRequestSchema,
|
|
32
|
+
marshalUpdateWorkspaceBindingsRequestSchema,
|
|
33
|
+
unmarshalGetCatalogWorkspaceBindingsRequest_ResponseSchema,
|
|
34
|
+
unmarshalGetWorkspaceBindingsRequest_ResponseSchema,
|
|
35
|
+
unmarshalUpdateCatalogWorkspaceBindingsRequest_ResponseSchema,
|
|
36
|
+
unmarshalUpdateWorkspaceBindingsRequest_ResponseSchema,
|
|
37
|
+
} from './model';
|
|
38
|
+
|
|
39
|
+
// Package identity segment for this client to be used in the User-Agent header.
|
|
40
|
+
const PACKAGE_SEGMENT = {
|
|
41
|
+
key: 'sdk-js-' + pkgJson.name.replace(/^@[^/]+\/sdk-/, ''),
|
|
42
|
+
value: pkgJson.version,
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export class WorkspaceBindingsClient {
|
|
46
|
+
private readonly host: string;
|
|
47
|
+
// Workspace ID used to route workspace-level calls on unified hosts (SPOG).
|
|
48
|
+
// When set, workspace-level methods send X-Databricks-Org-Id on every
|
|
49
|
+
// request.
|
|
50
|
+
private readonly workspaceId: string | undefined;
|
|
51
|
+
private readonly httpClient: HttpClient;
|
|
52
|
+
private readonly logger: Logger;
|
|
53
|
+
// User-Agent header value. Composed once at construction from
|
|
54
|
+
// createDefault() merged with this package's identity and the active
|
|
55
|
+
// credential's name.
|
|
56
|
+
private readonly userAgent: string;
|
|
57
|
+
|
|
58
|
+
constructor(options: ClientOptions) {
|
|
59
|
+
if (options.host === undefined) {
|
|
60
|
+
throw new Error('Host is required.');
|
|
61
|
+
}
|
|
62
|
+
this.host = options.host.replace(/\/$/, '');
|
|
63
|
+
this.workspaceId = options.workspaceId;
|
|
64
|
+
this.logger = options.logger ?? new NoOpLogger();
|
|
65
|
+
const info = createDefault()
|
|
66
|
+
.with(PACKAGE_SEGMENT)
|
|
67
|
+
.with({key: 'sdk-js-auth', value: AUTH_VERSION})
|
|
68
|
+
.with({key: 'auth', value: options.credentials?.name() ?? 'default'});
|
|
69
|
+
this.userAgent = info.toString();
|
|
70
|
+
this.httpClient = newHttpClient(options);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Gets workspace bindings of the catalog.
|
|
75
|
+
* The caller must be a metastore admin or an owner of the catalog.
|
|
76
|
+
*/
|
|
77
|
+
async getCatalogWorkspaceBindings(
|
|
78
|
+
req: GetCatalogWorkspaceBindingsRequest,
|
|
79
|
+
options?: CallOptions
|
|
80
|
+
): Promise<GetCatalogWorkspaceBindingsRequest_Response> {
|
|
81
|
+
const url = `${this.host}/api/2.1/unity-catalog/workspace-bindings/catalogs/${req.catalogName ?? ''}`;
|
|
82
|
+
let resp: GetCatalogWorkspaceBindingsRequest_Response | undefined;
|
|
83
|
+
const call = async (callSignal?: AbortSignal): Promise<void> => {
|
|
84
|
+
const headers = new Headers();
|
|
85
|
+
if (this.workspaceId !== undefined) {
|
|
86
|
+
headers.set('X-Databricks-Org-Id', this.workspaceId);
|
|
87
|
+
}
|
|
88
|
+
headers.set('User-Agent', this.userAgent);
|
|
89
|
+
const httpReq = buildHttpRequest('GET', url, headers, callSignal);
|
|
90
|
+
const respBody = await executeHttpCall({
|
|
91
|
+
request: httpReq,
|
|
92
|
+
httpClient: this.httpClient,
|
|
93
|
+
logger: this.logger,
|
|
94
|
+
});
|
|
95
|
+
resp = parseResponse(
|
|
96
|
+
respBody,
|
|
97
|
+
unmarshalGetCatalogWorkspaceBindingsRequest_ResponseSchema
|
|
98
|
+
);
|
|
99
|
+
};
|
|
100
|
+
await executeCall(call, options);
|
|
101
|
+
if (resp === undefined) {
|
|
102
|
+
throw new Error('operation completed without a result.');
|
|
103
|
+
}
|
|
104
|
+
return resp;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Gets workspace bindings of the securable.
|
|
109
|
+
* The caller must be a metastore admin or an owner of the securable.
|
|
110
|
+
*
|
|
111
|
+
* NOTE: we recommend using max_results=0 to use the paginated version of this API. Unpaginated calls will be deprecated soon.
|
|
112
|
+
*
|
|
113
|
+
* PAGINATION BEHAVIOR: When using pagination (max_results >= 0), a page may contain zero results while still providing a next_page_token.
|
|
114
|
+
* Clients must continue reading pages until next_page_token is absent, which is the only indication that the end of results has been reached.
|
|
115
|
+
*/
|
|
116
|
+
async getWorkspaceBindings(
|
|
117
|
+
req: GetWorkspaceBindingsRequest,
|
|
118
|
+
options?: CallOptions
|
|
119
|
+
): Promise<GetWorkspaceBindingsRequest_Response> {
|
|
120
|
+
const url = `${this.host}/api/2.1/unity-catalog/bindings/${req.securableType ?? ''}/${req.securableFullName ?? ''}`;
|
|
121
|
+
const params = new URLSearchParams();
|
|
122
|
+
if (req.maxResults !== undefined) {
|
|
123
|
+
params.append('max_results', String(req.maxResults));
|
|
124
|
+
}
|
|
125
|
+
if (req.pageToken !== undefined) {
|
|
126
|
+
params.append('page_token', req.pageToken);
|
|
127
|
+
}
|
|
128
|
+
const query = params.toString();
|
|
129
|
+
const fullUrl = query !== '' ? `${url}?${query}` : url;
|
|
130
|
+
let resp: GetWorkspaceBindingsRequest_Response | undefined;
|
|
131
|
+
const call = async (callSignal?: AbortSignal): Promise<void> => {
|
|
132
|
+
const headers = new Headers();
|
|
133
|
+
if (this.workspaceId !== undefined) {
|
|
134
|
+
headers.set('X-Databricks-Org-Id', this.workspaceId);
|
|
135
|
+
}
|
|
136
|
+
headers.set('User-Agent', this.userAgent);
|
|
137
|
+
const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
|
|
138
|
+
const respBody = await executeHttpCall({
|
|
139
|
+
request: httpReq,
|
|
140
|
+
httpClient: this.httpClient,
|
|
141
|
+
logger: this.logger,
|
|
142
|
+
});
|
|
143
|
+
resp = parseResponse(
|
|
144
|
+
respBody,
|
|
145
|
+
unmarshalGetWorkspaceBindingsRequest_ResponseSchema
|
|
146
|
+
);
|
|
147
|
+
};
|
|
148
|
+
await executeCall(call, options);
|
|
149
|
+
if (resp === undefined) {
|
|
150
|
+
throw new Error('operation completed without a result.');
|
|
151
|
+
}
|
|
152
|
+
return resp;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
async *getWorkspaceBindingsIter(
|
|
156
|
+
req: GetWorkspaceBindingsRequest,
|
|
157
|
+
options?: CallOptions
|
|
158
|
+
): AsyncGenerator<WorkspaceBindingInfo> {
|
|
159
|
+
const pageReq: GetWorkspaceBindingsRequest = {...req};
|
|
160
|
+
for (;;) {
|
|
161
|
+
const resp = await this.getWorkspaceBindings(pageReq, options);
|
|
162
|
+
for (const item of resp.bindings ?? []) {
|
|
163
|
+
yield item;
|
|
164
|
+
}
|
|
165
|
+
if (resp.nextPageToken === undefined || resp.nextPageToken === '') {
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
pageReq.pageToken = resp.nextPageToken;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* Updates workspace bindings of the catalog.
|
|
174
|
+
* The caller must be a metastore admin or an owner of the catalog.
|
|
175
|
+
*/
|
|
176
|
+
async updateCatalogWorkspaceBindings(
|
|
177
|
+
req: UpdateCatalogWorkspaceBindingsRequest,
|
|
178
|
+
options?: CallOptions
|
|
179
|
+
): Promise<UpdateCatalogWorkspaceBindingsRequest_Response> {
|
|
180
|
+
const url = `${this.host}/api/2.1/unity-catalog/workspace-bindings/catalogs/${req.catalogName ?? ''}`;
|
|
181
|
+
const body = marshalRequest(
|
|
182
|
+
req,
|
|
183
|
+
marshalUpdateCatalogWorkspaceBindingsRequestSchema
|
|
184
|
+
);
|
|
185
|
+
let resp: UpdateCatalogWorkspaceBindingsRequest_Response | undefined;
|
|
186
|
+
const call = async (callSignal?: AbortSignal): Promise<void> => {
|
|
187
|
+
const headers = new Headers({'Content-Type': 'application/json'});
|
|
188
|
+
if (this.workspaceId !== undefined) {
|
|
189
|
+
headers.set('X-Databricks-Org-Id', this.workspaceId);
|
|
190
|
+
}
|
|
191
|
+
headers.set('User-Agent', this.userAgent);
|
|
192
|
+
const httpReq = buildHttpRequest('PATCH', url, headers, callSignal, body);
|
|
193
|
+
const respBody = await executeHttpCall({
|
|
194
|
+
request: httpReq,
|
|
195
|
+
httpClient: this.httpClient,
|
|
196
|
+
logger: this.logger,
|
|
197
|
+
});
|
|
198
|
+
resp = parseResponse(
|
|
199
|
+
respBody,
|
|
200
|
+
unmarshalUpdateCatalogWorkspaceBindingsRequest_ResponseSchema
|
|
201
|
+
);
|
|
202
|
+
};
|
|
203
|
+
await executeCall(call, options);
|
|
204
|
+
if (resp === undefined) {
|
|
205
|
+
throw new Error('operation completed without a result.');
|
|
206
|
+
}
|
|
207
|
+
return resp;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* Updates workspace bindings of the securable.
|
|
212
|
+
* The caller must be a metastore admin or an owner of the securable.
|
|
213
|
+
*/
|
|
214
|
+
async updateWorkspaceBindings(
|
|
215
|
+
req: UpdateWorkspaceBindingsRequest,
|
|
216
|
+
options?: CallOptions
|
|
217
|
+
): Promise<UpdateWorkspaceBindingsRequest_Response> {
|
|
218
|
+
const url = `${this.host}/api/2.1/unity-catalog/bindings/${req.securableType ?? ''}/${req.securableFullName ?? ''}`;
|
|
219
|
+
const body = marshalRequest(
|
|
220
|
+
req,
|
|
221
|
+
marshalUpdateWorkspaceBindingsRequestSchema
|
|
222
|
+
);
|
|
223
|
+
let resp: UpdateWorkspaceBindingsRequest_Response | undefined;
|
|
224
|
+
const call = async (callSignal?: AbortSignal): Promise<void> => {
|
|
225
|
+
const headers = new Headers({'Content-Type': 'application/json'});
|
|
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('PATCH', url, headers, callSignal, body);
|
|
231
|
+
const respBody = await executeHttpCall({
|
|
232
|
+
request: httpReq,
|
|
233
|
+
httpClient: this.httpClient,
|
|
234
|
+
logger: this.logger,
|
|
235
|
+
});
|
|
236
|
+
resp = parseResponse(
|
|
237
|
+
respBody,
|
|
238
|
+
unmarshalUpdateWorkspaceBindingsRequest_ResponseSchema
|
|
239
|
+
);
|
|
240
|
+
};
|
|
241
|
+
await executeCall(call, options);
|
|
242
|
+
if (resp === undefined) {
|
|
243
|
+
throw new Error('operation completed without a result.');
|
|
244
|
+
}
|
|
245
|
+
return resp;
|
|
246
|
+
}
|
|
247
|
+
}
|
package/src/v1/index.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// Code generated from API definition by Databricks SDK Generator. DO NOT EDIT.
|
|
2
|
+
|
|
3
|
+
export {WorkspaceBindingsClient} from './client';
|
|
4
|
+
|
|
5
|
+
export {BindingType} from './model';
|
|
6
|
+
|
|
7
|
+
export type {
|
|
8
|
+
GetCatalogWorkspaceBindingsRequest,
|
|
9
|
+
GetCatalogWorkspaceBindingsRequest_Response,
|
|
10
|
+
GetWorkspaceBindingsRequest,
|
|
11
|
+
GetWorkspaceBindingsRequest_Response,
|
|
12
|
+
UpdateCatalogWorkspaceBindingsRequest,
|
|
13
|
+
UpdateCatalogWorkspaceBindingsRequest_Response,
|
|
14
|
+
UpdateWorkspaceBindingsRequest,
|
|
15
|
+
UpdateWorkspaceBindingsRequest_Response,
|
|
16
|
+
WorkspaceBindingInfo,
|
|
17
|
+
} from './model';
|