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

@@ -690,6 +690,35 @@ class ClusterAttributes:
690
690
  workload_type=_from_dict(d, 'workload_type', WorkloadType))
691
691
 
692
692
 
693
+ @dataclass
694
+ class ClusterCompliance:
695
+ cluster_id: str
696
+ """Canonical unique identifier for a cluster."""
697
+
698
+ is_compliant: Optional[bool] = None
699
+ """Whether this cluster is in compliance with the latest version of its policy."""
700
+
701
+ violations: Optional[Dict[str, str]] = None
702
+ """An object containing key-value mappings representing the first 200 policy validation errors. The
703
+ keys indicate the path where the policy validation error is occurring. The values indicate an
704
+ error message describing the policy validation error."""
705
+
706
+ def as_dict(self) -> dict:
707
+ """Serializes the ClusterCompliance into a dictionary suitable for use as a JSON request body."""
708
+ body = {}
709
+ if self.cluster_id is not None: body['cluster_id'] = self.cluster_id
710
+ if self.is_compliant is not None: body['is_compliant'] = self.is_compliant
711
+ if self.violations: body['violations'] = self.violations
712
+ return body
713
+
714
+ @classmethod
715
+ def from_dict(cls, d: Dict[str, any]) -> ClusterCompliance:
716
+ """Deserializes the ClusterCompliance from a dictionary."""
717
+ return cls(cluster_id=d.get('cluster_id', None),
718
+ is_compliant=d.get('is_compliant', None),
719
+ violations=d.get('violations', None))
720
+
721
+
693
722
  @dataclass
694
723
  class ClusterDetails:
695
724
  autoscale: Optional[AutoScale] = None
@@ -1377,6 +1406,40 @@ class ClusterPolicyPermissionsRequest:
1377
1406
  cluster_policy_id=d.get('cluster_policy_id', None))
1378
1407
 
1379
1408
 
1409
+ @dataclass
1410
+ class ClusterSettingsChange:
1411
+ """Represents a change to the cluster settings required for the cluster to become compliant with
1412
+ its policy."""
1413
+
1414
+ field: Optional[str] = None
1415
+ """The field where this change would be made."""
1416
+
1417
+ new_value: Optional[str] = None
1418
+ """The new value of this field after enforcing policy compliance (either a number, a boolean, or a
1419
+ string) converted to a string. This is intended to be read by a human. The typed new value of
1420
+ this field can be retrieved by reading the settings field in the API response."""
1421
+
1422
+ previous_value: Optional[str] = None
1423
+ """The previous value of this field before enforcing policy compliance (either a number, a boolean,
1424
+ or a string) converted to a string. This is intended to be read by a human. The type of the
1425
+ field can be retrieved by reading the settings field in the API response."""
1426
+
1427
+ def as_dict(self) -> dict:
1428
+ """Serializes the ClusterSettingsChange into a dictionary suitable for use as a JSON request body."""
1429
+ body = {}
1430
+ if self.field is not None: body['field'] = self.field
1431
+ if self.new_value is not None: body['new_value'] = self.new_value
1432
+ if self.previous_value is not None: body['previous_value'] = self.previous_value
1433
+ return body
1434
+
1435
+ @classmethod
1436
+ def from_dict(cls, d: Dict[str, any]) -> ClusterSettingsChange:
1437
+ """Deserializes the ClusterSettingsChange from a dictionary."""
1438
+ return cls(field=d.get('field', None),
1439
+ new_value=d.get('new_value', None),
1440
+ previous_value=d.get('previous_value', None))
1441
+
1442
+
1380
1443
  @dataclass
1381
1444
  class ClusterSize:
1382
1445
  autoscale: Optional[AutoScale] = None
@@ -2982,6 +3045,52 @@ class EditResponse:
2982
3045
  return cls()
2983
3046
 
2984
3047
 
3048
+ @dataclass
3049
+ class EnforceClusterComplianceRequest:
3050
+ cluster_id: str
3051
+ """The ID of the cluster you want to enforce policy compliance on."""
3052
+
3053
+ validate_only: Optional[bool] = None
3054
+ """If set, previews the changes that would be made to a cluster to enforce compliance but does not
3055
+ update the cluster."""
3056
+
3057
+ def as_dict(self) -> dict:
3058
+ """Serializes the EnforceClusterComplianceRequest into a dictionary suitable for use as a JSON request body."""
3059
+ body = {}
3060
+ if self.cluster_id is not None: body['cluster_id'] = self.cluster_id
3061
+ if self.validate_only is not None: body['validate_only'] = self.validate_only
3062
+ return body
3063
+
3064
+ @classmethod
3065
+ def from_dict(cls, d: Dict[str, any]) -> EnforceClusterComplianceRequest:
3066
+ """Deserializes the EnforceClusterComplianceRequest from a dictionary."""
3067
+ return cls(cluster_id=d.get('cluster_id', None), validate_only=d.get('validate_only', None))
3068
+
3069
+
3070
+ @dataclass
3071
+ class EnforceClusterComplianceResponse:
3072
+ changes: Optional[List[ClusterSettingsChange]] = None
3073
+ """A list of changes that have been made to the cluster settings for the cluster to become
3074
+ compliant with its policy."""
3075
+
3076
+ has_changes: Optional[bool] = None
3077
+ """Whether any changes have been made to the cluster settings for the cluster to become compliant
3078
+ with its policy."""
3079
+
3080
+ def as_dict(self) -> dict:
3081
+ """Serializes the EnforceClusterComplianceResponse into a dictionary suitable for use as a JSON request body."""
3082
+ body = {}
3083
+ if self.changes: body['changes'] = [v.as_dict() for v in self.changes]
3084
+ if self.has_changes is not None: body['has_changes'] = self.has_changes
3085
+ return body
3086
+
3087
+ @classmethod
3088
+ def from_dict(cls, d: Dict[str, any]) -> EnforceClusterComplianceResponse:
3089
+ """Deserializes the EnforceClusterComplianceResponse from a dictionary."""
3090
+ return cls(changes=_repeated_dict(d, 'changes', ClusterSettingsChange),
3091
+ has_changes=d.get('has_changes', None))
3092
+
3093
+
2985
3094
  @dataclass
2986
3095
  class Environment:
2987
3096
  """The environment entity used to preserve serverless environment side panel and jobs' environment
@@ -3251,6 +3360,30 @@ class GcsStorageInfo:
3251
3360
  return cls(destination=d.get('destination', None))
3252
3361
 
3253
3362
 
3363
+ @dataclass
3364
+ class GetClusterComplianceResponse:
3365
+ is_compliant: Optional[bool] = None
3366
+ """Whether the cluster is compliant with its policy or not. Clusters could be out of compliance if
3367
+ the policy was updated after the cluster was last edited."""
3368
+
3369
+ violations: Optional[Dict[str, str]] = None
3370
+ """An object containing key-value mappings representing the first 200 policy validation errors. The
3371
+ keys indicate the path where the policy validation error is occurring. The values indicate an
3372
+ error message describing the policy validation error."""
3373
+
3374
+ def as_dict(self) -> dict:
3375
+ """Serializes the GetClusterComplianceResponse into a dictionary suitable for use as a JSON request body."""
3376
+ body = {}
3377
+ if self.is_compliant is not None: body['is_compliant'] = self.is_compliant
3378
+ if self.violations: body['violations'] = self.violations
3379
+ return body
3380
+
3381
+ @classmethod
3382
+ def from_dict(cls, d: Dict[str, any]) -> GetClusterComplianceResponse:
3383
+ """Deserializes the GetClusterComplianceResponse from a dictionary."""
3384
+ return cls(is_compliant=d.get('is_compliant', None), violations=d.get('violations', None))
3385
+
3386
+
3254
3387
  @dataclass
3255
3388
  class GetClusterPermissionLevelsResponse:
3256
3389
  permission_levels: Optional[List[ClusterPermissionsDescription]] = None
@@ -4600,6 +4733,35 @@ class ListAvailableZonesResponse:
4600
4733
  return cls(default_zone=d.get('default_zone', None), zones=d.get('zones', None))
4601
4734
 
4602
4735
 
4736
+ @dataclass
4737
+ class ListClusterCompliancesResponse:
4738
+ clusters: Optional[List[ClusterCompliance]] = None
4739
+ """A list of clusters and their policy compliance statuses."""
4740
+
4741
+ next_page_token: Optional[str] = None
4742
+ """This field represents the pagination token to retrieve the next page of results. If the value is
4743
+ "", it means no further results for the request."""
4744
+
4745
+ prev_page_token: Optional[str] = None
4746
+ """This field represents the pagination token to retrieve the previous page of results. If the
4747
+ value is "", it means no further results for the request."""
4748
+
4749
+ def as_dict(self) -> dict:
4750
+ """Serializes the ListClusterCompliancesResponse into a dictionary suitable for use as a JSON request body."""
4751
+ body = {}
4752
+ if self.clusters: body['clusters'] = [v.as_dict() for v in self.clusters]
4753
+ if self.next_page_token is not None: body['next_page_token'] = self.next_page_token
4754
+ if self.prev_page_token is not None: body['prev_page_token'] = self.prev_page_token
4755
+ return body
4756
+
4757
+ @classmethod
4758
+ def from_dict(cls, d: Dict[str, any]) -> ListClusterCompliancesResponse:
4759
+ """Deserializes the ListClusterCompliancesResponse from a dictionary."""
4760
+ return cls(clusters=_repeated_dict(d, 'clusters', ClusterCompliance),
4761
+ next_page_token=d.get('next_page_token', None),
4762
+ prev_page_token=d.get('prev_page_token', None))
4763
+
4764
+
4603
4765
  @dataclass
4604
4766
  class ListClustersFilterBy:
4605
4767
  cluster_sources: Optional[List[ClusterSource]] = None
@@ -8584,6 +8746,116 @@ class LibrariesAPI:
8584
8746
  self._api.do('POST', '/api/2.0/libraries/uninstall', body=body, headers=headers)
8585
8747
 
8586
8748
 
8749
+ class PolicyComplianceForClustersAPI:
8750
+ """The policy compliance APIs allow you to view and manage the policy compliance status of clusters in your
8751
+ workspace.
8752
+
8753
+ A cluster is compliant with its policy if its configuration satisfies all its policy rules. Clusters could
8754
+ be out of compliance if their policy was updated after the cluster was last edited.
8755
+
8756
+ The get and list compliance APIs allow you to view the policy compliance status of a cluster. The enforce
8757
+ compliance API allows you to update a cluster to be compliant with the current version of its policy."""
8758
+
8759
+ def __init__(self, api_client):
8760
+ self._api = api_client
8761
+
8762
+ def enforce_compliance(self,
8763
+ cluster_id: str,
8764
+ *,
8765
+ validate_only: Optional[bool] = None) -> EnforceClusterComplianceResponse:
8766
+ """Enforce cluster policy compliance.
8767
+
8768
+ Updates a cluster to be compliant with the current version of its policy. A cluster can be updated if
8769
+ it is in a `RUNNING` or `TERMINATED` state.
8770
+
8771
+ If a cluster is updated while in a `RUNNING` state, it will be restarted so that the new attributes
8772
+ can take effect.
8773
+
8774
+ If a cluster is updated while in a `TERMINATED` state, it will remain `TERMINATED`. The next time the
8775
+ cluster is started, the new attributes will take effect.
8776
+
8777
+ Clusters created by the Databricks Jobs, DLT, or Models services cannot be enforced by this API.
8778
+ Instead, use the "Enforce job policy compliance" API to enforce policy compliance on jobs.
8779
+
8780
+ :param cluster_id: str
8781
+ The ID of the cluster you want to enforce policy compliance on.
8782
+ :param validate_only: bool (optional)
8783
+ If set, previews the changes that would be made to a cluster to enforce compliance but does not
8784
+ update the cluster.
8785
+
8786
+ :returns: :class:`EnforceClusterComplianceResponse`
8787
+ """
8788
+ body = {}
8789
+ if cluster_id is not None: body['cluster_id'] = cluster_id
8790
+ if validate_only is not None: body['validate_only'] = validate_only
8791
+ headers = {'Accept': 'application/json', 'Content-Type': 'application/json', }
8792
+
8793
+ res = self._api.do('POST',
8794
+ '/api/2.0/policies/clusters/enforce-compliance',
8795
+ body=body,
8796
+ headers=headers)
8797
+ return EnforceClusterComplianceResponse.from_dict(res)
8798
+
8799
+ def get_compliance(self, cluster_id: str) -> GetClusterComplianceResponse:
8800
+ """Get cluster policy compliance.
8801
+
8802
+ Returns the policy compliance status of a cluster. Clusters could be out of compliance if their policy
8803
+ was updated after the cluster was last edited.
8804
+
8805
+ :param cluster_id: str
8806
+ The ID of the cluster to get the compliance status
8807
+
8808
+ :returns: :class:`GetClusterComplianceResponse`
8809
+ """
8810
+
8811
+ query = {}
8812
+ if cluster_id is not None: query['cluster_id'] = cluster_id
8813
+ headers = {'Accept': 'application/json', }
8814
+
8815
+ res = self._api.do('GET', '/api/2.0/policies/clusters/get-compliance', query=query, headers=headers)
8816
+ return GetClusterComplianceResponse.from_dict(res)
8817
+
8818
+ def list_compliance(self,
8819
+ policy_id: str,
8820
+ *,
8821
+ page_size: Optional[int] = None,
8822
+ page_token: Optional[str] = None) -> Iterator[ClusterCompliance]:
8823
+ """List cluster policy compliance.
8824
+
8825
+ Returns the policy compliance status of all clusters that use a given policy. Clusters could be out of
8826
+ compliance if their policy was updated after the cluster was last edited.
8827
+
8828
+ :param policy_id: str
8829
+ Canonical unique identifier for the cluster policy.
8830
+ :param page_size: int (optional)
8831
+ Use this field to specify the maximum number of results to be returned by the server. The server may
8832
+ further constrain the maximum number of results returned in a single page.
8833
+ :param page_token: str (optional)
8834
+ A page token that can be used to navigate to the next page or previous page as returned by
8835
+ `next_page_token` or `prev_page_token`.
8836
+
8837
+ :returns: Iterator over :class:`ClusterCompliance`
8838
+ """
8839
+
8840
+ query = {}
8841
+ if page_size is not None: query['page_size'] = page_size
8842
+ if page_token is not None: query['page_token'] = page_token
8843
+ if policy_id is not None: query['policy_id'] = policy_id
8844
+ headers = {'Accept': 'application/json', }
8845
+
8846
+ while True:
8847
+ json = self._api.do('GET',
8848
+ '/api/2.0/policies/clusters/list-compliance',
8849
+ query=query,
8850
+ headers=headers)
8851
+ if 'clusters' in json:
8852
+ for v in json['clusters']:
8853
+ yield ClusterCompliance.from_dict(v)
8854
+ if 'next_page_token' not in json or not json['next_page_token']:
8855
+ return
8856
+ query['page_token'] = json['next_page_token']
8857
+
8858
+
8587
8859
  class PolicyFamiliesAPI:
8588
8860
  """View available policy families. A policy family contains a policy definition providing best practices for
8589
8861
  configuring clusters for a particular use case.
@@ -27,10 +27,11 @@ class CreateDashboardRequest:
27
27
 
28
28
  parent_path: Optional[str] = None
29
29
  """The workspace path of the folder containing the dashboard. Includes leading slash and no
30
- trailing slash."""
30
+ trailing slash. This field is excluded in List Dashboards responses."""
31
31
 
32
32
  serialized_dashboard: Optional[str] = None
33
- """The contents of the dashboard in serialized string form."""
33
+ """The contents of the dashboard in serialized string form. This field is excluded in List
34
+ Dashboards responses."""
34
35
 
35
36
  warehouse_id: Optional[str] = None
36
37
  """The warehouse ID used to run the dashboard."""
@@ -154,23 +155,26 @@ class Dashboard:
154
155
 
155
156
  etag: Optional[str] = None
156
157
  """The etag for the dashboard. Can be optionally provided on updates to ensure that the dashboard
157
- has not been modified since the last read."""
158
+ has not been modified since the last read. This field is excluded in List Dashboards responses."""
158
159
 
159
160
  lifecycle_state: Optional[LifecycleState] = None
160
161
  """The state of the dashboard resource. Used for tracking trashed status."""
161
162
 
162
163
  parent_path: Optional[str] = None
163
164
  """The workspace path of the folder containing the dashboard. Includes leading slash and no
164
- trailing slash."""
165
+ trailing slash. This field is excluded in List Dashboards responses."""
165
166
 
166
167
  path: Optional[str] = None
167
- """The workspace path of the dashboard asset, including the file name."""
168
+ """The workspace path of the dashboard asset, including the file name. This field is excluded in
169
+ List Dashboards responses."""
168
170
 
169
171
  serialized_dashboard: Optional[str] = None
170
- """The contents of the dashboard in serialized string form."""
172
+ """The contents of the dashboard in serialized string form. This field is excluded in List
173
+ Dashboards responses."""
171
174
 
172
175
  update_time: Optional[str] = None
173
- """The timestamp of when the dashboard was last updated by the user."""
176
+ """The timestamp of when the dashboard was last updated by the user. This field is excluded in List
177
+ Dashboards responses."""
174
178
 
175
179
  warehouse_id: Optional[str] = None
176
180
  """The warehouse ID used to run the dashboard."""
@@ -1020,10 +1024,11 @@ class UpdateDashboardRequest:
1020
1024
 
1021
1025
  etag: Optional[str] = None
1022
1026
  """The etag for the dashboard. Can be optionally provided on updates to ensure that the dashboard
1023
- has not been modified since the last read."""
1027
+ has not been modified since the last read. This field is excluded in List Dashboards responses."""
1024
1028
 
1025
1029
  serialized_dashboard: Optional[str] = None
1026
- """The contents of the dashboard in serialized string form."""
1030
+ """The contents of the dashboard in serialized string form. This field is excluded in List
1031
+ Dashboards responses."""
1027
1032
 
1028
1033
  warehouse_id: Optional[str] = None
1029
1034
  """The warehouse ID used to run the dashboard."""
@@ -1300,9 +1305,10 @@ class LakeviewAPI:
1300
1305
  The display name of the dashboard.
1301
1306
  :param parent_path: str (optional)
1302
1307
  The workspace path of the folder containing the dashboard. Includes leading slash and no trailing
1303
- slash.
1308
+ slash. This field is excluded in List Dashboards responses.
1304
1309
  :param serialized_dashboard: str (optional)
1305
- The contents of the dashboard in serialized string form.
1310
+ The contents of the dashboard in serialized string form. This field is excluded in List Dashboards
1311
+ responses.
1306
1312
  :param warehouse_id: str (optional)
1307
1313
  The warehouse ID used to run the dashboard.
1308
1314
 
@@ -1714,9 +1720,10 @@ class LakeviewAPI:
1714
1720
  The display name of the dashboard.
1715
1721
  :param etag: str (optional)
1716
1722
  The etag for the dashboard. Can be optionally provided on updates to ensure that the dashboard has
1717
- not been modified since the last read.
1723
+ not been modified since the last read. This field is excluded in List Dashboards responses.
1718
1724
  :param serialized_dashboard: str (optional)
1719
- The contents of the dashboard in serialized string form.
1725
+ The contents of the dashboard in serialized string form. This field is excluded in List Dashboards
1726
+ responses.
1720
1727
  :param warehouse_id: str (optional)
1721
1728
  The warehouse ID used to run the dashboard.
1722
1729