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.

Files changed (41) hide show
  1. databricks/sdk/__init__.py +121 -104
  2. databricks/sdk/core.py +76 -16
  3. databricks/sdk/dbutils.py +18 -17
  4. databricks/sdk/mixins/compute.py +6 -6
  5. databricks/sdk/mixins/dbfs.py +6 -6
  6. databricks/sdk/oauth.py +28 -14
  7. databricks/sdk/service/{unitycatalog.py → catalog.py} +375 -1146
  8. databricks/sdk/service/{clusters.py → compute.py} +2176 -61
  9. databricks/sdk/service/{dbfs.py → files.py} +6 -6
  10. databricks/sdk/service/{scim.py → iam.py} +567 -27
  11. databricks/sdk/service/jobs.py +44 -34
  12. databricks/sdk/service/{mlflow.py → ml.py} +976 -1071
  13. databricks/sdk/service/oauth2.py +3 -3
  14. databricks/sdk/service/pipelines.py +46 -30
  15. databricks/sdk/service/{deployment.py → provisioning.py} +47 -29
  16. databricks/sdk/service/settings.py +849 -0
  17. databricks/sdk/service/sharing.py +1176 -0
  18. databricks/sdk/service/sql.py +15 -15
  19. databricks/sdk/service/workspace.py +917 -22
  20. databricks/sdk/version.py +1 -1
  21. {databricks_sdk-0.0.7.dist-info → databricks_sdk-0.1.1.dist-info}/METADATA +3 -1
  22. databricks_sdk-0.1.1.dist-info/RECORD +37 -0
  23. databricks/sdk/service/clusterpolicies.py +0 -399
  24. databricks/sdk/service/commands.py +0 -478
  25. databricks/sdk/service/gitcredentials.py +0 -202
  26. databricks/sdk/service/globalinitscripts.py +0 -262
  27. databricks/sdk/service/instancepools.py +0 -757
  28. databricks/sdk/service/ipaccesslists.py +0 -340
  29. databricks/sdk/service/libraries.py +0 -282
  30. databricks/sdk/service/permissions.py +0 -470
  31. databricks/sdk/service/repos.py +0 -250
  32. databricks/sdk/service/secrets.py +0 -472
  33. databricks/sdk/service/tokenmanagement.py +0 -182
  34. databricks/sdk/service/tokens.py +0 -137
  35. databricks/sdk/service/workspaceconf.py +0 -50
  36. databricks_sdk-0.0.7.dist-info/RECORD +0 -48
  37. /databricks/sdk/service/{endpoints.py → serving.py} +0 -0
  38. {databricks_sdk-0.0.7.dist-info → databricks_sdk-0.1.1.dist-info}/LICENSE +0 -0
  39. {databricks_sdk-0.0.7.dist-info → databricks_sdk-0.1.1.dist-info}/NOTICE +0 -0
  40. {databricks_sdk-0.0.7.dist-info → databricks_sdk-0.1.1.dist-info}/WHEEL +0 -0
  41. {databricks_sdk-0.0.7.dist-info → databricks_sdk-0.1.1.dist-info}/top_level.txt +0 -0
@@ -12,6 +12,52 @@ _LOG = logging.getLogger('databricks.sdk')
12
12
  # all definitions in this file are in alphabetical order
13
13
 
14
14
 
15
+ @dataclass
16
+ class AccessControlRequest:
17
+ group_name: str = None
18
+ permission_level: 'PermissionLevel' = None
19
+ service_principal_name: str = None
20
+ user_name: str = None
21
+
22
+ def as_dict(self) -> dict:
23
+ body = {}
24
+ if self.group_name: body['group_name'] = self.group_name
25
+ if self.permission_level: body['permission_level'] = self.permission_level.value
26
+ if self.service_principal_name: body['service_principal_name'] = self.service_principal_name
27
+ if self.user_name: body['user_name'] = self.user_name
28
+ return body
29
+
30
+ @classmethod
31
+ def from_dict(cls, d: Dict[str, any]) -> 'AccessControlRequest':
32
+ return cls(group_name=d.get('group_name', None),
33
+ permission_level=_enum(d, 'permission_level', PermissionLevel),
34
+ service_principal_name=d.get('service_principal_name', None),
35
+ user_name=d.get('user_name', None))
36
+
37
+
38
+ @dataclass
39
+ class AccessControlResponse:
40
+ all_permissions: 'List[Permission]' = None
41
+ group_name: str = None
42
+ service_principal_name: str = None
43
+ user_name: str = None
44
+
45
+ def as_dict(self) -> dict:
46
+ body = {}
47
+ if self.all_permissions: body['all_permissions'] = [v.as_dict() for v in self.all_permissions]
48
+ if self.group_name: body['group_name'] = self.group_name
49
+ if self.service_principal_name: body['service_principal_name'] = self.service_principal_name
50
+ if self.user_name: body['user_name'] = self.user_name
51
+ return body
52
+
53
+ @classmethod
54
+ def from_dict(cls, d: Dict[str, any]) -> 'AccessControlResponse':
55
+ return cls(all_permissions=_repeated(d, 'all_permissions', Permission),
56
+ group_name=d.get('group_name', None),
57
+ service_principal_name=d.get('service_principal_name', None),
58
+ user_name=d.get('user_name', None))
59
+
60
+
15
61
  @dataclass
16
62
  class ComplexValue:
17
63
  display: str = None
@@ -35,6 +81,27 @@ class ComplexValue:
35
81
  value=d.get('value', None))
36
82
 
37
83
 
84
+ @dataclass
85
+ class DeleteAccountGroupRequest:
86
+ """Delete a group"""
87
+
88
+ id: str
89
+
90
+
91
+ @dataclass
92
+ class DeleteAccountServicePrincipalRequest:
93
+ """Delete a service principal"""
94
+
95
+ id: str
96
+
97
+
98
+ @dataclass
99
+ class DeleteAccountUserRequest:
100
+ """Delete a user"""
101
+
102
+ id: str
103
+
104
+
38
105
  @dataclass
39
106
  class DeleteGroupRequest:
40
107
  """Delete a group"""
@@ -56,6 +123,35 @@ class DeleteUserRequest:
56
123
  id: str
57
124
 
58
125
 
126
+ @dataclass
127
+ class DeleteWorkspaceAssignmentRequest:
128
+ """Delete permissions assignment"""
129
+
130
+ workspace_id: int
131
+ principal_id: int
132
+
133
+
134
+ @dataclass
135
+ class GetAccountGroupRequest:
136
+ """Get group details"""
137
+
138
+ id: str
139
+
140
+
141
+ @dataclass
142
+ class GetAccountServicePrincipalRequest:
143
+ """Get service principal details"""
144
+
145
+ id: str
146
+
147
+
148
+ @dataclass
149
+ class GetAccountUserRequest:
150
+ """Get user details"""
151
+
152
+ id: str
153
+
154
+
59
155
  @dataclass
60
156
  class GetGroupRequest:
61
157
  """Get group details"""
@@ -63,6 +159,36 @@ class GetGroupRequest:
63
159
  id: str
64
160
 
65
161
 
162
+ @dataclass
163
+ class GetPermissionLevelsRequest:
164
+ """Get permission levels"""
165
+
166
+ request_object_type: str
167
+ request_object_id: str
168
+
169
+
170
+ @dataclass
171
+ class GetPermissionLevelsResponse:
172
+ permission_levels: 'List[PermissionsDescription]' = None
173
+
174
+ def as_dict(self) -> dict:
175
+ body = {}
176
+ if self.permission_levels: body['permission_levels'] = [v.as_dict() for v in self.permission_levels]
177
+ return body
178
+
179
+ @classmethod
180
+ def from_dict(cls, d: Dict[str, any]) -> 'GetPermissionLevelsResponse':
181
+ return cls(permission_levels=_repeated(d, 'permission_levels', PermissionsDescription))
182
+
183
+
184
+ @dataclass
185
+ class GetPermissionRequest:
186
+ """Get object permissions"""
187
+
188
+ request_object_type: str
189
+ request_object_id: str
190
+
191
+
66
192
  @dataclass
67
193
  class GetServicePrincipalRequest:
68
194
  """Get service principal details"""
@@ -77,6 +203,13 @@ class GetUserRequest:
77
203
  id: str
78
204
 
79
205
 
206
+ @dataclass
207
+ class GetWorkspaceAssignmentRequest:
208
+ """List workspace permissions"""
209
+
210
+ workspace_id: int
211
+
212
+
80
213
  @dataclass
81
214
  class Group:
82
215
  id: str
@@ -109,6 +242,45 @@ class Group:
109
242
  roles=_repeated(d, 'roles', ComplexValue))
110
243
 
111
244
 
245
+ @dataclass
246
+ class ListAccountGroupsRequest:
247
+ """List group details"""
248
+
249
+ attributes: str = None
250
+ count: int = None
251
+ excluded_attributes: str = None
252
+ filter: str = None
253
+ sort_by: str = None
254
+ sort_order: 'ListSortOrder' = None
255
+ start_index: int = None
256
+
257
+
258
+ @dataclass
259
+ class ListAccountServicePrincipalsRequest:
260
+ """List service principals"""
261
+
262
+ attributes: str = None
263
+ count: int = None
264
+ excluded_attributes: str = None
265
+ filter: str = None
266
+ sort_by: str = None
267
+ sort_order: 'ListSortOrder' = None
268
+ start_index: int = None
269
+
270
+
271
+ @dataclass
272
+ class ListAccountUsersRequest:
273
+ """List users"""
274
+
275
+ attributes: str = None
276
+ count: int = None
277
+ excluded_attributes: str = None
278
+ filter: str = None
279
+ sort_by: str = None
280
+ sort_order: 'ListSortOrder' = None
281
+ start_index: int = None
282
+
283
+
112
284
  @dataclass
113
285
  class ListGroupsRequest:
114
286
  """List group details"""
@@ -223,6 +395,13 @@ class ListUsersResponse:
223
395
  total_results=d.get('totalResults', None))
224
396
 
225
397
 
398
+ @dataclass
399
+ class ListWorkspaceAssignmentRequest:
400
+ """Get permission assignments"""
401
+
402
+ workspace_id: int
403
+
404
+
226
405
  @dataclass
227
406
  class Name:
228
407
  family_name: str = None
@@ -239,6 +418,27 @@ class Name:
239
418
  return cls(family_name=d.get('familyName', None), given_name=d.get('givenName', None))
240
419
 
241
420
 
421
+ @dataclass
422
+ class ObjectPermissions:
423
+ access_control_list: 'List[AccessControlResponse]' = None
424
+ object_id: str = None
425
+ object_type: str = None
426
+
427
+ def as_dict(self) -> dict:
428
+ body = {}
429
+ if self.access_control_list:
430
+ body['access_control_list'] = [v.as_dict() for v in self.access_control_list]
431
+ if self.object_id: body['object_id'] = self.object_id
432
+ if self.object_type: body['object_type'] = self.object_type
433
+ return body
434
+
435
+ @classmethod
436
+ def from_dict(cls, d: Dict[str, any]) -> 'ObjectPermissions':
437
+ return cls(access_control_list=_repeated(d, 'access_control_list', AccessControlResponse),
438
+ object_id=d.get('object_id', None),
439
+ object_type=d.get('object_type', None))
440
+
441
+
242
442
  @dataclass
243
443
  class PartialUpdate:
244
444
  id: str
@@ -281,6 +481,162 @@ class PatchOp(Enum):
281
481
  replace = 'replace'
282
482
 
283
483
 
484
+ @dataclass
485
+ class Permission:
486
+ inherited: bool = None
487
+ inherited_from_object: 'List[str]' = None
488
+ permission_level: 'PermissionLevel' = None
489
+
490
+ def as_dict(self) -> dict:
491
+ body = {}
492
+ if self.inherited: body['inherited'] = self.inherited
493
+ if self.inherited_from_object: body['inherited_from_object'] = [v for v in self.inherited_from_object]
494
+ if self.permission_level: body['permission_level'] = self.permission_level.value
495
+ return body
496
+
497
+ @classmethod
498
+ def from_dict(cls, d: Dict[str, any]) -> 'Permission':
499
+ return cls(inherited=d.get('inherited', None),
500
+ inherited_from_object=d.get('inherited_from_object', None),
501
+ permission_level=_enum(d, 'permission_level', PermissionLevel))
502
+
503
+
504
+ @dataclass
505
+ class PermissionAssignment:
506
+ error: str = None
507
+ permissions: 'List[WorkspacePermission]' = None
508
+ principal: 'PrincipalOutput' = None
509
+
510
+ def as_dict(self) -> dict:
511
+ body = {}
512
+ if self.error: body['error'] = self.error
513
+ if self.permissions: body['permissions'] = [v for v in self.permissions]
514
+ if self.principal: body['principal'] = self.principal.as_dict()
515
+ return body
516
+
517
+ @classmethod
518
+ def from_dict(cls, d: Dict[str, any]) -> 'PermissionAssignment':
519
+ return cls(error=d.get('error', None),
520
+ permissions=d.get('permissions', None),
521
+ principal=_from_dict(d, 'principal', PrincipalOutput))
522
+
523
+
524
+ @dataclass
525
+ class PermissionAssignments:
526
+ permission_assignments: 'List[PermissionAssignment]' = None
527
+
528
+ def as_dict(self) -> dict:
529
+ body = {}
530
+ if self.permission_assignments:
531
+ body['permission_assignments'] = [v.as_dict() for v in self.permission_assignments]
532
+ return body
533
+
534
+ @classmethod
535
+ def from_dict(cls, d: Dict[str, any]) -> 'PermissionAssignments':
536
+ return cls(permission_assignments=_repeated(d, 'permission_assignments', PermissionAssignment))
537
+
538
+
539
+ class PermissionLevel(Enum):
540
+ """Permission level"""
541
+
542
+ CAN_ATTACH_TO = 'CAN_ATTACH_TO'
543
+ CAN_BIND = 'CAN_BIND'
544
+ CAN_EDIT = 'CAN_EDIT'
545
+ CAN_EDIT_METADATA = 'CAN_EDIT_METADATA'
546
+ CAN_MANAGE = 'CAN_MANAGE'
547
+ CAN_MANAGE_PRODUCTION_VERSIONS = 'CAN_MANAGE_PRODUCTION_VERSIONS'
548
+ CAN_MANAGE_RUN = 'CAN_MANAGE_RUN'
549
+ CAN_MANAGE_STAGING_VERSIONS = 'CAN_MANAGE_STAGING_VERSIONS'
550
+ CAN_READ = 'CAN_READ'
551
+ CAN_RESTART = 'CAN_RESTART'
552
+ CAN_RUN = 'CAN_RUN'
553
+ CAN_USE = 'CAN_USE'
554
+ CAN_VIEW = 'CAN_VIEW'
555
+ CAN_VIEW_METADATA = 'CAN_VIEW_METADATA'
556
+ IS_OWNER = 'IS_OWNER'
557
+
558
+
559
+ @dataclass
560
+ class PermissionOutput:
561
+ description: str = None
562
+ permission_level: 'WorkspacePermission' = None
563
+
564
+ def as_dict(self) -> dict:
565
+ body = {}
566
+ if self.description: body['description'] = self.description
567
+ if self.permission_level: body['permission_level'] = self.permission_level.value
568
+ return body
569
+
570
+ @classmethod
571
+ def from_dict(cls, d: Dict[str, any]) -> 'PermissionOutput':
572
+ return cls(description=d.get('description', None),
573
+ permission_level=_enum(d, 'permission_level', WorkspacePermission))
574
+
575
+
576
+ @dataclass
577
+ class PermissionsDescription:
578
+ description: str = None
579
+ permission_level: 'PermissionLevel' = None
580
+
581
+ def as_dict(self) -> dict:
582
+ body = {}
583
+ if self.description: body['description'] = self.description
584
+ if self.permission_level: body['permission_level'] = self.permission_level.value
585
+ return body
586
+
587
+ @classmethod
588
+ def from_dict(cls, d: Dict[str, any]) -> 'PermissionsDescription':
589
+ return cls(description=d.get('description', None),
590
+ permission_level=_enum(d, 'permission_level', PermissionLevel))
591
+
592
+
593
+ @dataclass
594
+ class PermissionsRequest:
595
+ request_object_type: str
596
+ request_object_id: str
597
+ access_control_list: 'List[AccessControlRequest]' = None
598
+
599
+ def as_dict(self) -> dict:
600
+ body = {}
601
+ if self.access_control_list:
602
+ body['access_control_list'] = [v.as_dict() for v in self.access_control_list]
603
+ if self.request_object_id: body['request_object_id'] = self.request_object_id
604
+ if self.request_object_type: body['request_object_type'] = self.request_object_type
605
+ return body
606
+
607
+ @classmethod
608
+ def from_dict(cls, d: Dict[str, any]) -> 'PermissionsRequest':
609
+ return cls(access_control_list=_repeated(d, 'access_control_list', AccessControlRequest),
610
+ request_object_id=d.get('request_object_id', None),
611
+ request_object_type=d.get('request_object_type', None))
612
+
613
+
614
+ @dataclass
615
+ class PrincipalOutput:
616
+ display_name: str = None
617
+ group_name: str = None
618
+ principal_id: int = None
619
+ service_principal_name: str = None
620
+ user_name: str = None
621
+
622
+ def as_dict(self) -> dict:
623
+ body = {}
624
+ if self.display_name: body['display_name'] = self.display_name
625
+ if self.group_name: body['group_name'] = self.group_name
626
+ if self.principal_id: body['principal_id'] = self.principal_id
627
+ if self.service_principal_name: body['service_principal_name'] = self.service_principal_name
628
+ if self.user_name: body['user_name'] = self.user_name
629
+ return body
630
+
631
+ @classmethod
632
+ def from_dict(cls, d: Dict[str, any]) -> 'PrincipalOutput':
633
+ return cls(display_name=d.get('display_name', None),
634
+ group_name=d.get('group_name', None),
635
+ principal_id=d.get('principal_id', None),
636
+ service_principal_name=d.get('service_principal_name', None),
637
+ user_name=d.get('user_name', None))
638
+
639
+
284
640
  @dataclass
285
641
  class ServicePrincipal:
286
642
  id: str
@@ -316,6 +672,26 @@ class ServicePrincipal:
316
672
  roles=_repeated(d, 'roles', ComplexValue))
317
673
 
318
674
 
675
+ @dataclass
676
+ class UpdateWorkspaceAssignments:
677
+ permissions: 'List[WorkspacePermission]'
678
+ workspace_id: int
679
+ principal_id: int
680
+
681
+ def as_dict(self) -> dict:
682
+ body = {}
683
+ if self.permissions: body['permissions'] = [v for v in self.permissions]
684
+ if self.principal_id: body['principal_id'] = self.principal_id
685
+ if self.workspace_id: body['workspace_id'] = self.workspace_id
686
+ return body
687
+
688
+ @classmethod
689
+ def from_dict(cls, d: Dict[str, any]) -> 'UpdateWorkspaceAssignments':
690
+ return cls(permissions=d.get('permissions', None),
691
+ principal_id=d.get('principal_id', None),
692
+ workspace_id=d.get('workspace_id', None))
693
+
694
+
319
695
  @dataclass
320
696
  class User:
321
697
  id: str
@@ -357,6 +733,27 @@ class User:
357
733
  user_name=d.get('userName', None))
358
734
 
359
735
 
736
+ class WorkspacePermission(Enum):
737
+
738
+ ADMIN = 'ADMIN'
739
+ UNKNOWN = 'UNKNOWN'
740
+ USER = 'USER'
741
+
742
+
743
+ @dataclass
744
+ class WorkspacePermissions:
745
+ permissions: 'List[PermissionOutput]' = None
746
+
747
+ def as_dict(self) -> dict:
748
+ body = {}
749
+ if self.permissions: body['permissions'] = [v.as_dict() for v in self.permissions]
750
+ return body
751
+
752
+ @classmethod
753
+ def from_dict(cls, d: Dict[str, any]) -> 'WorkspacePermissions':
754
+ return cls(permissions=_repeated(d, 'permissions', PermissionOutput))
755
+
756
+
360
757
  class AccountGroupsAPI:
361
758
  """Groups simplify identity management, making it easier to assign access to Databricks Account, data, and
362
759
  other securable objects.
@@ -401,7 +798,7 @@ class AccountGroupsAPI:
401
798
  Deletes a group from the Databricks Account."""
402
799
  request = kwargs.get('request', None)
403
800
  if not request: # request is not given through keyed args
404
- request = DeleteGroupRequest(id=id)
801
+ request = DeleteAccountGroupRequest(id=id)
405
802
 
406
803
  self._api.do('DELETE', f'/api/2.0/accounts/{self._api.account_id}/scim/v2/Groups/{request.id}')
407
804
 
@@ -411,7 +808,7 @@ class AccountGroupsAPI:
411
808
  Gets the information for a specific group in the Databricks Account."""
412
809
  request = kwargs.get('request', None)
413
810
  if not request: # request is not given through keyed args
414
- request = GetGroupRequest(id=id)
811
+ request = GetAccountGroupRequest(id=id)
415
812
 
416
813
  json = self._api.do('GET', f'/api/2.0/accounts/{self._api.account_id}/scim/v2/Groups/{request.id}')
417
814
  return Group.from_dict(json)
@@ -431,13 +828,13 @@ class AccountGroupsAPI:
431
828
  Gets all details of the groups associated with the Databricks Account."""
432
829
  request = kwargs.get('request', None)
433
830
  if not request: # request is not given through keyed args
434
- request = ListGroupsRequest(attributes=attributes,
435
- count=count,
436
- excluded_attributes=excluded_attributes,
437
- filter=filter,
438
- sort_by=sort_by,
439
- sort_order=sort_order,
440
- start_index=start_index)
831
+ request = ListAccountGroupsRequest(attributes=attributes,
832
+ count=count,
833
+ excluded_attributes=excluded_attributes,
834
+ filter=filter,
835
+ sort_by=sort_by,
836
+ sort_order=sort_order,
837
+ start_index=start_index)
441
838
 
442
839
  query = {}
443
840
  if attributes: query['attributes'] = request.attributes
@@ -538,7 +935,7 @@ class AccountServicePrincipalsAPI:
538
935
  Delete a single service principal in the Databricks Account."""
539
936
  request = kwargs.get('request', None)
540
937
  if not request: # request is not given through keyed args
541
- request = DeleteServicePrincipalRequest(id=id)
938
+ request = DeleteAccountServicePrincipalRequest(id=id)
542
939
 
543
940
  self._api.do('DELETE',
544
941
  f'/api/2.0/accounts/{self._api.account_id}/scim/v2/ServicePrincipals/{request.id}')
@@ -549,7 +946,7 @@ class AccountServicePrincipalsAPI:
549
946
  Gets the details for a single service principal define in the Databricks Account."""
550
947
  request = kwargs.get('request', None)
551
948
  if not request: # request is not given through keyed args
552
- request = GetServicePrincipalRequest(id=id)
949
+ request = GetAccountServicePrincipalRequest(id=id)
553
950
 
554
951
  json = self._api.do(
555
952
  'GET', f'/api/2.0/accounts/{self._api.account_id}/scim/v2/ServicePrincipals/{request.id}')
@@ -570,13 +967,13 @@ class AccountServicePrincipalsAPI:
570
967
  Gets the set of service principals associated with a Databricks Account."""
571
968
  request = kwargs.get('request', None)
572
969
  if not request: # request is not given through keyed args
573
- request = ListServicePrincipalsRequest(attributes=attributes,
574
- count=count,
575
- excluded_attributes=excluded_attributes,
576
- filter=filter,
577
- sort_by=sort_by,
578
- sort_order=sort_order,
579
- start_index=start_index)
970
+ request = ListAccountServicePrincipalsRequest(attributes=attributes,
971
+ count=count,
972
+ excluded_attributes=excluded_attributes,
973
+ filter=filter,
974
+ sort_by=sort_by,
975
+ sort_order=sort_order,
976
+ start_index=start_index)
580
977
 
581
978
  query = {}
582
979
  if attributes: query['attributes'] = request.attributes
@@ -691,7 +1088,7 @@ class AccountUsersAPI:
691
1088
  user."""
692
1089
  request = kwargs.get('request', None)
693
1090
  if not request: # request is not given through keyed args
694
- request = DeleteUserRequest(id=id)
1091
+ request = DeleteAccountUserRequest(id=id)
695
1092
 
696
1093
  self._api.do('DELETE', f'/api/2.0/accounts/{self._api.account_id}/scim/v2/Users/{request.id}')
697
1094
 
@@ -701,7 +1098,7 @@ class AccountUsersAPI:
701
1098
  Gets information for a specific user in Databricks Account."""
702
1099
  request = kwargs.get('request', None)
703
1100
  if not request: # request is not given through keyed args
704
- request = GetUserRequest(id=id)
1101
+ request = GetAccountUserRequest(id=id)
705
1102
 
706
1103
  json = self._api.do('GET', f'/api/2.0/accounts/{self._api.account_id}/scim/v2/Users/{request.id}')
707
1104
  return User.from_dict(json)
@@ -721,13 +1118,13 @@ class AccountUsersAPI:
721
1118
  Gets details for all the users associated with a Databricks Account."""
722
1119
  request = kwargs.get('request', None)
723
1120
  if not request: # request is not given through keyed args
724
- request = ListUsersRequest(attributes=attributes,
725
- count=count,
726
- excluded_attributes=excluded_attributes,
727
- filter=filter,
728
- sort_by=sort_by,
729
- sort_order=sort_order,
730
- start_index=start_index)
1121
+ request = ListAccountUsersRequest(attributes=attributes,
1122
+ count=count,
1123
+ excluded_attributes=excluded_attributes,
1124
+ filter=filter,
1125
+ sort_by=sort_by,
1126
+ sort_order=sort_order,
1127
+ start_index=start_index)
731
1128
 
732
1129
  query = {}
733
1130
  if attributes: query['attributes'] = request.attributes
@@ -930,6 +1327,83 @@ class GroupsAPI:
930
1327
  self._api.do('PUT', f'/api/2.0/preview/scim/v2/Groups/{request.id}', body=body)
931
1328
 
932
1329
 
1330
+ class PermissionsAPI:
1331
+ """Permissions API are used to create read, write, edit, update and manage access for various users on
1332
+ different objects and endpoints."""
1333
+
1334
+ def __init__(self, api_client):
1335
+ self._api = api_client
1336
+
1337
+ def get(self, request_object_type: str, request_object_id: str, **kwargs) -> ObjectPermissions:
1338
+ """Get object permissions.
1339
+
1340
+ Gets the permission of an object. Objects can inherit permissions from their parent objects or root
1341
+ objects."""
1342
+ request = kwargs.get('request', None)
1343
+ if not request: # request is not given through keyed args
1344
+ request = GetPermissionRequest(request_object_id=request_object_id,
1345
+ request_object_type=request_object_type)
1346
+
1347
+ json = self._api.do(
1348
+ 'GET', f'/api/2.0/permissions/{request.request_object_type}/{request.request_object_id}')
1349
+ return ObjectPermissions.from_dict(json)
1350
+
1351
+ def get_permission_levels(self, request_object_type: str, request_object_id: str,
1352
+ **kwargs) -> GetPermissionLevelsResponse:
1353
+ """Get permission levels.
1354
+
1355
+ Gets the permission levels that a user can have on an object."""
1356
+ request = kwargs.get('request', None)
1357
+ if not request: # request is not given through keyed args
1358
+ request = GetPermissionLevelsRequest(request_object_id=request_object_id,
1359
+ request_object_type=request_object_type)
1360
+
1361
+ json = self._api.do(
1362
+ 'GET',
1363
+ f'/api/2.0/permissions/{request.request_object_type}/{request.request_object_id}/permissionLevels'
1364
+ )
1365
+ return GetPermissionLevelsResponse.from_dict(json)
1366
+
1367
+ def set(self,
1368
+ request_object_type: str,
1369
+ request_object_id: str,
1370
+ *,
1371
+ access_control_list: List[AccessControlRequest] = None,
1372
+ **kwargs):
1373
+ """Set permissions.
1374
+
1375
+ Sets permissions on object. Objects can inherit permissions from their parent objects and root
1376
+ objects."""
1377
+ request = kwargs.get('request', None)
1378
+ if not request: # request is not given through keyed args
1379
+ request = PermissionsRequest(access_control_list=access_control_list,
1380
+ request_object_id=request_object_id,
1381
+ request_object_type=request_object_type)
1382
+ body = request.as_dict()
1383
+ self._api.do('PUT',
1384
+ f'/api/2.0/permissions/{request.request_object_type}/{request.request_object_id}',
1385
+ body=body)
1386
+
1387
+ def update(self,
1388
+ request_object_type: str,
1389
+ request_object_id: str,
1390
+ *,
1391
+ access_control_list: List[AccessControlRequest] = None,
1392
+ **kwargs):
1393
+ """Update permission.
1394
+
1395
+ Updates the permissions on an object."""
1396
+ request = kwargs.get('request', None)
1397
+ if not request: # request is not given through keyed args
1398
+ request = PermissionsRequest(access_control_list=access_control_list,
1399
+ request_object_id=request_object_id,
1400
+ request_object_type=request_object_type)
1401
+ body = request.as_dict()
1402
+ self._api.do('PATCH',
1403
+ f'/api/2.0/permissions/{request.request_object_type}/{request.request_object_id}',
1404
+ body=body)
1405
+
1406
+
933
1407
  class ServicePrincipalsAPI:
934
1408
  """Identities for use with jobs, automated tools, and systems such as scripts, apps, and CI/CD platforms.
935
1409
  Databricks recommends creating service principals to run production jobs or modify production data. If all
@@ -1210,3 +1684,69 @@ class UsersAPI:
1210
1684
  user_name=user_name)
1211
1685
  body = request.as_dict()
1212
1686
  self._api.do('PUT', f'/api/2.0/preview/scim/v2/Users/{request.id}', body=body)
1687
+
1688
+
1689
+ class WorkspaceAssignmentAPI:
1690
+ """The Workspace Permission Assignment API allows you to manage workspace permissions for principals in your
1691
+ account."""
1692
+
1693
+ def __init__(self, api_client):
1694
+ self._api = api_client
1695
+
1696
+ def delete(self, workspace_id: int, principal_id: int, **kwargs):
1697
+ """Delete permissions assignment.
1698
+
1699
+ Deletes the workspace permissions assignment in a given account and workspace for the specified
1700
+ principal."""
1701
+ request = kwargs.get('request', None)
1702
+ if not request: # request is not given through keyed args
1703
+ request = DeleteWorkspaceAssignmentRequest(principal_id=principal_id, workspace_id=workspace_id)
1704
+
1705
+ self._api.do(
1706
+ 'DELETE',
1707
+ f'/api/2.0/accounts/{self._api.account_id}/workspaces/{request.workspace_id}/permissionassignments/principals/{request.principal_id}'
1708
+ )
1709
+
1710
+ def get(self, workspace_id: int, **kwargs) -> WorkspacePermissions:
1711
+ """List workspace permissions.
1712
+
1713
+ Get an array of workspace permissions for the specified account and workspace."""
1714
+ request = kwargs.get('request', None)
1715
+ if not request: # request is not given through keyed args
1716
+ request = GetWorkspaceAssignmentRequest(workspace_id=workspace_id)
1717
+
1718
+ json = self._api.do(
1719
+ 'GET',
1720
+ f'/api/2.0/accounts/{self._api.account_id}/workspaces/{request.workspace_id}/permissionassignments/permissions'
1721
+ )
1722
+ return WorkspacePermissions.from_dict(json)
1723
+
1724
+ def list(self, workspace_id: int, **kwargs) -> Iterator[PermissionAssignment]:
1725
+ """Get permission assignments.
1726
+
1727
+ Get the permission assignments for the specified Databricks Account and Databricks Workspace."""
1728
+ request = kwargs.get('request', None)
1729
+ if not request: # request is not given through keyed args
1730
+ request = ListWorkspaceAssignmentRequest(workspace_id=workspace_id)
1731
+
1732
+ json = self._api.do(
1733
+ 'GET',
1734
+ f'/api/2.0/accounts/{self._api.account_id}/workspaces/{request.workspace_id}/permissionassignments'
1735
+ )
1736
+ return [PermissionAssignment.from_dict(v) for v in json.get('permission_assignments', [])]
1737
+
1738
+ def update(self, permissions: List[WorkspacePermission], workspace_id: int, principal_id: int, **kwargs):
1739
+ """Create or update permissions assignment.
1740
+
1741
+ Creates or updates the workspace permissions assignment in a given account and workspace for the
1742
+ specified principal."""
1743
+ request = kwargs.get('request', None)
1744
+ if not request: # request is not given through keyed args
1745
+ request = UpdateWorkspaceAssignments(permissions=permissions,
1746
+ principal_id=principal_id,
1747
+ workspace_id=workspace_id)
1748
+ body = request.as_dict()
1749
+ self._api.do(
1750
+ 'PUT',
1751
+ f'/api/2.0/accounts/{self._api.account_id}/workspaces/{request.workspace_id}/permissionassignments/principals/{request.principal_id}',
1752
+ body=body)