@databricks/sdk-clusterlibraries 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/v2/client.d.ts +37 -0
- package/dist/v2/client.d.ts.map +1 -0
- package/dist/v2/client.js +162 -0
- package/dist/v2/client.js.map +1 -0
- package/dist/v2/index.d.ts +4 -0
- package/dist/v2/index.d.ts.map +1 -0
- package/dist/v2/index.js +4 -0
- package/dist/v2/index.js.map +1 -0
- package/dist/v2/model.d.ts +178 -0
- package/dist/v2/model.d.ts.map +1 -0
- package/dist/v2/model.js +212 -0
- package/dist/v2/model.js.map +1 -0
- package/dist/v2/transport.d.ts +5 -0
- package/dist/v2/transport.d.ts.map +1 -0
- package/dist/v2/transport.js +57 -0
- package/dist/v2/transport.js.map +1 -0
- package/dist/v2/utils.d.ts +21 -0
- package/dist/v2/utils.d.ts.map +1 -0
- package/dist/v2/utils.js +113 -0
- package/dist/v2/utils.js.map +1 -0
- package/package.json +38 -4
- package/src/v2/client.ts +217 -0
- package/src/v2/index.ts +21 -0
- package/src/v2/model.ts +383 -0
- package/src/v2/transport.ts +73 -0
- package/src/v2/utils.ts +156 -0
- package/README.md +0 -1
- package/index.js +0 -1
package/src/v2/client.ts
ADDED
|
@@ -0,0 +1,217 @@
|
|
|
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
|
+
ClusterLibraryStatuses,
|
|
21
|
+
ClusterStatusRequest,
|
|
22
|
+
InstallLibrariesRequest,
|
|
23
|
+
InstallLibrariesRequest_Response,
|
|
24
|
+
ListAllClusterLibraryStatusesRequest,
|
|
25
|
+
ListAllClusterLibraryStatusesRequest_Response,
|
|
26
|
+
UninstallLibrariesRequest,
|
|
27
|
+
UninstallLibrariesRequest_Response,
|
|
28
|
+
} from './model';
|
|
29
|
+
import {
|
|
30
|
+
marshalInstallLibrariesRequestSchema,
|
|
31
|
+
marshalUninstallLibrariesRequestSchema,
|
|
32
|
+
unmarshalClusterLibraryStatusesSchema,
|
|
33
|
+
unmarshalInstallLibrariesRequest_ResponseSchema,
|
|
34
|
+
unmarshalListAllClusterLibraryStatusesRequest_ResponseSchema,
|
|
35
|
+
unmarshalUninstallLibrariesRequest_ResponseSchema,
|
|
36
|
+
} from './model';
|
|
37
|
+
|
|
38
|
+
// Package identity segment for this client to be used in the User-Agent header.
|
|
39
|
+
const PACKAGE_SEGMENT = {
|
|
40
|
+
key: 'sdk-js-' + pkgJson.name.replace(/^@[^/]+\/sdk-/, ''),
|
|
41
|
+
value: pkgJson.version,
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export class ClusterLibrariesClient {
|
|
45
|
+
private readonly host: string;
|
|
46
|
+
// Workspace ID used to route workspace-level calls on unified hosts (SPOG).
|
|
47
|
+
// When set, workspace-level methods send X-Databricks-Org-Id on every
|
|
48
|
+
// request.
|
|
49
|
+
private readonly workspaceId: string | undefined;
|
|
50
|
+
private readonly httpClient: HttpClient;
|
|
51
|
+
private readonly logger: Logger;
|
|
52
|
+
// User-Agent header value. Composed once at construction from
|
|
53
|
+
// createDefault() merged with this package's identity and the active
|
|
54
|
+
// credential's name.
|
|
55
|
+
private readonly userAgent: string;
|
|
56
|
+
|
|
57
|
+
constructor(options: ClientOptions) {
|
|
58
|
+
if (options.host === undefined) {
|
|
59
|
+
throw new Error('Host is required.');
|
|
60
|
+
}
|
|
61
|
+
this.host = options.host.replace(/\/$/, '');
|
|
62
|
+
this.workspaceId = options.workspaceId;
|
|
63
|
+
this.logger = options.logger ?? new NoOpLogger();
|
|
64
|
+
const info = createDefault()
|
|
65
|
+
.with(PACKAGE_SEGMENT)
|
|
66
|
+
.with({key: 'sdk-js-auth', value: AUTH_VERSION})
|
|
67
|
+
.with({key: 'auth', value: options.credentials?.name() ?? 'default'});
|
|
68
|
+
this.userAgent = info.toString();
|
|
69
|
+
this.httpClient = newHttpClient(options);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Get the status of all libraries on all clusters. A status is returned for all libraries installed on this cluster
|
|
74
|
+
* via the API or the libraries UI.
|
|
75
|
+
*/
|
|
76
|
+
async allClusterStatuses(
|
|
77
|
+
_req: ListAllClusterLibraryStatusesRequest,
|
|
78
|
+
options?: CallOptions
|
|
79
|
+
): Promise<ListAllClusterLibraryStatusesRequest_Response> {
|
|
80
|
+
const url = `${this.host}/api/2.0/libraries/all-cluster-statuses`;
|
|
81
|
+
let resp: ListAllClusterLibraryStatusesRequest_Response | undefined;
|
|
82
|
+
const call = async (callSignal?: AbortSignal): Promise<void> => {
|
|
83
|
+
const headers = new Headers();
|
|
84
|
+
if (this.workspaceId !== undefined) {
|
|
85
|
+
headers.set('X-Databricks-Org-Id', this.workspaceId);
|
|
86
|
+
}
|
|
87
|
+
headers.set('User-Agent', this.userAgent);
|
|
88
|
+
const httpReq = buildHttpRequest('GET', url, headers, callSignal);
|
|
89
|
+
const respBody = await executeHttpCall({
|
|
90
|
+
request: httpReq,
|
|
91
|
+
httpClient: this.httpClient,
|
|
92
|
+
logger: this.logger,
|
|
93
|
+
});
|
|
94
|
+
resp = parseResponse(
|
|
95
|
+
respBody,
|
|
96
|
+
unmarshalListAllClusterLibraryStatusesRequest_ResponseSchema
|
|
97
|
+
);
|
|
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
|
+
/**
|
|
107
|
+
* Get the status of libraries on a cluster. A status is returned for all libraries installed on this cluster via the API
|
|
108
|
+
* or the libraries UI.
|
|
109
|
+
* The order of returned libraries is as follows:
|
|
110
|
+
* 1. Libraries set to be installed on this cluster, in the order that the libraries were added
|
|
111
|
+
* to the cluster, are returned first.
|
|
112
|
+
* 2. Libraries that were previously requested to be installed on this cluster or,
|
|
113
|
+
* but are now marked for removal, in no particular order, are returned last.
|
|
114
|
+
*/
|
|
115
|
+
async clusterStatus(
|
|
116
|
+
req: ClusterStatusRequest,
|
|
117
|
+
options?: CallOptions
|
|
118
|
+
): Promise<ClusterLibraryStatuses> {
|
|
119
|
+
const url = `${this.host}/api/2.0/libraries/cluster-status`;
|
|
120
|
+
const params = new URLSearchParams();
|
|
121
|
+
if (req.clusterId !== undefined) {
|
|
122
|
+
params.append('cluster_id', req.clusterId);
|
|
123
|
+
}
|
|
124
|
+
const query = params.toString();
|
|
125
|
+
const fullUrl = query !== '' ? `${url}?${query}` : url;
|
|
126
|
+
let resp: ClusterLibraryStatuses | undefined;
|
|
127
|
+
const call = async (callSignal?: AbortSignal): Promise<void> => {
|
|
128
|
+
const headers = new Headers();
|
|
129
|
+
if (this.workspaceId !== undefined) {
|
|
130
|
+
headers.set('X-Databricks-Org-Id', this.workspaceId);
|
|
131
|
+
}
|
|
132
|
+
headers.set('User-Agent', this.userAgent);
|
|
133
|
+
const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
|
|
134
|
+
const respBody = await executeHttpCall({
|
|
135
|
+
request: httpReq,
|
|
136
|
+
httpClient: this.httpClient,
|
|
137
|
+
logger: this.logger,
|
|
138
|
+
});
|
|
139
|
+
resp = parseResponse(respBody, unmarshalClusterLibraryStatusesSchema);
|
|
140
|
+
};
|
|
141
|
+
await executeCall(call, options);
|
|
142
|
+
if (resp === undefined) {
|
|
143
|
+
throw new Error('operation completed without a result.');
|
|
144
|
+
}
|
|
145
|
+
return resp;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Add libraries to install on a cluster. The installation is asynchronous; it happens in
|
|
150
|
+
* the background after the completion of this request.
|
|
151
|
+
*/
|
|
152
|
+
async installLibraries(
|
|
153
|
+
req: InstallLibrariesRequest,
|
|
154
|
+
options?: CallOptions
|
|
155
|
+
): Promise<InstallLibrariesRequest_Response> {
|
|
156
|
+
const url = `${this.host}/api/2.0/libraries/install`;
|
|
157
|
+
const body = marshalRequest(req, marshalInstallLibrariesRequestSchema);
|
|
158
|
+
let resp: InstallLibrariesRequest_Response | undefined;
|
|
159
|
+
const call = async (callSignal?: AbortSignal): Promise<void> => {
|
|
160
|
+
const headers = new Headers({'Content-Type': 'application/json'});
|
|
161
|
+
if (this.workspaceId !== undefined) {
|
|
162
|
+
headers.set('X-Databricks-Org-Id', this.workspaceId);
|
|
163
|
+
}
|
|
164
|
+
headers.set('User-Agent', this.userAgent);
|
|
165
|
+
const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
|
|
166
|
+
const respBody = await executeHttpCall({
|
|
167
|
+
request: httpReq,
|
|
168
|
+
httpClient: this.httpClient,
|
|
169
|
+
logger: this.logger,
|
|
170
|
+
});
|
|
171
|
+
resp = parseResponse(
|
|
172
|
+
respBody,
|
|
173
|
+
unmarshalInstallLibrariesRequest_ResponseSchema
|
|
174
|
+
);
|
|
175
|
+
};
|
|
176
|
+
await executeCall(call, options);
|
|
177
|
+
if (resp === undefined) {
|
|
178
|
+
throw new Error('operation completed without a result.');
|
|
179
|
+
}
|
|
180
|
+
return resp;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* Set libraries to uninstall from a cluster. The libraries won't be uninstalled until
|
|
185
|
+
* the cluster is restarted. A request to uninstall a library that is not currently installed is ignored.
|
|
186
|
+
*/
|
|
187
|
+
async uninstallLibraries(
|
|
188
|
+
req: UninstallLibrariesRequest,
|
|
189
|
+
options?: CallOptions
|
|
190
|
+
): Promise<UninstallLibrariesRequest_Response> {
|
|
191
|
+
const url = `${this.host}/api/2.0/libraries/uninstall`;
|
|
192
|
+
const body = marshalRequest(req, marshalUninstallLibrariesRequestSchema);
|
|
193
|
+
let resp: UninstallLibrariesRequest_Response | undefined;
|
|
194
|
+
const call = async (callSignal?: AbortSignal): Promise<void> => {
|
|
195
|
+
const headers = new Headers({'Content-Type': 'application/json'});
|
|
196
|
+
if (this.workspaceId !== undefined) {
|
|
197
|
+
headers.set('X-Databricks-Org-Id', this.workspaceId);
|
|
198
|
+
}
|
|
199
|
+
headers.set('User-Agent', this.userAgent);
|
|
200
|
+
const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
|
|
201
|
+
const respBody = await executeHttpCall({
|
|
202
|
+
request: httpReq,
|
|
203
|
+
httpClient: this.httpClient,
|
|
204
|
+
logger: this.logger,
|
|
205
|
+
});
|
|
206
|
+
resp = parseResponse(
|
|
207
|
+
respBody,
|
|
208
|
+
unmarshalUninstallLibrariesRequest_ResponseSchema
|
|
209
|
+
);
|
|
210
|
+
};
|
|
211
|
+
await executeCall(call, options);
|
|
212
|
+
if (resp === undefined) {
|
|
213
|
+
throw new Error('operation completed without a result.');
|
|
214
|
+
}
|
|
215
|
+
return resp;
|
|
216
|
+
}
|
|
217
|
+
}
|
package/src/v2/index.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// Code generated from API definition by Databricks SDK Generator. DO NOT EDIT.
|
|
2
|
+
|
|
3
|
+
export {ClusterLibrariesClient} from './client';
|
|
4
|
+
|
|
5
|
+
export {LibraryInstallStatus} from './model';
|
|
6
|
+
|
|
7
|
+
export type {
|
|
8
|
+
ClusterLibraryStatuses,
|
|
9
|
+
ClusterStatusRequest,
|
|
10
|
+
InstallLibrariesRequest,
|
|
11
|
+
InstallLibrariesRequest_Response,
|
|
12
|
+
Library,
|
|
13
|
+
LibraryFullStatus,
|
|
14
|
+
ListAllClusterLibraryStatusesRequest,
|
|
15
|
+
ListAllClusterLibraryStatusesRequest_Response,
|
|
16
|
+
MavenLibrary,
|
|
17
|
+
PythonPyPiLibrary,
|
|
18
|
+
RCranLibrary,
|
|
19
|
+
UninstallLibrariesRequest,
|
|
20
|
+
UninstallLibrariesRequest_Response,
|
|
21
|
+
} from './model';
|
package/src/v2/model.ts
ADDED
|
@@ -0,0 +1,383 @@
|
|
|
1
|
+
// Code generated from API definition by Databricks SDK Generator. DO NOT EDIT.
|
|
2
|
+
|
|
3
|
+
import {z} from 'zod';
|
|
4
|
+
|
|
5
|
+
/** The status of a library on a specific cluster. */
|
|
6
|
+
export enum LibraryInstallStatus {
|
|
7
|
+
/** No action has yet been taken to install the library. This state should be very short lived. */
|
|
8
|
+
PENDING = 'PENDING',
|
|
9
|
+
/**
|
|
10
|
+
* Metadata necessary to install the library is being retrieved from the provided repository.
|
|
11
|
+
*
|
|
12
|
+
* For jar and egg libraries, this step is a no-op.
|
|
13
|
+
*/
|
|
14
|
+
RESOLVING = 'RESOLVING',
|
|
15
|
+
/**
|
|
16
|
+
* The library is actively being installed, either by adding resources to Spark or executing
|
|
17
|
+
* system commands inside the Spark nodes.
|
|
18
|
+
*/
|
|
19
|
+
INSTALLING = 'INSTALLING',
|
|
20
|
+
/** The library has been successfully installed and can now be used. */
|
|
21
|
+
INSTALLED = 'INSTALLED',
|
|
22
|
+
/** Some step in installation failed. More information can be found in the `messages` field. */
|
|
23
|
+
FAILED = 'FAILED',
|
|
24
|
+
/**
|
|
25
|
+
* The library has been marked for removal. Currently, libraries can only be removed when clusters
|
|
26
|
+
* are restarted, so libraries that enter this state will remain until the cluster is restarted.
|
|
27
|
+
*/
|
|
28
|
+
UNINSTALL_ON_RESTART = 'UNINSTALL_ON_RESTART',
|
|
29
|
+
/**
|
|
30
|
+
* Indicates that Library Manager decided to skip installation for this library.
|
|
31
|
+
* For example, shared libraries on DBR 7+ are skipped.
|
|
32
|
+
*/
|
|
33
|
+
SKIPPED = 'SKIPPED',
|
|
34
|
+
/** Library installation is restored and can be used. */
|
|
35
|
+
RESTORED = 'RESTORED',
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export interface ClusterLibraryStatuses {
|
|
39
|
+
/** Unique identifier for the cluster. */
|
|
40
|
+
clusterId?: string | undefined;
|
|
41
|
+
/** Status of all libraries on the cluster. */
|
|
42
|
+
libraryStatuses?: LibraryFullStatus[] | undefined;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export interface ClusterStatusRequest {
|
|
46
|
+
/** Unique identifier of the cluster whose status should be retrieved. */
|
|
47
|
+
clusterId?: string | undefined;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export interface InstallLibrariesRequest {
|
|
51
|
+
/** Unique identifier for the cluster on which to install these libraries. */
|
|
52
|
+
clusterId?: string | undefined;
|
|
53
|
+
/** The libraries to install. */
|
|
54
|
+
libraries?: Library[] | undefined;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention, @typescript-eslint/no-empty-object-type -- Proto-style nested message name.
|
|
58
|
+
export interface InstallLibrariesRequest_Response {}
|
|
59
|
+
|
|
60
|
+
export interface Library {
|
|
61
|
+
lib?:
|
|
62
|
+
| {
|
|
63
|
+
$case: 'jar';
|
|
64
|
+
/**
|
|
65
|
+
* URI of the JAR library to install. Supported URIs include Workspace paths, Unity Catalog Volumes paths, and S3 URIs.
|
|
66
|
+
* For example: `{ "jar": "/Workspace/path/to/library.jar" }`, `{ "jar" : "/Volumes/path/to/library.jar" }` or
|
|
67
|
+
* `{ "jar": "s3://my-bucket/library.jar" }`.
|
|
68
|
+
* If S3 is used, please make sure the cluster has read access on the library. You may need to
|
|
69
|
+
* launch the cluster with an IAM role to access the S3 URI.
|
|
70
|
+
*/
|
|
71
|
+
jar: string;
|
|
72
|
+
}
|
|
73
|
+
| {
|
|
74
|
+
$case: 'egg';
|
|
75
|
+
/** Deprecated. URI of the egg library to install. Installing Python egg files is deprecated and is not supported in Databricks Runtime 14.0 and above. */
|
|
76
|
+
egg: string;
|
|
77
|
+
}
|
|
78
|
+
| {
|
|
79
|
+
$case: 'pypi';
|
|
80
|
+
/**
|
|
81
|
+
* Specification of a PyPi library to be installed. For example:
|
|
82
|
+
* `{ "package": "simplejson" }`
|
|
83
|
+
*/
|
|
84
|
+
pypi: PythonPyPiLibrary;
|
|
85
|
+
}
|
|
86
|
+
| {
|
|
87
|
+
$case: 'maven';
|
|
88
|
+
/**
|
|
89
|
+
* Specification of a maven library to be installed. For example:
|
|
90
|
+
* `{ "coordinates": "org.jsoup:jsoup:1.7.2" }`
|
|
91
|
+
*/
|
|
92
|
+
maven: MavenLibrary;
|
|
93
|
+
}
|
|
94
|
+
| {
|
|
95
|
+
$case: 'cran';
|
|
96
|
+
/** Specification of a CRAN library to be installed as part of the library */
|
|
97
|
+
cran: RCranLibrary;
|
|
98
|
+
}
|
|
99
|
+
| {
|
|
100
|
+
$case: 'whl';
|
|
101
|
+
/**
|
|
102
|
+
* URI of the wheel library to install. Supported URIs include Workspace paths, Unity Catalog Volumes paths, and S3 URIs.
|
|
103
|
+
* For example: `{ "whl": "/Workspace/path/to/library.whl" }`, `{ "whl" : "/Volumes/path/to/library.whl" }` or
|
|
104
|
+
* `{ "whl": "s3://my-bucket/library.whl" }`.
|
|
105
|
+
* If S3 is used, please make sure the cluster has read access on the library. You may need to
|
|
106
|
+
* launch the cluster with an IAM role to access the S3 URI.
|
|
107
|
+
*/
|
|
108
|
+
whl: string;
|
|
109
|
+
}
|
|
110
|
+
| {
|
|
111
|
+
$case: 'requirements';
|
|
112
|
+
/**
|
|
113
|
+
* URI of the requirements.txt file to install. Only Workspace paths and Unity Catalog Volumes paths are supported.
|
|
114
|
+
* For example: `{ "requirements": "/Workspace/path/to/requirements.txt" }` or `{ "requirements" : "/Volumes/path/to/requirements.txt" }`
|
|
115
|
+
*/
|
|
116
|
+
requirements: string;
|
|
117
|
+
}
|
|
118
|
+
| undefined;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/** The status of the library on a specific cluster. */
|
|
122
|
+
export interface LibraryFullStatus {
|
|
123
|
+
/** Unique identifier for the library. */
|
|
124
|
+
library?: Library | undefined;
|
|
125
|
+
/** Status of installing the library on the cluster. */
|
|
126
|
+
status?: LibraryInstallStatus | undefined;
|
|
127
|
+
/** All the info and warning messages that have occurred so far for this library. */
|
|
128
|
+
messages?: string[] | undefined;
|
|
129
|
+
/** Whether the library was set to be installed on all clusters via the libraries UI. */
|
|
130
|
+
isLibraryForAllClusters?: boolean | undefined;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
|
134
|
+
export interface ListAllClusterLibraryStatusesRequest {}
|
|
135
|
+
|
|
136
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name.
|
|
137
|
+
export interface ListAllClusterLibraryStatusesRequest_Response {
|
|
138
|
+
/** A list of cluster statuses. */
|
|
139
|
+
statuses?: ClusterLibraryStatuses[] | undefined;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
export interface MavenLibrary {
|
|
143
|
+
/** Gradle-style maven coordinates. For example: "org.jsoup:jsoup:1.7.2". */
|
|
144
|
+
coordinates?: string | undefined;
|
|
145
|
+
/**
|
|
146
|
+
* Maven repo to install the Maven package from. If omitted, both Maven Central Repository
|
|
147
|
+
* and Spark Packages are searched.
|
|
148
|
+
*/
|
|
149
|
+
repo?: string | undefined;
|
|
150
|
+
/**
|
|
151
|
+
* List of dependences to exclude. For example: `["slf4j:slf4j", "*:hadoop-client"]`.
|
|
152
|
+
*
|
|
153
|
+
* Maven dependency exclusions:
|
|
154
|
+
* https://maven.apache.org/guides/introduction/introduction-to-optional-and-excludes-dependencies.html.
|
|
155
|
+
*/
|
|
156
|
+
exclusions?: string[] | undefined;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
export interface PythonPyPiLibrary {
|
|
160
|
+
/**
|
|
161
|
+
* The name of the pypi package to install. An optional exact version specification is also
|
|
162
|
+
* supported. Examples: "simplejson" and "simplejson==3.8.0".
|
|
163
|
+
*/
|
|
164
|
+
package?: string | undefined;
|
|
165
|
+
/**
|
|
166
|
+
* The repository where the package can be found. If not specified, the default pip index is
|
|
167
|
+
* used.
|
|
168
|
+
*/
|
|
169
|
+
repo?: string | undefined;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
export interface RCranLibrary {
|
|
173
|
+
/** The name of the CRAN package to install. */
|
|
174
|
+
package?: string | undefined;
|
|
175
|
+
/** The repository where the package can be found. If not specified, the default CRAN repo is used. */
|
|
176
|
+
repo?: string | undefined;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
export interface UninstallLibrariesRequest {
|
|
180
|
+
/** Unique identifier for the cluster on which to uninstall these libraries. */
|
|
181
|
+
clusterId?: string | undefined;
|
|
182
|
+
/** The libraries to uninstall. */
|
|
183
|
+
libraries?: Library[] | undefined;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention, @typescript-eslint/no-empty-object-type -- Proto-style nested message name.
|
|
187
|
+
export interface UninstallLibrariesRequest_Response {}
|
|
188
|
+
|
|
189
|
+
export const unmarshalClusterLibraryStatusesSchema: z.ZodType<ClusterLibraryStatuses> =
|
|
190
|
+
z
|
|
191
|
+
.object({
|
|
192
|
+
cluster_id: z.string().optional(),
|
|
193
|
+
library_statuses: z
|
|
194
|
+
.array(z.lazy(() => unmarshalLibraryFullStatusSchema))
|
|
195
|
+
.optional(),
|
|
196
|
+
})
|
|
197
|
+
.transform(d => ({
|
|
198
|
+
clusterId: d.cluster_id,
|
|
199
|
+
libraryStatuses: d.library_statuses,
|
|
200
|
+
}));
|
|
201
|
+
|
|
202
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name.
|
|
203
|
+
export const unmarshalInstallLibrariesRequest_ResponseSchema: z.ZodType<InstallLibrariesRequest_Response> =
|
|
204
|
+
z.object({});
|
|
205
|
+
|
|
206
|
+
export const unmarshalLibrarySchema: z.ZodType<Library> = z
|
|
207
|
+
.object({
|
|
208
|
+
jar: z.string().optional(),
|
|
209
|
+
egg: z.string().optional(),
|
|
210
|
+
pypi: z.lazy(() => unmarshalPythonPyPiLibrarySchema).optional(),
|
|
211
|
+
maven: z.lazy(() => unmarshalMavenLibrarySchema).optional(),
|
|
212
|
+
cran: z.lazy(() => unmarshalRCranLibrarySchema).optional(),
|
|
213
|
+
whl: z.string().optional(),
|
|
214
|
+
requirements: z.string().optional(),
|
|
215
|
+
})
|
|
216
|
+
.transform(d => ({
|
|
217
|
+
lib:
|
|
218
|
+
d.jar !== undefined
|
|
219
|
+
? {$case: 'jar' as const, jar: d.jar}
|
|
220
|
+
: d.egg !== undefined
|
|
221
|
+
? {$case: 'egg' as const, egg: d.egg}
|
|
222
|
+
: d.pypi !== undefined
|
|
223
|
+
? {$case: 'pypi' as const, pypi: d.pypi}
|
|
224
|
+
: d.maven !== undefined
|
|
225
|
+
? {$case: 'maven' as const, maven: d.maven}
|
|
226
|
+
: d.cran !== undefined
|
|
227
|
+
? {$case: 'cran' as const, cran: d.cran}
|
|
228
|
+
: d.whl !== undefined
|
|
229
|
+
? {$case: 'whl' as const, whl: d.whl}
|
|
230
|
+
: d.requirements !== undefined
|
|
231
|
+
? {
|
|
232
|
+
$case: 'requirements' as const,
|
|
233
|
+
requirements: d.requirements,
|
|
234
|
+
}
|
|
235
|
+
: undefined,
|
|
236
|
+
}));
|
|
237
|
+
|
|
238
|
+
export const unmarshalLibraryFullStatusSchema: z.ZodType<LibraryFullStatus> = z
|
|
239
|
+
.object({
|
|
240
|
+
library: z.lazy(() => unmarshalLibrarySchema).optional(),
|
|
241
|
+
status: z.enum(LibraryInstallStatus).optional(),
|
|
242
|
+
messages: z.array(z.string()).optional(),
|
|
243
|
+
is_library_for_all_clusters: z.boolean().optional(),
|
|
244
|
+
})
|
|
245
|
+
.transform(d => ({
|
|
246
|
+
library: d.library,
|
|
247
|
+
status: d.status,
|
|
248
|
+
messages: d.messages,
|
|
249
|
+
isLibraryForAllClusters: d.is_library_for_all_clusters,
|
|
250
|
+
}));
|
|
251
|
+
|
|
252
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name.
|
|
253
|
+
export const unmarshalListAllClusterLibraryStatusesRequest_ResponseSchema: z.ZodType<ListAllClusterLibraryStatusesRequest_Response> =
|
|
254
|
+
z
|
|
255
|
+
.object({
|
|
256
|
+
statuses: z
|
|
257
|
+
.array(z.lazy(() => unmarshalClusterLibraryStatusesSchema))
|
|
258
|
+
.optional(),
|
|
259
|
+
})
|
|
260
|
+
.transform(d => ({
|
|
261
|
+
statuses: d.statuses,
|
|
262
|
+
}));
|
|
263
|
+
|
|
264
|
+
export const unmarshalMavenLibrarySchema: z.ZodType<MavenLibrary> = z
|
|
265
|
+
.object({
|
|
266
|
+
coordinates: z.string().optional(),
|
|
267
|
+
repo: z.string().optional(),
|
|
268
|
+
exclusions: z.array(z.string()).optional(),
|
|
269
|
+
})
|
|
270
|
+
.transform(d => ({
|
|
271
|
+
coordinates: d.coordinates,
|
|
272
|
+
repo: d.repo,
|
|
273
|
+
exclusions: d.exclusions,
|
|
274
|
+
}));
|
|
275
|
+
|
|
276
|
+
export const unmarshalPythonPyPiLibrarySchema: z.ZodType<PythonPyPiLibrary> = z
|
|
277
|
+
.object({
|
|
278
|
+
package: z.string().optional(),
|
|
279
|
+
repo: z.string().optional(),
|
|
280
|
+
})
|
|
281
|
+
.transform(d => ({
|
|
282
|
+
package: d.package,
|
|
283
|
+
repo: d.repo,
|
|
284
|
+
}));
|
|
285
|
+
|
|
286
|
+
export const unmarshalRCranLibrarySchema: z.ZodType<RCranLibrary> = z
|
|
287
|
+
.object({
|
|
288
|
+
package: z.string().optional(),
|
|
289
|
+
repo: z.string().optional(),
|
|
290
|
+
})
|
|
291
|
+
.transform(d => ({
|
|
292
|
+
package: d.package,
|
|
293
|
+
repo: d.repo,
|
|
294
|
+
}));
|
|
295
|
+
|
|
296
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name.
|
|
297
|
+
export const unmarshalUninstallLibrariesRequest_ResponseSchema: z.ZodType<UninstallLibrariesRequest_Response> =
|
|
298
|
+
z.object({});
|
|
299
|
+
|
|
300
|
+
export const marshalInstallLibrariesRequestSchema: z.ZodType = z
|
|
301
|
+
.object({
|
|
302
|
+
clusterId: z.string().optional(),
|
|
303
|
+
libraries: z.array(z.lazy(() => marshalLibrarySchema)).optional(),
|
|
304
|
+
})
|
|
305
|
+
.transform(d => ({
|
|
306
|
+
cluster_id: d.clusterId,
|
|
307
|
+
libraries: d.libraries,
|
|
308
|
+
}));
|
|
309
|
+
|
|
310
|
+
export const marshalLibrarySchema: z.ZodType = z
|
|
311
|
+
.object({
|
|
312
|
+
lib: z
|
|
313
|
+
.discriminatedUnion('$case', [
|
|
314
|
+
z.object({$case: z.literal('jar'), jar: z.string()}),
|
|
315
|
+
z.object({$case: z.literal('egg'), egg: z.string()}),
|
|
316
|
+
z.object({
|
|
317
|
+
$case: z.literal('pypi'),
|
|
318
|
+
pypi: z.lazy(() => marshalPythonPyPiLibrarySchema),
|
|
319
|
+
}),
|
|
320
|
+
z.object({
|
|
321
|
+
$case: z.literal('maven'),
|
|
322
|
+
maven: z.lazy(() => marshalMavenLibrarySchema),
|
|
323
|
+
}),
|
|
324
|
+
z.object({
|
|
325
|
+
$case: z.literal('cran'),
|
|
326
|
+
cran: z.lazy(() => marshalRCranLibrarySchema),
|
|
327
|
+
}),
|
|
328
|
+
z.object({$case: z.literal('whl'), whl: z.string()}),
|
|
329
|
+
z.object({$case: z.literal('requirements'), requirements: z.string()}),
|
|
330
|
+
])
|
|
331
|
+
.optional(),
|
|
332
|
+
})
|
|
333
|
+
.transform(d => ({
|
|
334
|
+
...(d.lib?.$case === 'jar' && {jar: d.lib.jar}),
|
|
335
|
+
...(d.lib?.$case === 'egg' && {egg: d.lib.egg}),
|
|
336
|
+
...(d.lib?.$case === 'pypi' && {pypi: d.lib.pypi}),
|
|
337
|
+
...(d.lib?.$case === 'maven' && {maven: d.lib.maven}),
|
|
338
|
+
...(d.lib?.$case === 'cran' && {cran: d.lib.cran}),
|
|
339
|
+
...(d.lib?.$case === 'whl' && {whl: d.lib.whl}),
|
|
340
|
+
...(d.lib?.$case === 'requirements' && {requirements: d.lib.requirements}),
|
|
341
|
+
}));
|
|
342
|
+
|
|
343
|
+
export const marshalMavenLibrarySchema: z.ZodType = z
|
|
344
|
+
.object({
|
|
345
|
+
coordinates: z.string().optional(),
|
|
346
|
+
repo: z.string().optional(),
|
|
347
|
+
exclusions: z.array(z.string()).optional(),
|
|
348
|
+
})
|
|
349
|
+
.transform(d => ({
|
|
350
|
+
coordinates: d.coordinates,
|
|
351
|
+
repo: d.repo,
|
|
352
|
+
exclusions: d.exclusions,
|
|
353
|
+
}));
|
|
354
|
+
|
|
355
|
+
export const marshalPythonPyPiLibrarySchema: z.ZodType = z
|
|
356
|
+
.object({
|
|
357
|
+
package: z.string().optional(),
|
|
358
|
+
repo: z.string().optional(),
|
|
359
|
+
})
|
|
360
|
+
.transform(d => ({
|
|
361
|
+
package: d.package,
|
|
362
|
+
repo: d.repo,
|
|
363
|
+
}));
|
|
364
|
+
|
|
365
|
+
export const marshalRCranLibrarySchema: z.ZodType = z
|
|
366
|
+
.object({
|
|
367
|
+
package: z.string().optional(),
|
|
368
|
+
repo: z.string().optional(),
|
|
369
|
+
})
|
|
370
|
+
.transform(d => ({
|
|
371
|
+
package: d.package,
|
|
372
|
+
repo: d.repo,
|
|
373
|
+
}));
|
|
374
|
+
|
|
375
|
+
export const marshalUninstallLibrariesRequestSchema: z.ZodType = z
|
|
376
|
+
.object({
|
|
377
|
+
clusterId: z.string().optional(),
|
|
378
|
+
libraries: z.array(z.lazy(() => marshalLibrarySchema)).optional(),
|
|
379
|
+
})
|
|
380
|
+
.transform(d => ({
|
|
381
|
+
cluster_id: d.clusterId,
|
|
382
|
+
libraries: d.libraries,
|
|
383
|
+
}));
|
|
@@ -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
|
+
}
|