databricks-sdk 0.0.7__py3-none-any.whl → 0.1.1__py3-none-any.whl
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.
Potentially problematic release.
This version of databricks-sdk might be problematic. Click here for more details.
- databricks/sdk/__init__.py +121 -104
- databricks/sdk/core.py +76 -16
- databricks/sdk/dbutils.py +18 -17
- databricks/sdk/mixins/compute.py +6 -6
- databricks/sdk/mixins/dbfs.py +6 -6
- databricks/sdk/oauth.py +28 -14
- databricks/sdk/service/{unitycatalog.py → catalog.py} +375 -1146
- databricks/sdk/service/{clusters.py → compute.py} +2176 -61
- databricks/sdk/service/{dbfs.py → files.py} +6 -6
- databricks/sdk/service/{scim.py → iam.py} +567 -27
- databricks/sdk/service/jobs.py +44 -34
- databricks/sdk/service/{mlflow.py → ml.py} +976 -1071
- databricks/sdk/service/oauth2.py +3 -3
- databricks/sdk/service/pipelines.py +46 -30
- databricks/sdk/service/{deployment.py → provisioning.py} +47 -29
- databricks/sdk/service/settings.py +849 -0
- databricks/sdk/service/sharing.py +1176 -0
- databricks/sdk/service/sql.py +15 -15
- databricks/sdk/service/workspace.py +917 -22
- databricks/sdk/version.py +1 -1
- {databricks_sdk-0.0.7.dist-info → databricks_sdk-0.1.1.dist-info}/METADATA +3 -1
- databricks_sdk-0.1.1.dist-info/RECORD +37 -0
- databricks/sdk/service/clusterpolicies.py +0 -399
- databricks/sdk/service/commands.py +0 -478
- databricks/sdk/service/gitcredentials.py +0 -202
- databricks/sdk/service/globalinitscripts.py +0 -262
- databricks/sdk/service/instancepools.py +0 -757
- databricks/sdk/service/ipaccesslists.py +0 -340
- databricks/sdk/service/libraries.py +0 -282
- databricks/sdk/service/permissions.py +0 -470
- databricks/sdk/service/repos.py +0 -250
- databricks/sdk/service/secrets.py +0 -472
- databricks/sdk/service/tokenmanagement.py +0 -182
- databricks/sdk/service/tokens.py +0 -137
- databricks/sdk/service/workspaceconf.py +0 -50
- databricks_sdk-0.0.7.dist-info/RECORD +0 -48
- /databricks/sdk/service/{endpoints.py → serving.py} +0 -0
- {databricks_sdk-0.0.7.dist-info → databricks_sdk-0.1.1.dist-info}/LICENSE +0 -0
- {databricks_sdk-0.0.7.dist-info → databricks_sdk-0.1.1.dist-info}/NOTICE +0 -0
- {databricks_sdk-0.0.7.dist-info → databricks_sdk-0.1.1.dist-info}/WHEEL +0 -0
- {databricks_sdk-0.0.7.dist-info → databricks_sdk-0.1.1.dist-info}/top_level.txt +0 -0
|
@@ -1,340 +0,0 @@
|
|
|
1
|
-
# Code generated from OpenAPI specs by Databricks SDK Generator. DO NOT EDIT.
|
|
2
|
-
|
|
3
|
-
import logging
|
|
4
|
-
from dataclasses import dataclass
|
|
5
|
-
from enum import Enum
|
|
6
|
-
from typing import Dict, Iterator, List
|
|
7
|
-
|
|
8
|
-
from ._internal import _enum, _from_dict, _repeated
|
|
9
|
-
|
|
10
|
-
_LOG = logging.getLogger('databricks.sdk')
|
|
11
|
-
|
|
12
|
-
# all definitions in this file are in alphabetical order
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
@dataclass
|
|
16
|
-
class CreateIpAccessList:
|
|
17
|
-
label: str
|
|
18
|
-
list_type: 'ListType'
|
|
19
|
-
ip_addresses: 'List[str]'
|
|
20
|
-
|
|
21
|
-
def as_dict(self) -> dict:
|
|
22
|
-
body = {}
|
|
23
|
-
if self.ip_addresses: body['ip_addresses'] = [v for v in self.ip_addresses]
|
|
24
|
-
if self.label: body['label'] = self.label
|
|
25
|
-
if self.list_type: body['list_type'] = self.list_type.value
|
|
26
|
-
return body
|
|
27
|
-
|
|
28
|
-
@classmethod
|
|
29
|
-
def from_dict(cls, d: Dict[str, any]) -> 'CreateIpAccessList':
|
|
30
|
-
return cls(ip_addresses=d.get('ip_addresses', None),
|
|
31
|
-
label=d.get('label', None),
|
|
32
|
-
list_type=_enum(d, 'list_type', ListType))
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
@dataclass
|
|
36
|
-
class CreateIpAccessListResponse:
|
|
37
|
-
ip_access_list: 'IpAccessListInfo' = None
|
|
38
|
-
|
|
39
|
-
def as_dict(self) -> dict:
|
|
40
|
-
body = {}
|
|
41
|
-
if self.ip_access_list: body['ip_access_list'] = self.ip_access_list.as_dict()
|
|
42
|
-
return body
|
|
43
|
-
|
|
44
|
-
@classmethod
|
|
45
|
-
def from_dict(cls, d: Dict[str, any]) -> 'CreateIpAccessListResponse':
|
|
46
|
-
return cls(ip_access_list=_from_dict(d, 'ip_access_list', IpAccessListInfo))
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
@dataclass
|
|
50
|
-
class Delete:
|
|
51
|
-
"""Delete access list"""
|
|
52
|
-
|
|
53
|
-
ip_access_list_id: str
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
@dataclass
|
|
57
|
-
class FetchIpAccessListResponse:
|
|
58
|
-
ip_access_list: 'IpAccessListInfo' = None
|
|
59
|
-
|
|
60
|
-
def as_dict(self) -> dict:
|
|
61
|
-
body = {}
|
|
62
|
-
if self.ip_access_list: body['ip_access_list'] = self.ip_access_list.as_dict()
|
|
63
|
-
return body
|
|
64
|
-
|
|
65
|
-
@classmethod
|
|
66
|
-
def from_dict(cls, d: Dict[str, any]) -> 'FetchIpAccessListResponse':
|
|
67
|
-
return cls(ip_access_list=_from_dict(d, 'ip_access_list', IpAccessListInfo))
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
@dataclass
|
|
71
|
-
class Get:
|
|
72
|
-
"""Get access list"""
|
|
73
|
-
|
|
74
|
-
ip_access_list_id: str
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
@dataclass
|
|
78
|
-
class GetIpAccessListResponse:
|
|
79
|
-
ip_access_lists: 'List[IpAccessListInfo]' = None
|
|
80
|
-
|
|
81
|
-
def as_dict(self) -> dict:
|
|
82
|
-
body = {}
|
|
83
|
-
if self.ip_access_lists: body['ip_access_lists'] = [v.as_dict() for v in self.ip_access_lists]
|
|
84
|
-
return body
|
|
85
|
-
|
|
86
|
-
@classmethod
|
|
87
|
-
def from_dict(cls, d: Dict[str, any]) -> 'GetIpAccessListResponse':
|
|
88
|
-
return cls(ip_access_lists=_repeated(d, 'ip_access_lists', IpAccessListInfo))
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
@dataclass
|
|
92
|
-
class IpAccessListInfo:
|
|
93
|
-
address_count: int = None
|
|
94
|
-
created_at: int = None
|
|
95
|
-
created_by: int = None
|
|
96
|
-
enabled: bool = None
|
|
97
|
-
ip_addresses: 'List[str]' = None
|
|
98
|
-
label: str = None
|
|
99
|
-
list_id: str = None
|
|
100
|
-
list_type: 'ListType' = None
|
|
101
|
-
updated_at: int = None
|
|
102
|
-
updated_by: int = None
|
|
103
|
-
|
|
104
|
-
def as_dict(self) -> dict:
|
|
105
|
-
body = {}
|
|
106
|
-
if self.address_count: body['address_count'] = self.address_count
|
|
107
|
-
if self.created_at: body['created_at'] = self.created_at
|
|
108
|
-
if self.created_by: body['created_by'] = self.created_by
|
|
109
|
-
if self.enabled: body['enabled'] = self.enabled
|
|
110
|
-
if self.ip_addresses: body['ip_addresses'] = [v for v in self.ip_addresses]
|
|
111
|
-
if self.label: body['label'] = self.label
|
|
112
|
-
if self.list_id: body['list_id'] = self.list_id
|
|
113
|
-
if self.list_type: body['list_type'] = self.list_type.value
|
|
114
|
-
if self.updated_at: body['updated_at'] = self.updated_at
|
|
115
|
-
if self.updated_by: body['updated_by'] = self.updated_by
|
|
116
|
-
return body
|
|
117
|
-
|
|
118
|
-
@classmethod
|
|
119
|
-
def from_dict(cls, d: Dict[str, any]) -> 'IpAccessListInfo':
|
|
120
|
-
return cls(address_count=d.get('address_count', None),
|
|
121
|
-
created_at=d.get('created_at', None),
|
|
122
|
-
created_by=d.get('created_by', None),
|
|
123
|
-
enabled=d.get('enabled', None),
|
|
124
|
-
ip_addresses=d.get('ip_addresses', None),
|
|
125
|
-
label=d.get('label', None),
|
|
126
|
-
list_id=d.get('list_id', None),
|
|
127
|
-
list_type=_enum(d, 'list_type', ListType),
|
|
128
|
-
updated_at=d.get('updated_at', None),
|
|
129
|
-
updated_by=d.get('updated_by', None))
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
class ListType(Enum):
|
|
133
|
-
"""This describes an enum"""
|
|
134
|
-
|
|
135
|
-
ALLOW = 'ALLOW'
|
|
136
|
-
BLOCK = 'BLOCK'
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
@dataclass
|
|
140
|
-
class ReplaceIpAccessList:
|
|
141
|
-
label: str
|
|
142
|
-
list_type: 'ListType'
|
|
143
|
-
ip_addresses: 'List[str]'
|
|
144
|
-
enabled: bool
|
|
145
|
-
ip_access_list_id: str
|
|
146
|
-
list_id: str = None
|
|
147
|
-
|
|
148
|
-
def as_dict(self) -> dict:
|
|
149
|
-
body = {}
|
|
150
|
-
if self.enabled: body['enabled'] = self.enabled
|
|
151
|
-
if self.ip_access_list_id: body['ip_access_list_id'] = self.ip_access_list_id
|
|
152
|
-
if self.ip_addresses: body['ip_addresses'] = [v for v in self.ip_addresses]
|
|
153
|
-
if self.label: body['label'] = self.label
|
|
154
|
-
if self.list_id: body['list_id'] = self.list_id
|
|
155
|
-
if self.list_type: body['list_type'] = self.list_type.value
|
|
156
|
-
return body
|
|
157
|
-
|
|
158
|
-
@classmethod
|
|
159
|
-
def from_dict(cls, d: Dict[str, any]) -> 'ReplaceIpAccessList':
|
|
160
|
-
return cls(enabled=d.get('enabled', None),
|
|
161
|
-
ip_access_list_id=d.get('ip_access_list_id', None),
|
|
162
|
-
ip_addresses=d.get('ip_addresses', None),
|
|
163
|
-
label=d.get('label', None),
|
|
164
|
-
list_id=d.get('list_id', None),
|
|
165
|
-
list_type=_enum(d, 'list_type', ListType))
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
@dataclass
|
|
169
|
-
class UpdateIpAccessList:
|
|
170
|
-
label: str
|
|
171
|
-
list_type: 'ListType'
|
|
172
|
-
ip_addresses: 'List[str]'
|
|
173
|
-
enabled: bool
|
|
174
|
-
ip_access_list_id: str
|
|
175
|
-
list_id: str = None
|
|
176
|
-
|
|
177
|
-
def as_dict(self) -> dict:
|
|
178
|
-
body = {}
|
|
179
|
-
if self.enabled: body['enabled'] = self.enabled
|
|
180
|
-
if self.ip_access_list_id: body['ip_access_list_id'] = self.ip_access_list_id
|
|
181
|
-
if self.ip_addresses: body['ip_addresses'] = [v for v in self.ip_addresses]
|
|
182
|
-
if self.label: body['label'] = self.label
|
|
183
|
-
if self.list_id: body['list_id'] = self.list_id
|
|
184
|
-
if self.list_type: body['list_type'] = self.list_type.value
|
|
185
|
-
return body
|
|
186
|
-
|
|
187
|
-
@classmethod
|
|
188
|
-
def from_dict(cls, d: Dict[str, any]) -> 'UpdateIpAccessList':
|
|
189
|
-
return cls(enabled=d.get('enabled', None),
|
|
190
|
-
ip_access_list_id=d.get('ip_access_list_id', None),
|
|
191
|
-
ip_addresses=d.get('ip_addresses', None),
|
|
192
|
-
label=d.get('label', None),
|
|
193
|
-
list_id=d.get('list_id', None),
|
|
194
|
-
list_type=_enum(d, 'list_type', ListType))
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
class IpAccessListsAPI:
|
|
198
|
-
"""IP Access List enables admins to configure IP access lists.
|
|
199
|
-
|
|
200
|
-
IP access lists affect web application access and REST API access to this workspace only. If the feature
|
|
201
|
-
is disabled for a workspace, all access is allowed for this workspace. There is support for allow lists
|
|
202
|
-
(inclusion) and block lists (exclusion).
|
|
203
|
-
|
|
204
|
-
When a connection is attempted: 1. **First, all block lists are checked.** If the connection IP address
|
|
205
|
-
matches any block list, the connection is rejected. 2. **If the connection was not rejected by block
|
|
206
|
-
lists**, the IP address is compared with the allow lists.
|
|
207
|
-
|
|
208
|
-
If there is at least one allow list for the workspace, the connection is allowed only if the IP address
|
|
209
|
-
matches an allow list. If there are no allow lists for the workspace, all IP addresses are allowed.
|
|
210
|
-
|
|
211
|
-
For all allow lists and block lists combined, the workspace supports a maximum of 1000 IP/CIDR values,
|
|
212
|
-
where one CIDR counts as a single value.
|
|
213
|
-
|
|
214
|
-
After changes to the IP access list feature, it can take a few minutes for changes to take effect."""
|
|
215
|
-
|
|
216
|
-
def __init__(self, api_client):
|
|
217
|
-
self._api = api_client
|
|
218
|
-
|
|
219
|
-
def create(self, label: str, list_type: ListType, ip_addresses: List[str],
|
|
220
|
-
**kwargs) -> CreateIpAccessListResponse:
|
|
221
|
-
"""Create access list.
|
|
222
|
-
|
|
223
|
-
Creates an IP access list for this workspace.
|
|
224
|
-
|
|
225
|
-
A list can be an allow list or a block list. See the top of this file for a description of how the
|
|
226
|
-
server treats allow lists and block lists at runtime.
|
|
227
|
-
|
|
228
|
-
When creating or updating an IP access list:
|
|
229
|
-
|
|
230
|
-
* For all allow lists and block lists combined, the API supports a maximum of 1000 IP/CIDR values,
|
|
231
|
-
where one CIDR counts as a single value. Attempts to exceed that number return error 400 with
|
|
232
|
-
`error_code` value `QUOTA_EXCEEDED`. * If the new list would block the calling user's current IP,
|
|
233
|
-
error 400 is returned with `error_code` value `INVALID_STATE`.
|
|
234
|
-
|
|
235
|
-
It can take a few minutes for the changes to take effect. **Note**: Your new IP access list has no
|
|
236
|
-
effect until you enable the feature. See :method:workspaceconf/setStatus"""
|
|
237
|
-
request = kwargs.get('request', None)
|
|
238
|
-
if not request: # request is not given through keyed args
|
|
239
|
-
request = CreateIpAccessList(ip_addresses=ip_addresses, label=label, list_type=list_type)
|
|
240
|
-
body = request.as_dict()
|
|
241
|
-
|
|
242
|
-
json = self._api.do('POST', '/api/2.0/ip-access-lists', body=body)
|
|
243
|
-
return CreateIpAccessListResponse.from_dict(json)
|
|
244
|
-
|
|
245
|
-
def delete(self, ip_access_list_id: str, **kwargs):
|
|
246
|
-
"""Delete access list.
|
|
247
|
-
|
|
248
|
-
Deletes an IP access list, specified by its list ID."""
|
|
249
|
-
request = kwargs.get('request', None)
|
|
250
|
-
if not request: # request is not given through keyed args
|
|
251
|
-
request = Delete(ip_access_list_id=ip_access_list_id)
|
|
252
|
-
|
|
253
|
-
self._api.do('DELETE', f'/api/2.0/ip-access-lists/{request.ip_access_list_id}')
|
|
254
|
-
|
|
255
|
-
def get(self, ip_access_list_id: str, **kwargs) -> FetchIpAccessListResponse:
|
|
256
|
-
"""Get access list.
|
|
257
|
-
|
|
258
|
-
Gets an IP access list, specified by its list ID."""
|
|
259
|
-
request = kwargs.get('request', None)
|
|
260
|
-
if not request: # request is not given through keyed args
|
|
261
|
-
request = Get(ip_access_list_id=ip_access_list_id)
|
|
262
|
-
|
|
263
|
-
json = self._api.do('GET', f'/api/2.0/ip-access-lists/{request.ip_access_list_id}')
|
|
264
|
-
return FetchIpAccessListResponse.from_dict(json)
|
|
265
|
-
|
|
266
|
-
def list(self) -> Iterator[IpAccessListInfo]:
|
|
267
|
-
"""Get access lists.
|
|
268
|
-
|
|
269
|
-
Gets all IP access lists for the specified workspace."""
|
|
270
|
-
|
|
271
|
-
json = self._api.do('GET', '/api/2.0/ip-access-lists')
|
|
272
|
-
return [IpAccessListInfo.from_dict(v) for v in json.get('ip_access_lists', [])]
|
|
273
|
-
|
|
274
|
-
def replace(self,
|
|
275
|
-
label: str,
|
|
276
|
-
list_type: ListType,
|
|
277
|
-
ip_addresses: List[str],
|
|
278
|
-
enabled: bool,
|
|
279
|
-
ip_access_list_id: str,
|
|
280
|
-
*,
|
|
281
|
-
list_id: str = None,
|
|
282
|
-
**kwargs):
|
|
283
|
-
"""Replace access list.
|
|
284
|
-
|
|
285
|
-
Replaces an IP access list, specified by its ID.
|
|
286
|
-
|
|
287
|
-
A list can include allow lists and block lists. See the top of this file for a description of how the
|
|
288
|
-
server treats allow lists and block lists at run time. When replacing an IP access list: * For all
|
|
289
|
-
allow lists and block lists combined, the API supports a maximum of 1000 IP/CIDR values, where one
|
|
290
|
-
CIDR counts as a single value. Attempts to exceed that number return error 400 with `error_code` value
|
|
291
|
-
`QUOTA_EXCEEDED`. * If the resulting list would block the calling user's current IP, error 400 is
|
|
292
|
-
returned with `error_code` value `INVALID_STATE`. It can take a few minutes for the changes to take
|
|
293
|
-
effect. Note that your resulting IP access list has no effect until you enable the feature. See
|
|
294
|
-
:method:workspaceconf/setStatus."""
|
|
295
|
-
request = kwargs.get('request', None)
|
|
296
|
-
if not request: # request is not given through keyed args
|
|
297
|
-
request = ReplaceIpAccessList(enabled=enabled,
|
|
298
|
-
ip_access_list_id=ip_access_list_id,
|
|
299
|
-
ip_addresses=ip_addresses,
|
|
300
|
-
label=label,
|
|
301
|
-
list_id=list_id,
|
|
302
|
-
list_type=list_type)
|
|
303
|
-
body = request.as_dict()
|
|
304
|
-
self._api.do('PUT', f'/api/2.0/ip-access-lists/{request.ip_access_list_id}', body=body)
|
|
305
|
-
|
|
306
|
-
def update(self,
|
|
307
|
-
label: str,
|
|
308
|
-
list_type: ListType,
|
|
309
|
-
ip_addresses: List[str],
|
|
310
|
-
enabled: bool,
|
|
311
|
-
ip_access_list_id: str,
|
|
312
|
-
*,
|
|
313
|
-
list_id: str = None,
|
|
314
|
-
**kwargs):
|
|
315
|
-
"""Update access list.
|
|
316
|
-
|
|
317
|
-
Updates an existing IP access list, specified by its ID.
|
|
318
|
-
|
|
319
|
-
A list can include allow lists and block lists. See the top of this file for a description of how the
|
|
320
|
-
server treats allow lists and block lists at run time.
|
|
321
|
-
|
|
322
|
-
When updating an IP access list:
|
|
323
|
-
|
|
324
|
-
* For all allow lists and block lists combined, the API supports a maximum of 1000 IP/CIDR values,
|
|
325
|
-
where one CIDR counts as a single value. Attempts to exceed that number return error 400 with
|
|
326
|
-
`error_code` value `QUOTA_EXCEEDED`. * If the updated list would block the calling user's current IP,
|
|
327
|
-
error 400 is returned with `error_code` value `INVALID_STATE`.
|
|
328
|
-
|
|
329
|
-
It can take a few minutes for the changes to take effect. Note that your resulting IP access list has
|
|
330
|
-
no effect until you enable the feature. See :method:workspaceconf/setStatus."""
|
|
331
|
-
request = kwargs.get('request', None)
|
|
332
|
-
if not request: # request is not given through keyed args
|
|
333
|
-
request = UpdateIpAccessList(enabled=enabled,
|
|
334
|
-
ip_access_list_id=ip_access_list_id,
|
|
335
|
-
ip_addresses=ip_addresses,
|
|
336
|
-
label=label,
|
|
337
|
-
list_id=list_id,
|
|
338
|
-
list_type=list_type)
|
|
339
|
-
body = request.as_dict()
|
|
340
|
-
self._api.do('PATCH', f'/api/2.0/ip-access-lists/{request.ip_access_list_id}', body=body)
|
|
@@ -1,282 +0,0 @@
|
|
|
1
|
-
# Code generated from OpenAPI specs by Databricks SDK Generator. DO NOT EDIT.
|
|
2
|
-
|
|
3
|
-
import logging
|
|
4
|
-
from dataclasses import dataclass
|
|
5
|
-
from enum import Enum
|
|
6
|
-
from typing import Dict, List
|
|
7
|
-
|
|
8
|
-
from ._internal import _enum, _from_dict, _repeated
|
|
9
|
-
|
|
10
|
-
_LOG = logging.getLogger('databricks.sdk')
|
|
11
|
-
|
|
12
|
-
# all definitions in this file are in alphabetical order
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
@dataclass
|
|
16
|
-
class ClusterLibraryStatuses:
|
|
17
|
-
cluster_id: str = None
|
|
18
|
-
library_statuses: 'List[LibraryFullStatus]' = None
|
|
19
|
-
|
|
20
|
-
def as_dict(self) -> dict:
|
|
21
|
-
body = {}
|
|
22
|
-
if self.cluster_id: body['cluster_id'] = self.cluster_id
|
|
23
|
-
if self.library_statuses: body['library_statuses'] = [v.as_dict() for v in self.library_statuses]
|
|
24
|
-
return body
|
|
25
|
-
|
|
26
|
-
@classmethod
|
|
27
|
-
def from_dict(cls, d: Dict[str, any]) -> 'ClusterLibraryStatuses':
|
|
28
|
-
return cls(cluster_id=d.get('cluster_id', None),
|
|
29
|
-
library_statuses=_repeated(d, 'library_statuses', LibraryFullStatus))
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
@dataclass
|
|
33
|
-
class ClusterStatus:
|
|
34
|
-
"""Get status"""
|
|
35
|
-
|
|
36
|
-
cluster_id: str
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
@dataclass
|
|
40
|
-
class InstallLibraries:
|
|
41
|
-
cluster_id: str
|
|
42
|
-
libraries: 'List[Library]'
|
|
43
|
-
|
|
44
|
-
def as_dict(self) -> dict:
|
|
45
|
-
body = {}
|
|
46
|
-
if self.cluster_id: body['cluster_id'] = self.cluster_id
|
|
47
|
-
if self.libraries: body['libraries'] = [v.as_dict() for v in self.libraries]
|
|
48
|
-
return body
|
|
49
|
-
|
|
50
|
-
@classmethod
|
|
51
|
-
def from_dict(cls, d: Dict[str, any]) -> 'InstallLibraries':
|
|
52
|
-
return cls(cluster_id=d.get('cluster_id', None), libraries=_repeated(d, 'libraries', Library))
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
@dataclass
|
|
56
|
-
class Library:
|
|
57
|
-
cran: 'RCranLibrary' = None
|
|
58
|
-
egg: str = None
|
|
59
|
-
jar: str = None
|
|
60
|
-
maven: 'MavenLibrary' = None
|
|
61
|
-
pypi: 'PythonPyPiLibrary' = None
|
|
62
|
-
whl: str = None
|
|
63
|
-
|
|
64
|
-
def as_dict(self) -> dict:
|
|
65
|
-
body = {}
|
|
66
|
-
if self.cran: body['cran'] = self.cran.as_dict()
|
|
67
|
-
if self.egg: body['egg'] = self.egg
|
|
68
|
-
if self.jar: body['jar'] = self.jar
|
|
69
|
-
if self.maven: body['maven'] = self.maven.as_dict()
|
|
70
|
-
if self.pypi: body['pypi'] = self.pypi.as_dict()
|
|
71
|
-
if self.whl: body['whl'] = self.whl
|
|
72
|
-
return body
|
|
73
|
-
|
|
74
|
-
@classmethod
|
|
75
|
-
def from_dict(cls, d: Dict[str, any]) -> 'Library':
|
|
76
|
-
return cls(cran=_from_dict(d, 'cran', RCranLibrary),
|
|
77
|
-
egg=d.get('egg', None),
|
|
78
|
-
jar=d.get('jar', None),
|
|
79
|
-
maven=_from_dict(d, 'maven', MavenLibrary),
|
|
80
|
-
pypi=_from_dict(d, 'pypi', PythonPyPiLibrary),
|
|
81
|
-
whl=d.get('whl', None))
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
@dataclass
|
|
85
|
-
class LibraryFullStatus:
|
|
86
|
-
is_library_for_all_clusters: bool = None
|
|
87
|
-
library: 'Library' = None
|
|
88
|
-
messages: 'List[str]' = None
|
|
89
|
-
status: 'LibraryFullStatusStatus' = None
|
|
90
|
-
|
|
91
|
-
def as_dict(self) -> dict:
|
|
92
|
-
body = {}
|
|
93
|
-
if self.is_library_for_all_clusters:
|
|
94
|
-
body['is_library_for_all_clusters'] = self.is_library_for_all_clusters
|
|
95
|
-
if self.library: body['library'] = self.library.as_dict()
|
|
96
|
-
if self.messages: body['messages'] = [v for v in self.messages]
|
|
97
|
-
if self.status: body['status'] = self.status.value
|
|
98
|
-
return body
|
|
99
|
-
|
|
100
|
-
@classmethod
|
|
101
|
-
def from_dict(cls, d: Dict[str, any]) -> 'LibraryFullStatus':
|
|
102
|
-
return cls(is_library_for_all_clusters=d.get('is_library_for_all_clusters', None),
|
|
103
|
-
library=_from_dict(d, 'library', Library),
|
|
104
|
-
messages=d.get('messages', None),
|
|
105
|
-
status=_enum(d, 'status', LibraryFullStatusStatus))
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
class LibraryFullStatusStatus(Enum):
|
|
109
|
-
"""Status of installing the library on the cluster."""
|
|
110
|
-
|
|
111
|
-
FAILED = 'FAILED'
|
|
112
|
-
INSTALLED = 'INSTALLED'
|
|
113
|
-
INSTALLING = 'INSTALLING'
|
|
114
|
-
PENDING = 'PENDING'
|
|
115
|
-
RESOLVING = 'RESOLVING'
|
|
116
|
-
SKIPPED = 'SKIPPED'
|
|
117
|
-
UNINSTALL_ON_RESTART = 'UNINSTALL_ON_RESTART'
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
@dataclass
|
|
121
|
-
class ListAllClusterLibraryStatusesResponse:
|
|
122
|
-
statuses: 'List[ClusterLibraryStatuses]' = None
|
|
123
|
-
|
|
124
|
-
def as_dict(self) -> dict:
|
|
125
|
-
body = {}
|
|
126
|
-
if self.statuses: body['statuses'] = [v.as_dict() for v in self.statuses]
|
|
127
|
-
return body
|
|
128
|
-
|
|
129
|
-
@classmethod
|
|
130
|
-
def from_dict(cls, d: Dict[str, any]) -> 'ListAllClusterLibraryStatusesResponse':
|
|
131
|
-
return cls(statuses=_repeated(d, 'statuses', ClusterLibraryStatuses))
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
@dataclass
|
|
135
|
-
class MavenLibrary:
|
|
136
|
-
coordinates: str
|
|
137
|
-
exclusions: 'List[str]' = None
|
|
138
|
-
repo: str = None
|
|
139
|
-
|
|
140
|
-
def as_dict(self) -> dict:
|
|
141
|
-
body = {}
|
|
142
|
-
if self.coordinates: body['coordinates'] = self.coordinates
|
|
143
|
-
if self.exclusions: body['exclusions'] = [v for v in self.exclusions]
|
|
144
|
-
if self.repo: body['repo'] = self.repo
|
|
145
|
-
return body
|
|
146
|
-
|
|
147
|
-
@classmethod
|
|
148
|
-
def from_dict(cls, d: Dict[str, any]) -> 'MavenLibrary':
|
|
149
|
-
return cls(coordinates=d.get('coordinates', None),
|
|
150
|
-
exclusions=d.get('exclusions', None),
|
|
151
|
-
repo=d.get('repo', None))
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
@dataclass
|
|
155
|
-
class PythonPyPiLibrary:
|
|
156
|
-
package: str
|
|
157
|
-
repo: str = None
|
|
158
|
-
|
|
159
|
-
def as_dict(self) -> dict:
|
|
160
|
-
body = {}
|
|
161
|
-
if self.package: body['package'] = self.package
|
|
162
|
-
if self.repo: body['repo'] = self.repo
|
|
163
|
-
return body
|
|
164
|
-
|
|
165
|
-
@classmethod
|
|
166
|
-
def from_dict(cls, d: Dict[str, any]) -> 'PythonPyPiLibrary':
|
|
167
|
-
return cls(package=d.get('package', None), repo=d.get('repo', None))
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
@dataclass
|
|
171
|
-
class RCranLibrary:
|
|
172
|
-
package: str
|
|
173
|
-
repo: str = None
|
|
174
|
-
|
|
175
|
-
def as_dict(self) -> dict:
|
|
176
|
-
body = {}
|
|
177
|
-
if self.package: body['package'] = self.package
|
|
178
|
-
if self.repo: body['repo'] = self.repo
|
|
179
|
-
return body
|
|
180
|
-
|
|
181
|
-
@classmethod
|
|
182
|
-
def from_dict(cls, d: Dict[str, any]) -> 'RCranLibrary':
|
|
183
|
-
return cls(package=d.get('package', None), repo=d.get('repo', None))
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
@dataclass
|
|
187
|
-
class UninstallLibraries:
|
|
188
|
-
cluster_id: str
|
|
189
|
-
libraries: 'List[Library]'
|
|
190
|
-
|
|
191
|
-
def as_dict(self) -> dict:
|
|
192
|
-
body = {}
|
|
193
|
-
if self.cluster_id: body['cluster_id'] = self.cluster_id
|
|
194
|
-
if self.libraries: body['libraries'] = [v.as_dict() for v in self.libraries]
|
|
195
|
-
return body
|
|
196
|
-
|
|
197
|
-
@classmethod
|
|
198
|
-
def from_dict(cls, d: Dict[str, any]) -> 'UninstallLibraries':
|
|
199
|
-
return cls(cluster_id=d.get('cluster_id', None), libraries=_repeated(d, 'libraries', Library))
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
class LibrariesAPI:
|
|
203
|
-
"""The Libraries API allows you to install and uninstall libraries and get the status of libraries on a
|
|
204
|
-
cluster.
|
|
205
|
-
|
|
206
|
-
To make third-party or custom code available to notebooks and jobs running on your clusters, you can
|
|
207
|
-
install a library. Libraries can be written in Python, Java, Scala, and R. You can upload Java, Scala, and
|
|
208
|
-
Python libraries and point to external packages in PyPI, Maven, and CRAN repositories.
|
|
209
|
-
|
|
210
|
-
Cluster libraries can be used by all notebooks running on a cluster. You can install a cluster library
|
|
211
|
-
directly from a public repository such as PyPI or Maven, using a previously installed workspace library,
|
|
212
|
-
or using an init script.
|
|
213
|
-
|
|
214
|
-
When you install a library on a cluster, a notebook already attached to that cluster will not immediately
|
|
215
|
-
see the new library. You must first detach and then reattach the notebook to the cluster.
|
|
216
|
-
|
|
217
|
-
When you uninstall a library from a cluster, the library is removed only when you restart the cluster.
|
|
218
|
-
Until you restart the cluster, the status of the uninstalled library appears as Uninstall pending restart."""
|
|
219
|
-
|
|
220
|
-
def __init__(self, api_client):
|
|
221
|
-
self._api = api_client
|
|
222
|
-
|
|
223
|
-
def all_cluster_statuses(self) -> ListAllClusterLibraryStatusesResponse:
|
|
224
|
-
"""Get all statuses.
|
|
225
|
-
|
|
226
|
-
Get the status of all libraries on all clusters. A status will be available for all libraries
|
|
227
|
-
installed on this cluster via the API or the libraries UI as well as libraries set to be installed on
|
|
228
|
-
all clusters via the libraries UI."""
|
|
229
|
-
|
|
230
|
-
json = self._api.do('GET', '/api/2.0/libraries/all-cluster-statuses')
|
|
231
|
-
return ListAllClusterLibraryStatusesResponse.from_dict(json)
|
|
232
|
-
|
|
233
|
-
def cluster_status(self, cluster_id: str, **kwargs) -> ClusterLibraryStatuses:
|
|
234
|
-
"""Get status.
|
|
235
|
-
|
|
236
|
-
Get the status of libraries on a cluster. A status will be available for all libraries installed on
|
|
237
|
-
this cluster via the API or the libraries UI as well as libraries set to be installed on all clusters
|
|
238
|
-
via the libraries UI. The order of returned libraries will be as follows.
|
|
239
|
-
|
|
240
|
-
1. Libraries set to be installed on this cluster will be returned first. Within this group, the final
|
|
241
|
-
order will be order in which the libraries were added to the cluster.
|
|
242
|
-
|
|
243
|
-
2. Libraries set to be installed on all clusters are returned next. Within this group there is no
|
|
244
|
-
order guarantee.
|
|
245
|
-
|
|
246
|
-
3. Libraries that were previously requested on this cluster or on all clusters, but now marked for
|
|
247
|
-
removal. Within this group there is no order guarantee."""
|
|
248
|
-
request = kwargs.get('request', None)
|
|
249
|
-
if not request: # request is not given through keyed args
|
|
250
|
-
request = ClusterStatus(cluster_id=cluster_id)
|
|
251
|
-
|
|
252
|
-
query = {}
|
|
253
|
-
if cluster_id: query['cluster_id'] = request.cluster_id
|
|
254
|
-
|
|
255
|
-
json = self._api.do('GET', '/api/2.0/libraries/cluster-status', query=query)
|
|
256
|
-
return ClusterLibraryStatuses.from_dict(json)
|
|
257
|
-
|
|
258
|
-
def install(self, cluster_id: str, libraries: List[Library], **kwargs):
|
|
259
|
-
"""Add a library.
|
|
260
|
-
|
|
261
|
-
Add libraries to be installed on a cluster. The installation is asynchronous; it happens in the
|
|
262
|
-
background after the completion of this request.
|
|
263
|
-
|
|
264
|
-
**Note**: The actual set of libraries to be installed on a cluster is the union of the libraries
|
|
265
|
-
specified via this method and the libraries set to be installed on all clusters via the libraries UI."""
|
|
266
|
-
request = kwargs.get('request', None)
|
|
267
|
-
if not request: # request is not given through keyed args
|
|
268
|
-
request = InstallLibraries(cluster_id=cluster_id, libraries=libraries)
|
|
269
|
-
body = request.as_dict()
|
|
270
|
-
self._api.do('POST', '/api/2.0/libraries/install', body=body)
|
|
271
|
-
|
|
272
|
-
def uninstall(self, cluster_id: str, libraries: List[Library], **kwargs):
|
|
273
|
-
"""Uninstall libraries.
|
|
274
|
-
|
|
275
|
-
Set libraries to be uninstalled on a cluster. The libraries won't be uninstalled until the cluster is
|
|
276
|
-
restarted. Uninstalling libraries that are not installed on the cluster will have no impact but is not
|
|
277
|
-
an error."""
|
|
278
|
-
request = kwargs.get('request', None)
|
|
279
|
-
if not request: # request is not given through keyed args
|
|
280
|
-
request = UninstallLibraries(cluster_id=cluster_id, libraries=libraries)
|
|
281
|
-
body = request.as_dict()
|
|
282
|
-
self._api.do('POST', '/api/2.0/libraries/uninstall', body=body)
|