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
|
@@ -0,0 +1,1176 @@
|
|
|
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 Any, Dict, Iterator, List
|
|
7
|
+
|
|
8
|
+
from ._internal import _enum, _from_dict, _repeated
|
|
9
|
+
|
|
10
|
+
_LOG = logging.getLogger('databricks.sdk')
|
|
11
|
+
|
|
12
|
+
from .catalog import PermissionsChange, PermissionsList
|
|
13
|
+
|
|
14
|
+
# all definitions in this file are in alphabetical order
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class AuthenticationType(Enum):
|
|
18
|
+
"""The delta sharing authentication type."""
|
|
19
|
+
|
|
20
|
+
DATABRICKS = 'DATABRICKS'
|
|
21
|
+
TOKEN = 'TOKEN'
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
@dataclass
|
|
25
|
+
class CreateProvider:
|
|
26
|
+
name: str
|
|
27
|
+
authentication_type: 'AuthenticationType'
|
|
28
|
+
comment: str = None
|
|
29
|
+
recipient_profile_str: str = None
|
|
30
|
+
|
|
31
|
+
def as_dict(self) -> dict:
|
|
32
|
+
body = {}
|
|
33
|
+
if self.authentication_type: body['authentication_type'] = self.authentication_type.value
|
|
34
|
+
if self.comment: body['comment'] = self.comment
|
|
35
|
+
if self.name: body['name'] = self.name
|
|
36
|
+
if self.recipient_profile_str: body['recipient_profile_str'] = self.recipient_profile_str
|
|
37
|
+
return body
|
|
38
|
+
|
|
39
|
+
@classmethod
|
|
40
|
+
def from_dict(cls, d: Dict[str, any]) -> 'CreateProvider':
|
|
41
|
+
return cls(authentication_type=_enum(d, 'authentication_type', AuthenticationType),
|
|
42
|
+
comment=d.get('comment', None),
|
|
43
|
+
name=d.get('name', None),
|
|
44
|
+
recipient_profile_str=d.get('recipient_profile_str', None))
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
@dataclass
|
|
48
|
+
class CreateRecipient:
|
|
49
|
+
name: str
|
|
50
|
+
authentication_type: 'AuthenticationType'
|
|
51
|
+
comment: str = None
|
|
52
|
+
data_recipient_global_metastore_id: Any = None
|
|
53
|
+
ip_access_list: 'IpAccessList' = None
|
|
54
|
+
owner: str = None
|
|
55
|
+
properties_kvpairs: Any = None
|
|
56
|
+
sharing_code: str = None
|
|
57
|
+
|
|
58
|
+
def as_dict(self) -> dict:
|
|
59
|
+
body = {}
|
|
60
|
+
if self.authentication_type: body['authentication_type'] = self.authentication_type.value
|
|
61
|
+
if self.comment: body['comment'] = self.comment
|
|
62
|
+
if self.data_recipient_global_metastore_id:
|
|
63
|
+
body['data_recipient_global_metastore_id'] = self.data_recipient_global_metastore_id
|
|
64
|
+
if self.ip_access_list: body['ip_access_list'] = self.ip_access_list.as_dict()
|
|
65
|
+
if self.name: body['name'] = self.name
|
|
66
|
+
if self.owner: body['owner'] = self.owner
|
|
67
|
+
if self.properties_kvpairs: body['properties_kvpairs'] = self.properties_kvpairs
|
|
68
|
+
if self.sharing_code: body['sharing_code'] = self.sharing_code
|
|
69
|
+
return body
|
|
70
|
+
|
|
71
|
+
@classmethod
|
|
72
|
+
def from_dict(cls, d: Dict[str, any]) -> 'CreateRecipient':
|
|
73
|
+
return cls(authentication_type=_enum(d, 'authentication_type', AuthenticationType),
|
|
74
|
+
comment=d.get('comment', None),
|
|
75
|
+
data_recipient_global_metastore_id=d.get('data_recipient_global_metastore_id', None),
|
|
76
|
+
ip_access_list=_from_dict(d, 'ip_access_list', IpAccessList),
|
|
77
|
+
name=d.get('name', None),
|
|
78
|
+
owner=d.get('owner', None),
|
|
79
|
+
properties_kvpairs=d.get('properties_kvpairs', None),
|
|
80
|
+
sharing_code=d.get('sharing_code', None))
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
@dataclass
|
|
84
|
+
class CreateShare:
|
|
85
|
+
name: str
|
|
86
|
+
comment: str = None
|
|
87
|
+
|
|
88
|
+
def as_dict(self) -> dict:
|
|
89
|
+
body = {}
|
|
90
|
+
if self.comment: body['comment'] = self.comment
|
|
91
|
+
if self.name: body['name'] = self.name
|
|
92
|
+
return body
|
|
93
|
+
|
|
94
|
+
@classmethod
|
|
95
|
+
def from_dict(cls, d: Dict[str, any]) -> 'CreateShare':
|
|
96
|
+
return cls(comment=d.get('comment', None), name=d.get('name', None))
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
@dataclass
|
|
100
|
+
class DeleteProviderRequest:
|
|
101
|
+
"""Delete a provider"""
|
|
102
|
+
|
|
103
|
+
name: str
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
@dataclass
|
|
107
|
+
class DeleteRecipientRequest:
|
|
108
|
+
"""Delete a share recipient"""
|
|
109
|
+
|
|
110
|
+
name: str
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
@dataclass
|
|
114
|
+
class DeleteShareRequest:
|
|
115
|
+
"""Delete a share"""
|
|
116
|
+
|
|
117
|
+
name: str
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
@dataclass
|
|
121
|
+
class GetActivationUrlInfoRequest:
|
|
122
|
+
"""Get a share activation URL"""
|
|
123
|
+
|
|
124
|
+
activation_url: str
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
@dataclass
|
|
128
|
+
class GetProviderRequest:
|
|
129
|
+
"""Get a provider"""
|
|
130
|
+
|
|
131
|
+
name: str
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
@dataclass
|
|
135
|
+
class GetRecipientRequest:
|
|
136
|
+
"""Get a share recipient"""
|
|
137
|
+
|
|
138
|
+
name: str
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
@dataclass
|
|
142
|
+
class GetRecipientSharePermissionsResponse:
|
|
143
|
+
permissions_out: 'List[ShareToPrivilegeAssignment]' = None
|
|
144
|
+
|
|
145
|
+
def as_dict(self) -> dict:
|
|
146
|
+
body = {}
|
|
147
|
+
if self.permissions_out: body['permissions_out'] = [v.as_dict() for v in self.permissions_out]
|
|
148
|
+
return body
|
|
149
|
+
|
|
150
|
+
@classmethod
|
|
151
|
+
def from_dict(cls, d: Dict[str, any]) -> 'GetRecipientSharePermissionsResponse':
|
|
152
|
+
return cls(permissions_out=_repeated(d, 'permissions_out', ShareToPrivilegeAssignment))
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
@dataclass
|
|
156
|
+
class GetShareRequest:
|
|
157
|
+
"""Get a share"""
|
|
158
|
+
|
|
159
|
+
name: str
|
|
160
|
+
include_shared_data: bool = None
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
@dataclass
|
|
164
|
+
class IpAccessList:
|
|
165
|
+
allowed_ip_addresses: 'List[str]' = None
|
|
166
|
+
|
|
167
|
+
def as_dict(self) -> dict:
|
|
168
|
+
body = {}
|
|
169
|
+
if self.allowed_ip_addresses: body['allowed_ip_addresses'] = [v for v in self.allowed_ip_addresses]
|
|
170
|
+
return body
|
|
171
|
+
|
|
172
|
+
@classmethod
|
|
173
|
+
def from_dict(cls, d: Dict[str, any]) -> 'IpAccessList':
|
|
174
|
+
return cls(allowed_ip_addresses=d.get('allowed_ip_addresses', None))
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
@dataclass
|
|
178
|
+
class ListProviderSharesResponse:
|
|
179
|
+
shares: 'List[ProviderShare]' = None
|
|
180
|
+
|
|
181
|
+
def as_dict(self) -> dict:
|
|
182
|
+
body = {}
|
|
183
|
+
if self.shares: body['shares'] = [v.as_dict() for v in self.shares]
|
|
184
|
+
return body
|
|
185
|
+
|
|
186
|
+
@classmethod
|
|
187
|
+
def from_dict(cls, d: Dict[str, any]) -> 'ListProviderSharesResponse':
|
|
188
|
+
return cls(shares=_repeated(d, 'shares', ProviderShare))
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
@dataclass
|
|
192
|
+
class ListProvidersRequest:
|
|
193
|
+
"""List providers"""
|
|
194
|
+
|
|
195
|
+
data_provider_global_metastore_id: str = None
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
@dataclass
|
|
199
|
+
class ListProvidersResponse:
|
|
200
|
+
providers: 'List[ProviderInfo]' = None
|
|
201
|
+
|
|
202
|
+
def as_dict(self) -> dict:
|
|
203
|
+
body = {}
|
|
204
|
+
if self.providers: body['providers'] = [v.as_dict() for v in self.providers]
|
|
205
|
+
return body
|
|
206
|
+
|
|
207
|
+
@classmethod
|
|
208
|
+
def from_dict(cls, d: Dict[str, any]) -> 'ListProvidersResponse':
|
|
209
|
+
return cls(providers=_repeated(d, 'providers', ProviderInfo))
|
|
210
|
+
|
|
211
|
+
|
|
212
|
+
@dataclass
|
|
213
|
+
class ListRecipientsRequest:
|
|
214
|
+
"""List share recipients"""
|
|
215
|
+
|
|
216
|
+
data_recipient_global_metastore_id: str = None
|
|
217
|
+
|
|
218
|
+
|
|
219
|
+
@dataclass
|
|
220
|
+
class ListRecipientsResponse:
|
|
221
|
+
recipients: 'List[RecipientInfo]' = None
|
|
222
|
+
|
|
223
|
+
def as_dict(self) -> dict:
|
|
224
|
+
body = {}
|
|
225
|
+
if self.recipients: body['recipients'] = [v.as_dict() for v in self.recipients]
|
|
226
|
+
return body
|
|
227
|
+
|
|
228
|
+
@classmethod
|
|
229
|
+
def from_dict(cls, d: Dict[str, any]) -> 'ListRecipientsResponse':
|
|
230
|
+
return cls(recipients=_repeated(d, 'recipients', RecipientInfo))
|
|
231
|
+
|
|
232
|
+
|
|
233
|
+
@dataclass
|
|
234
|
+
class ListSharesRequest:
|
|
235
|
+
"""List shares by Provider"""
|
|
236
|
+
|
|
237
|
+
name: str
|
|
238
|
+
|
|
239
|
+
|
|
240
|
+
@dataclass
|
|
241
|
+
class ListSharesResponse:
|
|
242
|
+
shares: 'List[ShareInfo]' = None
|
|
243
|
+
|
|
244
|
+
def as_dict(self) -> dict:
|
|
245
|
+
body = {}
|
|
246
|
+
if self.shares: body['shares'] = [v.as_dict() for v in self.shares]
|
|
247
|
+
return body
|
|
248
|
+
|
|
249
|
+
@classmethod
|
|
250
|
+
def from_dict(cls, d: Dict[str, any]) -> 'ListSharesResponse':
|
|
251
|
+
return cls(shares=_repeated(d, 'shares', ShareInfo))
|
|
252
|
+
|
|
253
|
+
|
|
254
|
+
@dataclass
|
|
255
|
+
class Partition:
|
|
256
|
+
values: 'List[PartitionValue]' = None
|
|
257
|
+
|
|
258
|
+
def as_dict(self) -> dict:
|
|
259
|
+
body = {}
|
|
260
|
+
if self.values: body['values'] = [v.as_dict() for v in self.values]
|
|
261
|
+
return body
|
|
262
|
+
|
|
263
|
+
@classmethod
|
|
264
|
+
def from_dict(cls, d: Dict[str, any]) -> 'Partition':
|
|
265
|
+
return cls(values=_repeated(d, 'values', PartitionValue))
|
|
266
|
+
|
|
267
|
+
|
|
268
|
+
@dataclass
|
|
269
|
+
class PartitionValue:
|
|
270
|
+
name: str = None
|
|
271
|
+
op: 'PartitionValueOp' = None
|
|
272
|
+
recipient_property_key: str = None
|
|
273
|
+
value: str = None
|
|
274
|
+
|
|
275
|
+
def as_dict(self) -> dict:
|
|
276
|
+
body = {}
|
|
277
|
+
if self.name: body['name'] = self.name
|
|
278
|
+
if self.op: body['op'] = self.op.value
|
|
279
|
+
if self.recipient_property_key: body['recipient_property_key'] = self.recipient_property_key
|
|
280
|
+
if self.value: body['value'] = self.value
|
|
281
|
+
return body
|
|
282
|
+
|
|
283
|
+
@classmethod
|
|
284
|
+
def from_dict(cls, d: Dict[str, any]) -> 'PartitionValue':
|
|
285
|
+
return cls(name=d.get('name', None),
|
|
286
|
+
op=_enum(d, 'op', PartitionValueOp),
|
|
287
|
+
recipient_property_key=d.get('recipient_property_key', None),
|
|
288
|
+
value=d.get('value', None))
|
|
289
|
+
|
|
290
|
+
|
|
291
|
+
class PartitionValueOp(Enum):
|
|
292
|
+
"""The operator to apply for the value."""
|
|
293
|
+
|
|
294
|
+
EQUAL = 'EQUAL'
|
|
295
|
+
LIKE = 'LIKE'
|
|
296
|
+
|
|
297
|
+
|
|
298
|
+
class Privilege(Enum):
|
|
299
|
+
|
|
300
|
+
ALL_PRIVILEGES = 'ALL_PRIVILEGES'
|
|
301
|
+
CREATE = 'CREATE'
|
|
302
|
+
CREATE_CATALOG = 'CREATE_CATALOG'
|
|
303
|
+
CREATE_EXTERNAL_LOCATION = 'CREATE_EXTERNAL_LOCATION'
|
|
304
|
+
CREATE_EXTERNAL_TABLE = 'CREATE_EXTERNAL_TABLE'
|
|
305
|
+
CREATE_FUNCTION = 'CREATE_FUNCTION'
|
|
306
|
+
CREATE_MANAGED_STORAGE = 'CREATE_MANAGED_STORAGE'
|
|
307
|
+
CREATE_MATERIALIZED_VIEW = 'CREATE_MATERIALIZED_VIEW'
|
|
308
|
+
CREATE_PROVIDER = 'CREATE_PROVIDER'
|
|
309
|
+
CREATE_RECIPIENT = 'CREATE_RECIPIENT'
|
|
310
|
+
CREATE_SCHEMA = 'CREATE_SCHEMA'
|
|
311
|
+
CREATE_SHARE = 'CREATE_SHARE'
|
|
312
|
+
CREATE_STORAGE_CREDENTIAL = 'CREATE_STORAGE_CREDENTIAL'
|
|
313
|
+
CREATE_TABLE = 'CREATE_TABLE'
|
|
314
|
+
CREATE_VIEW = 'CREATE_VIEW'
|
|
315
|
+
EXECUTE = 'EXECUTE'
|
|
316
|
+
MODIFY = 'MODIFY'
|
|
317
|
+
READ_FILES = 'READ_FILES'
|
|
318
|
+
READ_PRIVATE_FILES = 'READ_PRIVATE_FILES'
|
|
319
|
+
REFRESH = 'REFRESH'
|
|
320
|
+
SELECT = 'SELECT'
|
|
321
|
+
SET_SHARE_PERMISSION = 'SET_SHARE_PERMISSION'
|
|
322
|
+
USAGE = 'USAGE'
|
|
323
|
+
USE_CATALOG = 'USE_CATALOG'
|
|
324
|
+
USE_PROVIDER = 'USE_PROVIDER'
|
|
325
|
+
USE_RECIPIENT = 'USE_RECIPIENT'
|
|
326
|
+
USE_SCHEMA = 'USE_SCHEMA'
|
|
327
|
+
USE_SHARE = 'USE_SHARE'
|
|
328
|
+
WRITE_FILES = 'WRITE_FILES'
|
|
329
|
+
WRITE_PRIVATE_FILES = 'WRITE_PRIVATE_FILES'
|
|
330
|
+
|
|
331
|
+
|
|
332
|
+
@dataclass
|
|
333
|
+
class PrivilegeAssignment:
|
|
334
|
+
principal: str = None
|
|
335
|
+
privileges: 'List[Privilege]' = None
|
|
336
|
+
|
|
337
|
+
def as_dict(self) -> dict:
|
|
338
|
+
body = {}
|
|
339
|
+
if self.principal: body['principal'] = self.principal
|
|
340
|
+
if self.privileges: body['privileges'] = [v for v in self.privileges]
|
|
341
|
+
return body
|
|
342
|
+
|
|
343
|
+
@classmethod
|
|
344
|
+
def from_dict(cls, d: Dict[str, any]) -> 'PrivilegeAssignment':
|
|
345
|
+
return cls(principal=d.get('principal', None), privileges=d.get('privileges', None))
|
|
346
|
+
|
|
347
|
+
|
|
348
|
+
@dataclass
|
|
349
|
+
class ProviderInfo:
|
|
350
|
+
authentication_type: 'AuthenticationType' = None
|
|
351
|
+
cloud: str = None
|
|
352
|
+
comment: str = None
|
|
353
|
+
created_at: int = None
|
|
354
|
+
created_by: str = None
|
|
355
|
+
data_provider_global_metastore_id: str = None
|
|
356
|
+
metastore_id: str = None
|
|
357
|
+
name: str = None
|
|
358
|
+
owner: str = None
|
|
359
|
+
recipient_profile: 'RecipientProfile' = None
|
|
360
|
+
recipient_profile_str: str = None
|
|
361
|
+
region: str = None
|
|
362
|
+
updated_at: int = None
|
|
363
|
+
updated_by: str = None
|
|
364
|
+
|
|
365
|
+
def as_dict(self) -> dict:
|
|
366
|
+
body = {}
|
|
367
|
+
if self.authentication_type: body['authentication_type'] = self.authentication_type.value
|
|
368
|
+
if self.cloud: body['cloud'] = self.cloud
|
|
369
|
+
if self.comment: body['comment'] = self.comment
|
|
370
|
+
if self.created_at: body['created_at'] = self.created_at
|
|
371
|
+
if self.created_by: body['created_by'] = self.created_by
|
|
372
|
+
if self.data_provider_global_metastore_id:
|
|
373
|
+
body['data_provider_global_metastore_id'] = self.data_provider_global_metastore_id
|
|
374
|
+
if self.metastore_id: body['metastore_id'] = self.metastore_id
|
|
375
|
+
if self.name: body['name'] = self.name
|
|
376
|
+
if self.owner: body['owner'] = self.owner
|
|
377
|
+
if self.recipient_profile: body['recipient_profile'] = self.recipient_profile.as_dict()
|
|
378
|
+
if self.recipient_profile_str: body['recipient_profile_str'] = self.recipient_profile_str
|
|
379
|
+
if self.region: body['region'] = self.region
|
|
380
|
+
if self.updated_at: body['updated_at'] = self.updated_at
|
|
381
|
+
if self.updated_by: body['updated_by'] = self.updated_by
|
|
382
|
+
return body
|
|
383
|
+
|
|
384
|
+
@classmethod
|
|
385
|
+
def from_dict(cls, d: Dict[str, any]) -> 'ProviderInfo':
|
|
386
|
+
return cls(authentication_type=_enum(d, 'authentication_type', AuthenticationType),
|
|
387
|
+
cloud=d.get('cloud', None),
|
|
388
|
+
comment=d.get('comment', None),
|
|
389
|
+
created_at=d.get('created_at', None),
|
|
390
|
+
created_by=d.get('created_by', None),
|
|
391
|
+
data_provider_global_metastore_id=d.get('data_provider_global_metastore_id', None),
|
|
392
|
+
metastore_id=d.get('metastore_id', None),
|
|
393
|
+
name=d.get('name', None),
|
|
394
|
+
owner=d.get('owner', None),
|
|
395
|
+
recipient_profile=_from_dict(d, 'recipient_profile', RecipientProfile),
|
|
396
|
+
recipient_profile_str=d.get('recipient_profile_str', None),
|
|
397
|
+
region=d.get('region', None),
|
|
398
|
+
updated_at=d.get('updated_at', None),
|
|
399
|
+
updated_by=d.get('updated_by', None))
|
|
400
|
+
|
|
401
|
+
|
|
402
|
+
@dataclass
|
|
403
|
+
class ProviderShare:
|
|
404
|
+
name: str = None
|
|
405
|
+
|
|
406
|
+
def as_dict(self) -> dict:
|
|
407
|
+
body = {}
|
|
408
|
+
if self.name: body['name'] = self.name
|
|
409
|
+
return body
|
|
410
|
+
|
|
411
|
+
@classmethod
|
|
412
|
+
def from_dict(cls, d: Dict[str, any]) -> 'ProviderShare':
|
|
413
|
+
return cls(name=d.get('name', None))
|
|
414
|
+
|
|
415
|
+
|
|
416
|
+
@dataclass
|
|
417
|
+
class RecipientInfo:
|
|
418
|
+
activated: bool = None
|
|
419
|
+
activation_url: str = None
|
|
420
|
+
authentication_type: 'AuthenticationType' = None
|
|
421
|
+
cloud: str = None
|
|
422
|
+
comment: str = None
|
|
423
|
+
created_at: int = None
|
|
424
|
+
created_by: str = None
|
|
425
|
+
data_recipient_global_metastore_id: Any = None
|
|
426
|
+
ip_access_list: 'IpAccessList' = None
|
|
427
|
+
metastore_id: str = None
|
|
428
|
+
name: str = None
|
|
429
|
+
owner: str = None
|
|
430
|
+
properties_kvpairs: Any = None
|
|
431
|
+
region: str = None
|
|
432
|
+
sharing_code: str = None
|
|
433
|
+
tokens: 'List[RecipientTokenInfo]' = None
|
|
434
|
+
updated_at: int = None
|
|
435
|
+
updated_by: str = None
|
|
436
|
+
|
|
437
|
+
def as_dict(self) -> dict:
|
|
438
|
+
body = {}
|
|
439
|
+
if self.activated: body['activated'] = self.activated
|
|
440
|
+
if self.activation_url: body['activation_url'] = self.activation_url
|
|
441
|
+
if self.authentication_type: body['authentication_type'] = self.authentication_type.value
|
|
442
|
+
if self.cloud: body['cloud'] = self.cloud
|
|
443
|
+
if self.comment: body['comment'] = self.comment
|
|
444
|
+
if self.created_at: body['created_at'] = self.created_at
|
|
445
|
+
if self.created_by: body['created_by'] = self.created_by
|
|
446
|
+
if self.data_recipient_global_metastore_id:
|
|
447
|
+
body['data_recipient_global_metastore_id'] = self.data_recipient_global_metastore_id
|
|
448
|
+
if self.ip_access_list: body['ip_access_list'] = self.ip_access_list.as_dict()
|
|
449
|
+
if self.metastore_id: body['metastore_id'] = self.metastore_id
|
|
450
|
+
if self.name: body['name'] = self.name
|
|
451
|
+
if self.owner: body['owner'] = self.owner
|
|
452
|
+
if self.properties_kvpairs: body['properties_kvpairs'] = self.properties_kvpairs
|
|
453
|
+
if self.region: body['region'] = self.region
|
|
454
|
+
if self.sharing_code: body['sharing_code'] = self.sharing_code
|
|
455
|
+
if self.tokens: body['tokens'] = [v.as_dict() for v in self.tokens]
|
|
456
|
+
if self.updated_at: body['updated_at'] = self.updated_at
|
|
457
|
+
if self.updated_by: body['updated_by'] = self.updated_by
|
|
458
|
+
return body
|
|
459
|
+
|
|
460
|
+
@classmethod
|
|
461
|
+
def from_dict(cls, d: Dict[str, any]) -> 'RecipientInfo':
|
|
462
|
+
return cls(activated=d.get('activated', None),
|
|
463
|
+
activation_url=d.get('activation_url', None),
|
|
464
|
+
authentication_type=_enum(d, 'authentication_type', AuthenticationType),
|
|
465
|
+
cloud=d.get('cloud', None),
|
|
466
|
+
comment=d.get('comment', None),
|
|
467
|
+
created_at=d.get('created_at', None),
|
|
468
|
+
created_by=d.get('created_by', None),
|
|
469
|
+
data_recipient_global_metastore_id=d.get('data_recipient_global_metastore_id', None),
|
|
470
|
+
ip_access_list=_from_dict(d, 'ip_access_list', IpAccessList),
|
|
471
|
+
metastore_id=d.get('metastore_id', None),
|
|
472
|
+
name=d.get('name', None),
|
|
473
|
+
owner=d.get('owner', None),
|
|
474
|
+
properties_kvpairs=d.get('properties_kvpairs', None),
|
|
475
|
+
region=d.get('region', None),
|
|
476
|
+
sharing_code=d.get('sharing_code', None),
|
|
477
|
+
tokens=_repeated(d, 'tokens', RecipientTokenInfo),
|
|
478
|
+
updated_at=d.get('updated_at', None),
|
|
479
|
+
updated_by=d.get('updated_by', None))
|
|
480
|
+
|
|
481
|
+
|
|
482
|
+
@dataclass
|
|
483
|
+
class RecipientProfile:
|
|
484
|
+
bearer_token: str = None
|
|
485
|
+
endpoint: str = None
|
|
486
|
+
share_credentials_version: int = None
|
|
487
|
+
|
|
488
|
+
def as_dict(self) -> dict:
|
|
489
|
+
body = {}
|
|
490
|
+
if self.bearer_token: body['bearer_token'] = self.bearer_token
|
|
491
|
+
if self.endpoint: body['endpoint'] = self.endpoint
|
|
492
|
+
if self.share_credentials_version: body['share_credentials_version'] = self.share_credentials_version
|
|
493
|
+
return body
|
|
494
|
+
|
|
495
|
+
@classmethod
|
|
496
|
+
def from_dict(cls, d: Dict[str, any]) -> 'RecipientProfile':
|
|
497
|
+
return cls(bearer_token=d.get('bearer_token', None),
|
|
498
|
+
endpoint=d.get('endpoint', None),
|
|
499
|
+
share_credentials_version=d.get('share_credentials_version', None))
|
|
500
|
+
|
|
501
|
+
|
|
502
|
+
@dataclass
|
|
503
|
+
class RecipientTokenInfo:
|
|
504
|
+
activation_url: str = None
|
|
505
|
+
created_at: int = None
|
|
506
|
+
created_by: str = None
|
|
507
|
+
expiration_time: int = None
|
|
508
|
+
id: str = None
|
|
509
|
+
updated_at: int = None
|
|
510
|
+
updated_by: str = None
|
|
511
|
+
|
|
512
|
+
def as_dict(self) -> dict:
|
|
513
|
+
body = {}
|
|
514
|
+
if self.activation_url: body['activation_url'] = self.activation_url
|
|
515
|
+
if self.created_at: body['created_at'] = self.created_at
|
|
516
|
+
if self.created_by: body['created_by'] = self.created_by
|
|
517
|
+
if self.expiration_time: body['expiration_time'] = self.expiration_time
|
|
518
|
+
if self.id: body['id'] = self.id
|
|
519
|
+
if self.updated_at: body['updated_at'] = self.updated_at
|
|
520
|
+
if self.updated_by: body['updated_by'] = self.updated_by
|
|
521
|
+
return body
|
|
522
|
+
|
|
523
|
+
@classmethod
|
|
524
|
+
def from_dict(cls, d: Dict[str, any]) -> 'RecipientTokenInfo':
|
|
525
|
+
return cls(activation_url=d.get('activation_url', None),
|
|
526
|
+
created_at=d.get('created_at', None),
|
|
527
|
+
created_by=d.get('created_by', None),
|
|
528
|
+
expiration_time=d.get('expiration_time', None),
|
|
529
|
+
id=d.get('id', None),
|
|
530
|
+
updated_at=d.get('updated_at', None),
|
|
531
|
+
updated_by=d.get('updated_by', None))
|
|
532
|
+
|
|
533
|
+
|
|
534
|
+
@dataclass
|
|
535
|
+
class RetrieveTokenRequest:
|
|
536
|
+
"""Get an access token"""
|
|
537
|
+
|
|
538
|
+
activation_url: str
|
|
539
|
+
|
|
540
|
+
|
|
541
|
+
@dataclass
|
|
542
|
+
class RetrieveTokenResponse:
|
|
543
|
+
bearer_token: str = None
|
|
544
|
+
endpoint: str = None
|
|
545
|
+
expiration_time: str = None
|
|
546
|
+
share_credentials_version: int = None
|
|
547
|
+
|
|
548
|
+
def as_dict(self) -> dict:
|
|
549
|
+
body = {}
|
|
550
|
+
if self.bearer_token: body['bearerToken'] = self.bearer_token
|
|
551
|
+
if self.endpoint: body['endpoint'] = self.endpoint
|
|
552
|
+
if self.expiration_time: body['expirationTime'] = self.expiration_time
|
|
553
|
+
if self.share_credentials_version: body['shareCredentialsVersion'] = self.share_credentials_version
|
|
554
|
+
return body
|
|
555
|
+
|
|
556
|
+
@classmethod
|
|
557
|
+
def from_dict(cls, d: Dict[str, any]) -> 'RetrieveTokenResponse':
|
|
558
|
+
return cls(bearer_token=d.get('bearerToken', None),
|
|
559
|
+
endpoint=d.get('endpoint', None),
|
|
560
|
+
expiration_time=d.get('expirationTime', None),
|
|
561
|
+
share_credentials_version=d.get('shareCredentialsVersion', None))
|
|
562
|
+
|
|
563
|
+
|
|
564
|
+
@dataclass
|
|
565
|
+
class RotateRecipientToken:
|
|
566
|
+
existing_token_expire_in_seconds: int
|
|
567
|
+
name: str
|
|
568
|
+
|
|
569
|
+
def as_dict(self) -> dict:
|
|
570
|
+
body = {}
|
|
571
|
+
if self.existing_token_expire_in_seconds:
|
|
572
|
+
body['existing_token_expire_in_seconds'] = self.existing_token_expire_in_seconds
|
|
573
|
+
if self.name: body['name'] = self.name
|
|
574
|
+
return body
|
|
575
|
+
|
|
576
|
+
@classmethod
|
|
577
|
+
def from_dict(cls, d: Dict[str, any]) -> 'RotateRecipientToken':
|
|
578
|
+
return cls(existing_token_expire_in_seconds=d.get('existing_token_expire_in_seconds', None),
|
|
579
|
+
name=d.get('name', None))
|
|
580
|
+
|
|
581
|
+
|
|
582
|
+
@dataclass
|
|
583
|
+
class ShareInfo:
|
|
584
|
+
comment: str = None
|
|
585
|
+
created_at: int = None
|
|
586
|
+
created_by: str = None
|
|
587
|
+
name: str = None
|
|
588
|
+
objects: 'List[SharedDataObject]' = None
|
|
589
|
+
owner: str = None
|
|
590
|
+
updated_at: int = None
|
|
591
|
+
updated_by: str = None
|
|
592
|
+
|
|
593
|
+
def as_dict(self) -> dict:
|
|
594
|
+
body = {}
|
|
595
|
+
if self.comment: body['comment'] = self.comment
|
|
596
|
+
if self.created_at: body['created_at'] = self.created_at
|
|
597
|
+
if self.created_by: body['created_by'] = self.created_by
|
|
598
|
+
if self.name: body['name'] = self.name
|
|
599
|
+
if self.objects: body['objects'] = [v.as_dict() for v in self.objects]
|
|
600
|
+
if self.owner: body['owner'] = self.owner
|
|
601
|
+
if self.updated_at: body['updated_at'] = self.updated_at
|
|
602
|
+
if self.updated_by: body['updated_by'] = self.updated_by
|
|
603
|
+
return body
|
|
604
|
+
|
|
605
|
+
@classmethod
|
|
606
|
+
def from_dict(cls, d: Dict[str, any]) -> 'ShareInfo':
|
|
607
|
+
return cls(comment=d.get('comment', None),
|
|
608
|
+
created_at=d.get('created_at', None),
|
|
609
|
+
created_by=d.get('created_by', None),
|
|
610
|
+
name=d.get('name', None),
|
|
611
|
+
objects=_repeated(d, 'objects', SharedDataObject),
|
|
612
|
+
owner=d.get('owner', None),
|
|
613
|
+
updated_at=d.get('updated_at', None),
|
|
614
|
+
updated_by=d.get('updated_by', None))
|
|
615
|
+
|
|
616
|
+
|
|
617
|
+
@dataclass
|
|
618
|
+
class SharePermissionsRequest:
|
|
619
|
+
"""Get recipient share permissions"""
|
|
620
|
+
|
|
621
|
+
name: str
|
|
622
|
+
|
|
623
|
+
|
|
624
|
+
@dataclass
|
|
625
|
+
class ShareToPrivilegeAssignment:
|
|
626
|
+
privilege_assignments: 'List[PrivilegeAssignment]' = None
|
|
627
|
+
share_name: str = None
|
|
628
|
+
|
|
629
|
+
def as_dict(self) -> dict:
|
|
630
|
+
body = {}
|
|
631
|
+
if self.privilege_assignments:
|
|
632
|
+
body['privilege_assignments'] = [v.as_dict() for v in self.privilege_assignments]
|
|
633
|
+
if self.share_name: body['share_name'] = self.share_name
|
|
634
|
+
return body
|
|
635
|
+
|
|
636
|
+
@classmethod
|
|
637
|
+
def from_dict(cls, d: Dict[str, any]) -> 'ShareToPrivilegeAssignment':
|
|
638
|
+
return cls(privilege_assignments=_repeated(d, 'privilege_assignments', PrivilegeAssignment),
|
|
639
|
+
share_name=d.get('share_name', None))
|
|
640
|
+
|
|
641
|
+
|
|
642
|
+
@dataclass
|
|
643
|
+
class SharedDataObject:
|
|
644
|
+
name: str
|
|
645
|
+
added_at: int = None
|
|
646
|
+
added_by: str = None
|
|
647
|
+
cdf_enabled: bool = None
|
|
648
|
+
comment: str = None
|
|
649
|
+
data_object_type: str = None
|
|
650
|
+
partitions: 'List[Partition]' = None
|
|
651
|
+
shared_as: str = None
|
|
652
|
+
start_version: int = None
|
|
653
|
+
status: 'SharedDataObjectStatus' = None
|
|
654
|
+
|
|
655
|
+
def as_dict(self) -> dict:
|
|
656
|
+
body = {}
|
|
657
|
+
if self.added_at: body['added_at'] = self.added_at
|
|
658
|
+
if self.added_by: body['added_by'] = self.added_by
|
|
659
|
+
if self.cdf_enabled: body['cdf_enabled'] = self.cdf_enabled
|
|
660
|
+
if self.comment: body['comment'] = self.comment
|
|
661
|
+
if self.data_object_type: body['data_object_type'] = self.data_object_type
|
|
662
|
+
if self.name: body['name'] = self.name
|
|
663
|
+
if self.partitions: body['partitions'] = [v.as_dict() for v in self.partitions]
|
|
664
|
+
if self.shared_as: body['shared_as'] = self.shared_as
|
|
665
|
+
if self.start_version: body['start_version'] = self.start_version
|
|
666
|
+
if self.status: body['status'] = self.status.value
|
|
667
|
+
return body
|
|
668
|
+
|
|
669
|
+
@classmethod
|
|
670
|
+
def from_dict(cls, d: Dict[str, any]) -> 'SharedDataObject':
|
|
671
|
+
return cls(added_at=d.get('added_at', None),
|
|
672
|
+
added_by=d.get('added_by', None),
|
|
673
|
+
cdf_enabled=d.get('cdf_enabled', None),
|
|
674
|
+
comment=d.get('comment', None),
|
|
675
|
+
data_object_type=d.get('data_object_type', None),
|
|
676
|
+
name=d.get('name', None),
|
|
677
|
+
partitions=_repeated(d, 'partitions', Partition),
|
|
678
|
+
shared_as=d.get('shared_as', None),
|
|
679
|
+
start_version=d.get('start_version', None),
|
|
680
|
+
status=_enum(d, 'status', SharedDataObjectStatus))
|
|
681
|
+
|
|
682
|
+
|
|
683
|
+
class SharedDataObjectStatus(Enum):
|
|
684
|
+
"""One of: **ACTIVE**, **PERMISSION_DENIED**."""
|
|
685
|
+
|
|
686
|
+
ACTIVE = 'ACTIVE'
|
|
687
|
+
PERMISSION_DENIED = 'PERMISSION_DENIED'
|
|
688
|
+
|
|
689
|
+
|
|
690
|
+
@dataclass
|
|
691
|
+
class SharedDataObjectUpdate:
|
|
692
|
+
action: 'SharedDataObjectUpdateAction' = None
|
|
693
|
+
data_object: 'SharedDataObject' = None
|
|
694
|
+
|
|
695
|
+
def as_dict(self) -> dict:
|
|
696
|
+
body = {}
|
|
697
|
+
if self.action: body['action'] = self.action.value
|
|
698
|
+
if self.data_object: body['data_object'] = self.data_object.as_dict()
|
|
699
|
+
return body
|
|
700
|
+
|
|
701
|
+
@classmethod
|
|
702
|
+
def from_dict(cls, d: Dict[str, any]) -> 'SharedDataObjectUpdate':
|
|
703
|
+
return cls(action=_enum(d, 'action', SharedDataObjectUpdateAction),
|
|
704
|
+
data_object=_from_dict(d, 'data_object', SharedDataObject))
|
|
705
|
+
|
|
706
|
+
|
|
707
|
+
class SharedDataObjectUpdateAction(Enum):
|
|
708
|
+
"""One of: **ADD**, **REMOVE**, **UPDATE**."""
|
|
709
|
+
|
|
710
|
+
ADD = 'ADD'
|
|
711
|
+
REMOVE = 'REMOVE'
|
|
712
|
+
UPDATE = 'UPDATE'
|
|
713
|
+
|
|
714
|
+
|
|
715
|
+
@dataclass
|
|
716
|
+
class UpdateProvider:
|
|
717
|
+
name: str
|
|
718
|
+
comment: str = None
|
|
719
|
+
owner: str = None
|
|
720
|
+
recipient_profile_str: str = None
|
|
721
|
+
|
|
722
|
+
def as_dict(self) -> dict:
|
|
723
|
+
body = {}
|
|
724
|
+
if self.comment: body['comment'] = self.comment
|
|
725
|
+
if self.name: body['name'] = self.name
|
|
726
|
+
if self.owner: body['owner'] = self.owner
|
|
727
|
+
if self.recipient_profile_str: body['recipient_profile_str'] = self.recipient_profile_str
|
|
728
|
+
return body
|
|
729
|
+
|
|
730
|
+
@classmethod
|
|
731
|
+
def from_dict(cls, d: Dict[str, any]) -> 'UpdateProvider':
|
|
732
|
+
return cls(comment=d.get('comment', None),
|
|
733
|
+
name=d.get('name', None),
|
|
734
|
+
owner=d.get('owner', None),
|
|
735
|
+
recipient_profile_str=d.get('recipient_profile_str', None))
|
|
736
|
+
|
|
737
|
+
|
|
738
|
+
@dataclass
|
|
739
|
+
class UpdateRecipient:
|
|
740
|
+
name: str
|
|
741
|
+
comment: str = None
|
|
742
|
+
ip_access_list: 'IpAccessList' = None
|
|
743
|
+
owner: str = None
|
|
744
|
+
properties_kvpairs: Any = None
|
|
745
|
+
|
|
746
|
+
def as_dict(self) -> dict:
|
|
747
|
+
body = {}
|
|
748
|
+
if self.comment: body['comment'] = self.comment
|
|
749
|
+
if self.ip_access_list: body['ip_access_list'] = self.ip_access_list.as_dict()
|
|
750
|
+
if self.name: body['name'] = self.name
|
|
751
|
+
if self.owner: body['owner'] = self.owner
|
|
752
|
+
if self.properties_kvpairs: body['properties_kvpairs'] = self.properties_kvpairs
|
|
753
|
+
return body
|
|
754
|
+
|
|
755
|
+
@classmethod
|
|
756
|
+
def from_dict(cls, d: Dict[str, any]) -> 'UpdateRecipient':
|
|
757
|
+
return cls(comment=d.get('comment', None),
|
|
758
|
+
ip_access_list=_from_dict(d, 'ip_access_list', IpAccessList),
|
|
759
|
+
name=d.get('name', None),
|
|
760
|
+
owner=d.get('owner', None),
|
|
761
|
+
properties_kvpairs=d.get('properties_kvpairs', None))
|
|
762
|
+
|
|
763
|
+
|
|
764
|
+
@dataclass
|
|
765
|
+
class UpdateShare:
|
|
766
|
+
name: str
|
|
767
|
+
comment: str = None
|
|
768
|
+
owner: str = None
|
|
769
|
+
updates: 'List[SharedDataObjectUpdate]' = None
|
|
770
|
+
|
|
771
|
+
def as_dict(self) -> dict:
|
|
772
|
+
body = {}
|
|
773
|
+
if self.comment: body['comment'] = self.comment
|
|
774
|
+
if self.name: body['name'] = self.name
|
|
775
|
+
if self.owner: body['owner'] = self.owner
|
|
776
|
+
if self.updates: body['updates'] = [v.as_dict() for v in self.updates]
|
|
777
|
+
return body
|
|
778
|
+
|
|
779
|
+
@classmethod
|
|
780
|
+
def from_dict(cls, d: Dict[str, any]) -> 'UpdateShare':
|
|
781
|
+
return cls(comment=d.get('comment', None),
|
|
782
|
+
name=d.get('name', None),
|
|
783
|
+
owner=d.get('owner', None),
|
|
784
|
+
updates=_repeated(d, 'updates', SharedDataObjectUpdate))
|
|
785
|
+
|
|
786
|
+
|
|
787
|
+
@dataclass
|
|
788
|
+
class UpdateSharePermissions:
|
|
789
|
+
name: str
|
|
790
|
+
changes: 'List[PermissionsChange]' = None
|
|
791
|
+
|
|
792
|
+
def as_dict(self) -> dict:
|
|
793
|
+
body = {}
|
|
794
|
+
if self.changes: body['changes'] = [v for v in self.changes]
|
|
795
|
+
if self.name: body['name'] = self.name
|
|
796
|
+
return body
|
|
797
|
+
|
|
798
|
+
@classmethod
|
|
799
|
+
def from_dict(cls, d: Dict[str, any]) -> 'UpdateSharePermissions':
|
|
800
|
+
return cls(changes=d.get('changes', None), name=d.get('name', None))
|
|
801
|
+
|
|
802
|
+
|
|
803
|
+
class ProvidersAPI:
|
|
804
|
+
"""Databricks Providers REST API"""
|
|
805
|
+
|
|
806
|
+
def __init__(self, api_client):
|
|
807
|
+
self._api = api_client
|
|
808
|
+
|
|
809
|
+
def create(self,
|
|
810
|
+
name: str,
|
|
811
|
+
authentication_type: AuthenticationType,
|
|
812
|
+
*,
|
|
813
|
+
comment: str = None,
|
|
814
|
+
recipient_profile_str: str = None,
|
|
815
|
+
**kwargs) -> ProviderInfo:
|
|
816
|
+
"""Create an auth provider.
|
|
817
|
+
|
|
818
|
+
Creates a new authentication provider minimally based on a name and authentication type. The caller
|
|
819
|
+
must be an admin on the metastore."""
|
|
820
|
+
request = kwargs.get('request', None)
|
|
821
|
+
if not request: # request is not given through keyed args
|
|
822
|
+
request = CreateProvider(authentication_type=authentication_type,
|
|
823
|
+
comment=comment,
|
|
824
|
+
name=name,
|
|
825
|
+
recipient_profile_str=recipient_profile_str)
|
|
826
|
+
body = request.as_dict()
|
|
827
|
+
|
|
828
|
+
json = self._api.do('POST', '/api/2.1/unity-catalog/providers', body=body)
|
|
829
|
+
return ProviderInfo.from_dict(json)
|
|
830
|
+
|
|
831
|
+
def delete(self, name: str, **kwargs):
|
|
832
|
+
"""Delete a provider.
|
|
833
|
+
|
|
834
|
+
Deletes an authentication provider, if the caller is a metastore admin or is the owner of the
|
|
835
|
+
provider."""
|
|
836
|
+
request = kwargs.get('request', None)
|
|
837
|
+
if not request: # request is not given through keyed args
|
|
838
|
+
request = DeleteProviderRequest(name=name)
|
|
839
|
+
|
|
840
|
+
self._api.do('DELETE', f'/api/2.1/unity-catalog/providers/{request.name}')
|
|
841
|
+
|
|
842
|
+
def get(self, name: str, **kwargs) -> ProviderInfo:
|
|
843
|
+
"""Get a provider.
|
|
844
|
+
|
|
845
|
+
Gets a specific authentication provider. The caller must supply the name of the provider, and must
|
|
846
|
+
either be a metastore admin or the owner of the provider."""
|
|
847
|
+
request = kwargs.get('request', None)
|
|
848
|
+
if not request: # request is not given through keyed args
|
|
849
|
+
request = GetProviderRequest(name=name)
|
|
850
|
+
|
|
851
|
+
json = self._api.do('GET', f'/api/2.1/unity-catalog/providers/{request.name}')
|
|
852
|
+
return ProviderInfo.from_dict(json)
|
|
853
|
+
|
|
854
|
+
def list(self, *, data_provider_global_metastore_id: str = None, **kwargs) -> Iterator[ProviderInfo]:
|
|
855
|
+
"""List providers.
|
|
856
|
+
|
|
857
|
+
Gets an array of available authentication providers. The caller must either be a metastore admin or
|
|
858
|
+
the owner of the providers. Providers not owned by the caller are not included in the response. There
|
|
859
|
+
is no guarantee of a specific ordering of the elements in the array."""
|
|
860
|
+
request = kwargs.get('request', None)
|
|
861
|
+
if not request: # request is not given through keyed args
|
|
862
|
+
request = ListProvidersRequest(
|
|
863
|
+
data_provider_global_metastore_id=data_provider_global_metastore_id)
|
|
864
|
+
|
|
865
|
+
query = {}
|
|
866
|
+
if data_provider_global_metastore_id:
|
|
867
|
+
query['data_provider_global_metastore_id'] = request.data_provider_global_metastore_id
|
|
868
|
+
|
|
869
|
+
json = self._api.do('GET', '/api/2.1/unity-catalog/providers', query=query)
|
|
870
|
+
return [ProviderInfo.from_dict(v) for v in json.get('providers', [])]
|
|
871
|
+
|
|
872
|
+
def list_shares(self, name: str, **kwargs) -> ListProviderSharesResponse:
|
|
873
|
+
"""List shares by Provider.
|
|
874
|
+
|
|
875
|
+
Gets an array of a specified provider's shares within the metastore where:
|
|
876
|
+
|
|
877
|
+
* the caller is a metastore admin, or * the caller is the owner."""
|
|
878
|
+
request = kwargs.get('request', None)
|
|
879
|
+
if not request: # request is not given through keyed args
|
|
880
|
+
request = ListSharesRequest(name=name)
|
|
881
|
+
|
|
882
|
+
json = self._api.do('GET', f'/api/2.1/unity-catalog/providers/{request.name}/shares')
|
|
883
|
+
return ListProviderSharesResponse.from_dict(json)
|
|
884
|
+
|
|
885
|
+
def update(self,
|
|
886
|
+
name: str,
|
|
887
|
+
*,
|
|
888
|
+
comment: str = None,
|
|
889
|
+
owner: str = None,
|
|
890
|
+
recipient_profile_str: str = None,
|
|
891
|
+
**kwargs) -> ProviderInfo:
|
|
892
|
+
"""Update a provider.
|
|
893
|
+
|
|
894
|
+
Updates the information for an authentication provider, if the caller is a metastore admin or is the
|
|
895
|
+
owner of the provider. If the update changes the provider name, the caller must be both a metastore
|
|
896
|
+
admin and the owner of the provider."""
|
|
897
|
+
request = kwargs.get('request', None)
|
|
898
|
+
if not request: # request is not given through keyed args
|
|
899
|
+
request = UpdateProvider(comment=comment,
|
|
900
|
+
name=name,
|
|
901
|
+
owner=owner,
|
|
902
|
+
recipient_profile_str=recipient_profile_str)
|
|
903
|
+
body = request.as_dict()
|
|
904
|
+
|
|
905
|
+
json = self._api.do('PATCH', f'/api/2.1/unity-catalog/providers/{request.name}', body=body)
|
|
906
|
+
return ProviderInfo.from_dict(json)
|
|
907
|
+
|
|
908
|
+
|
|
909
|
+
class RecipientActivationAPI:
|
|
910
|
+
"""Databricks Recipient Activation REST API"""
|
|
911
|
+
|
|
912
|
+
def __init__(self, api_client):
|
|
913
|
+
self._api = api_client
|
|
914
|
+
|
|
915
|
+
def get_activation_url_info(self, activation_url: str, **kwargs):
|
|
916
|
+
"""Get a share activation URL.
|
|
917
|
+
|
|
918
|
+
Gets an activation URL for a share."""
|
|
919
|
+
request = kwargs.get('request', None)
|
|
920
|
+
if not request: # request is not given through keyed args
|
|
921
|
+
request = GetActivationUrlInfoRequest(activation_url=activation_url)
|
|
922
|
+
|
|
923
|
+
self._api.do('GET',
|
|
924
|
+
f'/api/2.1/unity-catalog/public/data_sharing_activation_info/{request.activation_url}')
|
|
925
|
+
|
|
926
|
+
def retrieve_token(self, activation_url: str, **kwargs) -> RetrieveTokenResponse:
|
|
927
|
+
"""Get an access token.
|
|
928
|
+
|
|
929
|
+
Retrieve access token with an activation url. This is a public API without any authentication."""
|
|
930
|
+
request = kwargs.get('request', None)
|
|
931
|
+
if not request: # request is not given through keyed args
|
|
932
|
+
request = RetrieveTokenRequest(activation_url=activation_url)
|
|
933
|
+
|
|
934
|
+
json = self._api.do(
|
|
935
|
+
'GET', f'/api/2.1/unity-catalog/public/data_sharing_activation/{request.activation_url}')
|
|
936
|
+
return RetrieveTokenResponse.from_dict(json)
|
|
937
|
+
|
|
938
|
+
|
|
939
|
+
class RecipientsAPI:
|
|
940
|
+
"""Databricks Recipients REST API"""
|
|
941
|
+
|
|
942
|
+
def __init__(self, api_client):
|
|
943
|
+
self._api = api_client
|
|
944
|
+
|
|
945
|
+
def create(self,
|
|
946
|
+
name: str,
|
|
947
|
+
authentication_type: AuthenticationType,
|
|
948
|
+
*,
|
|
949
|
+
comment: str = None,
|
|
950
|
+
data_recipient_global_metastore_id: Any = None,
|
|
951
|
+
ip_access_list: IpAccessList = None,
|
|
952
|
+
owner: str = None,
|
|
953
|
+
properties_kvpairs: Any = None,
|
|
954
|
+
sharing_code: str = None,
|
|
955
|
+
**kwargs) -> RecipientInfo:
|
|
956
|
+
"""Create a share recipient.
|
|
957
|
+
|
|
958
|
+
Creates a new recipient with the delta sharing authentication type in the metastore. The caller must
|
|
959
|
+
be a metastore admin or has the **CREATE_RECIPIENT** privilege on the metastore."""
|
|
960
|
+
request = kwargs.get('request', None)
|
|
961
|
+
if not request: # request is not given through keyed args
|
|
962
|
+
request = CreateRecipient(authentication_type=authentication_type,
|
|
963
|
+
comment=comment,
|
|
964
|
+
data_recipient_global_metastore_id=data_recipient_global_metastore_id,
|
|
965
|
+
ip_access_list=ip_access_list,
|
|
966
|
+
name=name,
|
|
967
|
+
owner=owner,
|
|
968
|
+
properties_kvpairs=properties_kvpairs,
|
|
969
|
+
sharing_code=sharing_code)
|
|
970
|
+
body = request.as_dict()
|
|
971
|
+
|
|
972
|
+
json = self._api.do('POST', '/api/2.1/unity-catalog/recipients', body=body)
|
|
973
|
+
return RecipientInfo.from_dict(json)
|
|
974
|
+
|
|
975
|
+
def delete(self, name: str, **kwargs):
|
|
976
|
+
"""Delete a share recipient.
|
|
977
|
+
|
|
978
|
+
Deletes the specified recipient from the metastore. The caller must be the owner of the recipient."""
|
|
979
|
+
request = kwargs.get('request', None)
|
|
980
|
+
if not request: # request is not given through keyed args
|
|
981
|
+
request = DeleteRecipientRequest(name=name)
|
|
982
|
+
|
|
983
|
+
self._api.do('DELETE', f'/api/2.1/unity-catalog/recipients/{request.name}')
|
|
984
|
+
|
|
985
|
+
def get(self, name: str, **kwargs) -> RecipientInfo:
|
|
986
|
+
"""Get a share recipient.
|
|
987
|
+
|
|
988
|
+
Gets a share recipient from the metastore if:
|
|
989
|
+
|
|
990
|
+
* the caller is the owner of the share recipient, or: * is a metastore admin"""
|
|
991
|
+
request = kwargs.get('request', None)
|
|
992
|
+
if not request: # request is not given through keyed args
|
|
993
|
+
request = GetRecipientRequest(name=name)
|
|
994
|
+
|
|
995
|
+
json = self._api.do('GET', f'/api/2.1/unity-catalog/recipients/{request.name}')
|
|
996
|
+
return RecipientInfo.from_dict(json)
|
|
997
|
+
|
|
998
|
+
def list(self, *, data_recipient_global_metastore_id: str = None, **kwargs) -> Iterator[RecipientInfo]:
|
|
999
|
+
"""List share recipients.
|
|
1000
|
+
|
|
1001
|
+
Gets an array of all share recipients within the current metastore where:
|
|
1002
|
+
|
|
1003
|
+
* the caller is a metastore admin, or * the caller is the owner. There is no guarantee of a specific
|
|
1004
|
+
ordering of the elements in the array."""
|
|
1005
|
+
request = kwargs.get('request', None)
|
|
1006
|
+
if not request: # request is not given through keyed args
|
|
1007
|
+
request = ListRecipientsRequest(
|
|
1008
|
+
data_recipient_global_metastore_id=data_recipient_global_metastore_id)
|
|
1009
|
+
|
|
1010
|
+
query = {}
|
|
1011
|
+
if data_recipient_global_metastore_id:
|
|
1012
|
+
query['data_recipient_global_metastore_id'] = request.data_recipient_global_metastore_id
|
|
1013
|
+
|
|
1014
|
+
json = self._api.do('GET', '/api/2.1/unity-catalog/recipients', query=query)
|
|
1015
|
+
return [RecipientInfo.from_dict(v) for v in json.get('recipients', [])]
|
|
1016
|
+
|
|
1017
|
+
def rotate_token(self, existing_token_expire_in_seconds: int, name: str, **kwargs) -> RecipientInfo:
|
|
1018
|
+
"""Rotate a token.
|
|
1019
|
+
|
|
1020
|
+
Refreshes the specified recipient's delta sharing authentication token with the provided token info.
|
|
1021
|
+
The caller must be the owner of the recipient."""
|
|
1022
|
+
request = kwargs.get('request', None)
|
|
1023
|
+
if not request: # request is not given through keyed args
|
|
1024
|
+
request = RotateRecipientToken(existing_token_expire_in_seconds=existing_token_expire_in_seconds,
|
|
1025
|
+
name=name)
|
|
1026
|
+
body = request.as_dict()
|
|
1027
|
+
|
|
1028
|
+
json = self._api.do('POST',
|
|
1029
|
+
f'/api/2.1/unity-catalog/recipients/{request.name}/rotate-token',
|
|
1030
|
+
body=body)
|
|
1031
|
+
return RecipientInfo.from_dict(json)
|
|
1032
|
+
|
|
1033
|
+
def share_permissions(self, name: str, **kwargs) -> GetRecipientSharePermissionsResponse:
|
|
1034
|
+
"""Get recipient share permissions.
|
|
1035
|
+
|
|
1036
|
+
Gets the share permissions for the specified Recipient. The caller must be a metastore admin or the
|
|
1037
|
+
owner of the Recipient."""
|
|
1038
|
+
request = kwargs.get('request', None)
|
|
1039
|
+
if not request: # request is not given through keyed args
|
|
1040
|
+
request = SharePermissionsRequest(name=name)
|
|
1041
|
+
|
|
1042
|
+
json = self._api.do('GET', f'/api/2.1/unity-catalog/recipients/{request.name}/share-permissions')
|
|
1043
|
+
return GetRecipientSharePermissionsResponse.from_dict(json)
|
|
1044
|
+
|
|
1045
|
+
def update(self,
|
|
1046
|
+
name: str,
|
|
1047
|
+
*,
|
|
1048
|
+
comment: str = None,
|
|
1049
|
+
ip_access_list: IpAccessList = None,
|
|
1050
|
+
owner: str = None,
|
|
1051
|
+
properties_kvpairs: Any = None,
|
|
1052
|
+
**kwargs):
|
|
1053
|
+
"""Update a share recipient.
|
|
1054
|
+
|
|
1055
|
+
Updates an existing recipient in the metastore. The caller must be a metastore admin or the owner of
|
|
1056
|
+
the recipient. If the recipient name will be updated, the user must be both a metastore admin and the
|
|
1057
|
+
owner of the recipient."""
|
|
1058
|
+
request = kwargs.get('request', None)
|
|
1059
|
+
if not request: # request is not given through keyed args
|
|
1060
|
+
request = UpdateRecipient(comment=comment,
|
|
1061
|
+
ip_access_list=ip_access_list,
|
|
1062
|
+
name=name,
|
|
1063
|
+
owner=owner,
|
|
1064
|
+
properties_kvpairs=properties_kvpairs)
|
|
1065
|
+
body = request.as_dict()
|
|
1066
|
+
self._api.do('PATCH', f'/api/2.1/unity-catalog/recipients/{request.name}', body=body)
|
|
1067
|
+
|
|
1068
|
+
|
|
1069
|
+
class SharesAPI:
|
|
1070
|
+
"""Databricks Shares REST API"""
|
|
1071
|
+
|
|
1072
|
+
def __init__(self, api_client):
|
|
1073
|
+
self._api = api_client
|
|
1074
|
+
|
|
1075
|
+
def create(self, name: str, *, comment: str = None, **kwargs) -> ShareInfo:
|
|
1076
|
+
"""Create a share.
|
|
1077
|
+
|
|
1078
|
+
Creates a new share for data objects. Data objects can be added after creation with **update**. The
|
|
1079
|
+
caller must be a metastore admin or have the **CREATE_SHARE** privilege on the metastore."""
|
|
1080
|
+
request = kwargs.get('request', None)
|
|
1081
|
+
if not request: # request is not given through keyed args
|
|
1082
|
+
request = CreateShare(comment=comment, name=name)
|
|
1083
|
+
body = request.as_dict()
|
|
1084
|
+
|
|
1085
|
+
json = self._api.do('POST', '/api/2.1/unity-catalog/shares', body=body)
|
|
1086
|
+
return ShareInfo.from_dict(json)
|
|
1087
|
+
|
|
1088
|
+
def delete(self, name: str, **kwargs):
|
|
1089
|
+
"""Delete a share.
|
|
1090
|
+
|
|
1091
|
+
Deletes a data object share from the metastore. The caller must be an owner of the share."""
|
|
1092
|
+
request = kwargs.get('request', None)
|
|
1093
|
+
if not request: # request is not given through keyed args
|
|
1094
|
+
request = DeleteShareRequest(name=name)
|
|
1095
|
+
|
|
1096
|
+
self._api.do('DELETE', f'/api/2.1/unity-catalog/shares/{request.name}')
|
|
1097
|
+
|
|
1098
|
+
def get(self, name: str, *, include_shared_data: bool = None, **kwargs) -> ShareInfo:
|
|
1099
|
+
"""Get a share.
|
|
1100
|
+
|
|
1101
|
+
Gets a data object share from the metastore. The caller must be a metastore admin or the owner of the
|
|
1102
|
+
share."""
|
|
1103
|
+
request = kwargs.get('request', None)
|
|
1104
|
+
if not request: # request is not given through keyed args
|
|
1105
|
+
request = GetShareRequest(include_shared_data=include_shared_data, name=name)
|
|
1106
|
+
|
|
1107
|
+
query = {}
|
|
1108
|
+
if include_shared_data: query['include_shared_data'] = request.include_shared_data
|
|
1109
|
+
|
|
1110
|
+
json = self._api.do('GET', f'/api/2.1/unity-catalog/shares/{request.name}', query=query)
|
|
1111
|
+
return ShareInfo.from_dict(json)
|
|
1112
|
+
|
|
1113
|
+
def list(self) -> Iterator[ShareInfo]:
|
|
1114
|
+
"""List shares.
|
|
1115
|
+
|
|
1116
|
+
Gets an array of data object shares from the metastore. The caller must be a metastore admin or the
|
|
1117
|
+
owner of the share. There is no guarantee of a specific ordering of the elements in the array."""
|
|
1118
|
+
|
|
1119
|
+
json = self._api.do('GET', '/api/2.1/unity-catalog/shares')
|
|
1120
|
+
return [ShareInfo.from_dict(v) for v in json.get('shares', [])]
|
|
1121
|
+
|
|
1122
|
+
def share_permissions(self, name: str, **kwargs) -> PermissionsList:
|
|
1123
|
+
"""Get permissions.
|
|
1124
|
+
|
|
1125
|
+
Gets the permissions for a data share from the metastore. The caller must be a metastore admin or the
|
|
1126
|
+
owner of the share."""
|
|
1127
|
+
request = kwargs.get('request', None)
|
|
1128
|
+
if not request: # request is not given through keyed args
|
|
1129
|
+
request = SharePermissionsRequest(name=name)
|
|
1130
|
+
|
|
1131
|
+
json = self._api.do('GET', f'/api/2.1/unity-catalog/shares/{request.name}/permissions')
|
|
1132
|
+
return PermissionsList.from_dict(json)
|
|
1133
|
+
|
|
1134
|
+
def update(self,
|
|
1135
|
+
name: str,
|
|
1136
|
+
*,
|
|
1137
|
+
comment: str = None,
|
|
1138
|
+
owner: str = None,
|
|
1139
|
+
updates: List[SharedDataObjectUpdate] = None,
|
|
1140
|
+
**kwargs) -> ShareInfo:
|
|
1141
|
+
"""Update a share.
|
|
1142
|
+
|
|
1143
|
+
Updates the share with the changes and data objects in the request. The caller must be the owner of
|
|
1144
|
+
the share or a metastore admin.
|
|
1145
|
+
|
|
1146
|
+
When the caller is a metastore admin, only the __owner__ field can be updated.
|
|
1147
|
+
|
|
1148
|
+
In the case that the share name is changed, **updateShare** requires that the caller is both the share
|
|
1149
|
+
owner and a metastore admin.
|
|
1150
|
+
|
|
1151
|
+
For each table that is added through this method, the share owner must also have **SELECT** privilege
|
|
1152
|
+
on the table. This privilege must be maintained indefinitely for recipients to be able to access the
|
|
1153
|
+
table. Typically, you should use a group as the share owner.
|
|
1154
|
+
|
|
1155
|
+
Table removals through **update** do not require additional privileges."""
|
|
1156
|
+
request = kwargs.get('request', None)
|
|
1157
|
+
if not request: # request is not given through keyed args
|
|
1158
|
+
request = UpdateShare(comment=comment, name=name, owner=owner, updates=updates)
|
|
1159
|
+
body = request.as_dict()
|
|
1160
|
+
|
|
1161
|
+
json = self._api.do('PATCH', f'/api/2.1/unity-catalog/shares/{request.name}', body=body)
|
|
1162
|
+
return ShareInfo.from_dict(json)
|
|
1163
|
+
|
|
1164
|
+
def update_permissions(self, name: str, *, changes: List[PermissionsChange] = None, **kwargs):
|
|
1165
|
+
"""Update permissions.
|
|
1166
|
+
|
|
1167
|
+
Updates the permissions for a data share in the metastore. The caller must be a metastore admin or an
|
|
1168
|
+
owner of the share.
|
|
1169
|
+
|
|
1170
|
+
For new recipient grants, the user must also be the owner of the recipients. recipient revocations do
|
|
1171
|
+
not require additional privileges."""
|
|
1172
|
+
request = kwargs.get('request', None)
|
|
1173
|
+
if not request: # request is not given through keyed args
|
|
1174
|
+
request = UpdateSharePermissions(changes=changes, name=name)
|
|
1175
|
+
body = request.as_dict()
|
|
1176
|
+
self._api.do('PATCH', f'/api/2.1/unity-catalog/shares/{request.name}/permissions', body=body)
|