databricks-sdk 0.23.0__py3-none-any.whl → 0.24.0__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.

@@ -1,4 +1,5 @@
1
1
  import datetime
2
+ import urllib.parse
2
3
  from typing import Callable, Dict, Generic, Optional, Type, TypeVar
3
4
 
4
5
 
@@ -38,6 +39,10 @@ def _repeated_enum(d: Dict[str, any], field: str, cls: Type) -> any:
38
39
  return res
39
40
 
40
41
 
42
+ def _escape_multi_segment_path_parameter(param: str) -> str:
43
+ return urllib.parse.quote(param)
44
+
45
+
41
46
  ReturnType = TypeVar('ReturnType')
42
47
 
43
48
 
@@ -117,6 +117,33 @@ class LifecycleState(Enum):
117
117
  TRASHED = 'TRASHED'
118
118
 
119
119
 
120
+ @dataclass
121
+ class MigrateDashboardRequest:
122
+ source_dashboard_id: str
123
+ """UUID of the dashboard to be migrated."""
124
+
125
+ display_name: Optional[str] = None
126
+ """Display name for the new Lakeview dashboard."""
127
+
128
+ parent_path: Optional[str] = None
129
+ """The workspace path of the folder to contain the migrated Lakeview dashboard."""
130
+
131
+ def as_dict(self) -> dict:
132
+ """Serializes the MigrateDashboardRequest into a dictionary suitable for use as a JSON request body."""
133
+ body = {}
134
+ if self.display_name is not None: body['display_name'] = self.display_name
135
+ if self.parent_path is not None: body['parent_path'] = self.parent_path
136
+ if self.source_dashboard_id is not None: body['source_dashboard_id'] = self.source_dashboard_id
137
+ return body
138
+
139
+ @classmethod
140
+ def from_dict(cls, d: Dict[str, any]) -> MigrateDashboardRequest:
141
+ """Deserializes the MigrateDashboardRequest from a dictionary."""
142
+ return cls(display_name=d.get('display_name', None),
143
+ parent_path=d.get('parent_path', None),
144
+ source_dashboard_id=d.get('source_dashboard_id', None))
145
+
146
+
120
147
  @dataclass
121
148
  class PublishRequest:
122
149
  dashboard_id: Optional[str] = None
@@ -191,6 +218,20 @@ class TrashDashboardResponse:
191
218
  return cls()
192
219
 
193
220
 
221
+ @dataclass
222
+ class UnpublishDashboardResponse:
223
+
224
+ def as_dict(self) -> dict:
225
+ """Serializes the UnpublishDashboardResponse into a dictionary suitable for use as a JSON request body."""
226
+ body = {}
227
+ return body
228
+
229
+ @classmethod
230
+ def from_dict(cls, d: Dict[str, any]) -> UnpublishDashboardResponse:
231
+ """Deserializes the UnpublishDashboardResponse from a dictionary."""
232
+ return cls()
233
+
234
+
194
235
  @dataclass
195
236
  class UpdateDashboardRequest:
196
237
  dashboard_id: Optional[str] = None
@@ -300,6 +341,33 @@ class LakeviewAPI:
300
341
  res = self._api.do('GET', f'/api/2.0/lakeview/dashboards/{dashboard_id}/published', headers=headers)
301
342
  return PublishedDashboard.from_dict(res)
302
343
 
344
+ def migrate(self,
345
+ source_dashboard_id: str,
346
+ *,
347
+ display_name: Optional[str] = None,
348
+ parent_path: Optional[str] = None) -> Dashboard:
349
+ """Migrate dashboard.
350
+
351
+ Migrates a classic SQL dashboard to Lakeview.
352
+
353
+ :param source_dashboard_id: str
354
+ UUID of the dashboard to be migrated.
355
+ :param display_name: str (optional)
356
+ Display name for the new Lakeview dashboard.
357
+ :param parent_path: str (optional)
358
+ The workspace path of the folder to contain the migrated Lakeview dashboard.
359
+
360
+ :returns: :class:`Dashboard`
361
+ """
362
+ body = {}
363
+ if display_name is not None: body['display_name'] = display_name
364
+ if parent_path is not None: body['parent_path'] = parent_path
365
+ if source_dashboard_id is not None: body['source_dashboard_id'] = source_dashboard_id
366
+ headers = {'Accept': 'application/json', 'Content-Type': 'application/json', }
367
+
368
+ res = self._api.do('POST', '/api/2.0/lakeview/dashboards/migrate', body=body, headers=headers)
369
+ return Dashboard.from_dict(res)
370
+
303
371
  def publish(self,
304
372
  dashboard_id: str,
305
373
  *,
@@ -345,6 +413,21 @@ class LakeviewAPI:
345
413
 
346
414
  self._api.do('DELETE', f'/api/2.0/lakeview/dashboards/{dashboard_id}', headers=headers)
347
415
 
416
+ def unpublish(self, dashboard_id: str):
417
+ """Unpublish dashboard.
418
+
419
+ Unpublish the dashboard.
420
+
421
+ :param dashboard_id: str
422
+ UUID identifying the dashboard to be published.
423
+
424
+
425
+ """
426
+
427
+ headers = {'Accept': 'application/json', }
428
+
429
+ self._api.do('DELETE', f'/api/2.0/lakeview/dashboards/{dashboard_id}/published', headers=headers)
430
+
348
431
  def update(self,
349
432
  dashboard_id: str,
350
433
  *,
@@ -6,7 +6,7 @@ import logging
6
6
  from dataclasses import dataclass
7
7
  from typing import BinaryIO, Dict, Iterator, List, Optional
8
8
 
9
- from ._internal import _repeated_dict
9
+ from ._internal import _escape_multi_segment_path_parameter, _repeated_dict
10
10
 
11
11
  _LOG = logging.getLogger('databricks.sdk')
12
12
 
@@ -789,7 +789,9 @@ class FilesAPI:
789
789
 
790
790
  headers = {}
791
791
 
792
- self._api.do('PUT', f'/api/2.0/fs/directories{directory_path}', headers=headers)
792
+ self._api.do('PUT',
793
+ f'/api/2.0/fs/directories{_escape_multi_segment_path_parameter(directory_path)}',
794
+ headers=headers)
793
795
 
794
796
  def delete(self, file_path: str):
795
797
  """Delete a file.
@@ -804,7 +806,9 @@ class FilesAPI:
804
806
 
805
807
  headers = {}
806
808
 
807
- self._api.do('DELETE', f'/api/2.0/fs/files{file_path}', headers=headers)
809
+ self._api.do('DELETE',
810
+ f'/api/2.0/fs/files{_escape_multi_segment_path_parameter(file_path)}',
811
+ headers=headers)
808
812
 
809
813
  def delete_directory(self, directory_path: str):
810
814
  """Delete a directory.
@@ -822,7 +826,9 @@ class FilesAPI:
822
826
 
823
827
  headers = {}
824
828
 
825
- self._api.do('DELETE', f'/api/2.0/fs/directories{directory_path}', headers=headers)
829
+ self._api.do('DELETE',
830
+ f'/api/2.0/fs/directories{_escape_multi_segment_path_parameter(directory_path)}',
831
+ headers=headers)
826
832
 
827
833
  def download(self, file_path: str) -> DownloadResponse:
828
834
  """Download a file.
@@ -839,7 +845,7 @@ class FilesAPI:
839
845
  headers = {'Accept': 'application/octet-stream', }
840
846
  response_headers = ['content-length', 'content-type', 'last-modified', ]
841
847
  res = self._api.do('GET',
842
- f'/api/2.0/fs/files{file_path}',
848
+ f'/api/2.0/fs/files{_escape_multi_segment_path_parameter(file_path)}',
843
849
  headers=headers,
844
850
  response_headers=response_headers,
845
851
  raw=True)
@@ -864,7 +870,9 @@ class FilesAPI:
864
870
 
865
871
  headers = {}
866
872
 
867
- self._api.do('HEAD', f'/api/2.0/fs/directories{directory_path}', headers=headers)
873
+ self._api.do('HEAD',
874
+ f'/api/2.0/fs/directories{_escape_multi_segment_path_parameter(directory_path)}',
875
+ headers=headers)
868
876
 
869
877
  def get_metadata(self, file_path: str) -> GetMetadataResponse:
870
878
  """Get file metadata.
@@ -880,7 +888,7 @@ class FilesAPI:
880
888
  headers = {}
881
889
  response_headers = ['content-length', 'content-type', 'last-modified', ]
882
890
  res = self._api.do('HEAD',
883
- f'/api/2.0/fs/files{file_path}',
891
+ f'/api/2.0/fs/files{_escape_multi_segment_path_parameter(file_path)}',
884
892
  headers=headers,
885
893
  response_headers=response_headers)
886
894
  return GetMetadataResponse.from_dict(res)
@@ -924,10 +932,11 @@ class FilesAPI:
924
932
  headers = {'Accept': 'application/json', }
925
933
 
926
934
  while True:
927
- json = self._api.do('GET',
928
- f'/api/2.0/fs/directories{directory_path}',
929
- query=query,
930
- headers=headers)
935
+ json = self._api.do(
936
+ 'GET',
937
+ f'/api/2.0/fs/directories{_escape_multi_segment_path_parameter(directory_path)}',
938
+ query=query,
939
+ headers=headers)
931
940
  if 'contents' in json:
932
941
  for v in json['contents']:
933
942
  yield DirectoryEntry.from_dict(v)
@@ -956,4 +965,8 @@ class FilesAPI:
956
965
  if overwrite is not None: query['overwrite'] = overwrite
957
966
  headers = {'Content-Type': 'application/octet-stream', }
958
967
 
959
- self._api.do('PUT', f'/api/2.0/fs/files{file_path}', query=query, headers=headers, data=contents)
968
+ self._api.do('PUT',
969
+ f'/api/2.0/fs/files{_escape_multi_segment_path_parameter(file_path)}',
970
+ query=query,
971
+ headers=headers,
972
+ data=contents)
@@ -2590,6 +2590,9 @@ class PermissionsAPI:
2590
2590
  For the mapping of the required permissions for specific actions or abilities and other important
2591
2591
  information, see [Access Control].
2592
2592
 
2593
+ Note that to manage access control on service principals, use **[Account Access Control
2594
+ Proxy](:service:accountaccesscontrolproxy)**.
2595
+
2593
2596
  [Access Control]: https://docs.databricks.com/security/auth-authz/access-control/index.html"""
2594
2597
 
2595
2598
  def __init__(self, api_client):