@databricks/sdk-usagedashboards 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 +16 -0
- package/dist/v1/client.d.ts.map +1 -0
- package/dist/v1/client.js +92 -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 +43 -0
- package/dist/v1/model.d.ts.map +1 -0
- package/dist/v1/model.js +46 -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 +132 -0
- package/src/v1/index.ts +12 -0
- package/src/v1/model.ts +85 -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/LICENSE
ADDED
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
Copyright 2026 Databricks, Inc. All rights reserved.
|
|
2
|
+
|
|
3
|
+
Apache License
|
|
4
|
+
Version 2.0, January 2004
|
|
5
|
+
http://www.apache.org/licenses/
|
|
6
|
+
|
|
7
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
8
|
+
|
|
9
|
+
1. Definitions.
|
|
10
|
+
|
|
11
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
12
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
13
|
+
|
|
14
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
15
|
+
the copyright owner that is granting the License.
|
|
16
|
+
|
|
17
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
18
|
+
other entities that control, are controlled by, or are under common
|
|
19
|
+
control with that entity. For the purposes of this definition,
|
|
20
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
21
|
+
direction or management of such entity, whether by contract or
|
|
22
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
23
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
24
|
+
|
|
25
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
26
|
+
exercising permissions granted by this License.
|
|
27
|
+
|
|
28
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
29
|
+
including but not limited to software source code, documentation
|
|
30
|
+
source, and configuration files.
|
|
31
|
+
|
|
32
|
+
"Object" form shall mean any form resulting from mechanical
|
|
33
|
+
transformation or translation of a Source form, including but
|
|
34
|
+
not limited to compiled object code, generated documentation,
|
|
35
|
+
and conversions to other media types.
|
|
36
|
+
|
|
37
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
38
|
+
Object form, made available under the License, as indicated by a
|
|
39
|
+
copyright notice that is included in or attached to the work
|
|
40
|
+
(an example is provided in the Appendix below).
|
|
41
|
+
|
|
42
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
43
|
+
form, that is based on (or derived from) the Work and for which the
|
|
44
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
45
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
46
|
+
of this License, Derivative Works shall not include works that remain
|
|
47
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
48
|
+
the Work and Derivative Works thereof.
|
|
49
|
+
|
|
50
|
+
"Contribution" shall mean any work of authorship, including
|
|
51
|
+
the original version of the Work and any modifications or additions
|
|
52
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
53
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
54
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
55
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
56
|
+
means any form of electronic, verbal, or written communication sent
|
|
57
|
+
to the Licensor or its representatives, including but not limited to
|
|
58
|
+
communication on electronic mailing lists, source code control systems,
|
|
59
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
60
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
61
|
+
excluding communication that is conspicuously marked or otherwise
|
|
62
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
63
|
+
|
|
64
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
65
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
66
|
+
subsequently incorporated within the Work.
|
|
67
|
+
|
|
68
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
69
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
70
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
71
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
72
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
73
|
+
Work and such Derivative Works in Source or Object form.
|
|
74
|
+
|
|
75
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
76
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
77
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
78
|
+
(except as stated in this section) patent license to make, have made,
|
|
79
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
80
|
+
where such license applies only to those patent claims licensable
|
|
81
|
+
by such Contributor that are necessarily infringed by their
|
|
82
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
83
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
84
|
+
institute patent litigation against any entity (including a
|
|
85
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
86
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
87
|
+
or contributory patent infringement, then any patent licenses
|
|
88
|
+
granted to You under this License for that Work shall terminate
|
|
89
|
+
as of the date such litigation is filed.
|
|
90
|
+
|
|
91
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
92
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
93
|
+
modifications, and in Source or Object form, provided that You
|
|
94
|
+
meet the following conditions:
|
|
95
|
+
|
|
96
|
+
(a) You must give any other recipients of the Work or
|
|
97
|
+
Derivative Works a copy of this License; and
|
|
98
|
+
|
|
99
|
+
(b) You must cause any modified files to carry prominent notices
|
|
100
|
+
stating that You changed the files; and
|
|
101
|
+
|
|
102
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
103
|
+
that You distribute, all copyright, patent, trademark, and
|
|
104
|
+
attribution notices from the Source form of the Work,
|
|
105
|
+
excluding those notices that do not pertain to any part of
|
|
106
|
+
the Derivative Works; and
|
|
107
|
+
|
|
108
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
109
|
+
distribution, then any Derivative Works that You distribute must
|
|
110
|
+
include a readable copy of the attribution notices contained
|
|
111
|
+
within such NOTICE file, excluding those notices that do not
|
|
112
|
+
pertain to any part of the Derivative Works, in at least one
|
|
113
|
+
of the following places: within a NOTICE text file distributed
|
|
114
|
+
as part of the Derivative Works; within the Source form or
|
|
115
|
+
documentation, if provided along with the Derivative Works; or,
|
|
116
|
+
within a display generated by the Derivative Works, if and
|
|
117
|
+
wherever such third-party notices normally appear. The contents
|
|
118
|
+
of the NOTICE file are for informational purposes only and
|
|
119
|
+
do not modify the License. You may add Your own attribution
|
|
120
|
+
notices within Derivative Works that You distribute, alongside
|
|
121
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
122
|
+
that such additional attribution notices cannot be construed
|
|
123
|
+
as modifying the License.
|
|
124
|
+
|
|
125
|
+
You may add Your own copyright statement to Your modifications and
|
|
126
|
+
may provide additional or different license terms and conditions
|
|
127
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
128
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
129
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
130
|
+
the conditions stated in this License.
|
|
131
|
+
|
|
132
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
133
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
134
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
135
|
+
this License, without any additional terms or conditions.
|
|
136
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
137
|
+
the terms of any separate license agreement you may have executed
|
|
138
|
+
with Licensor regarding such Contributions.
|
|
139
|
+
|
|
140
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
141
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
142
|
+
except as required for reasonable and customary use in describing the
|
|
143
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
144
|
+
|
|
145
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
146
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
147
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
148
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
149
|
+
implied, including, without limitation, any warranties or conditions
|
|
150
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
151
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
152
|
+
appropriateness of using or redistributing the Work and assume any
|
|
153
|
+
risks associated with Your exercise of permissions under this License.
|
|
154
|
+
|
|
155
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
156
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
157
|
+
unless required by applicable law (such as deliberate and grossly
|
|
158
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
159
|
+
liable to You for damages, including any direct, indirect, special,
|
|
160
|
+
incidental, or consequential damages of any character arising as a
|
|
161
|
+
result of this License or out of the use or inability to use the
|
|
162
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
163
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
164
|
+
other commercial damages or losses), even if such Contributor
|
|
165
|
+
has been advised of the possibility of such damages.
|
|
166
|
+
|
|
167
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
168
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
169
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
170
|
+
or other liability obligations and/or rights consistent with this
|
|
171
|
+
License. However, in accepting such obligations, You may act only
|
|
172
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
173
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
174
|
+
defend, and hold each Contributor harmless for any liability
|
|
175
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
176
|
+
of your accepting any such warranty or additional liability.
|
|
177
|
+
|
|
178
|
+
END OF TERMS AND CONDITIONS
|
|
179
|
+
|
|
180
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
181
|
+
|
|
182
|
+
To apply the Apache License to your work, attach the following
|
|
183
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
184
|
+
replaced with your own identifying information. (Don't include
|
|
185
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
186
|
+
comment syntax for the file format. We also recommend that a
|
|
187
|
+
file or class name and description of purpose be included on the
|
|
188
|
+
same "printed page" as the copyright notice for easier
|
|
189
|
+
identification within third-party archives.
|
|
190
|
+
|
|
191
|
+
Copyright [yyyy] [name of copyright owner]
|
|
192
|
+
|
|
193
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
194
|
+
you may not use this file except in compliance with the License.
|
|
195
|
+
You may obtain a copy of the License at
|
|
196
|
+
|
|
197
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
198
|
+
|
|
199
|
+
Unless required by applicable law or agreed to in writing, software
|
|
200
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
201
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
202
|
+
See the License for the specific language governing permissions and
|
|
203
|
+
limitations under the License.
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { CallOptions } from '@databricks/sdk-options/call';
|
|
2
|
+
import type { ClientOptions } from '@databricks/sdk-options/client';
|
|
3
|
+
import type { CreateBillingUsageDashboardRequest, CreateBillingUsageDashboardRequest_Response, GetBillingUsageDashboardRequest, GetBillingUsageDashboardRequest_Response } from './model';
|
|
4
|
+
export declare class UsageDashboardsClient {
|
|
5
|
+
private readonly host;
|
|
6
|
+
private readonly accountId;
|
|
7
|
+
private readonly httpClient;
|
|
8
|
+
private readonly logger;
|
|
9
|
+
private readonly userAgent;
|
|
10
|
+
constructor(options: ClientOptions);
|
|
11
|
+
/** Create a usage dashboard specified by workspaceId, accountId, and dashboard type. */
|
|
12
|
+
createBillingUsageDashboard(req: CreateBillingUsageDashboardRequest, options?: CallOptions): Promise<CreateBillingUsageDashboardRequest_Response>;
|
|
13
|
+
/** Get a usage dashboard specified by workspaceId, accountId, and dashboard type. */
|
|
14
|
+
getBillingUsageDashboard(req: GetBillingUsageDashboardRequest, options?: CallOptions): Promise<GetBillingUsageDashboardRequest_Response>;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +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,kCAAkC,EAClC,2CAA2C,EAC3C,+BAA+B,EAC/B,wCAAwC,EACzC,MAAM,SAAS,CAAC;AAajB,qBAAa,qBAAqB;IAChC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAS;IAG9B,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAqB;IAC/C,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAa;IACxC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAIhC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAS;gBAEvB,OAAO,EAAE,aAAa;IAelC,wFAAwF;IAClF,2BAA2B,CAC/B,GAAG,EAAE,kCAAkC,EACvC,OAAO,CAAC,EAAE,WAAW,GACpB,OAAO,CAAC,2CAA2C,CAAC;IA4BvD,qFAAqF;IAC/E,wBAAwB,CAC5B,GAAG,EAAE,+BAA+B,EACpC,OAAO,CAAC,EAAE,WAAW,GACpB,OAAO,CAAC,wCAAwC,CAAC;CAgCrD"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
// Code generated from API definition by Databricks SDK Generator. DO NOT EDIT.
|
|
2
|
+
import { VERSION as AUTH_VERSION } from '@databricks/sdk-auth';
|
|
3
|
+
import { createDefault } from '@databricks/sdk-core/clientinfo';
|
|
4
|
+
import { NoOpLogger } from '@databricks/sdk-core/logger';
|
|
5
|
+
import { newHttpClient } from './transport';
|
|
6
|
+
import { buildHttpRequest, executeCall, executeHttpCall, marshalRequest, parseResponse, } from './utils';
|
|
7
|
+
import pkgJson from '../../package.json' with { type: 'json' };
|
|
8
|
+
import { marshalCreateBillingUsageDashboardRequestSchema, unmarshalCreateBillingUsageDashboardRequest_ResponseSchema, unmarshalGetBillingUsageDashboardRequest_ResponseSchema, } from './model';
|
|
9
|
+
// Package identity segment for this client to be used in the User-Agent header.
|
|
10
|
+
const PACKAGE_SEGMENT = {
|
|
11
|
+
key: 'sdk-js-' + pkgJson.name.replace(/^@[^/]+\/sdk-/, ''),
|
|
12
|
+
value: pkgJson.version,
|
|
13
|
+
};
|
|
14
|
+
export class UsageDashboardsClient {
|
|
15
|
+
host;
|
|
16
|
+
// Fallback for endpoints whose path contains {account_id}. If the request
|
|
17
|
+
// already carries an accountId, that value wins.
|
|
18
|
+
accountId;
|
|
19
|
+
httpClient;
|
|
20
|
+
logger;
|
|
21
|
+
// User-Agent header value. Composed once at construction from
|
|
22
|
+
// createDefault() merged with this package's identity and the active
|
|
23
|
+
// credential's name.
|
|
24
|
+
userAgent;
|
|
25
|
+
constructor(options) {
|
|
26
|
+
if (options.host === undefined) {
|
|
27
|
+
throw new Error('Host is required.');
|
|
28
|
+
}
|
|
29
|
+
this.host = options.host.replace(/\/$/, '');
|
|
30
|
+
this.accountId = options.accountId;
|
|
31
|
+
this.logger = options.logger ?? new NoOpLogger();
|
|
32
|
+
const info = createDefault()
|
|
33
|
+
.with(PACKAGE_SEGMENT)
|
|
34
|
+
.with({ key: 'sdk-js-auth', value: AUTH_VERSION })
|
|
35
|
+
.with({ key: 'auth', value: options.credentials?.name() ?? 'default' });
|
|
36
|
+
this.userAgent = info.toString();
|
|
37
|
+
this.httpClient = newHttpClient(options);
|
|
38
|
+
}
|
|
39
|
+
/** Create a usage dashboard specified by workspaceId, accountId, and dashboard type. */
|
|
40
|
+
async createBillingUsageDashboard(req, options) {
|
|
41
|
+
const url = `${this.host}/api/2.0/accounts/${req.accountId ?? this.accountId ?? ''}/dashboard`;
|
|
42
|
+
const body = marshalRequest(req, marshalCreateBillingUsageDashboardRequestSchema);
|
|
43
|
+
let resp;
|
|
44
|
+
const call = async (callSignal) => {
|
|
45
|
+
const headers = new Headers({ 'Content-Type': 'application/json' });
|
|
46
|
+
headers.set('User-Agent', this.userAgent);
|
|
47
|
+
const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
|
|
48
|
+
const respBody = await executeHttpCall({
|
|
49
|
+
request: httpReq,
|
|
50
|
+
httpClient: this.httpClient,
|
|
51
|
+
logger: this.logger,
|
|
52
|
+
});
|
|
53
|
+
resp = parseResponse(respBody, unmarshalCreateBillingUsageDashboardRequest_ResponseSchema);
|
|
54
|
+
};
|
|
55
|
+
await executeCall(call, options);
|
|
56
|
+
if (resp === undefined) {
|
|
57
|
+
throw new Error('operation completed without a result.');
|
|
58
|
+
}
|
|
59
|
+
return resp;
|
|
60
|
+
}
|
|
61
|
+
/** Get a usage dashboard specified by workspaceId, accountId, and dashboard type. */
|
|
62
|
+
async getBillingUsageDashboard(req, options) {
|
|
63
|
+
const url = `${this.host}/api/2.0/accounts/${req.accountId ?? this.accountId ?? ''}/dashboard`;
|
|
64
|
+
const params = new URLSearchParams();
|
|
65
|
+
if (req.workspaceId !== undefined) {
|
|
66
|
+
params.append('workspace_id', String(req.workspaceId));
|
|
67
|
+
}
|
|
68
|
+
if (req.dashboardType !== undefined) {
|
|
69
|
+
params.append('dashboard_type', req.dashboardType);
|
|
70
|
+
}
|
|
71
|
+
const query = params.toString();
|
|
72
|
+
const fullUrl = query !== '' ? `${url}?${query}` : url;
|
|
73
|
+
let resp;
|
|
74
|
+
const call = async (callSignal) => {
|
|
75
|
+
const headers = new Headers();
|
|
76
|
+
headers.set('User-Agent', this.userAgent);
|
|
77
|
+
const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
|
|
78
|
+
const respBody = await executeHttpCall({
|
|
79
|
+
request: httpReq,
|
|
80
|
+
httpClient: this.httpClient,
|
|
81
|
+
logger: this.logger,
|
|
82
|
+
});
|
|
83
|
+
resp = parseResponse(respBody, unmarshalGetBillingUsageDashboardRequest_ResponseSchema);
|
|
84
|
+
};
|
|
85
|
+
await executeCall(call, options);
|
|
86
|
+
if (resp === undefined) {
|
|
87
|
+
throw new Error('operation completed without a result.');
|
|
88
|
+
}
|
|
89
|
+
return resp;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +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,aAAa,EAAC,MAAM,aAAa,CAAC;AAC1C,OAAO,EACL,gBAAgB,EAChB,WAAW,EACX,eAAe,EACf,cAAc,EACd,aAAa,GACd,MAAM,SAAS,CAAC;AAC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AM,IAAI,KAAK,CAAC,uCAAuC,CAAC,CAAC;QAC3D,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;CACF"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { UsageDashboardsClient } from './client';
|
|
2
|
+
export { UsageDashboardMajorVersion, UsageDashboardType } from './model';
|
|
3
|
+
export type { CreateBillingUsageDashboardRequest, CreateBillingUsageDashboardRequest_Response, GetBillingUsageDashboardRequest, GetBillingUsageDashboardRequest_Response, } from './model';
|
|
4
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/v1/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,qBAAqB,EAAC,MAAM,UAAU,CAAC;AAE/C,OAAO,EAAC,0BAA0B,EAAE,kBAAkB,EAAC,MAAM,SAAS,CAAC;AAEvE,YAAY,EACV,kCAAkC,EAClC,2CAA2C,EAC3C,+BAA+B,EAC/B,wCAAwC,GACzC,MAAM,SAAS,CAAC"}
|
package/dist/v1/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/v1/index.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAE/E,OAAO,EAAC,qBAAqB,EAAC,MAAM,UAAU,CAAC;AAE/C,OAAO,EAAC,0BAA0B,EAAE,kBAAkB,EAAC,MAAM,SAAS,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare enum UsageDashboardMajorVersion {
|
|
3
|
+
USAGE_DASHBOARD_MAJOR_VERSION_UNSPECIFIED = "USAGE_DASHBOARD_MAJOR_VERSION_UNSPECIFIED",
|
|
4
|
+
USAGE_DASHBOARD_MAJOR_VERSION_1 = "USAGE_DASHBOARD_MAJOR_VERSION_1",
|
|
5
|
+
USAGE_DASHBOARD_MAJOR_VERSION_2 = "USAGE_DASHBOARD_MAJOR_VERSION_2"
|
|
6
|
+
}
|
|
7
|
+
export declare enum UsageDashboardType {
|
|
8
|
+
USAGE_DASHBOARD_TYPE_UNSPECIFIED = "USAGE_DASHBOARD_TYPE_UNSPECIFIED",
|
|
9
|
+
USAGE_DASHBOARD_TYPE_WORKSPACE = "USAGE_DASHBOARD_TYPE_WORKSPACE",
|
|
10
|
+
USAGE_DASHBOARD_TYPE_GLOBAL = "USAGE_DASHBOARD_TYPE_GLOBAL"
|
|
11
|
+
}
|
|
12
|
+
export interface CreateBillingUsageDashboardRequest {
|
|
13
|
+
/** The workspace ID of the workspace in which the usage dashboard is created. */
|
|
14
|
+
workspaceId?: bigint | undefined;
|
|
15
|
+
/** <Databricks> account ID. */
|
|
16
|
+
accountId?: string | undefined;
|
|
17
|
+
/** Workspace level usage dashboard shows usage data for the specified workspace ID. Global level usage dashboard shows usage data for all workspaces in the account. */
|
|
18
|
+
dashboardType?: UsageDashboardType | undefined;
|
|
19
|
+
/** The major version of the usage dashboard template to use. Defaults to VERSION_1. */
|
|
20
|
+
majorVersion?: UsageDashboardMajorVersion | undefined;
|
|
21
|
+
}
|
|
22
|
+
export interface CreateBillingUsageDashboardRequest_Response {
|
|
23
|
+
/** The unique id of the usage dashboard. */
|
|
24
|
+
dashboardId?: string | undefined;
|
|
25
|
+
}
|
|
26
|
+
export interface GetBillingUsageDashboardRequest {
|
|
27
|
+
/** The workspace ID of the workspace in which the usage dashboard is created. */
|
|
28
|
+
workspaceId?: bigint | undefined;
|
|
29
|
+
/** <Databricks> account ID. */
|
|
30
|
+
accountId?: string | undefined;
|
|
31
|
+
/** Workspace level usage dashboard shows usage data for the specified workspace ID. Global level usage dashboard shows usage data for all workspaces in the account. */
|
|
32
|
+
dashboardType?: UsageDashboardType | undefined;
|
|
33
|
+
}
|
|
34
|
+
export interface GetBillingUsageDashboardRequest_Response {
|
|
35
|
+
/** The unique id of the usage dashboard. */
|
|
36
|
+
dashboardId?: string | undefined;
|
|
37
|
+
/** The URL of the usage dashboard. */
|
|
38
|
+
dashboardUrl?: string | undefined;
|
|
39
|
+
}
|
|
40
|
+
export declare const unmarshalCreateBillingUsageDashboardRequest_ResponseSchema: z.ZodType<CreateBillingUsageDashboardRequest_Response>;
|
|
41
|
+
export declare const unmarshalGetBillingUsageDashboardRequest_ResponseSchema: z.ZodType<GetBillingUsageDashboardRequest_Response>;
|
|
42
|
+
export declare const marshalCreateBillingUsageDashboardRequestSchema: z.ZodType;
|
|
43
|
+
//# sourceMappingURL=model.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../../src/v1/model.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,CAAC,EAAC,MAAM,KAAK,CAAC;AAEtB,oBAAY,0BAA0B;IACpC,yCAAyC,8CAA8C;IACvF,+BAA+B,oCAAoC;IACnE,+BAA+B,oCAAoC;CACpE;AAED,oBAAY,kBAAkB;IAC5B,gCAAgC,qCAAqC;IACrE,8BAA8B,mCAAmC;IACjE,2BAA2B,gCAAgC;CAC5D;AAED,MAAM,WAAW,kCAAkC;IACjD,iFAAiF;IACjF,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACjC,+BAA+B;IAC/B,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC/B,wKAAwK;IACxK,aAAa,CAAC,EAAE,kBAAkB,GAAG,SAAS,CAAC;IAC/C,uFAAuF;IACvF,YAAY,CAAC,EAAE,0BAA0B,GAAG,SAAS,CAAC;CACvD;AAGD,MAAM,WAAW,2CAA2C;IAC1D,4CAA4C;IAC5C,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAClC;AAED,MAAM,WAAW,+BAA+B;IAC9C,iFAAiF;IACjF,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACjC,+BAA+B;IAC/B,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC/B,wKAAwK;IACxK,aAAa,CAAC,EAAE,kBAAkB,GAAG,SAAS,CAAC;CAChD;AAGD,MAAM,WAAW,wCAAwC;IACvD,4CAA4C;IAC5C,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACjC,sCAAsC;IACtC,YAAY,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CACnC;AAGD,eAAO,MAAM,0DAA0D,EAAE,CAAC,CAAC,OAAO,CAAC,2CAA2C,CAOvH,CAAC;AAGR,eAAO,MAAM,uDAAuD,EAAE,CAAC,CAAC,OAAO,CAAC,wCAAwC,CASjH,CAAC;AAER,eAAO,MAAM,+CAA+C,EAAE,CAAC,CAAC,OAY3D,CAAC"}
|
package/dist/v1/model.js
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
// Code generated from API definition by Databricks SDK Generator. DO NOT EDIT.
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
export var UsageDashboardMajorVersion;
|
|
4
|
+
(function (UsageDashboardMajorVersion) {
|
|
5
|
+
UsageDashboardMajorVersion["USAGE_DASHBOARD_MAJOR_VERSION_UNSPECIFIED"] = "USAGE_DASHBOARD_MAJOR_VERSION_UNSPECIFIED";
|
|
6
|
+
UsageDashboardMajorVersion["USAGE_DASHBOARD_MAJOR_VERSION_1"] = "USAGE_DASHBOARD_MAJOR_VERSION_1";
|
|
7
|
+
UsageDashboardMajorVersion["USAGE_DASHBOARD_MAJOR_VERSION_2"] = "USAGE_DASHBOARD_MAJOR_VERSION_2";
|
|
8
|
+
})(UsageDashboardMajorVersion || (UsageDashboardMajorVersion = {}));
|
|
9
|
+
export var UsageDashboardType;
|
|
10
|
+
(function (UsageDashboardType) {
|
|
11
|
+
UsageDashboardType["USAGE_DASHBOARD_TYPE_UNSPECIFIED"] = "USAGE_DASHBOARD_TYPE_UNSPECIFIED";
|
|
12
|
+
UsageDashboardType["USAGE_DASHBOARD_TYPE_WORKSPACE"] = "USAGE_DASHBOARD_TYPE_WORKSPACE";
|
|
13
|
+
UsageDashboardType["USAGE_DASHBOARD_TYPE_GLOBAL"] = "USAGE_DASHBOARD_TYPE_GLOBAL";
|
|
14
|
+
})(UsageDashboardType || (UsageDashboardType = {}));
|
|
15
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name.
|
|
16
|
+
export const unmarshalCreateBillingUsageDashboardRequest_ResponseSchema = z
|
|
17
|
+
.object({
|
|
18
|
+
dashboard_id: z.string().optional(),
|
|
19
|
+
})
|
|
20
|
+
.transform(d => ({
|
|
21
|
+
dashboardId: d.dashboard_id,
|
|
22
|
+
}));
|
|
23
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name.
|
|
24
|
+
export const unmarshalGetBillingUsageDashboardRequest_ResponseSchema = z
|
|
25
|
+
.object({
|
|
26
|
+
dashboard_id: z.string().optional(),
|
|
27
|
+
dashboard_url: z.string().optional(),
|
|
28
|
+
})
|
|
29
|
+
.transform(d => ({
|
|
30
|
+
dashboardId: d.dashboard_id,
|
|
31
|
+
dashboardUrl: d.dashboard_url,
|
|
32
|
+
}));
|
|
33
|
+
export const marshalCreateBillingUsageDashboardRequestSchema = z
|
|
34
|
+
.object({
|
|
35
|
+
workspaceId: z.bigint().optional(),
|
|
36
|
+
accountId: z.string().optional(),
|
|
37
|
+
dashboardType: z.enum(UsageDashboardType).optional(),
|
|
38
|
+
majorVersion: z.enum(UsageDashboardMajorVersion).optional(),
|
|
39
|
+
})
|
|
40
|
+
.transform(d => ({
|
|
41
|
+
workspace_id: d.workspaceId,
|
|
42
|
+
account_id: d.accountId,
|
|
43
|
+
dashboard_type: d.dashboardType,
|
|
44
|
+
major_version: d.majorVersion,
|
|
45
|
+
}));
|
|
46
|
+
//# sourceMappingURL=model.js.map
|
|
@@ -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,K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AC,IAAI,CAAC,0BAA0B,CAAC,CAAC,QAAQ,EAAE;CAC5D,CAAC;KACD,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;IACf,YAAY,EAAE,CAAC,CAAC,WAAW;IAC3B,UAAU,EAAE,CAAC,CAAC,SAAS;IACvB,cAAc,EAAE,CAAC,CAAC,aAAa;IAC/B,aAAa,EAAE,CAAC,CAAC,YAAY;CAC9B,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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AAG,IAAI,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QAC7C,KAAK,MAAM,CAAC,IAAI,WAAW,EAAE,CAAC;YAC5B,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC;QAC9B,CAAC;QACD,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,EAAC,GAAG,OAAO,EAAE,OAAO,EAAC,CAAC,CAAC;IAC/C,CAAC;CACF;AAED,qEAAqE;AACrE,MAAM,iBAAiB;IAEF;IACA;IAFnB,YACmB,IAAgB,EAChB,OAAe;QADf,SAAI,GAAJ,IAAI,CAAY;QAChB,YAAO,GAAP,OAAO,CAAQ;IAC/B,CAAC;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,O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AAM,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-usagedashboards",
|
|
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,132 @@
|
|
|
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
|
+
CreateBillingUsageDashboardRequest,
|
|
21
|
+
CreateBillingUsageDashboardRequest_Response,
|
|
22
|
+
GetBillingUsageDashboardRequest,
|
|
23
|
+
GetBillingUsageDashboardRequest_Response,
|
|
24
|
+
} from './model';
|
|
25
|
+
import {
|
|
26
|
+
marshalCreateBillingUsageDashboardRequestSchema,
|
|
27
|
+
unmarshalCreateBillingUsageDashboardRequest_ResponseSchema,
|
|
28
|
+
unmarshalGetBillingUsageDashboardRequest_ResponseSchema,
|
|
29
|
+
} from './model';
|
|
30
|
+
|
|
31
|
+
// Package identity segment for this client to be used in the User-Agent header.
|
|
32
|
+
const PACKAGE_SEGMENT = {
|
|
33
|
+
key: 'sdk-js-' + pkgJson.name.replace(/^@[^/]+\/sdk-/, ''),
|
|
34
|
+
value: pkgJson.version,
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export class UsageDashboardsClient {
|
|
38
|
+
private readonly host: string;
|
|
39
|
+
// Fallback for endpoints whose path contains {account_id}. If the request
|
|
40
|
+
// already carries an accountId, that value wins.
|
|
41
|
+
private readonly accountId: string | undefined;
|
|
42
|
+
private readonly httpClient: HttpClient;
|
|
43
|
+
private readonly logger: Logger;
|
|
44
|
+
// User-Agent header value. Composed once at construction from
|
|
45
|
+
// createDefault() merged with this package's identity and the active
|
|
46
|
+
// credential's name.
|
|
47
|
+
private readonly userAgent: string;
|
|
48
|
+
|
|
49
|
+
constructor(options: ClientOptions) {
|
|
50
|
+
if (options.host === undefined) {
|
|
51
|
+
throw new Error('Host is required.');
|
|
52
|
+
}
|
|
53
|
+
this.host = options.host.replace(/\/$/, '');
|
|
54
|
+
this.accountId = options.accountId;
|
|
55
|
+
this.logger = options.logger ?? new NoOpLogger();
|
|
56
|
+
const info = createDefault()
|
|
57
|
+
.with(PACKAGE_SEGMENT)
|
|
58
|
+
.with({key: 'sdk-js-auth', value: AUTH_VERSION})
|
|
59
|
+
.with({key: 'auth', value: options.credentials?.name() ?? 'default'});
|
|
60
|
+
this.userAgent = info.toString();
|
|
61
|
+
this.httpClient = newHttpClient(options);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/** Create a usage dashboard specified by workspaceId, accountId, and dashboard type. */
|
|
65
|
+
async createBillingUsageDashboard(
|
|
66
|
+
req: CreateBillingUsageDashboardRequest,
|
|
67
|
+
options?: CallOptions
|
|
68
|
+
): Promise<CreateBillingUsageDashboardRequest_Response> {
|
|
69
|
+
const url = `${this.host}/api/2.0/accounts/${req.accountId ?? this.accountId ?? ''}/dashboard`;
|
|
70
|
+
const body = marshalRequest(
|
|
71
|
+
req,
|
|
72
|
+
marshalCreateBillingUsageDashboardRequestSchema
|
|
73
|
+
);
|
|
74
|
+
let resp: CreateBillingUsageDashboardRequest_Response | undefined;
|
|
75
|
+
const call = async (callSignal?: AbortSignal): Promise<void> => {
|
|
76
|
+
const headers = new Headers({'Content-Type': 'application/json'});
|
|
77
|
+
headers.set('User-Agent', this.userAgent);
|
|
78
|
+
const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
|
|
79
|
+
const respBody = await executeHttpCall({
|
|
80
|
+
request: httpReq,
|
|
81
|
+
httpClient: this.httpClient,
|
|
82
|
+
logger: this.logger,
|
|
83
|
+
});
|
|
84
|
+
resp = parseResponse(
|
|
85
|
+
respBody,
|
|
86
|
+
unmarshalCreateBillingUsageDashboardRequest_ResponseSchema
|
|
87
|
+
);
|
|
88
|
+
};
|
|
89
|
+
await executeCall(call, options);
|
|
90
|
+
if (resp === undefined) {
|
|
91
|
+
throw new Error('operation completed without a result.');
|
|
92
|
+
}
|
|
93
|
+
return resp;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/** Get a usage dashboard specified by workspaceId, accountId, and dashboard type. */
|
|
97
|
+
async getBillingUsageDashboard(
|
|
98
|
+
req: GetBillingUsageDashboardRequest,
|
|
99
|
+
options?: CallOptions
|
|
100
|
+
): Promise<GetBillingUsageDashboardRequest_Response> {
|
|
101
|
+
const url = `${this.host}/api/2.0/accounts/${req.accountId ?? this.accountId ?? ''}/dashboard`;
|
|
102
|
+
const params = new URLSearchParams();
|
|
103
|
+
if (req.workspaceId !== undefined) {
|
|
104
|
+
params.append('workspace_id', String(req.workspaceId));
|
|
105
|
+
}
|
|
106
|
+
if (req.dashboardType !== undefined) {
|
|
107
|
+
params.append('dashboard_type', req.dashboardType);
|
|
108
|
+
}
|
|
109
|
+
const query = params.toString();
|
|
110
|
+
const fullUrl = query !== '' ? `${url}?${query}` : url;
|
|
111
|
+
let resp: GetBillingUsageDashboardRequest_Response | undefined;
|
|
112
|
+
const call = async (callSignal?: AbortSignal): Promise<void> => {
|
|
113
|
+
const headers = new Headers();
|
|
114
|
+
headers.set('User-Agent', this.userAgent);
|
|
115
|
+
const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
|
|
116
|
+
const respBody = await executeHttpCall({
|
|
117
|
+
request: httpReq,
|
|
118
|
+
httpClient: this.httpClient,
|
|
119
|
+
logger: this.logger,
|
|
120
|
+
});
|
|
121
|
+
resp = parseResponse(
|
|
122
|
+
respBody,
|
|
123
|
+
unmarshalGetBillingUsageDashboardRequest_ResponseSchema
|
|
124
|
+
);
|
|
125
|
+
};
|
|
126
|
+
await executeCall(call, options);
|
|
127
|
+
if (resp === undefined) {
|
|
128
|
+
throw new Error('operation completed without a result.');
|
|
129
|
+
}
|
|
130
|
+
return resp;
|
|
131
|
+
}
|
|
132
|
+
}
|
package/src/v1/index.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// Code generated from API definition by Databricks SDK Generator. DO NOT EDIT.
|
|
2
|
+
|
|
3
|
+
export {UsageDashboardsClient} from './client';
|
|
4
|
+
|
|
5
|
+
export {UsageDashboardMajorVersion, UsageDashboardType} from './model';
|
|
6
|
+
|
|
7
|
+
export type {
|
|
8
|
+
CreateBillingUsageDashboardRequest,
|
|
9
|
+
CreateBillingUsageDashboardRequest_Response,
|
|
10
|
+
GetBillingUsageDashboardRequest,
|
|
11
|
+
GetBillingUsageDashboardRequest_Response,
|
|
12
|
+
} from './model';
|
package/src/v1/model.ts
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
// Code generated from API definition by Databricks SDK Generator. DO NOT EDIT.
|
|
2
|
+
|
|
3
|
+
import {z} from 'zod';
|
|
4
|
+
|
|
5
|
+
export enum UsageDashboardMajorVersion {
|
|
6
|
+
USAGE_DASHBOARD_MAJOR_VERSION_UNSPECIFIED = 'USAGE_DASHBOARD_MAJOR_VERSION_UNSPECIFIED',
|
|
7
|
+
USAGE_DASHBOARD_MAJOR_VERSION_1 = 'USAGE_DASHBOARD_MAJOR_VERSION_1',
|
|
8
|
+
USAGE_DASHBOARD_MAJOR_VERSION_2 = 'USAGE_DASHBOARD_MAJOR_VERSION_2',
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export enum UsageDashboardType {
|
|
12
|
+
USAGE_DASHBOARD_TYPE_UNSPECIFIED = 'USAGE_DASHBOARD_TYPE_UNSPECIFIED',
|
|
13
|
+
USAGE_DASHBOARD_TYPE_WORKSPACE = 'USAGE_DASHBOARD_TYPE_WORKSPACE',
|
|
14
|
+
USAGE_DASHBOARD_TYPE_GLOBAL = 'USAGE_DASHBOARD_TYPE_GLOBAL',
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface CreateBillingUsageDashboardRequest {
|
|
18
|
+
/** The workspace ID of the workspace in which the usage dashboard is created. */
|
|
19
|
+
workspaceId?: bigint | undefined;
|
|
20
|
+
/** <Databricks> account ID. */
|
|
21
|
+
accountId?: string | undefined;
|
|
22
|
+
/** Workspace level usage dashboard shows usage data for the specified workspace ID. Global level usage dashboard shows usage data for all workspaces in the account. */
|
|
23
|
+
dashboardType?: UsageDashboardType | undefined;
|
|
24
|
+
/** The major version of the usage dashboard template to use. Defaults to VERSION_1. */
|
|
25
|
+
majorVersion?: UsageDashboardMajorVersion | undefined;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name.
|
|
29
|
+
export interface CreateBillingUsageDashboardRequest_Response {
|
|
30
|
+
/** The unique id of the usage dashboard. */
|
|
31
|
+
dashboardId?: string | undefined;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export interface GetBillingUsageDashboardRequest {
|
|
35
|
+
/** The workspace ID of the workspace in which the usage dashboard is created. */
|
|
36
|
+
workspaceId?: bigint | undefined;
|
|
37
|
+
/** <Databricks> account ID. */
|
|
38
|
+
accountId?: string | undefined;
|
|
39
|
+
/** Workspace level usage dashboard shows usage data for the specified workspace ID. Global level usage dashboard shows usage data for all workspaces in the account. */
|
|
40
|
+
dashboardType?: UsageDashboardType | undefined;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name.
|
|
44
|
+
export interface GetBillingUsageDashboardRequest_Response {
|
|
45
|
+
/** The unique id of the usage dashboard. */
|
|
46
|
+
dashboardId?: string | undefined;
|
|
47
|
+
/** The URL of the usage dashboard. */
|
|
48
|
+
dashboardUrl?: string | undefined;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name.
|
|
52
|
+
export const unmarshalCreateBillingUsageDashboardRequest_ResponseSchema: z.ZodType<CreateBillingUsageDashboardRequest_Response> =
|
|
53
|
+
z
|
|
54
|
+
.object({
|
|
55
|
+
dashboard_id: z.string().optional(),
|
|
56
|
+
})
|
|
57
|
+
.transform(d => ({
|
|
58
|
+
dashboardId: d.dashboard_id,
|
|
59
|
+
}));
|
|
60
|
+
|
|
61
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name.
|
|
62
|
+
export const unmarshalGetBillingUsageDashboardRequest_ResponseSchema: z.ZodType<GetBillingUsageDashboardRequest_Response> =
|
|
63
|
+
z
|
|
64
|
+
.object({
|
|
65
|
+
dashboard_id: z.string().optional(),
|
|
66
|
+
dashboard_url: z.string().optional(),
|
|
67
|
+
})
|
|
68
|
+
.transform(d => ({
|
|
69
|
+
dashboardId: d.dashboard_id,
|
|
70
|
+
dashboardUrl: d.dashboard_url,
|
|
71
|
+
}));
|
|
72
|
+
|
|
73
|
+
export const marshalCreateBillingUsageDashboardRequestSchema: z.ZodType = z
|
|
74
|
+
.object({
|
|
75
|
+
workspaceId: z.bigint().optional(),
|
|
76
|
+
accountId: z.string().optional(),
|
|
77
|
+
dashboardType: z.enum(UsageDashboardType).optional(),
|
|
78
|
+
majorVersion: z.enum(UsageDashboardMajorVersion).optional(),
|
|
79
|
+
})
|
|
80
|
+
.transform(d => ({
|
|
81
|
+
workspace_id: d.workspaceId,
|
|
82
|
+
account_id: d.accountId,
|
|
83
|
+
dashboard_type: d.dashboardType,
|
|
84
|
+
major_version: d.majorVersion,
|
|
85
|
+
}));
|
|
@@ -0,0 +1,73 @@
|
|
|
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
ADDED
|
@@ -0,0 +1,156 @@
|
|
|
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
|
+
}
|
package/README.md
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
This is a placeholder release used to enable OIDC trusted publishing. Real code lands in a later version.
|
package/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
module.exports = {};
|