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

@@ -1778,14 +1778,6 @@ class DisableResponse:
1778
1778
  return cls()
1779
1779
 
1780
1780
 
1781
- class DisableSchemaName(Enum):
1782
-
1783
- ACCESS = 'access'
1784
- BILLING = 'billing'
1785
- LINEAGE = 'lineage'
1786
- OPERATIONAL_DATA = 'operational_data'
1787
-
1788
-
1789
1781
  @dataclass
1790
1782
  class EffectivePermissionsList:
1791
1783
  privilege_assignments: Optional[List[EffectivePrivilegeAssignment]] = None
@@ -1916,14 +1908,6 @@ class EnableResponse:
1916
1908
  return cls()
1917
1909
 
1918
1910
 
1919
- class EnableSchemaName(Enum):
1920
-
1921
- ACCESS = 'access'
1922
- BILLING = 'billing'
1923
- LINEAGE = 'lineage'
1924
- OPERATIONAL_DATA = 'operational_data'
1925
-
1926
-
1927
1911
  @dataclass
1928
1912
  class EncryptionDetails:
1929
1913
  """Encryption options that apply to clients connecting to cloud storage."""
@@ -2575,16 +2559,22 @@ class ListConnectionsResponse:
2575
2559
  connections: Optional[List[ConnectionInfo]] = None
2576
2560
  """An array of connection information objects."""
2577
2561
 
2562
+ next_page_token: Optional[str] = None
2563
+ """Opaque token to retrieve the next page of results. Absent if there are no more pages.
2564
+ __page_token__ should be set to this value for the next request (for the next page of results)."""
2565
+
2578
2566
  def as_dict(self) -> dict:
2579
2567
  """Serializes the ListConnectionsResponse into a dictionary suitable for use as a JSON request body."""
2580
2568
  body = {}
2581
2569
  if self.connections: body['connections'] = [v.as_dict() for v in self.connections]
2570
+ if self.next_page_token is not None: body['next_page_token'] = self.next_page_token
2582
2571
  return body
2583
2572
 
2584
2573
  @classmethod
2585
2574
  def from_dict(cls, d: Dict[str, any]) -> ListConnectionsResponse:
2586
2575
  """Deserializes the ListConnectionsResponse from a dictionary."""
2587
- return cls(connections=_repeated_dict(d, 'connections', ConnectionInfo))
2576
+ return cls(connections=_repeated_dict(d, 'connections', ConnectionInfo),
2577
+ next_page_token=d.get('next_page_token', None))
2588
2578
 
2589
2579
 
2590
2580
  @dataclass
@@ -3500,6 +3490,23 @@ class MonitorRefreshInfoTrigger(Enum):
3500
3490
  SCHEDULE = 'SCHEDULE'
3501
3491
 
3502
3492
 
3493
+ @dataclass
3494
+ class MonitorRefreshListResponse:
3495
+ refreshes: Optional[List[MonitorRefreshInfo]] = None
3496
+ """List of refreshes."""
3497
+
3498
+ def as_dict(self) -> dict:
3499
+ """Serializes the MonitorRefreshListResponse into a dictionary suitable for use as a JSON request body."""
3500
+ body = {}
3501
+ if self.refreshes: body['refreshes'] = [v.as_dict() for v in self.refreshes]
3502
+ return body
3503
+
3504
+ @classmethod
3505
+ def from_dict(cls, d: Dict[str, any]) -> MonitorRefreshListResponse:
3506
+ """Deserializes the MonitorRefreshListResponse from a dictionary."""
3507
+ return cls(refreshes=_repeated_dict(d, 'refreshes', MonitorRefreshInfo))
3508
+
3509
+
3503
3510
  @dataclass
3504
3511
  class MonitorSnapshot:
3505
3512
 
@@ -3882,6 +3889,7 @@ class Privilege(Enum):
3882
3889
  REFRESH = 'REFRESH'
3883
3890
  SELECT = 'SELECT'
3884
3891
  SET_SHARE_PERMISSION = 'SET_SHARE_PERMISSION'
3892
+ SINGLE_USER_ACCESS = 'SINGLE_USER_ACCESS'
3885
3893
  USAGE = 'USAGE'
3886
3894
  USE_CATALOG = 'USE_CATALOG'
3887
3895
  USE_CONNECTION = 'USE_CONNECTION'
@@ -5084,6 +5092,10 @@ class UpdateMonitor:
5084
5092
  metrics (from already computed aggregate metrics), or drift metrics (comparing metrics across
5085
5093
  time windows)."""
5086
5094
 
5095
+ dashboard_id: Optional[str] = None
5096
+ """Id of dashboard that visualizes the computed metrics. This can be empty if the monitor is in
5097
+ PENDING state."""
5098
+
5087
5099
  data_classification_config: Optional[MonitorDataClassificationConfig] = None
5088
5100
  """The data classification config for the monitor."""
5089
5101
 
@@ -5115,6 +5127,7 @@ class UpdateMonitor:
5115
5127
  body = {}
5116
5128
  if self.baseline_table_name is not None: body['baseline_table_name'] = self.baseline_table_name
5117
5129
  if self.custom_metrics: body['custom_metrics'] = [v.as_dict() for v in self.custom_metrics]
5130
+ if self.dashboard_id is not None: body['dashboard_id'] = self.dashboard_id
5118
5131
  if self.data_classification_config:
5119
5132
  body['data_classification_config'] = self.data_classification_config.as_dict()
5120
5133
  if self.inference_log: body['inference_log'] = self.inference_log.as_dict()
@@ -5132,6 +5145,7 @@ class UpdateMonitor:
5132
5145
  """Deserializes the UpdateMonitor from a dictionary."""
5133
5146
  return cls(baseline_table_name=d.get('baseline_table_name', None),
5134
5147
  custom_metrics=_repeated_dict(d, 'custom_metrics', MonitorMetric),
5148
+ dashboard_id=d.get('dashboard_id', None),
5135
5149
  data_classification_config=_from_dict(d, 'data_classification_config',
5136
5150
  MonitorDataClassificationConfig),
5137
5151
  inference_log=_from_dict(d, 'inference_log', MonitorInferenceLog),
@@ -6372,19 +6386,38 @@ class ConnectionsAPI:
6372
6386
  res = self._api.do('GET', f'/api/2.1/unity-catalog/connections/{name}', headers=headers)
6373
6387
  return ConnectionInfo.from_dict(res)
6374
6388
 
6375
- def list(self) -> Iterator[ConnectionInfo]:
6389
+ def list(self,
6390
+ *,
6391
+ max_results: Optional[int] = None,
6392
+ page_token: Optional[str] = None) -> Iterator[ConnectionInfo]:
6376
6393
  """List connections.
6377
6394
 
6378
6395
  List all connections.
6379
6396
 
6397
+ :param max_results: int (optional)
6398
+ Maximum number of connections to return. - If not set, all connections are returned (not
6399
+ recommended). - when set to a value greater than 0, the page length is the minimum of this value and
6400
+ a server configured value; - when set to 0, the page length is set to a server configured value
6401
+ (recommended); - when set to a value less than 0, an invalid parameter error is returned;
6402
+ :param page_token: str (optional)
6403
+ Opaque pagination token to go to next page based on previous query.
6404
+
6380
6405
  :returns: Iterator over :class:`ConnectionInfo`
6381
6406
  """
6382
6407
 
6408
+ query = {}
6409
+ if max_results is not None: query['max_results'] = max_results
6410
+ if page_token is not None: query['page_token'] = page_token
6383
6411
  headers = {'Accept': 'application/json', }
6384
6412
 
6385
- json = self._api.do('GET', '/api/2.1/unity-catalog/connections', headers=headers)
6386
- parsed = ListConnectionsResponse.from_dict(json).connections
6387
- return parsed if parsed is not None else []
6413
+ while True:
6414
+ json = self._api.do('GET', '/api/2.1/unity-catalog/connections', query=query, headers=headers)
6415
+ if 'connections' in json:
6416
+ for v in json['connections']:
6417
+ yield ConnectionInfo.from_dict(v)
6418
+ if 'next_page_token' not in json or not json['next_page_token']:
6419
+ return
6420
+ query['page_token'] = json['next_page_token']
6388
6421
 
6389
6422
  def update(self,
6390
6423
  name: str,
@@ -6896,364 +6929,249 @@ class GrantsAPI:
6896
6929
  return PermissionsList.from_dict(res)
6897
6930
 
6898
6931
 
6899
- class LakehouseMonitorsAPI:
6900
- """A monitor computes and monitors data or model quality metrics for a table over time. It generates metrics
6901
- tables and a dashboard that you can use to monitor table health and set alerts.
6932
+ class MetastoresAPI:
6933
+ """A metastore is the top-level container of objects in Unity Catalog. It stores data assets (tables and
6934
+ views) and the permissions that govern access to them. Databricks account admins can create metastores and
6935
+ assign them to Databricks workspaces to control which workloads use each metastore. For a workspace to use
6936
+ Unity Catalog, it must have a Unity Catalog metastore attached.
6902
6937
 
6903
- Most write operations require the user to be the owner of the table (or its parent schema or parent
6904
- catalog). Viewing the dashboard, computed metrics, or monitor configuration only requires the user to have
6905
- **SELECT** privileges on the table (along with **USE_SCHEMA** and **USE_CATALOG**)."""
6938
+ Each metastore is configured with a root storage location in a cloud storage account. This storage
6939
+ location is used for metadata and managed tables data.
6940
+
6941
+ NOTE: This metastore is distinct from the metastore included in Databricks workspaces created before Unity
6942
+ Catalog was released. If your workspace includes a legacy Hive metastore, the data in that metastore is
6943
+ available in a catalog named hive_metastore."""
6906
6944
 
6907
6945
  def __init__(self, api_client):
6908
6946
  self._api = api_client
6909
6947
 
6910
- def cancel_refresh(self, table_name: str, refresh_id: str):
6911
- """Cancel refresh.
6912
-
6913
- Cancel an active monitor refresh for the given refresh ID.
6914
-
6915
- The caller must either: 1. be an owner of the table's parent catalog 2. have **USE_CATALOG** on the
6916
- table's parent catalog and be an owner of the table's parent schema 3. have the following permissions:
6917
- - **USE_CATALOG** on the table's parent catalog - **USE_SCHEMA** on the table's parent schema - be an
6918
- owner of the table
6948
+ def assign(self, workspace_id: int, metastore_id: str, default_catalog_name: str):
6949
+ """Create an assignment.
6919
6950
 
6920
- Additionally, the call must be made from the workspace where the monitor was created.
6951
+ Creates a new metastore assignment. If an assignment for the same __workspace_id__ exists, it will be
6952
+ overwritten by the new __metastore_id__ and __default_catalog_name__. The caller must be an account
6953
+ admin.
6921
6954
 
6922
- :param table_name: str
6923
- Full name of the table.
6924
- :param refresh_id: str
6925
- ID of the refresh.
6955
+ :param workspace_id: int
6956
+ A workspace ID.
6957
+ :param metastore_id: str
6958
+ The unique ID of the metastore.
6959
+ :param default_catalog_name: str
6960
+ The name of the default catalog in the metastore.
6926
6961
 
6927
6962
 
6928
6963
  """
6964
+ body = {}
6965
+ if default_catalog_name is not None: body['default_catalog_name'] = default_catalog_name
6966
+ if metastore_id is not None: body['metastore_id'] = metastore_id
6967
+ headers = {'Accept': 'application/json', 'Content-Type': 'application/json', }
6929
6968
 
6930
- headers = {}
6931
-
6932
- self._api.do('POST',
6933
- f'/api/2.1/unity-catalog/tables/{table_name}/monitor/refreshes/{refresh_id}/cancel',
6969
+ self._api.do('PUT',
6970
+ f'/api/2.1/unity-catalog/workspaces/{workspace_id}/metastore',
6971
+ body=body,
6934
6972
  headers=headers)
6935
6973
 
6936
6974
  def create(self,
6937
- table_name: str,
6938
- assets_dir: str,
6939
- output_schema_name: str,
6975
+ name: str,
6940
6976
  *,
6941
- baseline_table_name: Optional[str] = None,
6942
- custom_metrics: Optional[List[MonitorMetric]] = None,
6943
- data_classification_config: Optional[MonitorDataClassificationConfig] = None,
6944
- inference_log: Optional[MonitorInferenceLog] = None,
6945
- notifications: Optional[MonitorNotifications] = None,
6946
- schedule: Optional[MonitorCronSchedule] = None,
6947
- skip_builtin_dashboard: Optional[bool] = None,
6948
- slicing_exprs: Optional[List[str]] = None,
6949
- snapshot: Optional[MonitorSnapshot] = None,
6950
- time_series: Optional[MonitorTimeSeries] = None,
6951
- warehouse_id: Optional[str] = None) -> MonitorInfo:
6952
- """Create a table monitor.
6953
-
6954
- Creates a new monitor for the specified table.
6955
-
6956
- The caller must either: 1. be an owner of the table's parent catalog, have **USE_SCHEMA** on the
6957
- table's parent schema, and have **SELECT** access on the table 2. have **USE_CATALOG** on the table's
6958
- parent catalog, be an owner of the table's parent schema, and have **SELECT** access on the table. 3.
6959
- have the following permissions: - **USE_CATALOG** on the table's parent catalog - **USE_SCHEMA** on
6960
- the table's parent schema - be an owner of the table.
6977
+ region: Optional[str] = None,
6978
+ storage_root: Optional[str] = None) -> MetastoreInfo:
6979
+ """Create a metastore.
6961
6980
 
6962
- Workspace assets, such as the dashboard, will be created in the workspace where this call was made.
6981
+ Creates a new metastore based on a provided name and optional storage root path. By default (if the
6982
+ __owner__ field is not set), the owner of the new metastore is the user calling the
6983
+ __createMetastore__ API. If the __owner__ field is set to the empty string (**""**), the ownership is
6984
+ assigned to the System User instead.
6963
6985
 
6964
- :param table_name: str
6965
- Full name of the table.
6966
- :param assets_dir: str
6967
- The directory to store monitoring assets (e.g. dashboard, metric tables).
6968
- :param output_schema_name: str
6969
- Schema where output metric tables are created.
6970
- :param baseline_table_name: str (optional)
6971
- Name of the baseline table from which drift metrics are computed from. Columns in the monitored
6972
- table should also be present in the baseline table.
6973
- :param custom_metrics: List[:class:`MonitorMetric`] (optional)
6974
- Custom metrics to compute on the monitored table. These can be aggregate metrics, derived metrics
6975
- (from already computed aggregate metrics), or drift metrics (comparing metrics across time windows).
6976
- :param data_classification_config: :class:`MonitorDataClassificationConfig` (optional)
6977
- The data classification config for the monitor.
6978
- :param inference_log: :class:`MonitorInferenceLog` (optional)
6979
- Configuration for monitoring inference logs.
6980
- :param notifications: :class:`MonitorNotifications` (optional)
6981
- The notification settings for the monitor.
6982
- :param schedule: :class:`MonitorCronSchedule` (optional)
6983
- The schedule for automatically updating and refreshing metric tables.
6984
- :param skip_builtin_dashboard: bool (optional)
6985
- Whether to skip creating a default dashboard summarizing data quality metrics.
6986
- :param slicing_exprs: List[str] (optional)
6987
- List of column expressions to slice data with for targeted analysis. The data is grouped by each
6988
- expression independently, resulting in a separate slice for each predicate and its complements. For
6989
- high-cardinality columns, only the top 100 unique values by frequency will generate slices.
6990
- :param snapshot: :class:`MonitorSnapshot` (optional)
6991
- Configuration for monitoring snapshot tables.
6992
- :param time_series: :class:`MonitorTimeSeries` (optional)
6993
- Configuration for monitoring time series tables.
6994
- :param warehouse_id: str (optional)
6995
- Optional argument to specify the warehouse for dashboard creation. If not specified, the first
6996
- running warehouse will be used.
6986
+ :param name: str
6987
+ The user-specified name of the metastore.
6988
+ :param region: str (optional)
6989
+ Cloud region which the metastore serves (e.g., `us-west-2`, `westus`). If this field is omitted, the
6990
+ region of the workspace receiving the request will be used.
6991
+ :param storage_root: str (optional)
6992
+ The storage root URL for metastore
6997
6993
 
6998
- :returns: :class:`MonitorInfo`
6994
+ :returns: :class:`MetastoreInfo`
6999
6995
  """
7000
6996
  body = {}
7001
- if assets_dir is not None: body['assets_dir'] = assets_dir
7002
- if baseline_table_name is not None: body['baseline_table_name'] = baseline_table_name
7003
- if custom_metrics is not None: body['custom_metrics'] = [v.as_dict() for v in custom_metrics]
7004
- if data_classification_config is not None:
7005
- body['data_classification_config'] = data_classification_config.as_dict()
7006
- if inference_log is not None: body['inference_log'] = inference_log.as_dict()
7007
- if notifications is not None: body['notifications'] = notifications.as_dict()
7008
- if output_schema_name is not None: body['output_schema_name'] = output_schema_name
7009
- if schedule is not None: body['schedule'] = schedule.as_dict()
7010
- if skip_builtin_dashboard is not None: body['skip_builtin_dashboard'] = skip_builtin_dashboard
7011
- if slicing_exprs is not None: body['slicing_exprs'] = [v for v in slicing_exprs]
7012
- if snapshot is not None: body['snapshot'] = snapshot.as_dict()
7013
- if time_series is not None: body['time_series'] = time_series.as_dict()
7014
- if warehouse_id is not None: body['warehouse_id'] = warehouse_id
6997
+ if name is not None: body['name'] = name
6998
+ if region is not None: body['region'] = region
6999
+ if storage_root is not None: body['storage_root'] = storage_root
7015
7000
  headers = {'Accept': 'application/json', 'Content-Type': 'application/json', }
7016
7001
 
7017
- res = self._api.do('POST',
7018
- f'/api/2.1/unity-catalog/tables/{table_name}/monitor',
7019
- body=body,
7020
- headers=headers)
7021
- return MonitorInfo.from_dict(res)
7002
+ res = self._api.do('POST', '/api/2.1/unity-catalog/metastores', body=body, headers=headers)
7003
+ return MetastoreInfo.from_dict(res)
7022
7004
 
7023
- def delete(self, table_name: str):
7024
- """Delete a table monitor.
7025
-
7026
- Deletes a monitor for the specified table.
7005
+ def current(self) -> MetastoreAssignment:
7006
+ """Get metastore assignment for workspace.
7027
7007
 
7028
- The caller must either: 1. be an owner of the table's parent catalog 2. have **USE_CATALOG** on the
7029
- table's parent catalog and be an owner of the table's parent schema 3. have the following permissions:
7030
- - **USE_CATALOG** on the table's parent catalog - **USE_SCHEMA** on the table's parent schema - be an
7031
- owner of the table.
7008
+ Gets the metastore assignment for the workspace being accessed.
7032
7009
 
7033
- Additionally, the call must be made from the workspace where the monitor was created.
7010
+ :returns: :class:`MetastoreAssignment`
7011
+ """
7012
+
7013
+ headers = {'Accept': 'application/json', }
7014
+
7015
+ res = self._api.do('GET', '/api/2.1/unity-catalog/current-metastore-assignment', headers=headers)
7016
+ return MetastoreAssignment.from_dict(res)
7017
+
7018
+ def delete(self, id: str, *, force: Optional[bool] = None):
7019
+ """Delete a metastore.
7034
7020
 
7035
- Note that the metric tables and dashboard will not be deleted as part of this call; those assets must
7036
- be manually cleaned up (if desired).
7021
+ Deletes a metastore. The caller must be a metastore admin.
7037
7022
 
7038
- :param table_name: str
7039
- Full name of the table.
7023
+ :param id: str
7024
+ Unique ID of the metastore.
7025
+ :param force: bool (optional)
7026
+ Force deletion even if the metastore is not empty. Default is false.
7040
7027
 
7041
7028
 
7042
7029
  """
7043
7030
 
7044
- headers = {}
7031
+ query = {}
7032
+ if force is not None: query['force'] = force
7033
+ headers = {'Accept': 'application/json', }
7045
7034
 
7046
- self._api.do('DELETE', f'/api/2.1/unity-catalog/tables/{table_name}/monitor', headers=headers)
7035
+ self._api.do('DELETE', f'/api/2.1/unity-catalog/metastores/{id}', query=query, headers=headers)
7047
7036
 
7048
- def get(self, table_name: str) -> MonitorInfo:
7049
- """Get a table monitor.
7050
-
7051
- Gets a monitor for the specified table.
7052
-
7053
- The caller must either: 1. be an owner of the table's parent catalog 2. have **USE_CATALOG** on the
7054
- table's parent catalog and be an owner of the table's parent schema. 3. have the following
7055
- permissions: - **USE_CATALOG** on the table's parent catalog - **USE_SCHEMA** on the table's parent
7056
- schema - **SELECT** privilege on the table.
7037
+ def get(self, id: str) -> MetastoreInfo:
7038
+ """Get a metastore.
7057
7039
 
7058
- The returned information includes configuration values, as well as information on assets created by
7059
- the monitor. Some information (e.g., dashboard) may be filtered out if the caller is in a different
7060
- workspace than where the monitor was created.
7040
+ Gets a metastore that matches the supplied ID. The caller must be a metastore admin to retrieve this
7041
+ info.
7061
7042
 
7062
- :param table_name: str
7063
- Full name of the table.
7043
+ :param id: str
7044
+ Unique ID of the metastore.
7064
7045
 
7065
- :returns: :class:`MonitorInfo`
7046
+ :returns: :class:`MetastoreInfo`
7066
7047
  """
7067
7048
 
7068
7049
  headers = {'Accept': 'application/json', }
7069
7050
 
7070
- res = self._api.do('GET', f'/api/2.1/unity-catalog/tables/{table_name}/monitor', headers=headers)
7071
- return MonitorInfo.from_dict(res)
7051
+ res = self._api.do('GET', f'/api/2.1/unity-catalog/metastores/{id}', headers=headers)
7052
+ return MetastoreInfo.from_dict(res)
7072
7053
 
7073
- def get_refresh(self, table_name: str, refresh_id: str) -> MonitorRefreshInfo:
7074
- """Get refresh.
7075
-
7076
- Gets info about a specific monitor refresh using the given refresh ID.
7077
-
7078
- The caller must either: 1. be an owner of the table's parent catalog 2. have **USE_CATALOG** on the
7079
- table's parent catalog and be an owner of the table's parent schema 3. have the following permissions:
7080
- - **USE_CATALOG** on the table's parent catalog - **USE_SCHEMA** on the table's parent schema -
7081
- **SELECT** privilege on the table.
7082
-
7083
- Additionally, the call must be made from the workspace where the monitor was created.
7054
+ def list(self) -> Iterator[MetastoreInfo]:
7055
+ """List metastores.
7084
7056
 
7085
- :param table_name: str
7086
- Full name of the table.
7087
- :param refresh_id: str
7088
- ID of the refresh.
7057
+ Gets an array of the available metastores (as __MetastoreInfo__ objects). The caller must be an admin
7058
+ to retrieve this info. There is no guarantee of a specific ordering of the elements in the array.
7089
7059
 
7090
- :returns: :class:`MonitorRefreshInfo`
7060
+ :returns: Iterator over :class:`MetastoreInfo`
7091
7061
  """
7092
7062
 
7093
7063
  headers = {'Accept': 'application/json', }
7094
7064
 
7095
- res = self._api.do('GET',
7096
- f'/api/2.1/unity-catalog/tables/{table_name}/monitor/refreshes/{refresh_id}',
7097
- headers=headers)
7098
- return MonitorRefreshInfo.from_dict(res)
7065
+ json = self._api.do('GET', '/api/2.1/unity-catalog/metastores', headers=headers)
7066
+ parsed = ListMetastoresResponse.from_dict(json).metastores
7067
+ return parsed if parsed is not None else []
7099
7068
 
7100
- def list_refreshes(self, table_name: str) -> Iterator[MonitorRefreshInfo]:
7101
- """List refreshes.
7102
-
7103
- Gets an array containing the history of the most recent refreshes (up to 25) for this table.
7104
-
7105
- The caller must either: 1. be an owner of the table's parent catalog 2. have **USE_CATALOG** on the
7106
- table's parent catalog and be an owner of the table's parent schema 3. have the following permissions:
7107
- - **USE_CATALOG** on the table's parent catalog - **USE_SCHEMA** on the table's parent schema -
7108
- **SELECT** privilege on the table.
7109
-
7110
- Additionally, the call must be made from the workspace where the monitor was created.
7069
+ def summary(self) -> GetMetastoreSummaryResponse:
7070
+ """Get a metastore summary.
7111
7071
 
7112
- :param table_name: str
7113
- Full name of the table.
7072
+ Gets information about a metastore. This summary includes the storage credential, the cloud vendor,
7073
+ the cloud region, and the global metastore ID.
7114
7074
 
7115
- :returns: Iterator over :class:`MonitorRefreshInfo`
7075
+ :returns: :class:`GetMetastoreSummaryResponse`
7116
7076
  """
7117
7077
 
7118
7078
  headers = {'Accept': 'application/json', }
7119
7079
 
7120
- res = self._api.do('GET',
7121
- f'/api/2.1/unity-catalog/tables/{table_name}/monitor/refreshes',
7122
- headers=headers)
7123
- return [MonitorRefreshInfo.from_dict(v) for v in res]
7080
+ res = self._api.do('GET', '/api/2.1/unity-catalog/metastore_summary', headers=headers)
7081
+ return GetMetastoreSummaryResponse.from_dict(res)
7124
7082
 
7125
- def run_refresh(self, table_name: str) -> MonitorRefreshInfo:
7126
- """Queue a metric refresh for a monitor.
7127
-
7128
- Queues a metric refresh on the monitor for the specified table. The refresh will execute in the
7129
- background.
7083
+ def unassign(self, workspace_id: int, metastore_id: str):
7084
+ """Delete an assignment.
7130
7085
 
7131
- The caller must either: 1. be an owner of the table's parent catalog 2. have **USE_CATALOG** on the
7132
- table's parent catalog and be an owner of the table's parent schema 3. have the following permissions:
7133
- - **USE_CATALOG** on the table's parent catalog - **USE_SCHEMA** on the table's parent schema - be an
7134
- owner of the table
7086
+ Deletes a metastore assignment. The caller must be an account administrator.
7135
7087
 
7136
- Additionally, the call must be made from the workspace where the monitor was created.
7088
+ :param workspace_id: int
7089
+ A workspace ID.
7090
+ :param metastore_id: str
7091
+ Query for the ID of the metastore to delete.
7137
7092
 
7138
- :param table_name: str
7139
- Full name of the table.
7140
7093
 
7141
- :returns: :class:`MonitorRefreshInfo`
7142
7094
  """
7143
7095
 
7096
+ query = {}
7097
+ if metastore_id is not None: query['metastore_id'] = metastore_id
7144
7098
  headers = {'Accept': 'application/json', }
7145
7099
 
7146
- res = self._api.do('POST',
7147
- f'/api/2.1/unity-catalog/tables/{table_name}/monitor/refreshes',
7148
- headers=headers)
7149
- return MonitorRefreshInfo.from_dict(res)
7100
+ self._api.do('DELETE',
7101
+ f'/api/2.1/unity-catalog/workspaces/{workspace_id}/metastore',
7102
+ query=query,
7103
+ headers=headers)
7150
7104
 
7151
7105
  def update(self,
7152
- table_name: str,
7153
- output_schema_name: str,
7106
+ id: str,
7154
7107
  *,
7155
- baseline_table_name: Optional[str] = None,
7156
- custom_metrics: Optional[List[MonitorMetric]] = None,
7157
- data_classification_config: Optional[MonitorDataClassificationConfig] = None,
7158
- inference_log: Optional[MonitorInferenceLog] = None,
7159
- notifications: Optional[MonitorNotifications] = None,
7160
- schedule: Optional[MonitorCronSchedule] = None,
7161
- slicing_exprs: Optional[List[str]] = None,
7162
- snapshot: Optional[MonitorSnapshot] = None,
7163
- time_series: Optional[MonitorTimeSeries] = None) -> MonitorInfo:
7164
- """Update a table monitor.
7165
-
7166
- Updates a monitor for the specified table.
7167
-
7168
- The caller must either: 1. be an owner of the table's parent catalog 2. have **USE_CATALOG** on the
7169
- table's parent catalog and be an owner of the table's parent schema 3. have the following permissions:
7170
- - **USE_CATALOG** on the table's parent catalog - **USE_SCHEMA** on the table's parent schema - be an
7171
- owner of the table.
7172
-
7173
- Additionally, the call must be made from the workspace where the monitor was created, and the caller
7174
- must be the original creator of the monitor.
7108
+ delta_sharing_organization_name: Optional[str] = None,
7109
+ delta_sharing_recipient_token_lifetime_in_seconds: Optional[int] = None,
7110
+ delta_sharing_scope: Optional[UpdateMetastoreDeltaSharingScope] = None,
7111
+ new_name: Optional[str] = None,
7112
+ owner: Optional[str] = None,
7113
+ privilege_model_version: Optional[str] = None,
7114
+ storage_root_credential_id: Optional[str] = None) -> MetastoreInfo:
7115
+ """Update a metastore.
7175
7116
 
7176
- Certain configuration fields, such as output asset identifiers, cannot be updated.
7117
+ Updates information for a specific metastore. The caller must be a metastore admin. If the __owner__
7118
+ field is set to the empty string (**""**), the ownership is updated to the System User.
7177
7119
 
7178
- :param table_name: str
7179
- Full name of the table.
7180
- :param output_schema_name: str
7181
- Schema where output metric tables are created.
7182
- :param baseline_table_name: str (optional)
7183
- Name of the baseline table from which drift metrics are computed from. Columns in the monitored
7184
- table should also be present in the baseline table.
7185
- :param custom_metrics: List[:class:`MonitorMetric`] (optional)
7186
- Custom metrics to compute on the monitored table. These can be aggregate metrics, derived metrics
7187
- (from already computed aggregate metrics), or drift metrics (comparing metrics across time windows).
7188
- :param data_classification_config: :class:`MonitorDataClassificationConfig` (optional)
7189
- The data classification config for the monitor.
7190
- :param inference_log: :class:`MonitorInferenceLog` (optional)
7191
- Configuration for monitoring inference logs.
7192
- :param notifications: :class:`MonitorNotifications` (optional)
7193
- The notification settings for the monitor.
7194
- :param schedule: :class:`MonitorCronSchedule` (optional)
7195
- The schedule for automatically updating and refreshing metric tables.
7196
- :param slicing_exprs: List[str] (optional)
7197
- List of column expressions to slice data with for targeted analysis. The data is grouped by each
7198
- expression independently, resulting in a separate slice for each predicate and its complements. For
7199
- high-cardinality columns, only the top 100 unique values by frequency will generate slices.
7200
- :param snapshot: :class:`MonitorSnapshot` (optional)
7201
- Configuration for monitoring snapshot tables.
7202
- :param time_series: :class:`MonitorTimeSeries` (optional)
7203
- Configuration for monitoring time series tables.
7120
+ :param id: str
7121
+ Unique ID of the metastore.
7122
+ :param delta_sharing_organization_name: str (optional)
7123
+ The organization name of a Delta Sharing entity, to be used in Databricks-to-Databricks Delta
7124
+ Sharing as the official name.
7125
+ :param delta_sharing_recipient_token_lifetime_in_seconds: int (optional)
7126
+ The lifetime of delta sharing recipient token in seconds.
7127
+ :param delta_sharing_scope: :class:`UpdateMetastoreDeltaSharingScope` (optional)
7128
+ The scope of Delta Sharing enabled for the metastore.
7129
+ :param new_name: str (optional)
7130
+ New name for the metastore.
7131
+ :param owner: str (optional)
7132
+ The owner of the metastore.
7133
+ :param privilege_model_version: str (optional)
7134
+ Privilege model version of the metastore, of the form `major.minor` (e.g., `1.0`).
7135
+ :param storage_root_credential_id: str (optional)
7136
+ UUID of storage credential to access the metastore storage_root.
7204
7137
 
7205
- :returns: :class:`MonitorInfo`
7138
+ :returns: :class:`MetastoreInfo`
7206
7139
  """
7207
7140
  body = {}
7208
- if baseline_table_name is not None: body['baseline_table_name'] = baseline_table_name
7209
- if custom_metrics is not None: body['custom_metrics'] = [v.as_dict() for v in custom_metrics]
7210
- if data_classification_config is not None:
7211
- body['data_classification_config'] = data_classification_config.as_dict()
7212
- if inference_log is not None: body['inference_log'] = inference_log.as_dict()
7213
- if notifications is not None: body['notifications'] = notifications.as_dict()
7214
- if output_schema_name is not None: body['output_schema_name'] = output_schema_name
7215
- if schedule is not None: body['schedule'] = schedule.as_dict()
7216
- if slicing_exprs is not None: body['slicing_exprs'] = [v for v in slicing_exprs]
7217
- if snapshot is not None: body['snapshot'] = snapshot.as_dict()
7218
- if time_series is not None: body['time_series'] = time_series.as_dict()
7141
+ if delta_sharing_organization_name is not None:
7142
+ body['delta_sharing_organization_name'] = delta_sharing_organization_name
7143
+ if delta_sharing_recipient_token_lifetime_in_seconds is not None:
7144
+ body[
7145
+ 'delta_sharing_recipient_token_lifetime_in_seconds'] = delta_sharing_recipient_token_lifetime_in_seconds
7146
+ if delta_sharing_scope is not None: body['delta_sharing_scope'] = delta_sharing_scope.value
7147
+ if new_name is not None: body['new_name'] = new_name
7148
+ if owner is not None: body['owner'] = owner
7149
+ if privilege_model_version is not None: body['privilege_model_version'] = privilege_model_version
7150
+ if storage_root_credential_id is not None:
7151
+ body['storage_root_credential_id'] = storage_root_credential_id
7219
7152
  headers = {'Accept': 'application/json', 'Content-Type': 'application/json', }
7220
7153
 
7221
- res = self._api.do('PUT',
7222
- f'/api/2.1/unity-catalog/tables/{table_name}/monitor',
7223
- body=body,
7224
- headers=headers)
7225
- return MonitorInfo.from_dict(res)
7226
-
7227
-
7228
- class MetastoresAPI:
7229
- """A metastore is the top-level container of objects in Unity Catalog. It stores data assets (tables and
7230
- views) and the permissions that govern access to them. Databricks account admins can create metastores and
7231
- assign them to Databricks workspaces to control which workloads use each metastore. For a workspace to use
7232
- Unity Catalog, it must have a Unity Catalog metastore attached.
7233
-
7234
- Each metastore is configured with a root storage location in a cloud storage account. This storage
7235
- location is used for metadata and managed tables data.
7236
-
7237
- NOTE: This metastore is distinct from the metastore included in Databricks workspaces created before Unity
7238
- Catalog was released. If your workspace includes a legacy Hive metastore, the data in that metastore is
7239
- available in a catalog named hive_metastore."""
7240
-
7241
- def __init__(self, api_client):
7242
- self._api = api_client
7154
+ res = self._api.do('PATCH', f'/api/2.1/unity-catalog/metastores/{id}', body=body, headers=headers)
7155
+ return MetastoreInfo.from_dict(res)
7243
7156
 
7244
- def assign(self, workspace_id: int, metastore_id: str, default_catalog_name: str):
7245
- """Create an assignment.
7157
+ def update_assignment(self,
7158
+ workspace_id: int,
7159
+ *,
7160
+ default_catalog_name: Optional[str] = None,
7161
+ metastore_id: Optional[str] = None):
7162
+ """Update an assignment.
7246
7163
 
7247
- Creates a new metastore assignment. If an assignment for the same __workspace_id__ exists, it will be
7248
- overwritten by the new __metastore_id__ and __default_catalog_name__. The caller must be an account
7249
- admin.
7164
+ Updates a metastore assignment. This operation can be used to update __metastore_id__ or
7165
+ __default_catalog_name__ for a specified Workspace, if the Workspace is already assigned a metastore.
7166
+ The caller must be an account admin to update __metastore_id__; otherwise, the caller can be a
7167
+ Workspace admin.
7250
7168
 
7251
7169
  :param workspace_id: int
7252
7170
  A workspace ID.
7253
- :param metastore_id: str
7171
+ :param default_catalog_name: str (optional)
7172
+ The name of the default catalog for the metastore.
7173
+ :param metastore_id: str (optional)
7254
7174
  The unique ID of the metastore.
7255
- :param default_catalog_name: str
7256
- The name of the default catalog in the metastore.
7257
7175
 
7258
7176
 
7259
7177
  """
@@ -7262,463 +7180,583 @@ class MetastoresAPI:
7262
7180
  if metastore_id is not None: body['metastore_id'] = metastore_id
7263
7181
  headers = {'Accept': 'application/json', 'Content-Type': 'application/json', }
7264
7182
 
7265
- self._api.do('PUT',
7183
+ self._api.do('PATCH',
7266
7184
  f'/api/2.1/unity-catalog/workspaces/{workspace_id}/metastore',
7267
7185
  body=body,
7268
7186
  headers=headers)
7269
7187
 
7270
- def create(self,
7271
- name: str,
7272
- *,
7273
- region: Optional[str] = None,
7274
- storage_root: Optional[str] = None) -> MetastoreInfo:
7275
- """Create a metastore.
7188
+
7189
+ class ModelVersionsAPI:
7190
+ """Databricks provides a hosted version of MLflow Model Registry in Unity Catalog. Models in Unity Catalog
7191
+ provide centralized access control, auditing, lineage, and discovery of ML models across Databricks
7192
+ workspaces.
7193
+
7194
+ This API reference documents the REST endpoints for managing model versions in Unity Catalog. For more
7195
+ details, see the [registered models API docs](/api/workspace/registeredmodels)."""
7196
+
7197
+ def __init__(self, api_client):
7198
+ self._api = api_client
7199
+
7200
+ def delete(self, full_name: str, version: int):
7201
+ """Delete a Model Version.
7276
7202
 
7277
- Creates a new metastore based on a provided name and optional storage root path. By default (if the
7278
- __owner__ field is not set), the owner of the new metastore is the user calling the
7279
- __createMetastore__ API. If the __owner__ field is set to the empty string (**""**), the ownership is
7280
- assigned to the System User instead.
7203
+ Deletes a model version from the specified registered model. Any aliases assigned to the model version
7204
+ will also be deleted.
7281
7205
 
7282
- :param name: str
7283
- The user-specified name of the metastore.
7284
- :param region: str (optional)
7285
- Cloud region which the metastore serves (e.g., `us-west-2`, `westus`). If this field is omitted, the
7286
- region of the workspace receiving the request will be used.
7287
- :param storage_root: str (optional)
7288
- The storage root URL for metastore
7206
+ The caller must be a metastore admin or an owner of the parent registered model. For the latter case,
7207
+ the caller must also be the owner or have the **USE_CATALOG** privilege on the parent catalog and the
7208
+ **USE_SCHEMA** privilege on the parent schema.
7289
7209
 
7290
- :returns: :class:`MetastoreInfo`
7291
- """
7292
- body = {}
7293
- if name is not None: body['name'] = name
7294
- if region is not None: body['region'] = region
7295
- if storage_root is not None: body['storage_root'] = storage_root
7296
- headers = {'Accept': 'application/json', 'Content-Type': 'application/json', }
7297
-
7298
- res = self._api.do('POST', '/api/2.1/unity-catalog/metastores', body=body, headers=headers)
7299
- return MetastoreInfo.from_dict(res)
7300
-
7301
- def current(self) -> MetastoreAssignment:
7302
- """Get metastore assignment for workspace.
7210
+ :param full_name: str
7211
+ The three-level (fully qualified) name of the model version
7212
+ :param version: int
7213
+ The integer version number of the model version
7303
7214
 
7304
- Gets the metastore assignment for the workspace being accessed.
7305
7215
 
7306
- :returns: :class:`MetastoreAssignment`
7307
7216
  """
7308
7217
 
7309
- headers = {'Accept': 'application/json', }
7218
+ headers = {}
7310
7219
 
7311
- res = self._api.do('GET', '/api/2.1/unity-catalog/current-metastore-assignment', headers=headers)
7312
- return MetastoreAssignment.from_dict(res)
7220
+ self._api.do('DELETE',
7221
+ f'/api/2.1/unity-catalog/models/{full_name}/versions/{version}',
7222
+ headers=headers)
7313
7223
 
7314
- def delete(self, id: str, *, force: Optional[bool] = None):
7315
- """Delete a metastore.
7224
+ def get(self,
7225
+ full_name: str,
7226
+ version: int,
7227
+ *,
7228
+ include_browse: Optional[bool] = None) -> RegisteredModelInfo:
7229
+ """Get a Model Version.
7316
7230
 
7317
- Deletes a metastore. The caller must be a metastore admin.
7231
+ Get a model version.
7318
7232
 
7319
- :param id: str
7320
- Unique ID of the metastore.
7321
- :param force: bool (optional)
7322
- Force deletion even if the metastore is not empty. Default is false.
7233
+ The caller must be a metastore admin or an owner of (or have the **EXECUTE** privilege on) the parent
7234
+ registered model. For the latter case, the caller must also be the owner or have the **USE_CATALOG**
7235
+ privilege on the parent catalog and the **USE_SCHEMA** privilege on the parent schema.
7323
7236
 
7237
+ :param full_name: str
7238
+ The three-level (fully qualified) name of the model version
7239
+ :param version: int
7240
+ The integer version number of the model version
7241
+ :param include_browse: bool (optional)
7242
+ Whether to include model versions in the response for which the principal can only access selective
7243
+ metadata for
7324
7244
 
7245
+ :returns: :class:`RegisteredModelInfo`
7325
7246
  """
7326
7247
 
7327
7248
  query = {}
7328
- if force is not None: query['force'] = force
7249
+ if include_browse is not None: query['include_browse'] = include_browse
7329
7250
  headers = {'Accept': 'application/json', }
7330
7251
 
7331
- self._api.do('DELETE', f'/api/2.1/unity-catalog/metastores/{id}', query=query, headers=headers)
7252
+ res = self._api.do('GET',
7253
+ f'/api/2.1/unity-catalog/models/{full_name}/versions/{version}',
7254
+ query=query,
7255
+ headers=headers)
7256
+ return RegisteredModelInfo.from_dict(res)
7332
7257
 
7333
- def get(self, id: str) -> MetastoreInfo:
7334
- """Get a metastore.
7258
+ def get_by_alias(self, full_name: str, alias: str) -> ModelVersionInfo:
7259
+ """Get Model Version By Alias.
7335
7260
 
7336
- Gets a metastore that matches the supplied ID. The caller must be a metastore admin to retrieve this
7337
- info.
7261
+ Get a model version by alias.
7338
7262
 
7339
- :param id: str
7340
- Unique ID of the metastore.
7263
+ The caller must be a metastore admin or an owner of (or have the **EXECUTE** privilege on) the
7264
+ registered model. For the latter case, the caller must also be the owner or have the **USE_CATALOG**
7265
+ privilege on the parent catalog and the **USE_SCHEMA** privilege on the parent schema.
7341
7266
 
7342
- :returns: :class:`MetastoreInfo`
7267
+ :param full_name: str
7268
+ The three-level (fully qualified) name of the registered model
7269
+ :param alias: str
7270
+ The name of the alias
7271
+
7272
+ :returns: :class:`ModelVersionInfo`
7343
7273
  """
7344
7274
 
7345
7275
  headers = {'Accept': 'application/json', }
7346
7276
 
7347
- res = self._api.do('GET', f'/api/2.1/unity-catalog/metastores/{id}', headers=headers)
7348
- return MetastoreInfo.from_dict(res)
7277
+ res = self._api.do('GET',
7278
+ f'/api/2.1/unity-catalog/models/{full_name}/aliases/{alias}',
7279
+ headers=headers)
7280
+ return ModelVersionInfo.from_dict(res)
7349
7281
 
7350
- def list(self) -> Iterator[MetastoreInfo]:
7351
- """List metastores.
7282
+ def list(self,
7283
+ full_name: str,
7284
+ *,
7285
+ include_browse: Optional[bool] = None,
7286
+ max_results: Optional[int] = None,
7287
+ page_token: Optional[str] = None) -> Iterator[ModelVersionInfo]:
7288
+ """List Model Versions.
7352
7289
 
7353
- Gets an array of the available metastores (as __MetastoreInfo__ objects). The caller must be an admin
7354
- to retrieve this info. There is no guarantee of a specific ordering of the elements in the array.
7290
+ List model versions. You can list model versions under a particular schema, or list all model versions
7291
+ in the current metastore.
7355
7292
 
7356
- :returns: Iterator over :class:`MetastoreInfo`
7357
- """
7358
-
7359
- headers = {'Accept': 'application/json', }
7360
-
7361
- json = self._api.do('GET', '/api/2.1/unity-catalog/metastores', headers=headers)
7362
- parsed = ListMetastoresResponse.from_dict(json).metastores
7363
- return parsed if parsed is not None else []
7364
-
7365
- def summary(self) -> GetMetastoreSummaryResponse:
7366
- """Get a metastore summary.
7293
+ The returned models are filtered based on the privileges of the calling user. For example, the
7294
+ metastore admin is able to list all the model versions. A regular user needs to be the owner or have
7295
+ the **EXECUTE** privilege on the parent registered model to recieve the model versions in the
7296
+ response. For the latter case, the caller must also be the owner or have the **USE_CATALOG** privilege
7297
+ on the parent catalog and the **USE_SCHEMA** privilege on the parent schema.
7367
7298
 
7368
- Gets information about a metastore. This summary includes the storage credential, the cloud vendor,
7369
- the cloud region, and the global metastore ID.
7299
+ There is no guarantee of a specific ordering of the elements in the response. The elements in the
7300
+ response will not contain any aliases or tags.
7370
7301
 
7371
- :returns: :class:`GetMetastoreSummaryResponse`
7302
+ :param full_name: str
7303
+ The full three-level name of the registered model under which to list model versions
7304
+ :param include_browse: bool (optional)
7305
+ Whether to include model versions in the response for which the principal can only access selective
7306
+ metadata for
7307
+ :param max_results: int (optional)
7308
+ Maximum number of model versions to return. If not set, the page length is set to a server
7309
+ configured value (100, as of 1/3/2024). - when set to a value greater than 0, the page length is the
7310
+ minimum of this value and a server configured value(1000, as of 1/3/2024); - when set to 0, the page
7311
+ length is set to a server configured value (100, as of 1/3/2024) (recommended); - when set to a
7312
+ value less than 0, an invalid parameter error is returned;
7313
+ :param page_token: str (optional)
7314
+ Opaque pagination token to go to next page based on previous query.
7315
+
7316
+ :returns: Iterator over :class:`ModelVersionInfo`
7372
7317
  """
7373
7318
 
7319
+ query = {}
7320
+ if include_browse is not None: query['include_browse'] = include_browse
7321
+ if max_results is not None: query['max_results'] = max_results
7322
+ if page_token is not None: query['page_token'] = page_token
7374
7323
  headers = {'Accept': 'application/json', }
7375
7324
 
7376
- res = self._api.do('GET', '/api/2.1/unity-catalog/metastore_summary', headers=headers)
7377
- return GetMetastoreSummaryResponse.from_dict(res)
7325
+ while True:
7326
+ json = self._api.do('GET',
7327
+ f'/api/2.1/unity-catalog/models/{full_name}/versions',
7328
+ query=query,
7329
+ headers=headers)
7330
+ if 'model_versions' in json:
7331
+ for v in json['model_versions']:
7332
+ yield ModelVersionInfo.from_dict(v)
7333
+ if 'next_page_token' not in json or not json['next_page_token']:
7334
+ return
7335
+ query['page_token'] = json['next_page_token']
7378
7336
 
7379
- def unassign(self, workspace_id: int, metastore_id: str):
7380
- """Delete an assignment.
7337
+ def update(self, full_name: str, version: int, *, comment: Optional[str] = None) -> ModelVersionInfo:
7338
+ """Update a Model Version.
7381
7339
 
7382
- Deletes a metastore assignment. The caller must be an account administrator.
7340
+ Updates the specified model version.
7383
7341
 
7384
- :param workspace_id: int
7385
- A workspace ID.
7386
- :param metastore_id: str
7387
- Query for the ID of the metastore to delete.
7342
+ The caller must be a metastore admin or an owner of the parent registered model. For the latter case,
7343
+ the caller must also be the owner or have the **USE_CATALOG** privilege on the parent catalog and the
7344
+ **USE_SCHEMA** privilege on the parent schema.
7345
+
7346
+ Currently only the comment of the model version can be updated.
7388
7347
 
7348
+ :param full_name: str
7349
+ The three-level (fully qualified) name of the model version
7350
+ :param version: int
7351
+ The integer version number of the model version
7352
+ :param comment: str (optional)
7353
+ The comment attached to the model version
7389
7354
 
7355
+ :returns: :class:`ModelVersionInfo`
7390
7356
  """
7357
+ body = {}
7358
+ if comment is not None: body['comment'] = comment
7359
+ headers = {'Accept': 'application/json', 'Content-Type': 'application/json', }
7391
7360
 
7392
- query = {}
7393
- if metastore_id is not None: query['metastore_id'] = metastore_id
7394
- headers = {'Accept': 'application/json', }
7361
+ res = self._api.do('PATCH',
7362
+ f'/api/2.1/unity-catalog/models/{full_name}/versions/{version}',
7363
+ body=body,
7364
+ headers=headers)
7365
+ return ModelVersionInfo.from_dict(res)
7395
7366
 
7396
- self._api.do('DELETE',
7397
- f'/api/2.1/unity-catalog/workspaces/{workspace_id}/metastore',
7398
- query=query,
7399
- headers=headers)
7400
7367
 
7401
- def update(self,
7402
- id: str,
7403
- *,
7404
- delta_sharing_organization_name: Optional[str] = None,
7405
- delta_sharing_recipient_token_lifetime_in_seconds: Optional[int] = None,
7406
- delta_sharing_scope: Optional[UpdateMetastoreDeltaSharingScope] = None,
7407
- new_name: Optional[str] = None,
7408
- owner: Optional[str] = None,
7409
- privilege_model_version: Optional[str] = None,
7410
- storage_root_credential_id: Optional[str] = None) -> MetastoreInfo:
7411
- """Update a metastore.
7368
+ class OnlineTablesAPI:
7369
+ """Online tables provide lower latency and higher QPS access to data from Delta tables."""
7370
+
7371
+ def __init__(self, api_client):
7372
+ self._api = api_client
7373
+
7374
+ def create(self, *, name: Optional[str] = None, spec: Optional[OnlineTableSpec] = None) -> OnlineTable:
7375
+ """Create an Online Table.
7412
7376
 
7413
- Updates information for a specific metastore. The caller must be a metastore admin. If the __owner__
7414
- field is set to the empty string (**""**), the ownership is updated to the System User.
7377
+ Create a new Online Table.
7415
7378
 
7416
- :param id: str
7417
- Unique ID of the metastore.
7418
- :param delta_sharing_organization_name: str (optional)
7419
- The organization name of a Delta Sharing entity, to be used in Databricks-to-Databricks Delta
7420
- Sharing as the official name.
7421
- :param delta_sharing_recipient_token_lifetime_in_seconds: int (optional)
7422
- The lifetime of delta sharing recipient token in seconds.
7423
- :param delta_sharing_scope: :class:`UpdateMetastoreDeltaSharingScope` (optional)
7424
- The scope of Delta Sharing enabled for the metastore.
7425
- :param new_name: str (optional)
7426
- New name for the metastore.
7427
- :param owner: str (optional)
7428
- The owner of the metastore.
7429
- :param privilege_model_version: str (optional)
7430
- Privilege model version of the metastore, of the form `major.minor` (e.g., `1.0`).
7431
- :param storage_root_credential_id: str (optional)
7432
- UUID of storage credential to access the metastore storage_root.
7379
+ :param name: str (optional)
7380
+ Full three-part (catalog, schema, table) name of the table.
7381
+ :param spec: :class:`OnlineTableSpec` (optional)
7382
+ Specification of the online table.
7433
7383
 
7434
- :returns: :class:`MetastoreInfo`
7384
+ :returns: :class:`OnlineTable`
7435
7385
  """
7436
7386
  body = {}
7437
- if delta_sharing_organization_name is not None:
7438
- body['delta_sharing_organization_name'] = delta_sharing_organization_name
7439
- if delta_sharing_recipient_token_lifetime_in_seconds is not None:
7440
- body[
7441
- 'delta_sharing_recipient_token_lifetime_in_seconds'] = delta_sharing_recipient_token_lifetime_in_seconds
7442
- if delta_sharing_scope is not None: body['delta_sharing_scope'] = delta_sharing_scope.value
7443
- if new_name is not None: body['new_name'] = new_name
7444
- if owner is not None: body['owner'] = owner
7445
- if privilege_model_version is not None: body['privilege_model_version'] = privilege_model_version
7446
- if storage_root_credential_id is not None:
7447
- body['storage_root_credential_id'] = storage_root_credential_id
7387
+ if name is not None: body['name'] = name
7388
+ if spec is not None: body['spec'] = spec.as_dict()
7448
7389
  headers = {'Accept': 'application/json', 'Content-Type': 'application/json', }
7449
7390
 
7450
- res = self._api.do('PATCH', f'/api/2.1/unity-catalog/metastores/{id}', body=body, headers=headers)
7451
- return MetastoreInfo.from_dict(res)
7391
+ res = self._api.do('POST', '/api/2.0/online-tables', body=body, headers=headers)
7392
+ return OnlineTable.from_dict(res)
7452
7393
 
7453
- def update_assignment(self,
7454
- workspace_id: int,
7455
- *,
7456
- default_catalog_name: Optional[str] = None,
7457
- metastore_id: Optional[str] = None):
7458
- """Update an assignment.
7394
+ def delete(self, name: str):
7395
+ """Delete an Online Table.
7459
7396
 
7460
- Updates a metastore assignment. This operation can be used to update __metastore_id__ or
7461
- __default_catalog_name__ for a specified Workspace, if the Workspace is already assigned a metastore.
7462
- The caller must be an account admin to update __metastore_id__; otherwise, the caller can be a
7463
- Workspace admin.
7397
+ Delete an online table. Warning: This will delete all the data in the online table. If the source
7398
+ Delta table was deleted or modified since this Online Table was created, this will lose the data
7399
+ forever!
7464
7400
 
7465
- :param workspace_id: int
7466
- A workspace ID.
7467
- :param default_catalog_name: str (optional)
7468
- The name of the default catalog for the metastore.
7469
- :param metastore_id: str (optional)
7470
- The unique ID of the metastore.
7401
+ :param name: str
7402
+ Full three-part (catalog, schema, table) name of the table.
7471
7403
 
7472
7404
 
7473
7405
  """
7474
- body = {}
7475
- if default_catalog_name is not None: body['default_catalog_name'] = default_catalog_name
7476
- if metastore_id is not None: body['metastore_id'] = metastore_id
7477
- headers = {'Accept': 'application/json', 'Content-Type': 'application/json', }
7478
7406
 
7479
- self._api.do('PATCH',
7480
- f'/api/2.1/unity-catalog/workspaces/{workspace_id}/metastore',
7481
- body=body,
7482
- headers=headers)
7407
+ headers = {'Accept': 'application/json', }
7483
7408
 
7409
+ self._api.do('DELETE', f'/api/2.0/online-tables/{name}', headers=headers)
7484
7410
 
7485
- class ModelVersionsAPI:
7486
- """Databricks provides a hosted version of MLflow Model Registry in Unity Catalog. Models in Unity Catalog
7487
- provide centralized access control, auditing, lineage, and discovery of ML models across Databricks
7488
- workspaces.
7411
+ def get(self, name: str) -> OnlineTable:
7412
+ """Get an Online Table.
7413
+
7414
+ Get information about an existing online table and its status.
7415
+
7416
+ :param name: str
7417
+ Full three-part (catalog, schema, table) name of the table.
7418
+
7419
+ :returns: :class:`OnlineTable`
7420
+ """
7421
+
7422
+ headers = {'Accept': 'application/json', }
7423
+
7424
+ res = self._api.do('GET', f'/api/2.0/online-tables/{name}', headers=headers)
7425
+ return OnlineTable.from_dict(res)
7426
+
7427
+
7428
+ class QualityMonitorsAPI:
7429
+ """A monitor computes and monitors data or model quality metrics for a table over time. It generates metrics
7430
+ tables and a dashboard that you can use to monitor table health and set alerts.
7489
7431
 
7490
- This API reference documents the REST endpoints for managing model versions in Unity Catalog. For more
7491
- details, see the [registered models API docs](/api/workspace/registeredmodels)."""
7432
+ Most write operations require the user to be the owner of the table (or its parent schema or parent
7433
+ catalog). Viewing the dashboard, computed metrics, or monitor configuration only requires the user to have
7434
+ **SELECT** privileges on the table (along with **USE_SCHEMA** and **USE_CATALOG**)."""
7492
7435
 
7493
7436
  def __init__(self, api_client):
7494
7437
  self._api = api_client
7495
7438
 
7496
- def delete(self, full_name: str, version: int):
7497
- """Delete a Model Version.
7439
+ def cancel_refresh(self, table_name: str, refresh_id: str):
7440
+ """Cancel refresh.
7498
7441
 
7499
- Deletes a model version from the specified registered model. Any aliases assigned to the model version
7500
- will also be deleted.
7442
+ Cancel an active monitor refresh for the given refresh ID.
7501
7443
 
7502
- The caller must be a metastore admin or an owner of the parent registered model. For the latter case,
7503
- the caller must also be the owner or have the **USE_CATALOG** privilege on the parent catalog and the
7504
- **USE_SCHEMA** privilege on the parent schema.
7444
+ The caller must either: 1. be an owner of the table's parent catalog 2. have **USE_CATALOG** on the
7445
+ table's parent catalog and be an owner of the table's parent schema 3. have the following permissions:
7446
+ - **USE_CATALOG** on the table's parent catalog - **USE_SCHEMA** on the table's parent schema - be an
7447
+ owner of the table
7505
7448
 
7506
- :param full_name: str
7507
- The three-level (fully qualified) name of the model version
7508
- :param version: int
7509
- The integer version number of the model version
7449
+ Additionally, the call must be made from the workspace where the monitor was created.
7450
+
7451
+ :param table_name: str
7452
+ Full name of the table.
7453
+ :param refresh_id: str
7454
+ ID of the refresh.
7510
7455
 
7511
7456
 
7512
7457
  """
7513
7458
 
7514
7459
  headers = {}
7515
7460
 
7516
- self._api.do('DELETE',
7517
- f'/api/2.1/unity-catalog/models/{full_name}/versions/{version}',
7461
+ self._api.do('POST',
7462
+ f'/api/2.1/unity-catalog/tables/{table_name}/monitor/refreshes/{refresh_id}/cancel',
7518
7463
  headers=headers)
7519
7464
 
7520
- def get(self,
7521
- full_name: str,
7522
- version: int,
7523
- *,
7524
- include_browse: Optional[bool] = None) -> RegisteredModelInfo:
7525
- """Get a Model Version.
7465
+ def create(self,
7466
+ table_name: str,
7467
+ assets_dir: str,
7468
+ output_schema_name: str,
7469
+ *,
7470
+ baseline_table_name: Optional[str] = None,
7471
+ custom_metrics: Optional[List[MonitorMetric]] = None,
7472
+ data_classification_config: Optional[MonitorDataClassificationConfig] = None,
7473
+ inference_log: Optional[MonitorInferenceLog] = None,
7474
+ notifications: Optional[MonitorNotifications] = None,
7475
+ schedule: Optional[MonitorCronSchedule] = None,
7476
+ skip_builtin_dashboard: Optional[bool] = None,
7477
+ slicing_exprs: Optional[List[str]] = None,
7478
+ snapshot: Optional[MonitorSnapshot] = None,
7479
+ time_series: Optional[MonitorTimeSeries] = None,
7480
+ warehouse_id: Optional[str] = None) -> MonitorInfo:
7481
+ """Create a table monitor.
7526
7482
 
7527
- Get a model version.
7483
+ Creates a new monitor for the specified table.
7528
7484
 
7529
- The caller must be a metastore admin or an owner of (or have the **EXECUTE** privilege on) the parent
7530
- registered model. For the latter case, the caller must also be the owner or have the **USE_CATALOG**
7531
- privilege on the parent catalog and the **USE_SCHEMA** privilege on the parent schema.
7485
+ The caller must either: 1. be an owner of the table's parent catalog, have **USE_SCHEMA** on the
7486
+ table's parent schema, and have **SELECT** access on the table 2. have **USE_CATALOG** on the table's
7487
+ parent catalog, be an owner of the table's parent schema, and have **SELECT** access on the table. 3.
7488
+ have the following permissions: - **USE_CATALOG** on the table's parent catalog - **USE_SCHEMA** on
7489
+ the table's parent schema - be an owner of the table.
7532
7490
 
7533
- :param full_name: str
7534
- The three-level (fully qualified) name of the model version
7535
- :param version: int
7536
- The integer version number of the model version
7537
- :param include_browse: bool (optional)
7538
- Whether to include model versions in the response for which the principal can only access selective
7539
- metadata for
7491
+ Workspace assets, such as the dashboard, will be created in the workspace where this call was made.
7540
7492
 
7541
- :returns: :class:`RegisteredModelInfo`
7493
+ :param table_name: str
7494
+ Full name of the table.
7495
+ :param assets_dir: str
7496
+ The directory to store monitoring assets (e.g. dashboard, metric tables).
7497
+ :param output_schema_name: str
7498
+ Schema where output metric tables are created.
7499
+ :param baseline_table_name: str (optional)
7500
+ Name of the baseline table from which drift metrics are computed from. Columns in the monitored
7501
+ table should also be present in the baseline table.
7502
+ :param custom_metrics: List[:class:`MonitorMetric`] (optional)
7503
+ Custom metrics to compute on the monitored table. These can be aggregate metrics, derived metrics
7504
+ (from already computed aggregate metrics), or drift metrics (comparing metrics across time windows).
7505
+ :param data_classification_config: :class:`MonitorDataClassificationConfig` (optional)
7506
+ The data classification config for the monitor.
7507
+ :param inference_log: :class:`MonitorInferenceLog` (optional)
7508
+ Configuration for monitoring inference logs.
7509
+ :param notifications: :class:`MonitorNotifications` (optional)
7510
+ The notification settings for the monitor.
7511
+ :param schedule: :class:`MonitorCronSchedule` (optional)
7512
+ The schedule for automatically updating and refreshing metric tables.
7513
+ :param skip_builtin_dashboard: bool (optional)
7514
+ Whether to skip creating a default dashboard summarizing data quality metrics.
7515
+ :param slicing_exprs: List[str] (optional)
7516
+ List of column expressions to slice data with for targeted analysis. The data is grouped by each
7517
+ expression independently, resulting in a separate slice for each predicate and its complements. For
7518
+ high-cardinality columns, only the top 100 unique values by frequency will generate slices.
7519
+ :param snapshot: :class:`MonitorSnapshot` (optional)
7520
+ Configuration for monitoring snapshot tables.
7521
+ :param time_series: :class:`MonitorTimeSeries` (optional)
7522
+ Configuration for monitoring time series tables.
7523
+ :param warehouse_id: str (optional)
7524
+ Optional argument to specify the warehouse for dashboard creation. If not specified, the first
7525
+ running warehouse will be used.
7526
+
7527
+ :returns: :class:`MonitorInfo`
7542
7528
  """
7529
+ body = {}
7530
+ if assets_dir is not None: body['assets_dir'] = assets_dir
7531
+ if baseline_table_name is not None: body['baseline_table_name'] = baseline_table_name
7532
+ if custom_metrics is not None: body['custom_metrics'] = [v.as_dict() for v in custom_metrics]
7533
+ if data_classification_config is not None:
7534
+ body['data_classification_config'] = data_classification_config.as_dict()
7535
+ if inference_log is not None: body['inference_log'] = inference_log.as_dict()
7536
+ if notifications is not None: body['notifications'] = notifications.as_dict()
7537
+ if output_schema_name is not None: body['output_schema_name'] = output_schema_name
7538
+ if schedule is not None: body['schedule'] = schedule.as_dict()
7539
+ if skip_builtin_dashboard is not None: body['skip_builtin_dashboard'] = skip_builtin_dashboard
7540
+ if slicing_exprs is not None: body['slicing_exprs'] = [v for v in slicing_exprs]
7541
+ if snapshot is not None: body['snapshot'] = snapshot.as_dict()
7542
+ if time_series is not None: body['time_series'] = time_series.as_dict()
7543
+ if warehouse_id is not None: body['warehouse_id'] = warehouse_id
7544
+ headers = {'Accept': 'application/json', 'Content-Type': 'application/json', }
7543
7545
 
7544
- query = {}
7545
- if include_browse is not None: query['include_browse'] = include_browse
7546
- headers = {'Accept': 'application/json', }
7547
-
7548
- res = self._api.do('GET',
7549
- f'/api/2.1/unity-catalog/models/{full_name}/versions/{version}',
7550
- query=query,
7546
+ res = self._api.do('POST',
7547
+ f'/api/2.1/unity-catalog/tables/{table_name}/monitor',
7548
+ body=body,
7551
7549
  headers=headers)
7552
- return RegisteredModelInfo.from_dict(res)
7550
+ return MonitorInfo.from_dict(res)
7553
7551
 
7554
- def get_by_alias(self, full_name: str, alias: str) -> ModelVersionInfo:
7555
- """Get Model Version By Alias.
7552
+ def delete(self, table_name: str):
7553
+ """Delete a table monitor.
7556
7554
 
7557
- Get a model version by alias.
7555
+ Deletes a monitor for the specified table.
7558
7556
 
7559
- The caller must be a metastore admin or an owner of (or have the **EXECUTE** privilege on) the
7560
- registered model. For the latter case, the caller must also be the owner or have the **USE_CATALOG**
7561
- privilege on the parent catalog and the **USE_SCHEMA** privilege on the parent schema.
7557
+ The caller must either: 1. be an owner of the table's parent catalog 2. have **USE_CATALOG** on the
7558
+ table's parent catalog and be an owner of the table's parent schema 3. have the following permissions:
7559
+ - **USE_CATALOG** on the table's parent catalog - **USE_SCHEMA** on the table's parent schema - be an
7560
+ owner of the table.
7561
+
7562
+ Additionally, the call must be made from the workspace where the monitor was created.
7563
+
7564
+ Note that the metric tables and dashboard will not be deleted as part of this call; those assets must
7565
+ be manually cleaned up (if desired).
7566
+
7567
+ :param table_name: str
7568
+ Full name of the table.
7562
7569
 
7563
- :param full_name: str
7564
- The three-level (fully qualified) name of the registered model
7565
- :param alias: str
7566
- The name of the alias
7567
7570
 
7568
- :returns: :class:`ModelVersionInfo`
7569
7571
  """
7570
7572
 
7571
- headers = {'Accept': 'application/json', }
7573
+ headers = {}
7572
7574
 
7573
- res = self._api.do('GET',
7574
- f'/api/2.1/unity-catalog/models/{full_name}/aliases/{alias}',
7575
- headers=headers)
7576
- return ModelVersionInfo.from_dict(res)
7575
+ self._api.do('DELETE', f'/api/2.1/unity-catalog/tables/{table_name}/monitor', headers=headers)
7577
7576
 
7578
- def list(self,
7579
- full_name: str,
7580
- *,
7581
- include_browse: Optional[bool] = None,
7582
- max_results: Optional[int] = None,
7583
- page_token: Optional[str] = None) -> Iterator[ModelVersionInfo]:
7584
- """List Model Versions.
7577
+ def get(self, table_name: str) -> MonitorInfo:
7578
+ """Get a table monitor.
7585
7579
 
7586
- List model versions. You can list model versions under a particular schema, or list all model versions
7587
- in the current metastore.
7580
+ Gets a monitor for the specified table.
7588
7581
 
7589
- The returned models are filtered based on the privileges of the calling user. For example, the
7590
- metastore admin is able to list all the model versions. A regular user needs to be the owner or have
7591
- the **EXECUTE** privilege on the parent registered model to recieve the model versions in the
7592
- response. For the latter case, the caller must also be the owner or have the **USE_CATALOG** privilege
7593
- on the parent catalog and the **USE_SCHEMA** privilege on the parent schema.
7582
+ The caller must either: 1. be an owner of the table's parent catalog 2. have **USE_CATALOG** on the
7583
+ table's parent catalog and be an owner of the table's parent schema. 3. have the following
7584
+ permissions: - **USE_CATALOG** on the table's parent catalog - **USE_SCHEMA** on the table's parent
7585
+ schema - **SELECT** privilege on the table.
7594
7586
 
7595
- There is no guarantee of a specific ordering of the elements in the response. The elements in the
7596
- response will not contain any aliases or tags.
7587
+ The returned information includes configuration values, as well as information on assets created by
7588
+ the monitor. Some information (e.g., dashboard) may be filtered out if the caller is in a different
7589
+ workspace than where the monitor was created.
7597
7590
 
7598
- :param full_name: str
7599
- The full three-level name of the registered model under which to list model versions
7600
- :param include_browse: bool (optional)
7601
- Whether to include model versions in the response for which the principal can only access selective
7602
- metadata for
7603
- :param max_results: int (optional)
7604
- Maximum number of model versions to return. If not set, the page length is set to a server
7605
- configured value (100, as of 1/3/2024). - when set to a value greater than 0, the page length is the
7606
- minimum of this value and a server configured value(1000, as of 1/3/2024); - when set to 0, the page
7607
- length is set to a server configured value (100, as of 1/3/2024) (recommended); - when set to a
7608
- value less than 0, an invalid parameter error is returned;
7609
- :param page_token: str (optional)
7610
- Opaque pagination token to go to next page based on previous query.
7591
+ :param table_name: str
7592
+ Full name of the table.
7611
7593
 
7612
- :returns: Iterator over :class:`ModelVersionInfo`
7594
+ :returns: :class:`MonitorInfo`
7613
7595
  """
7614
7596
 
7615
- query = {}
7616
- if include_browse is not None: query['include_browse'] = include_browse
7617
- if max_results is not None: query['max_results'] = max_results
7618
- if page_token is not None: query['page_token'] = page_token
7619
7597
  headers = {'Accept': 'application/json', }
7620
7598
 
7621
- while True:
7622
- json = self._api.do('GET',
7623
- f'/api/2.1/unity-catalog/models/{full_name}/versions',
7624
- query=query,
7625
- headers=headers)
7626
- if 'model_versions' in json:
7627
- for v in json['model_versions']:
7628
- yield ModelVersionInfo.from_dict(v)
7629
- if 'next_page_token' not in json or not json['next_page_token']:
7630
- return
7631
- query['page_token'] = json['next_page_token']
7599
+ res = self._api.do('GET', f'/api/2.1/unity-catalog/tables/{table_name}/monitor', headers=headers)
7600
+ return MonitorInfo.from_dict(res)
7632
7601
 
7633
- def update(self, full_name: str, version: int, *, comment: Optional[str] = None) -> ModelVersionInfo:
7634
- """Update a Model Version.
7602
+ def get_refresh(self, table_name: str, refresh_id: str) -> MonitorRefreshInfo:
7603
+ """Get refresh.
7635
7604
 
7636
- Updates the specified model version.
7605
+ Gets info about a specific monitor refresh using the given refresh ID.
7637
7606
 
7638
- The caller must be a metastore admin or an owner of the parent registered model. For the latter case,
7639
- the caller must also be the owner or have the **USE_CATALOG** privilege on the parent catalog and the
7640
- **USE_SCHEMA** privilege on the parent schema.
7607
+ The caller must either: 1. be an owner of the table's parent catalog 2. have **USE_CATALOG** on the
7608
+ table's parent catalog and be an owner of the table's parent schema 3. have the following permissions:
7609
+ - **USE_CATALOG** on the table's parent catalog - **USE_SCHEMA** on the table's parent schema -
7610
+ **SELECT** privilege on the table.
7641
7611
 
7642
- Currently only the comment of the model version can be updated.
7612
+ Additionally, the call must be made from the workspace where the monitor was created.
7643
7613
 
7644
- :param full_name: str
7645
- The three-level (fully qualified) name of the model version
7646
- :param version: int
7647
- The integer version number of the model version
7648
- :param comment: str (optional)
7649
- The comment attached to the model version
7614
+ :param table_name: str
7615
+ Full name of the table.
7616
+ :param refresh_id: str
7617
+ ID of the refresh.
7650
7618
 
7651
- :returns: :class:`ModelVersionInfo`
7619
+ :returns: :class:`MonitorRefreshInfo`
7652
7620
  """
7653
- body = {}
7654
- if comment is not None: body['comment'] = comment
7655
- headers = {'Accept': 'application/json', 'Content-Type': 'application/json', }
7656
-
7657
- res = self._api.do('PATCH',
7658
- f'/api/2.1/unity-catalog/models/{full_name}/versions/{version}',
7659
- body=body,
7660
- headers=headers)
7661
- return ModelVersionInfo.from_dict(res)
7662
-
7663
7621
 
7664
- class OnlineTablesAPI:
7665
- """Online tables provide lower latency and higher QPS access to data from Delta tables."""
7622
+ headers = {'Accept': 'application/json', }
7666
7623
 
7667
- def __init__(self, api_client):
7668
- self._api = api_client
7624
+ res = self._api.do('GET',
7625
+ f'/api/2.1/unity-catalog/tables/{table_name}/monitor/refreshes/{refresh_id}',
7626
+ headers=headers)
7627
+ return MonitorRefreshInfo.from_dict(res)
7669
7628
 
7670
- def create(self, *, name: Optional[str] = None, spec: Optional[OnlineTableSpec] = None) -> OnlineTable:
7671
- """Create an Online Table.
7629
+ def list_refreshes(self, table_name: str) -> MonitorRefreshListResponse:
7630
+ """List refreshes.
7672
7631
 
7673
- Create a new Online Table.
7632
+ Gets an array containing the history of the most recent refreshes (up to 25) for this table.
7674
7633
 
7675
- :param name: str (optional)
7676
- Full three-part (catalog, schema, table) name of the table.
7677
- :param spec: :class:`OnlineTableSpec` (optional)
7678
- Specification of the online table.
7634
+ The caller must either: 1. be an owner of the table's parent catalog 2. have **USE_CATALOG** on the
7635
+ table's parent catalog and be an owner of the table's parent schema 3. have the following permissions:
7636
+ - **USE_CATALOG** on the table's parent catalog - **USE_SCHEMA** on the table's parent schema -
7637
+ **SELECT** privilege on the table.
7679
7638
 
7680
- :returns: :class:`OnlineTable`
7639
+ Additionally, the call must be made from the workspace where the monitor was created.
7640
+
7641
+ :param table_name: str
7642
+ Full name of the table.
7643
+
7644
+ :returns: :class:`MonitorRefreshListResponse`
7681
7645
  """
7682
- body = {}
7683
- if name is not None: body['name'] = name
7684
- if spec is not None: body['spec'] = spec.as_dict()
7685
- headers = {'Accept': 'application/json', 'Content-Type': 'application/json', }
7686
7646
 
7687
- res = self._api.do('POST', '/api/2.0/online-tables', body=body, headers=headers)
7688
- return OnlineTable.from_dict(res)
7647
+ headers = {'Accept': 'application/json', }
7689
7648
 
7690
- def delete(self, name: str):
7691
- """Delete an Online Table.
7649
+ res = self._api.do('GET',
7650
+ f'/api/2.1/unity-catalog/tables/{table_name}/monitor/refreshes',
7651
+ headers=headers)
7652
+ return MonitorRefreshListResponse.from_dict(res)
7653
+
7654
+ def run_refresh(self, table_name: str) -> MonitorRefreshInfo:
7655
+ """Queue a metric refresh for a monitor.
7692
7656
 
7693
- Delete an online table. Warning: This will delete all the data in the online table. If the source
7694
- Delta table was deleted or modified since this Online Table was created, this will lose the data
7695
- forever!
7657
+ Queues a metric refresh on the monitor for the specified table. The refresh will execute in the
7658
+ background.
7696
7659
 
7697
- :param name: str
7698
- Full three-part (catalog, schema, table) name of the table.
7660
+ The caller must either: 1. be an owner of the table's parent catalog 2. have **USE_CATALOG** on the
7661
+ table's parent catalog and be an owner of the table's parent schema 3. have the following permissions:
7662
+ - **USE_CATALOG** on the table's parent catalog - **USE_SCHEMA** on the table's parent schema - be an
7663
+ owner of the table
7699
7664
 
7665
+ Additionally, the call must be made from the workspace where the monitor was created.
7666
+
7667
+ :param table_name: str
7668
+ Full name of the table.
7700
7669
 
7670
+ :returns: :class:`MonitorRefreshInfo`
7701
7671
  """
7702
7672
 
7703
7673
  headers = {'Accept': 'application/json', }
7704
7674
 
7705
- self._api.do('DELETE', f'/api/2.0/online-tables/{name}', headers=headers)
7675
+ res = self._api.do('POST',
7676
+ f'/api/2.1/unity-catalog/tables/{table_name}/monitor/refreshes',
7677
+ headers=headers)
7678
+ return MonitorRefreshInfo.from_dict(res)
7706
7679
 
7707
- def get(self, name: str) -> OnlineTable:
7708
- """Get an Online Table.
7680
+ def update(self,
7681
+ table_name: str,
7682
+ output_schema_name: str,
7683
+ *,
7684
+ baseline_table_name: Optional[str] = None,
7685
+ custom_metrics: Optional[List[MonitorMetric]] = None,
7686
+ dashboard_id: Optional[str] = None,
7687
+ data_classification_config: Optional[MonitorDataClassificationConfig] = None,
7688
+ inference_log: Optional[MonitorInferenceLog] = None,
7689
+ notifications: Optional[MonitorNotifications] = None,
7690
+ schedule: Optional[MonitorCronSchedule] = None,
7691
+ slicing_exprs: Optional[List[str]] = None,
7692
+ snapshot: Optional[MonitorSnapshot] = None,
7693
+ time_series: Optional[MonitorTimeSeries] = None) -> MonitorInfo:
7694
+ """Update a table monitor.
7709
7695
 
7710
- Get information about an existing online table and its status.
7696
+ Updates a monitor for the specified table.
7711
7697
 
7712
- :param name: str
7713
- Full three-part (catalog, schema, table) name of the table.
7698
+ The caller must either: 1. be an owner of the table's parent catalog 2. have **USE_CATALOG** on the
7699
+ table's parent catalog and be an owner of the table's parent schema 3. have the following permissions:
7700
+ - **USE_CATALOG** on the table's parent catalog - **USE_SCHEMA** on the table's parent schema - be an
7701
+ owner of the table.
7714
7702
 
7715
- :returns: :class:`OnlineTable`
7703
+ Additionally, the call must be made from the workspace where the monitor was created, and the caller
7704
+ must be the original creator of the monitor.
7705
+
7706
+ Certain configuration fields, such as output asset identifiers, cannot be updated.
7707
+
7708
+ :param table_name: str
7709
+ Full name of the table.
7710
+ :param output_schema_name: str
7711
+ Schema where output metric tables are created.
7712
+ :param baseline_table_name: str (optional)
7713
+ Name of the baseline table from which drift metrics are computed from. Columns in the monitored
7714
+ table should also be present in the baseline table.
7715
+ :param custom_metrics: List[:class:`MonitorMetric`] (optional)
7716
+ Custom metrics to compute on the monitored table. These can be aggregate metrics, derived metrics
7717
+ (from already computed aggregate metrics), or drift metrics (comparing metrics across time windows).
7718
+ :param dashboard_id: str (optional)
7719
+ Id of dashboard that visualizes the computed metrics. This can be empty if the monitor is in PENDING
7720
+ state.
7721
+ :param data_classification_config: :class:`MonitorDataClassificationConfig` (optional)
7722
+ The data classification config for the monitor.
7723
+ :param inference_log: :class:`MonitorInferenceLog` (optional)
7724
+ Configuration for monitoring inference logs.
7725
+ :param notifications: :class:`MonitorNotifications` (optional)
7726
+ The notification settings for the monitor.
7727
+ :param schedule: :class:`MonitorCronSchedule` (optional)
7728
+ The schedule for automatically updating and refreshing metric tables.
7729
+ :param slicing_exprs: List[str] (optional)
7730
+ List of column expressions to slice data with for targeted analysis. The data is grouped by each
7731
+ expression independently, resulting in a separate slice for each predicate and its complements. For
7732
+ high-cardinality columns, only the top 100 unique values by frequency will generate slices.
7733
+ :param snapshot: :class:`MonitorSnapshot` (optional)
7734
+ Configuration for monitoring snapshot tables.
7735
+ :param time_series: :class:`MonitorTimeSeries` (optional)
7736
+ Configuration for monitoring time series tables.
7737
+
7738
+ :returns: :class:`MonitorInfo`
7716
7739
  """
7740
+ body = {}
7741
+ if baseline_table_name is not None: body['baseline_table_name'] = baseline_table_name
7742
+ if custom_metrics is not None: body['custom_metrics'] = [v.as_dict() for v in custom_metrics]
7743
+ if dashboard_id is not None: body['dashboard_id'] = dashboard_id
7744
+ if data_classification_config is not None:
7745
+ body['data_classification_config'] = data_classification_config.as_dict()
7746
+ if inference_log is not None: body['inference_log'] = inference_log.as_dict()
7747
+ if notifications is not None: body['notifications'] = notifications.as_dict()
7748
+ if output_schema_name is not None: body['output_schema_name'] = output_schema_name
7749
+ if schedule is not None: body['schedule'] = schedule.as_dict()
7750
+ if slicing_exprs is not None: body['slicing_exprs'] = [v for v in slicing_exprs]
7751
+ if snapshot is not None: body['snapshot'] = snapshot.as_dict()
7752
+ if time_series is not None: body['time_series'] = time_series.as_dict()
7753
+ headers = {'Accept': 'application/json', 'Content-Type': 'application/json', }
7717
7754
 
7718
- headers = {'Accept': 'application/json', }
7719
-
7720
- res = self._api.do('GET', f'/api/2.0/online-tables/{name}', headers=headers)
7721
- return OnlineTable.from_dict(res)
7755
+ res = self._api.do('PUT',
7756
+ f'/api/2.1/unity-catalog/tables/{table_name}/monitor',
7757
+ body=body,
7758
+ headers=headers)
7759
+ return MonitorInfo.from_dict(res)
7722
7760
 
7723
7761
 
7724
7762
  class RegisteredModelsAPI:
@@ -8450,7 +8488,7 @@ class SystemSchemasAPI:
8450
8488
  def __init__(self, api_client):
8451
8489
  self._api = api_client
8452
8490
 
8453
- def disable(self, metastore_id: str, schema_name: DisableSchemaName):
8491
+ def disable(self, metastore_id: str, schema_name: str):
8454
8492
  """Disable a system schema.
8455
8493
 
8456
8494
  Disables the system schema and removes it from the system catalog. The caller must be an account admin
@@ -8458,7 +8496,7 @@ class SystemSchemasAPI:
8458
8496
 
8459
8497
  :param metastore_id: str
8460
8498
  The metastore ID under which the system schema lives.
8461
- :param schema_name: :class:`DisableSchemaName`
8499
+ :param schema_name: str
8462
8500
  Full name of the system schema.
8463
8501
 
8464
8502
 
@@ -8467,10 +8505,10 @@ class SystemSchemasAPI:
8467
8505
  headers = {'Accept': 'application/json', }
8468
8506
 
8469
8507
  self._api.do('DELETE',
8470
- f'/api/2.1/unity-catalog/metastores/{metastore_id}/systemschemas/{schema_name.value}',
8508
+ f'/api/2.1/unity-catalog/metastores/{metastore_id}/systemschemas/{schema_name}',
8471
8509
  headers=headers)
8472
8510
 
8473
- def enable(self, metastore_id: str, schema_name: EnableSchemaName):
8511
+ def enable(self, metastore_id: str, schema_name: str):
8474
8512
  """Enable a system schema.
8475
8513
 
8476
8514
  Enables the system schema and adds it to the system catalog. The caller must be an account admin or a
@@ -8478,7 +8516,7 @@ class SystemSchemasAPI:
8478
8516
 
8479
8517
  :param metastore_id: str
8480
8518
  The metastore ID under which the system schema lives.
8481
- :param schema_name: :class:`EnableSchemaName`
8519
+ :param schema_name: str
8482
8520
  Full name of the system schema.
8483
8521
 
8484
8522
 
@@ -8487,7 +8525,7 @@ class SystemSchemasAPI:
8487
8525
  headers = {'Accept': 'application/json', }
8488
8526
 
8489
8527
  self._api.do('PUT',
8490
- f'/api/2.1/unity-catalog/metastores/{metastore_id}/systemschemas/{schema_name.value}',
8528
+ f'/api/2.1/unity-catalog/metastores/{metastore_id}/systemschemas/{schema_name}',
8491
8529
  headers=headers)
8492
8530
 
8493
8531
  def list(self, metastore_id: str) -> Iterator[SystemSchemaInfo]: