databricks-sdk 0.49.0__py3-none-any.whl → 0.51.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.

@@ -21,6 +21,87 @@ from databricks.sdk.service import sql
21
21
  # all definitions in this file are in alphabetical order
22
22
 
23
23
 
24
+ @dataclass
25
+ class AuthorizationDetails:
26
+ grant_rules: Optional[List[AuthorizationDetailsGrantRule]] = None
27
+ """Represents downscoped permission rules with specific access rights. This field is specific to
28
+ `workspace_rule_set` constraint."""
29
+
30
+ resource_legacy_acl_path: Optional[str] = None
31
+ """The acl path of the tree store resource resource."""
32
+
33
+ resource_name: Optional[str] = None
34
+ """The resource name to which the authorization rule applies. This field is specific to
35
+ `workspace_rule_set` constraint. Format: `workspaces/{workspace_id}/dashboards/{dashboard_id}`"""
36
+
37
+ type: Optional[str] = None
38
+ """The type of authorization downscoping policy. Ex: `workspace_rule_set` defines access rules for
39
+ a specific workspace resource"""
40
+
41
+ def as_dict(self) -> dict:
42
+ """Serializes the AuthorizationDetails into a dictionary suitable for use as a JSON request body."""
43
+ body = {}
44
+ if self.grant_rules:
45
+ body["grant_rules"] = [v.as_dict() for v in self.grant_rules]
46
+ if self.resource_legacy_acl_path is not None:
47
+ body["resource_legacy_acl_path"] = self.resource_legacy_acl_path
48
+ if self.resource_name is not None:
49
+ body["resource_name"] = self.resource_name
50
+ if self.type is not None:
51
+ body["type"] = self.type
52
+ return body
53
+
54
+ def as_shallow_dict(self) -> dict:
55
+ """Serializes the AuthorizationDetails into a shallow dictionary of its immediate attributes."""
56
+ body = {}
57
+ if self.grant_rules:
58
+ body["grant_rules"] = self.grant_rules
59
+ if self.resource_legacy_acl_path is not None:
60
+ body["resource_legacy_acl_path"] = self.resource_legacy_acl_path
61
+ if self.resource_name is not None:
62
+ body["resource_name"] = self.resource_name
63
+ if self.type is not None:
64
+ body["type"] = self.type
65
+ return body
66
+
67
+ @classmethod
68
+ def from_dict(cls, d: Dict[str, Any]) -> AuthorizationDetails:
69
+ """Deserializes the AuthorizationDetails from a dictionary."""
70
+ return cls(
71
+ grant_rules=_repeated_dict(d, "grant_rules", AuthorizationDetailsGrantRule),
72
+ resource_legacy_acl_path=d.get("resource_legacy_acl_path", None),
73
+ resource_name=d.get("resource_name", None),
74
+ type=d.get("type", None),
75
+ )
76
+
77
+
78
+ @dataclass
79
+ class AuthorizationDetailsGrantRule:
80
+ permission_set: Optional[str] = None
81
+ """Permission sets for dashboard are defined in
82
+ iam-common/rbac-common/permission-sets/definitions/TreeStoreBasePermissionSets Ex:
83
+ `permissionSets/dashboard.runner`"""
84
+
85
+ def as_dict(self) -> dict:
86
+ """Serializes the AuthorizationDetailsGrantRule into a dictionary suitable for use as a JSON request body."""
87
+ body = {}
88
+ if self.permission_set is not None:
89
+ body["permission_set"] = self.permission_set
90
+ return body
91
+
92
+ def as_shallow_dict(self) -> dict:
93
+ """Serializes the AuthorizationDetailsGrantRule into a shallow dictionary of its immediate attributes."""
94
+ body = {}
95
+ if self.permission_set is not None:
96
+ body["permission_set"] = self.permission_set
97
+ return body
98
+
99
+ @classmethod
100
+ def from_dict(cls, d: Dict[str, Any]) -> AuthorizationDetailsGrantRule:
101
+ """Deserializes the AuthorizationDetailsGrantRule from a dictionary."""
102
+ return cls(permission_set=d.get("permission_set", None))
103
+
104
+
24
105
  @dataclass
25
106
  class CancelQueryExecutionResponse:
26
107
  status: Optional[List[CancelQueryExecutionResponseStatus]] = None
@@ -531,45 +612,53 @@ class GenieCreateConversationMessageRequest:
531
612
 
532
613
  @dataclass
533
614
  class GenieGenerateDownloadFullQueryResultResponse:
534
- error: Optional[str] = None
535
- """Error message if Genie failed to download the result"""
536
-
537
- status: Optional[MessageStatus] = None
538
- """Download result status"""
539
-
540
- transient_statement_id: Optional[str] = None
541
- """Transient Statement ID. Use this ID to track the download request in subsequent polling calls"""
615
+ download_id: Optional[str] = None
616
+ """Download ID. Use this ID to track the download request in subsequent polling calls"""
542
617
 
543
618
  def as_dict(self) -> dict:
544
619
  """Serializes the GenieGenerateDownloadFullQueryResultResponse into a dictionary suitable for use as a JSON request body."""
545
620
  body = {}
546
- if self.error is not None:
547
- body["error"] = self.error
548
- if self.status is not None:
549
- body["status"] = self.status.value
550
- if self.transient_statement_id is not None:
551
- body["transient_statement_id"] = self.transient_statement_id
621
+ if self.download_id is not None:
622
+ body["download_id"] = self.download_id
552
623
  return body
553
624
 
554
625
  def as_shallow_dict(self) -> dict:
555
626
  """Serializes the GenieGenerateDownloadFullQueryResultResponse into a shallow dictionary of its immediate attributes."""
556
627
  body = {}
557
- if self.error is not None:
558
- body["error"] = self.error
559
- if self.status is not None:
560
- body["status"] = self.status
561
- if self.transient_statement_id is not None:
562
- body["transient_statement_id"] = self.transient_statement_id
628
+ if self.download_id is not None:
629
+ body["download_id"] = self.download_id
563
630
  return body
564
631
 
565
632
  @classmethod
566
633
  def from_dict(cls, d: Dict[str, Any]) -> GenieGenerateDownloadFullQueryResultResponse:
567
634
  """Deserializes the GenieGenerateDownloadFullQueryResultResponse from a dictionary."""
568
- return cls(
569
- error=d.get("error", None),
570
- status=_enum(d, "status", MessageStatus),
571
- transient_statement_id=d.get("transient_statement_id", None),
572
- )
635
+ return cls(download_id=d.get("download_id", None))
636
+
637
+
638
+ @dataclass
639
+ class GenieGetDownloadFullQueryResultResponse:
640
+ statement_response: Optional[sql.StatementResponse] = None
641
+ """SQL Statement Execution response. See [Get status, manifest, and result first
642
+ chunk](:method:statementexecution/getstatement) for more details."""
643
+
644
+ def as_dict(self) -> dict:
645
+ """Serializes the GenieGetDownloadFullQueryResultResponse into a dictionary suitable for use as a JSON request body."""
646
+ body = {}
647
+ if self.statement_response:
648
+ body["statement_response"] = self.statement_response.as_dict()
649
+ return body
650
+
651
+ def as_shallow_dict(self) -> dict:
652
+ """Serializes the GenieGetDownloadFullQueryResultResponse into a shallow dictionary of its immediate attributes."""
653
+ body = {}
654
+ if self.statement_response:
655
+ body["statement_response"] = self.statement_response
656
+ return body
657
+
658
+ @classmethod
659
+ def from_dict(cls, d: Dict[str, Any]) -> GenieGetDownloadFullQueryResultResponse:
660
+ """Deserializes the GenieGetDownloadFullQueryResultResponse from a dictionary."""
661
+ return cls(statement_response=_from_dict(d, "statement_response", sql.StatementResponse))
573
662
 
574
663
 
575
664
  @dataclass
@@ -837,7 +926,7 @@ class GenieResultMetadata:
837
926
  @dataclass
838
927
  class GenieSpace:
839
928
  space_id: str
840
- """Space ID"""
929
+ """Genie space ID"""
841
930
 
842
931
  title: str
843
932
  """Title of the Genie Space"""
@@ -972,6 +1061,52 @@ class GetPublishedDashboardEmbeddedResponse:
972
1061
  return cls()
973
1062
 
974
1063
 
1064
+ @dataclass
1065
+ class GetPublishedDashboardTokenInfoResponse:
1066
+ authorization_details: Optional[List[AuthorizationDetails]] = None
1067
+ """Authorization constraints for accessing the published dashboard. Currently includes
1068
+ `workspace_rule_set` and could be enriched with `unity_catalog_privileges` before oAuth token
1069
+ generation."""
1070
+
1071
+ custom_claim: Optional[str] = None
1072
+ """Custom claim generated from external_value and external_viewer_id. Format:
1073
+ `urn:aibi:external_data:<external_value>:<external_viewer_id>:<dashboard_id>`"""
1074
+
1075
+ scope: Optional[str] = None
1076
+ """Scope defining access permissions."""
1077
+
1078
+ def as_dict(self) -> dict:
1079
+ """Serializes the GetPublishedDashboardTokenInfoResponse into a dictionary suitable for use as a JSON request body."""
1080
+ body = {}
1081
+ if self.authorization_details:
1082
+ body["authorization_details"] = [v.as_dict() for v in self.authorization_details]
1083
+ if self.custom_claim is not None:
1084
+ body["custom_claim"] = self.custom_claim
1085
+ if self.scope is not None:
1086
+ body["scope"] = self.scope
1087
+ return body
1088
+
1089
+ def as_shallow_dict(self) -> dict:
1090
+ """Serializes the GetPublishedDashboardTokenInfoResponse into a shallow dictionary of its immediate attributes."""
1091
+ body = {}
1092
+ if self.authorization_details:
1093
+ body["authorization_details"] = self.authorization_details
1094
+ if self.custom_claim is not None:
1095
+ body["custom_claim"] = self.custom_claim
1096
+ if self.scope is not None:
1097
+ body["scope"] = self.scope
1098
+ return body
1099
+
1100
+ @classmethod
1101
+ def from_dict(cls, d: Dict[str, Any]) -> GetPublishedDashboardTokenInfoResponse:
1102
+ """Deserializes the GetPublishedDashboardTokenInfoResponse from a dictionary."""
1103
+ return cls(
1104
+ authorization_details=_repeated_dict(d, "authorization_details", AuthorizationDetails),
1105
+ custom_claim=d.get("custom_claim", None),
1106
+ scope=d.get("scope", None),
1107
+ )
1108
+
1109
+
975
1110
  class LifecycleState(Enum):
976
1111
 
977
1112
  ACTIVE = "ACTIVE"
@@ -2037,11 +2172,14 @@ class GenieAPI:
2037
2172
  ) -> GenieGenerateDownloadFullQueryResultResponse:
2038
2173
  """Generate full query result download.
2039
2174
 
2040
- Initiate full SQL query result download and obtain a transient ID for tracking the download progress.
2041
- This call initiates a new SQL execution to generate the query result.
2175
+ Initiates a new SQL execution and returns a `download_id` that you can use to track the progress of
2176
+ the download. The query result is stored in an external link and can be retrieved using the [Get
2177
+ Download Full Query Result](:method:genie/getdownloadfullqueryresult) API. Warning: Databricks
2178
+ strongly recommends that you protect the URLs that are returned by the `EXTERNAL_LINKS` disposition.
2179
+ See [Execute Statement](:method:statementexecution/executestatement) for more details.
2042
2180
 
2043
2181
  :param space_id: str
2044
- Space ID
2182
+ Genie space ID
2045
2183
  :param conversation_id: str
2046
2184
  Conversation ID
2047
2185
  :param message_id: str
@@ -2058,11 +2196,50 @@ class GenieAPI:
2058
2196
 
2059
2197
  res = self._api.do(
2060
2198
  "POST",
2061
- f"/api/2.0/genie/spaces/{space_id}/conversations/{conversation_id}/messages/{message_id}/attachments/{attachment_id}/generate-download",
2199
+ f"/api/2.0/genie/spaces/{space_id}/conversations/{conversation_id}/messages/{message_id}/attachments/{attachment_id}/downloads",
2062
2200
  headers=headers,
2063
2201
  )
2064
2202
  return GenieGenerateDownloadFullQueryResultResponse.from_dict(res)
2065
2203
 
2204
+ def get_download_full_query_result(
2205
+ self, space_id: str, conversation_id: str, message_id: str, attachment_id: str, download_id: str
2206
+ ) -> GenieGetDownloadFullQueryResultResponse:
2207
+ """Get download full query result.
2208
+
2209
+ After [Generating a Full Query Result Download](:method:genie/getdownloadfullqueryresult) and
2210
+ successfully receiving a `download_id`, use this API to poll the download progress. When the download
2211
+ is complete, the API returns one or more external links to the query result files. Warning: Databricks
2212
+ strongly recommends that you protect the URLs that are returned by the `EXTERNAL_LINKS` disposition.
2213
+ You must not set an Authorization header in download requests. When using the `EXTERNAL_LINKS`
2214
+ disposition, Databricks returns presigned URLs that grant temporary access to data. See [Execute
2215
+ Statement](:method:statementexecution/executestatement) for more details.
2216
+
2217
+ :param space_id: str
2218
+ Genie space ID
2219
+ :param conversation_id: str
2220
+ Conversation ID
2221
+ :param message_id: str
2222
+ Message ID
2223
+ :param attachment_id: str
2224
+ Attachment ID
2225
+ :param download_id: str
2226
+ Download ID. This ID is provided by the [Generate Download
2227
+ endpoint](:method:genie/generateDownloadFullQueryResult)
2228
+
2229
+ :returns: :class:`GenieGetDownloadFullQueryResultResponse`
2230
+ """
2231
+
2232
+ headers = {
2233
+ "Accept": "application/json",
2234
+ }
2235
+
2236
+ res = self._api.do(
2237
+ "GET",
2238
+ f"/api/2.0/genie/spaces/{space_id}/conversations/{conversation_id}/messages/{message_id}/attachments/{attachment_id}/downloads/{download_id}",
2239
+ headers=headers,
2240
+ )
2241
+ return GenieGetDownloadFullQueryResultResponse.from_dict(res)
2242
+
2066
2243
  def get_message(self, space_id: str, conversation_id: str, message_id: str) -> GenieMessage:
2067
2244
  """Get conversation message.
2068
2245
 
@@ -2242,12 +2419,12 @@ class LakeviewAPI:
2242
2419
  def __init__(self, api_client):
2243
2420
  self._api = api_client
2244
2421
 
2245
- def create(self, *, dashboard: Optional[Dashboard] = None) -> Dashboard:
2422
+ def create(self, dashboard: Dashboard) -> Dashboard:
2246
2423
  """Create dashboard.
2247
2424
 
2248
2425
  Create a draft dashboard.
2249
2426
 
2250
- :param dashboard: :class:`Dashboard` (optional)
2427
+ :param dashboard: :class:`Dashboard`
2251
2428
 
2252
2429
  :returns: :class:`Dashboard`
2253
2430
  """
@@ -2260,12 +2437,12 @@ class LakeviewAPI:
2260
2437
  res = self._api.do("POST", "/api/2.0/lakeview/dashboards", body=body, headers=headers)
2261
2438
  return Dashboard.from_dict(res)
2262
2439
 
2263
- def create_schedule(self, dashboard_id: str, *, schedule: Optional[Schedule] = None) -> Schedule:
2440
+ def create_schedule(self, dashboard_id: str, schedule: Schedule) -> Schedule:
2264
2441
  """Create dashboard schedule.
2265
2442
 
2266
2443
  :param dashboard_id: str
2267
2444
  UUID identifying the dashboard to which the schedule belongs.
2268
- :param schedule: :class:`Schedule` (optional)
2445
+ :param schedule: :class:`Schedule`
2269
2446
 
2270
2447
  :returns: :class:`Schedule`
2271
2448
  """
@@ -2278,16 +2455,14 @@ class LakeviewAPI:
2278
2455
  res = self._api.do("POST", f"/api/2.0/lakeview/dashboards/{dashboard_id}/schedules", body=body, headers=headers)
2279
2456
  return Schedule.from_dict(res)
2280
2457
 
2281
- def create_subscription(
2282
- self, dashboard_id: str, schedule_id: str, *, subscription: Optional[Subscription] = None
2283
- ) -> Subscription:
2458
+ def create_subscription(self, dashboard_id: str, schedule_id: str, subscription: Subscription) -> Subscription:
2284
2459
  """Create schedule subscription.
2285
2460
 
2286
2461
  :param dashboard_id: str
2287
2462
  UUID identifying the dashboard to which the subscription belongs.
2288
2463
  :param schedule_id: str
2289
2464
  UUID identifying the schedule to which the subscription belongs.
2290
- :param subscription: :class:`Subscription` (optional)
2465
+ :param subscription: :class:`Subscription`
2291
2466
 
2292
2467
  :returns: :class:`Subscription`
2293
2468
  """
@@ -2673,14 +2848,14 @@ class LakeviewAPI:
2673
2848
 
2674
2849
  self._api.do("DELETE", f"/api/2.0/lakeview/dashboards/{dashboard_id}/published", headers=headers)
2675
2850
 
2676
- def update(self, dashboard_id: str, *, dashboard: Optional[Dashboard] = None) -> Dashboard:
2851
+ def update(self, dashboard_id: str, dashboard: Dashboard) -> Dashboard:
2677
2852
  """Update dashboard.
2678
2853
 
2679
2854
  Update a draft dashboard.
2680
2855
 
2681
2856
  :param dashboard_id: str
2682
2857
  UUID identifying the dashboard.
2683
- :param dashboard: :class:`Dashboard` (optional)
2858
+ :param dashboard: :class:`Dashboard`
2684
2859
 
2685
2860
  :returns: :class:`Dashboard`
2686
2861
  """
@@ -2693,14 +2868,14 @@ class LakeviewAPI:
2693
2868
  res = self._api.do("PATCH", f"/api/2.0/lakeview/dashboards/{dashboard_id}", body=body, headers=headers)
2694
2869
  return Dashboard.from_dict(res)
2695
2870
 
2696
- def update_schedule(self, dashboard_id: str, schedule_id: str, *, schedule: Optional[Schedule] = None) -> Schedule:
2871
+ def update_schedule(self, dashboard_id: str, schedule_id: str, schedule: Schedule) -> Schedule:
2697
2872
  """Update dashboard schedule.
2698
2873
 
2699
2874
  :param dashboard_id: str
2700
2875
  UUID identifying the dashboard to which the schedule belongs.
2701
2876
  :param schedule_id: str
2702
2877
  UUID identifying the schedule.
2703
- :param schedule: :class:`Schedule` (optional)
2878
+ :param schedule: :class:`Schedule`
2704
2879
 
2705
2880
  :returns: :class:`Schedule`
2706
2881
  """
@@ -2739,6 +2914,42 @@ class LakeviewEmbeddedAPI:
2739
2914
 
2740
2915
  self._api.do("GET", f"/api/2.0/lakeview/dashboards/{dashboard_id}/published/embedded", headers=headers)
2741
2916
 
2917
+ def get_published_dashboard_token_info(
2918
+ self, dashboard_id: str, *, external_value: Optional[str] = None, external_viewer_id: Optional[str] = None
2919
+ ) -> GetPublishedDashboardTokenInfoResponse:
2920
+ """Read an information of a published dashboard to mint an OAuth token.
2921
+
2922
+ Get a required authorization details and scopes of a published dashboard to mint an OAuth token. The
2923
+ `authorization_details` can be enriched to apply additional restriction.
2924
+
2925
+ Example: Adding the following `authorization_details` object to downscope the viewer permission to
2926
+ specific table ``` { type: "unity_catalog_privileges", privileges: ["SELECT"], object_type: "TABLE",
2927
+ object_full_path: "main.default.testdata" } ```
2928
+
2929
+ :param dashboard_id: str
2930
+ UUID identifying the published dashboard.
2931
+ :param external_value: str (optional)
2932
+ Provided external value to be included in the custom claim.
2933
+ :param external_viewer_id: str (optional)
2934
+ Provided external viewer id to be included in the custom claim.
2935
+
2936
+ :returns: :class:`GetPublishedDashboardTokenInfoResponse`
2937
+ """
2938
+
2939
+ query = {}
2940
+ if external_value is not None:
2941
+ query["external_value"] = external_value
2942
+ if external_viewer_id is not None:
2943
+ query["external_viewer_id"] = external_viewer_id
2944
+ headers = {
2945
+ "Accept": "application/json",
2946
+ }
2947
+
2948
+ res = self._api.do(
2949
+ "GET", f"/api/2.0/lakeview/dashboards/{dashboard_id}/published/tokeninfo", query=query, headers=headers
2950
+ )
2951
+ return GetPublishedDashboardTokenInfoResponse.from_dict(res)
2952
+
2742
2953
 
2743
2954
  class QueryExecutionAPI:
2744
2955
  """Query execution APIs for AI / BI Dashboards"""