@databricks/sdk-tokens 0.1.0-dev.3 → 0.1.0-dev.5
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/README.md +28 -0
- package/dist/v1/client.d.ts +3 -3
- package/dist/v1/client.d.ts.map +1 -1
- package/dist/v1/client.js +31 -29
- package/dist/v1/client.js.map +1 -1
- package/dist/v1/model.d.ts +10 -9
- package/dist/v1/model.d.ts.map +1 -1
- package/dist/v1/model.js +12 -12
- package/dist/v1/model.js.map +1 -1
- package/dist/v1/transport.d.ts +30 -2
- package/dist/v1/transport.d.ts.map +1 -1
- package/dist/v1/transport.js +33 -16
- package/dist/v1/transport.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 +9 -5
- package/src/v1/client.ts +0 -199
- package/src/v1/index.ts +0 -19
- package/src/v1/model.ts +0 -231
- package/src/v1/transport.ts +0 -73
- package/src/v1/utils.ts +0 -156
package/README.md
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# @databricks/sdk-tokens
|
|
2
|
+
|
|
3
|
+
> [!WARNING]
|
|
4
|
+
>
|
|
5
|
+
> ## PREVIEW - NOT FOR PRODUCTION USE
|
|
6
|
+
>
|
|
7
|
+
> **This SDK is in preview and is subject to change without notice.**
|
|
8
|
+
>
|
|
9
|
+
> - **Do NOT use in production environments**
|
|
10
|
+
> - **Breaking changes may occur at any time**
|
|
11
|
+
> - **APIs are experimental and unstable**
|
|
12
|
+
> - **Use for development and testing only**
|
|
13
|
+
|
|
14
|
+
## Installation
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
npm install @databricks/sdk-tokens
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Usage
|
|
21
|
+
|
|
22
|
+
```typescript
|
|
23
|
+
import {TokensClient} from '@databricks/sdk-tokens/v1';
|
|
24
|
+
|
|
25
|
+
const client = new TokensClient({});
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
For a full getting-started guide, see the [root README](../../README.md).
|
package/dist/v1/client.d.ts
CHANGED
|
@@ -2,12 +2,12 @@ import type { CallOptions } from '@databricks/sdk-options/call';
|
|
|
2
2
|
import type { ClientOptions } from '@databricks/sdk-options/client';
|
|
3
3
|
import type { CreateTokenRequest, CreateTokenResponse, ListTokensRequest, ListTokensResponse, RevokeTokenRequest, RevokeTokenResponse, UpdateTokenRequest, UpdateTokenResponse } from './model';
|
|
4
4
|
export declare class TokensClient {
|
|
5
|
-
private readonly
|
|
6
|
-
private readonly workspaceId;
|
|
7
|
-
private readonly httpClient;
|
|
5
|
+
private readonly options;
|
|
8
6
|
private readonly logger;
|
|
9
7
|
private readonly userAgent;
|
|
8
|
+
private config;
|
|
10
9
|
constructor(options: ClientOptions);
|
|
10
|
+
private resolveConfig;
|
|
11
11
|
/**
|
|
12
12
|
* Creates and returns a token for a user. If this call is made through token authentication, it creates
|
|
13
13
|
* a token with the same client ID as the authenticated token. If the user's token quota is exceeded, this call
|
package/dist/v1/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/v1/client.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,8BAA8B,CAAC;AAC9D,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,gCAAgC,CAAC;AAWlE,OAAO,KAAK,EACV,kBAAkB,EAClB,mBAAmB,EACnB,iBAAiB,EACjB,kBAAkB,EAClB,kBAAkB,EAClB,mBAAmB,EACnB,kBAAkB,EAClB,mBAAmB,EACpB,MAAM,SAAS,CAAC;AAiBjB,qBAAa,YAAY;IACvB,OAAO,CAAC,QAAQ,CAAC,
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/v1/client.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,8BAA8B,CAAC;AAC9D,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,gCAAgC,CAAC;AAWlE,OAAO,KAAK,EACV,kBAAkB,EAClB,mBAAmB,EACnB,iBAAiB,EACjB,kBAAkB,EAClB,kBAAkB,EAClB,mBAAmB,EACnB,kBAAkB,EAClB,mBAAmB,EACpB,MAAM,SAAS,CAAC;AAiBjB,qBAAa,YAAY;IACvB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAgB;IACxC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAIhC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAS;IAInC,OAAO,CAAC,MAAM,CAA4C;gBAE9C,OAAO,EAAE,aAAa;IAUlC,OAAO,CAAC,aAAa;IAKrB;;;;OAIG;IACG,WAAW,CACf,GAAG,EAAE,kBAAkB,EACvB,OAAO,CAAC,EAAE,WAAW,GACpB,OAAO,CAAC,mBAAmB,CAAC;IA0B/B,4DAA4D;IACtD,UAAU,CACd,IAAI,EAAE,iBAAiB,EACvB,OAAO,CAAC,EAAE,WAAW,GACpB,OAAO,CAAC,kBAAkB,CAAC;IAyB9B;;;;OAIG;IACG,WAAW,CACf,GAAG,EAAE,kBAAkB,EACvB,OAAO,CAAC,EAAE,WAAW,GACpB,OAAO,CAAC,mBAAmB,CAAC;IA0B/B;;;;OAIG;IACG,WAAW,CACf,GAAG,EAAE,kBAAkB,EACvB,OAAO,CAAC,EAAE,WAAW,GACpB,OAAO,CAAC,mBAAmB,CAAC;CAyBhC"}
|
package/dist/v1/client.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { VERSION as AUTH_VERSION } from '@databricks/sdk-auth';
|
|
3
3
|
import { createDefault } from '@databricks/sdk-core/clientinfo';
|
|
4
4
|
import { NoOpLogger } from '@databricks/sdk-core/logger';
|
|
5
|
-
import {
|
|
5
|
+
import { resolveClientConfig } from './transport';
|
|
6
6
|
import { buildHttpRequest, executeCall, executeHttpCall, marshalRequest, parseResponse, } from './utils';
|
|
7
7
|
import pkgJson from '../../package.json' with { type: 'json' };
|
|
8
8
|
import { marshalCreateTokenRequestSchema, marshalRevokeTokenRequestSchema, marshalUpdateTokenRequestSchema, unmarshalCreateTokenResponseSchema, unmarshalListTokensResponseSchema, unmarshalRevokeTokenResponseSchema, unmarshalUpdateTokenResponseSchema, } from './model';
|
|
@@ -12,30 +12,28 @@ const PACKAGE_SEGMENT = {
|
|
|
12
12
|
value: pkgJson.version,
|
|
13
13
|
};
|
|
14
14
|
export class TokensClient {
|
|
15
|
-
|
|
16
|
-
// Workspace ID used to route workspace-level calls on unified hosts (SPOG).
|
|
17
|
-
// When set, workspace-level methods send X-Databricks-Org-Id on every
|
|
18
|
-
// request.
|
|
19
|
-
workspaceId;
|
|
20
|
-
httpClient;
|
|
15
|
+
options;
|
|
21
16
|
logger;
|
|
22
17
|
// User-Agent header value. Composed once at construction from
|
|
23
18
|
// createDefault() merged with this package's identity and the active
|
|
24
19
|
// credential's name.
|
|
25
20
|
userAgent;
|
|
21
|
+
// Memoized configuration. The profile is resolved once, lazily, on the first
|
|
22
|
+
// request, then reused; host, workspaceId/accountId, and credentials are
|
|
23
|
+
// filled from it when not set explicitly on the options.
|
|
24
|
+
config;
|
|
26
25
|
constructor(options) {
|
|
27
|
-
|
|
28
|
-
throw new Error('Host is required.');
|
|
29
|
-
}
|
|
30
|
-
this.host = options.host.replace(/\/$/, '');
|
|
31
|
-
this.workspaceId = options.workspaceId;
|
|
26
|
+
this.options = options;
|
|
32
27
|
this.logger = options.logger ?? new NoOpLogger();
|
|
33
28
|
const info = createDefault()
|
|
34
29
|
.with(PACKAGE_SEGMENT)
|
|
35
30
|
.with({ key: 'sdk-js-auth', value: AUTH_VERSION })
|
|
36
31
|
.with({ key: 'auth', value: options.credentials?.name() ?? 'default' });
|
|
37
32
|
this.userAgent = info.toString();
|
|
38
|
-
|
|
33
|
+
}
|
|
34
|
+
resolveConfig() {
|
|
35
|
+
this.config ??= resolveClientConfig(this.options);
|
|
36
|
+
return this.config;
|
|
39
37
|
}
|
|
40
38
|
/**
|
|
41
39
|
* Creates and returns a token for a user. If this call is made through token authentication, it creates
|
|
@@ -43,19 +41,20 @@ export class TokensClient {
|
|
|
43
41
|
* returns an error **QUOTA_EXCEEDED**.
|
|
44
42
|
*/
|
|
45
43
|
async createToken(req, options) {
|
|
46
|
-
const
|
|
44
|
+
const { host, workspaceId, httpClient } = await this.resolveConfig();
|
|
45
|
+
const url = `${host}/api/2.0/token/create`;
|
|
47
46
|
const body = marshalRequest(req, marshalCreateTokenRequestSchema);
|
|
48
47
|
let resp;
|
|
49
48
|
const call = async (callSignal) => {
|
|
50
49
|
const headers = new Headers({ 'Content-Type': 'application/json' });
|
|
51
|
-
if (
|
|
52
|
-
headers.set('X-Databricks-Org-Id',
|
|
50
|
+
if (workspaceId !== undefined) {
|
|
51
|
+
headers.set('X-Databricks-Org-Id', workspaceId);
|
|
53
52
|
}
|
|
54
53
|
headers.set('User-Agent', this.userAgent);
|
|
55
54
|
const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
|
|
56
55
|
const respBody = await executeHttpCall({
|
|
57
56
|
request: httpReq,
|
|
58
|
-
httpClient
|
|
57
|
+
httpClient,
|
|
59
58
|
logger: this.logger,
|
|
60
59
|
});
|
|
61
60
|
resp = parseResponse(respBody, unmarshalCreateTokenResponseSchema);
|
|
@@ -68,18 +67,19 @@ export class TokensClient {
|
|
|
68
67
|
}
|
|
69
68
|
/** Lists all the valid tokens for a user-workspace pair. */
|
|
70
69
|
async listTokens(_req, options) {
|
|
71
|
-
const
|
|
70
|
+
const { host, workspaceId, httpClient } = await this.resolveConfig();
|
|
71
|
+
const url = `${host}/api/2.0/token/list`;
|
|
72
72
|
let resp;
|
|
73
73
|
const call = async (callSignal) => {
|
|
74
74
|
const headers = new Headers();
|
|
75
|
-
if (
|
|
76
|
-
headers.set('X-Databricks-Org-Id',
|
|
75
|
+
if (workspaceId !== undefined) {
|
|
76
|
+
headers.set('X-Databricks-Org-Id', workspaceId);
|
|
77
77
|
}
|
|
78
78
|
headers.set('User-Agent', this.userAgent);
|
|
79
79
|
const httpReq = buildHttpRequest('GET', url, headers, callSignal);
|
|
80
80
|
const respBody = await executeHttpCall({
|
|
81
81
|
request: httpReq,
|
|
82
|
-
httpClient
|
|
82
|
+
httpClient,
|
|
83
83
|
logger: this.logger,
|
|
84
84
|
});
|
|
85
85
|
resp = parseResponse(respBody, unmarshalListTokensResponseSchema);
|
|
@@ -96,19 +96,20 @@ export class TokensClient {
|
|
|
96
96
|
* If a token with the specified ID is not valid, this call returns an error **RESOURCE_DOES_NOT_EXIST**.
|
|
97
97
|
*/
|
|
98
98
|
async revokeToken(req, options) {
|
|
99
|
-
const
|
|
99
|
+
const { host, workspaceId, httpClient } = await this.resolveConfig();
|
|
100
|
+
const url = `${host}/api/2.0/token/delete`;
|
|
100
101
|
const body = marshalRequest(req, marshalRevokeTokenRequestSchema);
|
|
101
102
|
let resp;
|
|
102
103
|
const call = async (callSignal) => {
|
|
103
104
|
const headers = new Headers({ 'Content-Type': 'application/json' });
|
|
104
|
-
if (
|
|
105
|
-
headers.set('X-Databricks-Org-Id',
|
|
105
|
+
if (workspaceId !== undefined) {
|
|
106
|
+
headers.set('X-Databricks-Org-Id', workspaceId);
|
|
106
107
|
}
|
|
107
108
|
headers.set('User-Agent', this.userAgent);
|
|
108
109
|
const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
|
|
109
110
|
const respBody = await executeHttpCall({
|
|
110
111
|
request: httpReq,
|
|
111
|
-
httpClient
|
|
112
|
+
httpClient,
|
|
112
113
|
logger: this.logger,
|
|
113
114
|
});
|
|
114
115
|
resp = parseResponse(respBody, unmarshalRevokeTokenResponseSchema);
|
|
@@ -125,19 +126,20 @@ export class TokensClient {
|
|
|
125
126
|
* If a token with the specified ID is not valid, this call returns an error **NOT_FOUND**.
|
|
126
127
|
*/
|
|
127
128
|
async updateToken(req, options) {
|
|
128
|
-
const
|
|
129
|
+
const { host, workspaceId, httpClient } = await this.resolveConfig();
|
|
130
|
+
const url = `${host}/api/2.0/token/${req.tokenId ?? ''}`;
|
|
129
131
|
const body = marshalRequest(req, marshalUpdateTokenRequestSchema);
|
|
130
132
|
let resp;
|
|
131
133
|
const call = async (callSignal) => {
|
|
132
134
|
const headers = new Headers({ 'Content-Type': 'application/json' });
|
|
133
|
-
if (
|
|
134
|
-
headers.set('X-Databricks-Org-Id',
|
|
135
|
+
if (workspaceId !== undefined) {
|
|
136
|
+
headers.set('X-Databricks-Org-Id', workspaceId);
|
|
135
137
|
}
|
|
136
138
|
headers.set('User-Agent', this.userAgent);
|
|
137
139
|
const httpReq = buildHttpRequest('PATCH', url, headers, callSignal, body);
|
|
138
140
|
const respBody = await executeHttpCall({
|
|
139
141
|
request: httpReq,
|
|
140
|
-
httpClient
|
|
142
|
+
httpClient,
|
|
141
143
|
logger: this.logger,
|
|
142
144
|
});
|
|
143
145
|
resp = parseResponse(respBody, unmarshalUpdateTokenResponseSchema);
|
package/dist/v1/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/v1/client.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAE/E,OAAO,EAAC,OAAO,IAAI,YAAY,EAAC,MAAM,sBAAsB,CAAC;AAC7D,OAAO,EAAC,aAAa,EAAC,MAAM,iCAAiC,CAAC;AAE9D,OAAO,EAAC,UAAU,EAAC,MAAM,6BAA6B,CAAC;AAIvD,OAAO,EAAC,
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/v1/client.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAE/E,OAAO,EAAC,OAAO,IAAI,YAAY,EAAC,MAAM,sBAAsB,CAAC;AAC7D,OAAO,EAAC,aAAa,EAAC,MAAM,iCAAiC,CAAC;AAE9D,OAAO,EAAC,UAAU,EAAC,MAAM,6BAA6B,CAAC;AAIvD,OAAO,EAAC,mBAAmB,EAAC,MAAM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,CAAC,GAAG,EAAE,+BAA+B,CAAC,CAAC;QAClE,IAAI,IAAqC,CAAC;QAC1C,MAAM,IAAI,GAAG,KAAK,EAAE,UAAwB,EAAiB,EAAE;YAC7D,MAAM,OAAO,GAAG,IAAI,OAAO,CAAC,EAAC,cAAc,EAAE,kBAAkB,EAAC,CAAC,CAAC;YAClE,IAAI,WAAW,KAAK,SAAS,EAAE,CAAC;gBAC9B,OAAO,CAAC,GAAG,CAAC,qBAAqB,EAAE,WAAW,CAAC,CAAC;YAClD,CAAC;YACD,OAAO,CAAC,GAAG,CAAC,YAAY,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;YAC1C,MAAM,OAAO,GAAG,gBAAgB,CAAC,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,UAAU,EAAE,IAAI,CAAC,CAAC;YAC1E,MAAM,QAAQ,GAAG,MAAM,eAAe,CAAC;gBACrC,OAAO,EAAE,OAAO;gBAChB,UAAU;gBACV,MAAM,EAAE,IAAI,CAAC,MAAM;aACpB,CAAC,CAAC;YACH,IAAI,GAAG,aAAa,CAAC,QAAQ,EAAE,kCAAkC,CAAC,CAAC;QACrE,CAAC,CAAC;QACF,MAAM,WAAW,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QACjC,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;YACvB,MAAM,IAAI,KAAK,CAAC,uCAAuC,CAAC,CAAC;QAC3D,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;CACF"}
|
package/dist/v1/model.d.ts
CHANGED
|
@@ -6,15 +6,16 @@ import { z } from 'zod';
|
|
|
6
6
|
* Token store and token management proto can depend on this.
|
|
7
7
|
* Principal context proto should NOT depend on this proto definitions because too many services depend on the principal context proto.
|
|
8
8
|
*/
|
|
9
|
-
export declare
|
|
10
|
-
AUTOSCOPE_STATE_UNSPECIFIED
|
|
11
|
-
AUTOSCOPE_STATE_DISABLED
|
|
12
|
-
AUTOSCOPE_STATE_RUNNING
|
|
13
|
-
AUTOSCOPE_STATE_COMPLETED
|
|
14
|
-
AUTOSCOPE_STATE_BACKFILLED
|
|
15
|
-
AUTOSCOPE_STATE_USER_SELECTED
|
|
16
|
-
AUTOSCOPE_STATE_API_NOT_COVERED
|
|
17
|
-
}
|
|
9
|
+
export declare const AutoscopeState: {
|
|
10
|
+
readonly AUTOSCOPE_STATE_UNSPECIFIED: "AUTOSCOPE_STATE_UNSPECIFIED";
|
|
11
|
+
readonly AUTOSCOPE_STATE_DISABLED: "AUTOSCOPE_STATE_DISABLED";
|
|
12
|
+
readonly AUTOSCOPE_STATE_RUNNING: "AUTOSCOPE_STATE_RUNNING";
|
|
13
|
+
readonly AUTOSCOPE_STATE_COMPLETED: "AUTOSCOPE_STATE_COMPLETED";
|
|
14
|
+
readonly AUTOSCOPE_STATE_BACKFILLED: "AUTOSCOPE_STATE_BACKFILLED";
|
|
15
|
+
readonly AUTOSCOPE_STATE_USER_SELECTED: "AUTOSCOPE_STATE_USER_SELECTED";
|
|
16
|
+
readonly AUTOSCOPE_STATE_API_NOT_COVERED: "AUTOSCOPE_STATE_API_NOT_COVERED";
|
|
17
|
+
};
|
|
18
|
+
export type AutoscopeState = (typeof AutoscopeState)[keyof typeof AutoscopeState] | (string & {});
|
|
18
19
|
export interface CreateTokenRequest {
|
|
19
20
|
/**
|
|
20
21
|
* The lifetime of the token, in seconds.
|
package/dist/v1/model.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../../src/v1/model.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,SAAS,EAAC,MAAM,0BAA0B,CAAC;AAEnD,OAAO,EAAC,CAAC,EAAC,MAAM,KAAK,CAAC;AAEtB;;;;;GAKG;
|
|
1
|
+
{"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../../src/v1/model.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,SAAS,EAAC,MAAM,0BAA0B,CAAC;AAEnD,OAAO,EA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AC,CAK5B"}
|
package/dist/v1/model.js
CHANGED
|
@@ -7,16 +7,16 @@ import { z } from 'zod';
|
|
|
7
7
|
* Token store and token management proto can depend on this.
|
|
8
8
|
* Principal context proto should NOT depend on this proto definitions because too many services depend on the principal context proto.
|
|
9
9
|
*/
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
10
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention -- Enum-style const object.
|
|
11
|
+
export const AutoscopeState = {
|
|
12
|
+
AUTOSCOPE_STATE_UNSPECIFIED: 'AUTOSCOPE_STATE_UNSPECIFIED',
|
|
13
|
+
AUTOSCOPE_STATE_DISABLED: 'AUTOSCOPE_STATE_DISABLED',
|
|
14
|
+
AUTOSCOPE_STATE_RUNNING: 'AUTOSCOPE_STATE_RUNNING',
|
|
15
|
+
AUTOSCOPE_STATE_COMPLETED: 'AUTOSCOPE_STATE_COMPLETED',
|
|
16
|
+
AUTOSCOPE_STATE_BACKFILLED: 'AUTOSCOPE_STATE_BACKFILLED',
|
|
17
|
+
AUTOSCOPE_STATE_USER_SELECTED: 'AUTOSCOPE_STATE_USER_SELECTED',
|
|
18
|
+
AUTOSCOPE_STATE_API_NOT_COVERED: 'AUTOSCOPE_STATE_API_NOT_COVERED',
|
|
19
|
+
};
|
|
20
20
|
export const unmarshalCreateTokenResponseSchema = z
|
|
21
21
|
.object({
|
|
22
22
|
token_value: z.string().optional(),
|
|
@@ -48,7 +48,7 @@ export const unmarshalPublicTokenInfoSchema = z
|
|
|
48
48
|
.optional(),
|
|
49
49
|
comment: z.string().optional(),
|
|
50
50
|
scopes: z.array(z.string()).optional(),
|
|
51
|
-
autoscope_state: z.
|
|
51
|
+
autoscope_state: z.string().optional(),
|
|
52
52
|
inferred_scopes: z.array(z.string()).optional(),
|
|
53
53
|
backfill_scopes: z.array(z.string()).optional(),
|
|
54
54
|
})
|
|
@@ -84,7 +84,7 @@ export const marshalPublicTokenInfoSchema = z
|
|
|
84
84
|
expiryTime: z.bigint().optional(),
|
|
85
85
|
comment: z.string().optional(),
|
|
86
86
|
scopes: z.array(z.string()).optional(),
|
|
87
|
-
autoscopeState: z.
|
|
87
|
+
autoscopeState: z.string().optional(),
|
|
88
88
|
inferredScopes: z.array(z.string()).optional(),
|
|
89
89
|
backfillScopes: z.array(z.string()).optional(),
|
|
90
90
|
})
|
package/dist/v1/model.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model.js","sourceRoot":"","sources":["../../src/v1/model.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAE/E,OAAO,EAAC,SAAS,EAAC,MAAM,0BAA0B,CAAC;AAEnD,OAAO,EAAC,CAAC,EAAC,MAAM,KAAK,CAAC;AAEtB;;;;;GAKG;AACH,MAAM,
|
|
1
|
+
{"version":3,"file":"model.js","sourceRoot":"","sources":["../../src/v1/model.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAE/E,OAAO,EAAC,SAAS,EAAC,MAAM,0BAA0B,CAAC;AAEnD,OAAO,EAAC,CAAC,EAAC,MAAM,KAAK,CAAC;AAEtB;;;;;GAKG;AACH,4FAA4F;AAC5F,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,2BAA2B,EAAE,6BAA6B;IAC1D,wBAAwB,EAAE,0BAA0B;IACpD,uBAAuB,EAAE,yBAAyB;IAClD,yBAAyB,EAAE,2BAA2B;IACtD,0BAA0B,EAAE,4BAA4B;IACxD,6BAA6B,EAAE,+BAA+B;IAC9D,+BAA+B,EAAE,iCAAiC;CAC1D,CAAC;AAgFX,MAAM,CAAC,MAAM,kCAAkC,GAC7C,CAAC;KACE,MAAM,CAAC;IACN,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAClC,UAAU,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,8BAA8B,CAA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 -1,5 +1,33 @@
|
|
|
1
1
|
import type { HttpClient } from '@databricks/sdk-core/http';
|
|
2
2
|
import type { ClientOptions } from '@databricks/sdk-options/client';
|
|
3
|
-
/**
|
|
4
|
-
|
|
3
|
+
/**
|
|
4
|
+
* The configuration a client needs to issue requests, resolved from
|
|
5
|
+
* {@link ClientOptions} and a configuration profile.
|
|
6
|
+
*/
|
|
7
|
+
export interface ResolvedClientConfig {
|
|
8
|
+
/** Host with any trailing slash removed. */
|
|
9
|
+
host: string;
|
|
10
|
+
/**
|
|
11
|
+
* Default account ID for account-level paths that contain an account_id
|
|
12
|
+
* segment. A request's own accountId still wins.
|
|
13
|
+
*/
|
|
14
|
+
accountId?: string;
|
|
15
|
+
/**
|
|
16
|
+
* Workspace ID used to route workspace-level calls on unified hosts (SPOG).
|
|
17
|
+
*/
|
|
18
|
+
workspaceId?: string;
|
|
19
|
+
/** HTTP client with authentication, and any configured timeout, applied. */
|
|
20
|
+
httpClient: HttpClient;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Resolves {@link ClientOptions} into a {@link ResolvedClientConfig}.
|
|
24
|
+
*
|
|
25
|
+
* A configuration profile is always resolved from the config file and
|
|
26
|
+
* environment variables (per options.profileOptions); it supplies host,
|
|
27
|
+
* accountId, workspaceId, and credentials wherever the caller did not set them
|
|
28
|
+
* explicitly. Explicit options always take precedence.
|
|
29
|
+
*
|
|
30
|
+
* @throws if host is neither provided nor present in the resolved profile.
|
|
31
|
+
*/
|
|
32
|
+
export declare function resolveClientConfig(options: ClientOptions): Promise<ResolvedClientConfig>;
|
|
5
33
|
//# sourceMappingURL=transport.d.ts.map
|
|
@@ -1 +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;
|
|
1
|
+
{"version":3,"file":"transport.d.ts","sourceRoot":"","sources":["../../src/v1/transport.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,UAAU,EAGX,MAAM,2BAA2B,CAAC;AAInC,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,gCAAgC,CAAC;AAElE;;;GAGG;AACH,MAAM,WAAW,oBAAoB;IACnC,4CAA4C;IAC5C,IAAI,EAAE,MAAM,CAAC;IAEb;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB,4EAA4E;IAC5E,UAAU,EAAE,UAAU,CAAC;CACxB;AAED;;;;;;;;;GASG;AACH,wBAAsB,mBAAmB,CACvC,OAAO,EAAE,aAAa,GACrB,OAAO,CAAC,oBAAoB,CAAC,CA4B/B"}
|
package/dist/v1/transport.js
CHANGED
|
@@ -1,24 +1,41 @@
|
|
|
1
1
|
// Code generated from API definition by Databricks SDK Generator. DO NOT EDIT.
|
|
2
2
|
import { defaultCredentials } from '@databricks/sdk-auth/credentials';
|
|
3
3
|
import { newFetchHttpClient } from '@databricks/sdk-core/http';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
4
|
+
import { resolve } from '@databricks/sdk-core/profiles';
|
|
5
|
+
/**
|
|
6
|
+
* Resolves {@link ClientOptions} into a {@link ResolvedClientConfig}.
|
|
7
|
+
*
|
|
8
|
+
* A configuration profile is always resolved from the config file and
|
|
9
|
+
* environment variables (per options.profileOptions); it supplies host,
|
|
10
|
+
* accountId, workspaceId, and credentials wherever the caller did not set them
|
|
11
|
+
* explicitly. Explicit options always take precedence.
|
|
12
|
+
*
|
|
13
|
+
* @throws if host is neither provided nor present in the resolved profile.
|
|
14
|
+
*/
|
|
15
|
+
export async function resolveClientConfig(options) {
|
|
16
|
+
const profile = await resolve(options.profileOptions);
|
|
17
|
+
const host = options.host ?? profile.host;
|
|
18
|
+
if (host === undefined) {
|
|
19
|
+
throw new Error('Host is required.');
|
|
14
20
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
21
|
+
// The provided httpClient (or the default fetch client) is the base wire;
|
|
22
|
+
// authentication and the optional timeout are layered on top of it. The
|
|
23
|
+
// default credential chain reuses the profile resolved above so that the
|
|
24
|
+
// same profileOptions govern host and authentication alike.
|
|
25
|
+
const base = options.httpClient ?? newFetchHttpClient();
|
|
26
|
+
const credentials = options.credentials ?? defaultCredentials({ profile });
|
|
27
|
+
let httpClient = new AuthHttpClient(base, credentials);
|
|
28
|
+
if (options.timeout !== undefined) {
|
|
29
|
+
httpClient = new TimeoutHttpClient(httpClient, options.timeout);
|
|
20
30
|
}
|
|
21
|
-
|
|
31
|
+
const accountId = options.accountId ?? profile.accountId;
|
|
32
|
+
const workspaceId = options.workspaceId ?? profile.workspaceId;
|
|
33
|
+
return {
|
|
34
|
+
host: host.replace(/\/$/, ''),
|
|
35
|
+
httpClient,
|
|
36
|
+
...(accountId !== undefined && { accountId }),
|
|
37
|
+
...(workspaceId !== undefined && { workspaceId }),
|
|
38
|
+
};
|
|
22
39
|
}
|
|
23
40
|
/** Wraps an HttpClient and adds authentication headers to requests. */
|
|
24
41
|
class AuthHttpClient {
|
package/dist/v1/transport.js.map
CHANGED
|
@@ -1 +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;
|
|
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,kBAA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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,
|
|
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,CAK1E;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
CHANGED
|
@@ -79,7 +79,8 @@ export function buildHttpRequest(method, url, headers, signal, body) {
|
|
|
79
79
|
}
|
|
80
80
|
export function parseResponse(body, schema) {
|
|
81
81
|
const text = new TextDecoder().decode(body);
|
|
82
|
-
|
|
82
|
+
// 204 responses return an empty body; treat as `{}`.
|
|
83
|
+
const parsed = text === '' ? {} : jsonBigint.parse(text);
|
|
83
84
|
return schema.parse(parsed);
|
|
84
85
|
}
|
|
85
86
|
export function marshalRequest(data, schema) {
|
package/dist/v1/utils.js.map
CHANGED
|
@@ -1 +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,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AAK,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,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@databricks/sdk-tokens",
|
|
3
|
-
"version": "0.1.0-dev.
|
|
3
|
+
"version": "0.1.0-dev.5",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -12,7 +12,6 @@
|
|
|
12
12
|
},
|
|
13
13
|
"files": [
|
|
14
14
|
"dist",
|
|
15
|
-
"src",
|
|
16
15
|
"LICENSE"
|
|
17
16
|
],
|
|
18
17
|
"scripts": {
|
|
@@ -28,10 +27,15 @@
|
|
|
28
27
|
},
|
|
29
28
|
"author": "Databricks",
|
|
30
29
|
"license": "Apache-2.0",
|
|
30
|
+
"repository": {
|
|
31
|
+
"type": "git",
|
|
32
|
+
"url": "https://github.com/databricks/sdk-js.git",
|
|
33
|
+
"directory": "packages/tokens"
|
|
34
|
+
},
|
|
31
35
|
"dependencies": {
|
|
32
|
-
"@databricks/sdk-auth": ">=0.1.0-dev.
|
|
33
|
-
"@databricks/sdk-core": ">=0.1.0-dev.
|
|
34
|
-
"@databricks/sdk-options": ">=0.1.0-dev.
|
|
36
|
+
"@databricks/sdk-auth": ">=0.1.0-dev.6 <1.0.0",
|
|
37
|
+
"@databricks/sdk-core": ">=0.1.0-dev.7 <1.0.0",
|
|
38
|
+
"@databricks/sdk-options": ">=0.1.0-dev.6 <1.0.0",
|
|
35
39
|
"@js-temporal/polyfill": "^0.5.0",
|
|
36
40
|
"json-bigint": "^1.0.0",
|
|
37
41
|
"zod": "^4.3.6"
|
package/src/v1/client.ts
DELETED
|
@@ -1,199 +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
|
-
CreateTokenRequest,
|
|
21
|
-
CreateTokenResponse,
|
|
22
|
-
ListTokensRequest,
|
|
23
|
-
ListTokensResponse,
|
|
24
|
-
RevokeTokenRequest,
|
|
25
|
-
RevokeTokenResponse,
|
|
26
|
-
UpdateTokenRequest,
|
|
27
|
-
UpdateTokenResponse,
|
|
28
|
-
} from './model';
|
|
29
|
-
import {
|
|
30
|
-
marshalCreateTokenRequestSchema,
|
|
31
|
-
marshalRevokeTokenRequestSchema,
|
|
32
|
-
marshalUpdateTokenRequestSchema,
|
|
33
|
-
unmarshalCreateTokenResponseSchema,
|
|
34
|
-
unmarshalListTokensResponseSchema,
|
|
35
|
-
unmarshalRevokeTokenResponseSchema,
|
|
36
|
-
unmarshalUpdateTokenResponseSchema,
|
|
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 TokensClient {
|
|
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
|
-
* Creates and returns a token for a user. If this call is made through token authentication, it creates
|
|
75
|
-
* a token with the same client ID as the authenticated token. If the user's token quota is exceeded, this call
|
|
76
|
-
* returns an error **QUOTA_EXCEEDED**.
|
|
77
|
-
*/
|
|
78
|
-
async createToken(
|
|
79
|
-
req: CreateTokenRequest,
|
|
80
|
-
options?: CallOptions
|
|
81
|
-
): Promise<CreateTokenResponse> {
|
|
82
|
-
const url = `${this.host}/api/2.0/token/create`;
|
|
83
|
-
const body = marshalRequest(req, marshalCreateTokenRequestSchema);
|
|
84
|
-
let resp: CreateTokenResponse | undefined;
|
|
85
|
-
const call = async (callSignal?: AbortSignal): Promise<void> => {
|
|
86
|
-
const headers = new Headers({'Content-Type': 'application/json'});
|
|
87
|
-
if (this.workspaceId !== undefined) {
|
|
88
|
-
headers.set('X-Databricks-Org-Id', this.workspaceId);
|
|
89
|
-
}
|
|
90
|
-
headers.set('User-Agent', this.userAgent);
|
|
91
|
-
const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
|
|
92
|
-
const respBody = await executeHttpCall({
|
|
93
|
-
request: httpReq,
|
|
94
|
-
httpClient: this.httpClient,
|
|
95
|
-
logger: this.logger,
|
|
96
|
-
});
|
|
97
|
-
resp = parseResponse(respBody, unmarshalCreateTokenResponseSchema);
|
|
98
|
-
};
|
|
99
|
-
await executeCall(call, options);
|
|
100
|
-
if (resp === undefined) {
|
|
101
|
-
throw new Error('operation completed without a result.');
|
|
102
|
-
}
|
|
103
|
-
return resp;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
/** Lists all the valid tokens for a user-workspace pair. */
|
|
107
|
-
async listTokens(
|
|
108
|
-
_req: ListTokensRequest,
|
|
109
|
-
options?: CallOptions
|
|
110
|
-
): Promise<ListTokensResponse> {
|
|
111
|
-
const url = `${this.host}/api/2.0/token/list`;
|
|
112
|
-
let resp: ListTokensResponse | undefined;
|
|
113
|
-
const call = async (callSignal?: AbortSignal): Promise<void> => {
|
|
114
|
-
const headers = new Headers();
|
|
115
|
-
if (this.workspaceId !== undefined) {
|
|
116
|
-
headers.set('X-Databricks-Org-Id', this.workspaceId);
|
|
117
|
-
}
|
|
118
|
-
headers.set('User-Agent', this.userAgent);
|
|
119
|
-
const httpReq = buildHttpRequest('GET', url, headers, callSignal);
|
|
120
|
-
const respBody = await executeHttpCall({
|
|
121
|
-
request: httpReq,
|
|
122
|
-
httpClient: this.httpClient,
|
|
123
|
-
logger: this.logger,
|
|
124
|
-
});
|
|
125
|
-
resp = parseResponse(respBody, unmarshalListTokensResponseSchema);
|
|
126
|
-
};
|
|
127
|
-
await executeCall(call, options);
|
|
128
|
-
if (resp === undefined) {
|
|
129
|
-
throw new Error('operation completed without a result.');
|
|
130
|
-
}
|
|
131
|
-
return resp;
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
/**
|
|
135
|
-
* Revokes an access token.
|
|
136
|
-
*
|
|
137
|
-
* If a token with the specified ID is not valid, this call returns an error **RESOURCE_DOES_NOT_EXIST**.
|
|
138
|
-
*/
|
|
139
|
-
async revokeToken(
|
|
140
|
-
req: RevokeTokenRequest,
|
|
141
|
-
options?: CallOptions
|
|
142
|
-
): Promise<RevokeTokenResponse> {
|
|
143
|
-
const url = `${this.host}/api/2.0/token/delete`;
|
|
144
|
-
const body = marshalRequest(req, marshalRevokeTokenRequestSchema);
|
|
145
|
-
let resp: RevokeTokenResponse | undefined;
|
|
146
|
-
const call = async (callSignal?: AbortSignal): Promise<void> => {
|
|
147
|
-
const headers = new Headers({'Content-Type': 'application/json'});
|
|
148
|
-
if (this.workspaceId !== undefined) {
|
|
149
|
-
headers.set('X-Databricks-Org-Id', this.workspaceId);
|
|
150
|
-
}
|
|
151
|
-
headers.set('User-Agent', this.userAgent);
|
|
152
|
-
const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
|
|
153
|
-
const respBody = await executeHttpCall({
|
|
154
|
-
request: httpReq,
|
|
155
|
-
httpClient: this.httpClient,
|
|
156
|
-
logger: this.logger,
|
|
157
|
-
});
|
|
158
|
-
resp = parseResponse(respBody, unmarshalRevokeTokenResponseSchema);
|
|
159
|
-
};
|
|
160
|
-
await executeCall(call, options);
|
|
161
|
-
if (resp === undefined) {
|
|
162
|
-
throw new Error('operation completed without a result.');
|
|
163
|
-
}
|
|
164
|
-
return resp;
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
/**
|
|
168
|
-
* Updates the comment or scopes of a token.
|
|
169
|
-
*
|
|
170
|
-
* If a token with the specified ID is not valid, this call returns an error **NOT_FOUND**.
|
|
171
|
-
*/
|
|
172
|
-
async updateToken(
|
|
173
|
-
req: UpdateTokenRequest,
|
|
174
|
-
options?: CallOptions
|
|
175
|
-
): Promise<UpdateTokenResponse> {
|
|
176
|
-
const url = `${this.host}/api/2.0/token/${req.tokenId ?? ''}`;
|
|
177
|
-
const body = marshalRequest(req, marshalUpdateTokenRequestSchema);
|
|
178
|
-
let resp: UpdateTokenResponse | undefined;
|
|
179
|
-
const call = async (callSignal?: AbortSignal): Promise<void> => {
|
|
180
|
-
const headers = new Headers({'Content-Type': 'application/json'});
|
|
181
|
-
if (this.workspaceId !== undefined) {
|
|
182
|
-
headers.set('X-Databricks-Org-Id', this.workspaceId);
|
|
183
|
-
}
|
|
184
|
-
headers.set('User-Agent', this.userAgent);
|
|
185
|
-
const httpReq = buildHttpRequest('PATCH', url, headers, callSignal, body);
|
|
186
|
-
const respBody = await executeHttpCall({
|
|
187
|
-
request: httpReq,
|
|
188
|
-
httpClient: this.httpClient,
|
|
189
|
-
logger: this.logger,
|
|
190
|
-
});
|
|
191
|
-
resp = parseResponse(respBody, unmarshalUpdateTokenResponseSchema);
|
|
192
|
-
};
|
|
193
|
-
await executeCall(call, options);
|
|
194
|
-
if (resp === undefined) {
|
|
195
|
-
throw new Error('operation completed without a result.');
|
|
196
|
-
}
|
|
197
|
-
return resp;
|
|
198
|
-
}
|
|
199
|
-
}
|
package/src/v1/index.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
// Code generated from API definition by Databricks SDK Generator. DO NOT EDIT.
|
|
2
|
-
|
|
3
|
-
export {TokensClient} from './client';
|
|
4
|
-
|
|
5
|
-
export {AutoscopeState} from './model';
|
|
6
|
-
|
|
7
|
-
export type {
|
|
8
|
-
CreateTokenRequest,
|
|
9
|
-
CreateTokenResponse,
|
|
10
|
-
ListTokensRequest,
|
|
11
|
-
ListTokensResponse,
|
|
12
|
-
PublicTokenInfo,
|
|
13
|
-
RevokeTokenRequest,
|
|
14
|
-
RevokeTokenResponse,
|
|
15
|
-
UpdateTokenRequest,
|
|
16
|
-
UpdateTokenResponse,
|
|
17
|
-
} from './model';
|
|
18
|
-
|
|
19
|
-
export {publicTokenInfoFieldMask} from './model';
|
package/src/v1/model.ts
DELETED
|
@@ -1,231 +0,0 @@
|
|
|
1
|
-
// Code generated from API definition by Databricks SDK Generator. DO NOT EDIT.
|
|
2
|
-
|
|
3
|
-
import {FieldMask} from '@databricks/sdk-core/wkt';
|
|
4
|
-
import type {FieldMaskSchema} from '@databricks/sdk-core/wkt';
|
|
5
|
-
import {z} from 'zod';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* State of inferred scope collection (autoscope) for an external PAT.
|
|
9
|
-
* Mirrored in databricks.identity.AutoscopeState in common/principal-context/api/proto/tokendetails.proto.
|
|
10
|
-
* Token store and token management proto can depend on this.
|
|
11
|
-
* Principal context proto should NOT depend on this proto definitions because too many services depend on the principal context proto.
|
|
12
|
-
*/
|
|
13
|
-
export enum AutoscopeState {
|
|
14
|
-
AUTOSCOPE_STATE_UNSPECIFIED = 'AUTOSCOPE_STATE_UNSPECIFIED',
|
|
15
|
-
AUTOSCOPE_STATE_DISABLED = 'AUTOSCOPE_STATE_DISABLED',
|
|
16
|
-
AUTOSCOPE_STATE_RUNNING = 'AUTOSCOPE_STATE_RUNNING',
|
|
17
|
-
AUTOSCOPE_STATE_COMPLETED = 'AUTOSCOPE_STATE_COMPLETED',
|
|
18
|
-
AUTOSCOPE_STATE_BACKFILLED = 'AUTOSCOPE_STATE_BACKFILLED',
|
|
19
|
-
AUTOSCOPE_STATE_USER_SELECTED = 'AUTOSCOPE_STATE_USER_SELECTED',
|
|
20
|
-
AUTOSCOPE_STATE_API_NOT_COVERED = 'AUTOSCOPE_STATE_API_NOT_COVERED',
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export interface CreateTokenRequest {
|
|
24
|
-
/**
|
|
25
|
-
* The lifetime of the token, in seconds.
|
|
26
|
-
*
|
|
27
|
-
* If the lifetime is not specified, this token remains valid for 2 years.
|
|
28
|
-
*/
|
|
29
|
-
lifetimeSeconds?: bigint | undefined;
|
|
30
|
-
/** Optional description to attach to the token. */
|
|
31
|
-
comment?: string | undefined;
|
|
32
|
-
/** Optional scopes of the token. */
|
|
33
|
-
scopes?: string[] | undefined;
|
|
34
|
-
/**
|
|
35
|
-
* Whether to enable autoscoping for this token. When true, the token will
|
|
36
|
-
* automatically collect inferred API path scopes as it is used.
|
|
37
|
-
*/
|
|
38
|
-
autoscopeEnabled?: boolean | undefined;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export interface CreateTokenResponse {
|
|
42
|
-
/** The value of the new token. */
|
|
43
|
-
tokenValue?: string | undefined;
|
|
44
|
-
/** The information for the new token. */
|
|
45
|
-
tokenInfo?: PublicTokenInfo | undefined;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
|
49
|
-
export interface ListTokensRequest {}
|
|
50
|
-
|
|
51
|
-
export interface ListTokensResponse {
|
|
52
|
-
/** The information for each token. */
|
|
53
|
-
tokenInfos?: PublicTokenInfo[] | undefined;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
export interface PublicTokenInfo {
|
|
57
|
-
/** The ID of this token. */
|
|
58
|
-
tokenId?: string | undefined;
|
|
59
|
-
/** Server time (in epoch milliseconds) when the token was created. */
|
|
60
|
-
creationTime?: bigint | undefined;
|
|
61
|
-
/** Server time (in epoch milliseconds) when the token will expire, or -1 if not applicable. */
|
|
62
|
-
expiryTime?: bigint | undefined;
|
|
63
|
-
/** Comment the token was created with, if applicable. */
|
|
64
|
-
comment?: string | undefined;
|
|
65
|
-
/** Scope of the token was created with, if applicable. */
|
|
66
|
-
scopes?: string[] | undefined;
|
|
67
|
-
/** Output only. The autoscope state of this token. */
|
|
68
|
-
autoscopeState?: AutoscopeState | undefined;
|
|
69
|
-
/** Output only. Inferred API path scopes collected for this token when autoscope is enabled. */
|
|
70
|
-
inferredScopes?: string[] | undefined;
|
|
71
|
-
/** Output only. Scopes inferred from offline backfill processing. */
|
|
72
|
-
backfillScopes?: string[] | undefined;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
export interface RevokeTokenRequest {
|
|
76
|
-
/** The ID of the token to be revoked. */
|
|
77
|
-
tokenId?: string | undefined;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
|
81
|
-
export interface RevokeTokenResponse {}
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* For the list of supported token scopes, see
|
|
85
|
-
* https://docs.databricks.com/api/workspace/api/scopes.
|
|
86
|
-
*/
|
|
87
|
-
export interface UpdateTokenRequest {
|
|
88
|
-
/** The SHA-256 hash of the token to be updated. */
|
|
89
|
-
tokenId?: string | undefined;
|
|
90
|
-
token?: PublicTokenInfo | undefined;
|
|
91
|
-
/** A list of field name under token, For example, {"update_mask": "comment,scopes"} */
|
|
92
|
-
updateMask?: FieldMask<PublicTokenInfo> | undefined;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
|
96
|
-
export interface UpdateTokenResponse {}
|
|
97
|
-
|
|
98
|
-
export const unmarshalCreateTokenResponseSchema: z.ZodType<CreateTokenResponse> =
|
|
99
|
-
z
|
|
100
|
-
.object({
|
|
101
|
-
token_value: z.string().optional(),
|
|
102
|
-
token_info: z.lazy(() => unmarshalPublicTokenInfoSchema).optional(),
|
|
103
|
-
})
|
|
104
|
-
.transform(d => ({
|
|
105
|
-
tokenValue: d.token_value,
|
|
106
|
-
tokenInfo: d.token_info,
|
|
107
|
-
}));
|
|
108
|
-
|
|
109
|
-
export const unmarshalListTokensResponseSchema: z.ZodType<ListTokensResponse> =
|
|
110
|
-
z
|
|
111
|
-
.object({
|
|
112
|
-
token_infos: z
|
|
113
|
-
.array(z.lazy(() => unmarshalPublicTokenInfoSchema))
|
|
114
|
-
.optional(),
|
|
115
|
-
})
|
|
116
|
-
.transform(d => ({
|
|
117
|
-
tokenInfos: d.token_infos,
|
|
118
|
-
}));
|
|
119
|
-
|
|
120
|
-
export const unmarshalPublicTokenInfoSchema: z.ZodType<PublicTokenInfo> = z
|
|
121
|
-
.object({
|
|
122
|
-
token_id: z.string().optional(),
|
|
123
|
-
creation_time: z
|
|
124
|
-
.union([z.number(), z.bigint()])
|
|
125
|
-
.transform(v => BigInt(v))
|
|
126
|
-
.optional(),
|
|
127
|
-
expiry_time: z
|
|
128
|
-
.union([z.number(), z.bigint()])
|
|
129
|
-
.transform(v => BigInt(v))
|
|
130
|
-
.optional(),
|
|
131
|
-
comment: z.string().optional(),
|
|
132
|
-
scopes: z.array(z.string()).optional(),
|
|
133
|
-
autoscope_state: z.enum(AutoscopeState).optional(),
|
|
134
|
-
inferred_scopes: z.array(z.string()).optional(),
|
|
135
|
-
backfill_scopes: z.array(z.string()).optional(),
|
|
136
|
-
})
|
|
137
|
-
.transform(d => ({
|
|
138
|
-
tokenId: d.token_id,
|
|
139
|
-
creationTime: d.creation_time,
|
|
140
|
-
expiryTime: d.expiry_time,
|
|
141
|
-
comment: d.comment,
|
|
142
|
-
scopes: d.scopes,
|
|
143
|
-
autoscopeState: d.autoscope_state,
|
|
144
|
-
inferredScopes: d.inferred_scopes,
|
|
145
|
-
backfillScopes: d.backfill_scopes,
|
|
146
|
-
}));
|
|
147
|
-
|
|
148
|
-
export const unmarshalRevokeTokenResponseSchema: z.ZodType<RevokeTokenResponse> =
|
|
149
|
-
z.object({});
|
|
150
|
-
|
|
151
|
-
export const unmarshalUpdateTokenResponseSchema: z.ZodType<UpdateTokenResponse> =
|
|
152
|
-
z.object({});
|
|
153
|
-
|
|
154
|
-
export const marshalCreateTokenRequestSchema: z.ZodType = z
|
|
155
|
-
.object({
|
|
156
|
-
lifetimeSeconds: z.bigint().optional(),
|
|
157
|
-
comment: z.string().optional(),
|
|
158
|
-
scopes: z.array(z.string()).optional(),
|
|
159
|
-
autoscopeEnabled: z.boolean().optional(),
|
|
160
|
-
})
|
|
161
|
-
.transform(d => ({
|
|
162
|
-
lifetime_seconds: d.lifetimeSeconds,
|
|
163
|
-
comment: d.comment,
|
|
164
|
-
scopes: d.scopes,
|
|
165
|
-
autoscope_enabled: d.autoscopeEnabled,
|
|
166
|
-
}));
|
|
167
|
-
|
|
168
|
-
export const marshalPublicTokenInfoSchema: z.ZodType = z
|
|
169
|
-
.object({
|
|
170
|
-
tokenId: z.string().optional(),
|
|
171
|
-
creationTime: z.bigint().optional(),
|
|
172
|
-
expiryTime: z.bigint().optional(),
|
|
173
|
-
comment: z.string().optional(),
|
|
174
|
-
scopes: z.array(z.string()).optional(),
|
|
175
|
-
autoscopeState: z.enum(AutoscopeState).optional(),
|
|
176
|
-
inferredScopes: z.array(z.string()).optional(),
|
|
177
|
-
backfillScopes: z.array(z.string()).optional(),
|
|
178
|
-
})
|
|
179
|
-
.transform(d => ({
|
|
180
|
-
token_id: d.tokenId,
|
|
181
|
-
creation_time: d.creationTime,
|
|
182
|
-
expiry_time: d.expiryTime,
|
|
183
|
-
comment: d.comment,
|
|
184
|
-
scopes: d.scopes,
|
|
185
|
-
autoscope_state: d.autoscopeState,
|
|
186
|
-
inferred_scopes: d.inferredScopes,
|
|
187
|
-
backfill_scopes: d.backfillScopes,
|
|
188
|
-
}));
|
|
189
|
-
|
|
190
|
-
export const marshalRevokeTokenRequestSchema: z.ZodType = z
|
|
191
|
-
.object({
|
|
192
|
-
tokenId: z.string().optional(),
|
|
193
|
-
})
|
|
194
|
-
.transform(d => ({
|
|
195
|
-
token_id: d.tokenId,
|
|
196
|
-
}));
|
|
197
|
-
|
|
198
|
-
export const marshalUpdateTokenRequestSchema: z.ZodType = z
|
|
199
|
-
.object({
|
|
200
|
-
tokenId: z.string().optional(),
|
|
201
|
-
token: z.lazy(() => marshalPublicTokenInfoSchema).optional(),
|
|
202
|
-
updateMask: z
|
|
203
|
-
.any()
|
|
204
|
-
.transform((m: FieldMask) => m.toString())
|
|
205
|
-
.optional(),
|
|
206
|
-
})
|
|
207
|
-
.transform(d => ({
|
|
208
|
-
token_id: d.tokenId,
|
|
209
|
-
token: d.token,
|
|
210
|
-
update_mask: d.updateMask,
|
|
211
|
-
}));
|
|
212
|
-
|
|
213
|
-
const publicTokenInfoFieldMaskSchema: FieldMaskSchema = {
|
|
214
|
-
autoscopeState: {wire: 'autoscope_state'},
|
|
215
|
-
backfillScopes: {wire: 'backfill_scopes'},
|
|
216
|
-
comment: {wire: 'comment'},
|
|
217
|
-
creationTime: {wire: 'creation_time'},
|
|
218
|
-
expiryTime: {wire: 'expiry_time'},
|
|
219
|
-
inferredScopes: {wire: 'inferred_scopes'},
|
|
220
|
-
scopes: {wire: 'scopes'},
|
|
221
|
-
tokenId: {wire: 'token_id'},
|
|
222
|
-
};
|
|
223
|
-
|
|
224
|
-
export function publicTokenInfoFieldMask(
|
|
225
|
-
...paths: string[]
|
|
226
|
-
): FieldMask<PublicTokenInfo> {
|
|
227
|
-
return FieldMask.build<PublicTokenInfo>(
|
|
228
|
-
paths,
|
|
229
|
-
publicTokenInfoFieldMaskSchema
|
|
230
|
-
);
|
|
231
|
-
}
|
package/src/v1/transport.ts
DELETED
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
// Code generated from API definition by Databricks SDK Generator. DO NOT EDIT.
|
|
2
|
-
|
|
3
|
-
import type {Credentials} from '@databricks/sdk-auth';
|
|
4
|
-
import {defaultCredentials} from '@databricks/sdk-auth/credentials';
|
|
5
|
-
import type {
|
|
6
|
-
HttpClient,
|
|
7
|
-
HttpRequest,
|
|
8
|
-
HttpResponse,
|
|
9
|
-
} from '@databricks/sdk-core/http';
|
|
10
|
-
import {newFetchHttpClient} from '@databricks/sdk-core/http';
|
|
11
|
-
import type {ClientOptions} from '@databricks/sdk-options/client';
|
|
12
|
-
|
|
13
|
-
/** Creates a new HTTP client with the given options. */
|
|
14
|
-
export function newHttpClient(options?: ClientOptions): HttpClient {
|
|
15
|
-
const opts = options ?? {};
|
|
16
|
-
|
|
17
|
-
// If an HTTP client is provided, use it as-is. Throw if other options are
|
|
18
|
-
// also set, since they would be silently ignored.
|
|
19
|
-
if (opts.httpClient !== undefined) {
|
|
20
|
-
if (opts.credentials !== undefined || opts.timeout !== undefined) {
|
|
21
|
-
throw new Error(
|
|
22
|
-
'httpClient cannot be combined with credentials or timeout'
|
|
23
|
-
);
|
|
24
|
-
}
|
|
25
|
-
return opts.httpClient;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
const credentials = opts.credentials ?? defaultCredentials();
|
|
29
|
-
|
|
30
|
-
const base = newFetchHttpClient();
|
|
31
|
-
let client: HttpClient = new AuthHttpClient(base, credentials);
|
|
32
|
-
|
|
33
|
-
if (opts.timeout !== undefined) {
|
|
34
|
-
client = new TimeoutHttpClient(client, opts.timeout);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
return client;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/** Wraps an HttpClient and adds authentication headers to requests. */
|
|
41
|
-
class AuthHttpClient implements HttpClient {
|
|
42
|
-
constructor(
|
|
43
|
-
private readonly base: HttpClient,
|
|
44
|
-
private readonly credentials: Credentials
|
|
45
|
-
) {}
|
|
46
|
-
|
|
47
|
-
async send(request: HttpRequest): Promise<HttpResponse> {
|
|
48
|
-
const authHeaders = await this.credentials.authHeaders();
|
|
49
|
-
// Do not modify the original request.
|
|
50
|
-
const headers = new Headers(request.headers);
|
|
51
|
-
for (const h of authHeaders) {
|
|
52
|
-
headers.set(h.key, h.value);
|
|
53
|
-
}
|
|
54
|
-
return this.base.send({...request, headers});
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
/** Wraps an HttpClient and applies a default timeout to requests. */
|
|
59
|
-
class TimeoutHttpClient implements HttpClient {
|
|
60
|
-
constructor(
|
|
61
|
-
private readonly base: HttpClient,
|
|
62
|
-
private readonly timeout: number
|
|
63
|
-
) {}
|
|
64
|
-
|
|
65
|
-
async send(request: HttpRequest): Promise<HttpResponse> {
|
|
66
|
-
const timeoutSignal = AbortSignal.timeout(this.timeout);
|
|
67
|
-
const signal =
|
|
68
|
-
request.signal !== undefined
|
|
69
|
-
? AbortSignal.any([request.signal, timeoutSignal])
|
|
70
|
-
: timeoutSignal;
|
|
71
|
-
return this.base.send({...request, signal});
|
|
72
|
-
}
|
|
73
|
-
}
|
package/src/v1/utils.ts
DELETED
|
@@ -1,156 +0,0 @@
|
|
|
1
|
-
// Code generated from API definition by Databricks SDK Generator. DO NOT EDIT.
|
|
2
|
-
|
|
3
|
-
import type {Options} from '@databricks/sdk-core/ops';
|
|
4
|
-
import {execute} from '@databricks/sdk-core/ops';
|
|
5
|
-
import {ApiError} from '@databricks/sdk-core/apierror';
|
|
6
|
-
import type {
|
|
7
|
-
HttpClient,
|
|
8
|
-
HttpRequest,
|
|
9
|
-
HttpResponse,
|
|
10
|
-
} from '@databricks/sdk-core/http';
|
|
11
|
-
import type {Logger} from '@databricks/sdk-core/logger';
|
|
12
|
-
import type {CallOptions} from '@databricks/sdk-options/call';
|
|
13
|
-
import JSONBig from 'json-bigint';
|
|
14
|
-
import type {z} from 'zod';
|
|
15
|
-
|
|
16
|
-
// JSON codec that preserves int64 precision. On the way in, large integer
|
|
17
|
-
// literals come back as bigint instead of being rounded to JS Number. On the
|
|
18
|
-
// way out, bigint values are emitted as raw JSON number digits.
|
|
19
|
-
const jsonBigint = JSONBig({useNativeBigInt: true});
|
|
20
|
-
|
|
21
|
-
export interface HttpCallOptions {
|
|
22
|
-
readonly request: HttpRequest;
|
|
23
|
-
readonly httpClient: HttpClient;
|
|
24
|
-
readonly logger: Logger;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Translates public CallOptions to the internal Options shape accepted by
|
|
29
|
-
* execute(). Even though the shapes match today, this isolates the public
|
|
30
|
-
* API from the executor's internal type so they can diverge.
|
|
31
|
-
*/
|
|
32
|
-
export async function executeCall(
|
|
33
|
-
call: (signal?: AbortSignal) => Promise<void>,
|
|
34
|
-
options?: CallOptions
|
|
35
|
-
): Promise<void> {
|
|
36
|
-
const opts: Options = {
|
|
37
|
-
...(options?.retrier !== undefined && {retrier: options.retrier}),
|
|
38
|
-
...(options?.rateLimiter !== undefined && {
|
|
39
|
-
rateLimiter: options.rateLimiter,
|
|
40
|
-
}),
|
|
41
|
-
...(options?.timeout !== undefined && {timeout: options.timeout}),
|
|
42
|
-
};
|
|
43
|
-
return execute(options?.signal, call, opts);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
async function readAll(
|
|
47
|
-
body: ReadableStream<Uint8Array> | null
|
|
48
|
-
): Promise<Uint8Array> {
|
|
49
|
-
if (body === null) {
|
|
50
|
-
return new Uint8Array(0);
|
|
51
|
-
}
|
|
52
|
-
const reader = body.getReader();
|
|
53
|
-
const chunks: Uint8Array[] = [];
|
|
54
|
-
for (;;) {
|
|
55
|
-
const {done, value} = await reader.read();
|
|
56
|
-
if (done) {
|
|
57
|
-
break;
|
|
58
|
-
}
|
|
59
|
-
chunks.push(value);
|
|
60
|
-
}
|
|
61
|
-
const totalLength = chunks.reduce((acc, chunk) => acc + chunk.length, 0);
|
|
62
|
-
const result = new Uint8Array(totalLength);
|
|
63
|
-
let offset = 0;
|
|
64
|
-
for (const chunk of chunks) {
|
|
65
|
-
result.set(chunk, offset);
|
|
66
|
-
offset += chunk.length;
|
|
67
|
-
}
|
|
68
|
-
return result;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
export async function executeHttpCall(
|
|
72
|
-
opts: HttpCallOptions
|
|
73
|
-
): Promise<Uint8Array> {
|
|
74
|
-
opts.logger.debug('HTTP request', {
|
|
75
|
-
method: opts.request.method,
|
|
76
|
-
url: opts.request.url,
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
let resp: HttpResponse;
|
|
80
|
-
try {
|
|
81
|
-
resp = await opts.httpClient.send(opts.request);
|
|
82
|
-
} catch (e: unknown) {
|
|
83
|
-
opts.logger.debug('HTTP request failed');
|
|
84
|
-
throw e;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
const body = await readAll(resp.body);
|
|
88
|
-
|
|
89
|
-
opts.logger.debug('HTTP response', {
|
|
90
|
-
statusCode: resp.statusCode,
|
|
91
|
-
body: new TextDecoder().decode(body),
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
const apiErr = ApiError.fromHttpError(resp.statusCode, resp.headers, body);
|
|
95
|
-
if (apiErr !== undefined) {
|
|
96
|
-
throw apiErr;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
return body;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
export function buildHttpRequest(
|
|
103
|
-
method: string,
|
|
104
|
-
url: string,
|
|
105
|
-
headers: Headers,
|
|
106
|
-
signal?: AbortSignal,
|
|
107
|
-
body?: string | ReadableStream<Uint8Array>
|
|
108
|
-
): HttpRequest {
|
|
109
|
-
const req: HttpRequest = {url, method, headers};
|
|
110
|
-
if (body !== undefined) {
|
|
111
|
-
req.body = body;
|
|
112
|
-
}
|
|
113
|
-
if (signal !== undefined) {
|
|
114
|
-
req.signal = signal;
|
|
115
|
-
}
|
|
116
|
-
return req;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
export function parseResponse<T>(body: Uint8Array, schema: z.ZodType<T>): T {
|
|
120
|
-
const text = new TextDecoder().decode(body);
|
|
121
|
-
const parsed: unknown = jsonBigint.parse(text);
|
|
122
|
-
return schema.parse(parsed);
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
export function marshalRequest(data: unknown, schema: z.ZodType): string {
|
|
126
|
-
return jsonBigint.stringify(schema.parse(data));
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
export function flattenQueryParams(
|
|
130
|
-
prefix: string,
|
|
131
|
-
value: unknown,
|
|
132
|
-
params: URLSearchParams
|
|
133
|
-
): void {
|
|
134
|
-
if (value === null || value === undefined) {
|
|
135
|
-
return;
|
|
136
|
-
}
|
|
137
|
-
if (Array.isArray(value)) {
|
|
138
|
-
// arrays of objects are not yet supported
|
|
139
|
-
for (const item of value) {
|
|
140
|
-
params.append(prefix, String(item));
|
|
141
|
-
}
|
|
142
|
-
} else if (typeof value === 'object') {
|
|
143
|
-
for (const [key, val] of Object.entries(value as Record<string, unknown>)) {
|
|
144
|
-
flattenQueryParams(`${prefix}.${key}`, val, params);
|
|
145
|
-
}
|
|
146
|
-
} else if (
|
|
147
|
-
typeof value === 'string' ||
|
|
148
|
-
typeof value === 'number' ||
|
|
149
|
-
typeof value === 'boolean' ||
|
|
150
|
-
typeof value === 'bigint'
|
|
151
|
-
) {
|
|
152
|
-
params.append(prefix, String(value));
|
|
153
|
-
} else {
|
|
154
|
-
throw new Error(`Unsupported query parameter type: ${typeof value}`);
|
|
155
|
-
}
|
|
156
|
-
}
|