From af9b8fcc018e9f86b8573a7b9ff19592a7f22bd8 Mon Sep 17 00:00:00 2001 From: Pieter Noordhuis Date: Mon, 4 Sep 2023 15:57:39 +0200 Subject: [PATCH] Release v0.8.0 (#338) * Fixed redeclared `test_streaming_response_read_partial` test ([#335](https://github.com/databricks/databricks-sdk-py/pull/335)). * Fixed `Incorrect type` warning ([#336](https://github.com/databricks/databricks-sdk-py/pull/336)). * Add notebook installation instructions ([#334](https://github.com/databricks/databricks-sdk-py/pull/334)). API Changes: * Renamed permissions APIs to no longer include the service name, for example: * `get_job_permission_levels` -> `get_permission_levels` * `get_job_permissions` -> `get_permissions` * `set_job_permissions` -> `set_permissions` * `update_job_permissions` -> `update_permissions` * Changed `create()` method for [w.volumes](https://databricks-sdk-py.readthedocs.io/en/latest/workspace/volumes.html) workspace-level service with new required argument order. * Added `supports_elastic_disk` field for `databricks.sdk.service.compute.NodeType`. * Changed `create()` method for [w.dashboards](https://databricks-sdk-py.readthedocs.io/en/latest/workspace/dashboards.html) workspace-level service with new required argument order. * Added [w.dashboard_widgets](https://databricks-sdk-py.readthedocs.io/en/latest/workspace/dashboard_widgets.html) workspace-level service. * Added [w.query_visualizations](https://databricks-sdk-py.readthedocs.io/en/latest/workspace/query_visualizations.html) workspace-level service. * Changed `name` field for `databricks.sdk.service.sql.CreateDashboardRequest` to be required. * Added `dashboard_filters_enabled` field for `databricks.sdk.service.sql.CreateDashboardRequest`. * Added `run_as_role` field for `databricks.sdk.service.sql.CreateDashboardRequest`. * Added `run_as_role` field for `databricks.sdk.service.sql.Query`. * Added `run_as_role` field for `databricks.sdk.service.sql.QueryPostContent`. * Removed `dashboard_id` field for `databricks.sdk.service.sql.WidgetOptions`. * Changed `position` field for `databricks.sdk.service.sql.WidgetOptions` to `databricks.sdk.service.sql.WidgetPosition` dataclass. * Removed `text` field for `databricks.sdk.service.sql.WidgetOptions`. * Added `description` field for `databricks.sdk.service.sql.WidgetOptions`. * Added `title` field for `databricks.sdk.service.sql.WidgetOptions`. * Added `databricks.sdk.service.sql.CreateQueryVisualizationRequest` dataclass. * Added `databricks.sdk.service.sql.CreateWidget` dataclass. * Added `databricks.sdk.service.sql.DeleteDashboardWidgetRequest` dataclass. * Added `databricks.sdk.service.sql.DeleteQueryVisualizationRequest` dataclass. * Added `databricks.sdk.service.sql.RunAsRole` dataclass. * Added `databricks.sdk.service.sql.WidgetPosition` dataclass. OpenAPI SHA: 09a7fa63d9ae243e5407941f200960ca14d48b07, Date: 2023-09-04 --- .codegen/_openapi_sha | 2 +- CHANGELOG.md | 36 +++ databricks/sdk/__init__.py | 8 +- databricks/sdk/service/billing.py | 32 +-- databricks/sdk/service/catalog.py | 8 +- databricks/sdk/service/compute.py | 35 +-- databricks/sdk/service/iam.py | 8 +- databricks/sdk/service/jobs.py | 8 +- databricks/sdk/service/ml.py | 123 +++++----- databricks/sdk/service/pipelines.py | 8 +- databricks/sdk/service/serving.py | 9 +- databricks/sdk/service/settings.py | 8 +- databricks/sdk/service/sql.py | 312 ++++++++++++++++++++++-- databricks/sdk/service/workspace.py | 57 +++-- databricks/sdk/version.py | 2 +- docs/account/log_delivery.rst | 32 +-- docs/workspace/cluster_policies.rst | 12 +- docs/workspace/clusters.rst | 8 +- docs/workspace/dashboard_widgets.rst | 52 ++++ docs/workspace/dashboards.rst | 10 +- docs/workspace/experiments.rst | 76 +++--- docs/workspace/instance_pools.rst | 8 +- docs/workspace/jobs.rst | 8 +- docs/workspace/model_registry.rst | 8 +- docs/workspace/pipelines.rst | 8 +- docs/workspace/queries.rst | 4 +- docs/workspace/query_visualizations.rst | 55 +++++ docs/workspace/repos.rst | 8 +- docs/workspace/serving_endpoints.rst | 8 +- docs/workspace/token_management.rst | 8 +- docs/workspace/users.rst | 8 +- docs/workspace/volumes.rst | 6 +- docs/workspace/warehouses.rst | 8 +- docs/workspace/workspace-sql.rst | 2 + docs/workspace/workspace.rst | 62 ++--- 35 files changed, 730 insertions(+), 317 deletions(-) create mode 100644 docs/workspace/dashboard_widgets.rst create mode 100644 docs/workspace/query_visualizations.rst diff --git a/.codegen/_openapi_sha b/.codegen/_openapi_sha index ded99bc1..b59218d3 100644 --- a/.codegen/_openapi_sha +++ b/.codegen/_openapi_sha @@ -1 +1 @@ -5d0ccbb790d341eae8e85321a685a9e9e2d5bf24 \ No newline at end of file +09a7fa63d9ae243e5407941f200960ca14d48b07 \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index c2c0fdf1..3cbd3bc9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,41 @@ # Version changelog +## 0.8.0 + +* Fixed redeclared `test_streaming_response_read_partial` test ([#335](https://github.com/databricks/databricks-sdk-py/pull/335)). +* Fixed `Incorrect type` warning ([#336](https://github.com/databricks/databricks-sdk-py/pull/336)). +* Add notebook installation instructions ([#334](https://github.com/databricks/databricks-sdk-py/pull/334)). + +API Changes: + +* Renamed permissions APIs to no longer include the service name, for example: + * `get_job_permission_levels` -> `get_permission_levels` + * `get_job_permissions` -> `get_permissions` + * `set_job_permissions` -> `set_permissions` + * `update_job_permissions` -> `update_permissions` +* Changed `create()` method for [w.volumes](https://databricks-sdk-py.readthedocs.io/en/latest/workspace/volumes.html) workspace-level service with new required argument order. +* Added `supports_elastic_disk` field for `databricks.sdk.service.compute.NodeType`. +* Changed `create()` method for [w.dashboards](https://databricks-sdk-py.readthedocs.io/en/latest/workspace/dashboards.html) workspace-level service with new required argument order. +* Added [w.dashboard_widgets](https://databricks-sdk-py.readthedocs.io/en/latest/workspace/dashboard_widgets.html) workspace-level service. +* Added [w.query_visualizations](https://databricks-sdk-py.readthedocs.io/en/latest/workspace/query_visualizations.html) workspace-level service. +* Changed `name` field for `databricks.sdk.service.sql.CreateDashboardRequest` to be required. +* Added `dashboard_filters_enabled` field for `databricks.sdk.service.sql.CreateDashboardRequest`. +* Added `run_as_role` field for `databricks.sdk.service.sql.CreateDashboardRequest`. +* Added `run_as_role` field for `databricks.sdk.service.sql.Query`. +* Added `run_as_role` field for `databricks.sdk.service.sql.QueryPostContent`. +* Removed `dashboard_id` field for `databricks.sdk.service.sql.WidgetOptions`. +* Changed `position` field for `databricks.sdk.service.sql.WidgetOptions` to `databricks.sdk.service.sql.WidgetPosition` dataclass. +* Removed `text` field for `databricks.sdk.service.sql.WidgetOptions`. +* Added `description` field for `databricks.sdk.service.sql.WidgetOptions`. +* Added `title` field for `databricks.sdk.service.sql.WidgetOptions`. +* Added `databricks.sdk.service.sql.CreateQueryVisualizationRequest` dataclass. +* Added `databricks.sdk.service.sql.CreateWidget` dataclass. +* Added `databricks.sdk.service.sql.DeleteDashboardWidgetRequest` dataclass. +* Added `databricks.sdk.service.sql.DeleteQueryVisualizationRequest` dataclass. +* Added `databricks.sdk.service.sql.RunAsRole` dataclass. +* Added `databricks.sdk.service.sql.WidgetPosition` dataclass. + +OpenAPI SHA: 09a7fa63d9ae243e5407941f200960ca14d48b07, Date: 2023-09-04 ## 0.7.1 * Improve file download performance ([#319](https://github.com/databricks/databricks-sdk-py/pull/319)). diff --git a/databricks/sdk/__init__.py b/databricks/sdk/__init__.py index 6bb37225..1004625e 100755 --- a/databricks/sdk/__init__.py +++ b/databricks/sdk/__init__.py @@ -56,8 +56,10 @@ RecipientActivationAPI, RecipientsAPI, SharesAPI) from databricks.sdk.service.sql import (AlertsAPI, DashboardsAPI, - DataSourcesAPI, DbsqlPermissionsAPI, - QueriesAPI, QueryHistoryAPI, + DashboardWidgetsAPI, DataSourcesAPI, + DbsqlPermissionsAPI, QueriesAPI, + QueryHistoryAPI, + QueryVisualizationsAPI, StatementExecutionAPI, WarehousesAPI) from databricks.sdk.service.workspace import (GitCredentialsAPI, ReposAPI, SecretsAPI, WorkspaceAPI) @@ -140,6 +142,7 @@ def __init__(self, self.command_execution = CommandExecutionAPI(self.api_client) self.connections = ConnectionsAPI(self.api_client) self.current_user = CurrentUserAPI(self.api_client) + self.dashboard_widgets = DashboardWidgetsAPI(self.api_client) self.dashboards = DashboardsAPI(self.api_client) self.data_sources = DataSourcesAPI(self.api_client) self.dbfs = DbfsExt(self.api_client) @@ -166,6 +169,7 @@ def __init__(self, self.providers = ProvidersAPI(self.api_client) self.queries = QueriesAPI(self.api_client) self.query_history = QueryHistoryAPI(self.api_client) + self.query_visualizations = QueryVisualizationsAPI(self.api_client) self.recipient_activation = RecipientActivationAPI(self.api_client) self.recipients = RecipientsAPI(self.api_client) self.registered_models = RegisteredModelsAPI(self.api_client) diff --git a/databricks/sdk/service/billing.py b/databricks/sdk/service/billing.py index f8b2f6bc..8bd2e049 100755 --- a/databricks/sdk/service/billing.py +++ b/databricks/sdk/service/billing.py @@ -556,18 +556,18 @@ class LogDeliveryAPI: status of log delivery attempts. The high-level flow of billable usage delivery: 1. **Create storage**: In AWS, [create a new AWS S3 bucket] with a specific bucket policy. Using - Databricks APIs, call the Account API to create a [storage configuration - object](#operation/create-storage-config) that uses the bucket name. 2. **Create credentials**: In AWS, - create the appropriate AWS IAM role. For full details, including the required IAM role policies and trust - relationship, see [Billable usage log delivery]. Using Databricks APIs, call the Account API to create a - [credential configuration object](#operation/create-credential-config) that uses the IAM role's ARN. 3. - **Create log delivery configuration**: Using Databricks APIs, call the Account API to [create a log - delivery configuration](#operation/create-log-delivery-config) that uses the credential and storage - configuration objects from previous steps. You can specify if the logs should include all events of that - log type in your account (_Account level_ delivery) or only events for a specific set of workspaces - (_workspace level_ delivery). Account level log delivery applies to all current and future workspaces plus - account level logs, while workspace level log delivery solely delivers logs related to the specified - workspaces. You can create multiple types of delivery configurations per account. + Databricks APIs, call the Account API to create a [storage configuration object](:method:Storage/Create) + that uses the bucket name. 2. **Create credentials**: In AWS, create the appropriate AWS IAM role. For + full details, including the required IAM role policies and trust relationship, see [Billable usage log + delivery]. Using Databricks APIs, call the Account API to create a [credential configuration + object](:method:Credentials/Create) that uses the IAM role"s ARN. 3. **Create log delivery + configuration**: Using Databricks APIs, call the Account API to [create a log delivery + configuration](:method:LogDelivery/Create) that uses the credential and storage configuration objects from + previous steps. You can specify if the logs should include all events of that log type in your account + (_Account level_ delivery) or only events for a specific set of workspaces (_workspace level_ delivery). + Account level log delivery applies to all current and future workspaces plus account level logs, while + workspace level log delivery solely delivers logs related to the specified workspaces. You can create + multiple types of delivery configurations per account. For billable usage delivery: * For more information about billable usage logs, see [Billable usage log delivery]. For the CSV schema, see the [Usage page]. * The delivery location is @@ -605,8 +605,8 @@ def create( Creates a new Databricks log delivery configuration to enable delivery of the specified type of logs to your storage location. This requires that you already created a [credential - object](#operation/create-credential-config) (which encapsulates a cross-account service IAM role) and - a [storage configuration object](#operation/create-storage-config) (which encapsulates an S3 bucket). + object](:method:Credentials/Create) (which encapsulates a cross-account service IAM role) and a + [storage configuration object](:method:Storage/Create) (which encapsulates an S3 bucket). For full details, including the required IAM role policies and bucket policies, see [Deliver and access billable usage logs] or [Configure audit logging]. @@ -619,7 +619,7 @@ def create( for no more than two delivery configurations per log type. You cannot delete a log delivery configuration, but you can disable it (see [Enable or disable log - delivery configuration](#operation/patch-log-delivery-config-status)). + delivery configuration](:method:LogDelivery/PatchStatus)). [Configure audit logging]: https://docs.databricks.com/administration-guide/account-settings/audit-logs.html [Deliver and access billable usage logs]: https://docs.databricks.com/administration-guide/account-settings/billable-usage-delivery.html @@ -692,7 +692,7 @@ def patch_status(self, status: LogDeliveryConfigStatus, log_delivery_configurati Enables or disables a log delivery configuration. Deletion of delivery configurations is not supported, so disable log delivery configurations that are no longer needed. Note that you can't re-enable a delivery configuration if this would violate the delivery configuration limits described - under [Create log delivery](#operation/create-log-delivery-config). + under [Create log delivery](:method:LogDelivery/Create). :param status: :class:`LogDeliveryConfigStatus` Status of log delivery configuration. Set to `ENABLED` (enabled) or `DISABLED` (disabled). Defaults diff --git a/databricks/sdk/service/catalog.py b/databricks/sdk/service/catalog.py index 116b4019..f9c3e8f8 100755 --- a/databricks/sdk/service/catalog.py +++ b/databricks/sdk/service/catalog.py @@ -926,8 +926,8 @@ def from_dict(cls, d: Dict[str, any]) -> 'CreateTableConstraint': @dataclass class CreateVolumeRequestContent: catalog_name: str - name: str schema_name: str + name: str volume_type: 'VolumeType' comment: Optional[str] = None storage_location: Optional[str] = None @@ -5633,8 +5633,8 @@ def __init__(self, api_client): def create(self, catalog_name: str, - name: str, schema_name: str, + name: str, volume_type: VolumeType, *, comment: Optional[str] = None, @@ -5659,10 +5659,10 @@ def create(self, :param catalog_name: str The name of the catalog where the schema and the volume are - :param name: str - The name of the volume :param schema_name: str The name of the schema where the volume is + :param name: str + The name of the volume :param volume_type: :class:`VolumeType` :param comment: str (optional) The comment attached to the volume diff --git a/databricks/sdk/service/compute.py b/databricks/sdk/service/compute.py index 42c4528e..506a7909 100755 --- a/databricks/sdk/service/compute.py +++ b/databricks/sdk/service/compute.py @@ -2812,6 +2812,7 @@ class NodeType: support_cluster_tags: Optional[bool] = None support_ebs_volumes: Optional[bool] = None support_port_forwarding: Optional[bool] = None + supports_elastic_disk: Optional[bool] = None def as_dict(self) -> dict: body = {} @@ -2837,6 +2838,7 @@ def as_dict(self) -> dict: if self.support_ebs_volumes is not None: body['support_ebs_volumes'] = self.support_ebs_volumes if self.support_port_forwarding is not None: body['support_port_forwarding'] = self.support_port_forwarding + if self.supports_elastic_disk is not None: body['supports_elastic_disk'] = self.supports_elastic_disk return body @classmethod @@ -2860,7 +2862,8 @@ def from_dict(cls, d: Dict[str, any]) -> 'NodeType': photon_worker_capable=d.get('photon_worker_capable', None), support_cluster_tags=d.get('support_cluster_tags', None), support_ebs_volumes=d.get('support_ebs_volumes', None), - support_port_forwarding=d.get('support_port_forwarding', None)) + support_port_forwarding=d.get('support_port_forwarding', None), + supports_elastic_disk=d.get('supports_elastic_disk', None)) @dataclass @@ -3560,7 +3563,7 @@ def edit(self, self._api.do('POST', '/api/2.0/policies/clusters/edit', body=body, headers=headers) def get(self, policy_id: str) -> Policy: - """Get entity. + """Get a cluster policy. Get a cluster policy entity. Creation and editing is available to admins only. @@ -3576,8 +3579,7 @@ def get(self, policy_id: str) -> Policy: res = self._api.do('GET', '/api/2.0/policies/clusters/get', query=query, headers=headers) return Policy.from_dict(res) - def get_cluster_policy_permission_levels( - self, cluster_policy_id: str) -> GetClusterPolicyPermissionLevelsResponse: + def get_permission_levels(self, cluster_policy_id: str) -> GetClusterPolicyPermissionLevelsResponse: """Get cluster policy permission levels. Gets the permission levels that a user can have on an object. @@ -3594,7 +3596,7 @@ def get_cluster_policy_permission_levels( headers=headers) return GetClusterPolicyPermissionLevelsResponse.from_dict(res) - def get_cluster_policy_permissions(self, cluster_policy_id: str) -> ClusterPolicyPermissions: + def get_permissions(self, cluster_policy_id: str) -> ClusterPolicyPermissions: """Get cluster policy permissions. Gets the permissions of a cluster policy. Cluster policies can inherit permissions from their root @@ -3616,7 +3618,7 @@ def list(self, *, sort_column: Optional[ListSortColumn] = None, sort_order: Optional[ListSortOrder] = None) -> Iterator[Policy]: - """Get a cluster policy. + """List cluster policies. Returns a list of policies accessible by the requesting user. @@ -3637,7 +3639,7 @@ def list(self, json = self._api.do('GET', '/api/2.0/policies/clusters/list', query=query, headers=headers) return [Policy.from_dict(v) for v in json.get('policies', [])] - def set_cluster_policy_permissions( + def set_permissions( self, cluster_policy_id: str, *, @@ -3663,7 +3665,7 @@ def set_cluster_policy_permissions( headers=headers) return ClusterPolicyPermissions.from_dict(res) - def update_cluster_policy_permissions( + def update_permissions( self, cluster_policy_id: str, *, @@ -4391,7 +4393,7 @@ def get(self, cluster_id: str) -> ClusterDetails: res = self._api.do('GET', '/api/2.0/clusters/get', query=query, headers=headers) return ClusterDetails.from_dict(res) - def get_cluster_permission_levels(self, cluster_id: str) -> GetClusterPermissionLevelsResponse: + def get_permission_levels(self, cluster_id: str) -> GetClusterPermissionLevelsResponse: """Get cluster permission levels. Gets the permission levels that a user can have on an object. @@ -4408,7 +4410,7 @@ def get_cluster_permission_levels(self, cluster_id: str) -> GetClusterPermission headers=headers) return GetClusterPermissionLevelsResponse.from_dict(res) - def get_cluster_permissions(self, cluster_id: str) -> ClusterPermissions: + def get_permissions(self, cluster_id: str) -> ClusterPermissions: """Get cluster permissions. Gets the permissions of a cluster. Clusters can inherit permissions from their root object. @@ -4584,7 +4586,7 @@ def restart_and_wait(self, timeout=timedelta(minutes=20)) -> ClusterDetails: return self.restart(cluster_id=cluster_id, restart_user=restart_user).result(timeout=timeout) - def set_cluster_permissions( + def set_permissions( self, cluster_id: str, *, @@ -4661,7 +4663,7 @@ def unpin(self, cluster_id: str): headers = {'Accept': 'application/json', 'Content-Type': 'application/json', } self._api.do('POST', '/api/2.0/clusters/unpin', body=body, headers=headers) - def update_cluster_permissions( + def update_permissions( self, cluster_id: str, *, @@ -5338,8 +5340,7 @@ def get(self, instance_pool_id: str) -> GetInstancePool: res = self._api.do('GET', '/api/2.0/instance-pools/get', query=query, headers=headers) return GetInstancePool.from_dict(res) - def get_instance_pool_permission_levels(self, - instance_pool_id: str) -> GetInstancePoolPermissionLevelsResponse: + def get_permission_levels(self, instance_pool_id: str) -> GetInstancePoolPermissionLevelsResponse: """Get instance pool permission levels. Gets the permission levels that a user can have on an object. @@ -5356,7 +5357,7 @@ def get_instance_pool_permission_levels(self, headers=headers) return GetInstancePoolPermissionLevelsResponse.from_dict(res) - def get_instance_pool_permissions(self, instance_pool_id: str) -> InstancePoolPermissions: + def get_permissions(self, instance_pool_id: str) -> InstancePoolPermissions: """Get instance pool permissions. Gets the permissions of an instance pool. Instance pools can inherit permissions from their root @@ -5384,7 +5385,7 @@ def list(self) -> Iterator[InstancePoolAndStats]: json = self._api.do('GET', '/api/2.0/instance-pools/list', headers=headers) return [InstancePoolAndStats.from_dict(v) for v in json.get('instance_pools', [])] - def set_instance_pool_permissions( + def set_permissions( self, instance_pool_id: str, *, @@ -5410,7 +5411,7 @@ def set_instance_pool_permissions( headers=headers) return InstancePoolPermissions.from_dict(res) - def update_instance_pool_permissions( + def update_permissions( self, instance_pool_id: str, *, diff --git a/databricks/sdk/service/iam.py b/databricks/sdk/service/iam.py index 1adece88..7ed86fa3 100755 --- a/databricks/sdk/service/iam.py +++ b/databricks/sdk/service/iam.py @@ -2285,7 +2285,7 @@ def get(self, id: str) -> User: res = self._api.do('GET', f'/api/2.0/preview/scim/v2/Users/{id}', headers=headers) return User.from_dict(res) - def get_password_permission_levels(self) -> GetPasswordPermissionLevelsResponse: + def get_permission_levels(self) -> GetPasswordPermissionLevelsResponse: """Get password permission levels. Gets the permission levels that a user can have on an object. @@ -2299,7 +2299,7 @@ def get_password_permission_levels(self) -> GetPasswordPermissionLevelsResponse: headers=headers) return GetPasswordPermissionLevelsResponse.from_dict(res) - def get_password_permissions(self) -> PasswordPermissions: + def get_permissions(self) -> PasswordPermissions: """Get password permissions. Gets the permissions of all passwords. Passwords can inherit permissions from their root object. @@ -2383,7 +2383,7 @@ def patch(self, headers = {'Accept': 'application/json', 'Content-Type': 'application/json', } self._api.do('PATCH', f'/api/2.0/preview/scim/v2/Users/{id}', body=body, headers=headers) - def set_password_permissions( + def set_permissions( self, *, access_control_list: Optional[List[PasswordAccessControlRequest]] = None) -> PasswordPermissions: @@ -2449,7 +2449,7 @@ def update(self, headers = {'Accept': 'application/json', 'Content-Type': 'application/json', } self._api.do('PUT', f'/api/2.0/preview/scim/v2/Users/{id}', body=body, headers=headers) - def update_password_permissions( + def update_permissions( self, *, access_control_list: Optional[List[PasswordAccessControlRequest]] = None) -> PasswordPermissions: diff --git a/databricks/sdk/service/jobs.py b/databricks/sdk/service/jobs.py index 895b1d9a..9a8243be 100755 --- a/databricks/sdk/service/jobs.py +++ b/databricks/sdk/service/jobs.py @@ -2969,7 +2969,7 @@ def get(self, job_id: int) -> Job: res = self._api.do('GET', '/api/2.1/jobs/get', query=query, headers=headers) return Job.from_dict(res) - def get_job_permission_levels(self, job_id: str) -> GetJobPermissionLevelsResponse: + def get_permission_levels(self, job_id: str) -> GetJobPermissionLevelsResponse: """Get job permission levels. Gets the permission levels that a user can have on an object. @@ -2984,7 +2984,7 @@ def get_job_permission_levels(self, job_id: str) -> GetJobPermissionLevelsRespon res = self._api.do('GET', f'/api/2.0/permissions/jobs/{job_id}/permissionLevels', headers=headers) return GetJobPermissionLevelsResponse.from_dict(res) - def get_job_permissions(self, job_id: str) -> JobPermissions: + def get_permissions(self, job_id: str) -> JobPermissions: """Get job permissions. Gets the permissions of a job. Jobs can inherit permissions from their root object. @@ -3487,7 +3487,7 @@ def run_now_and_wait(self, spark_submit_params=spark_submit_params, sql_params=sql_params).result(timeout=timeout) - def set_job_permissions( + def set_permissions( self, job_id: str, *, @@ -3650,7 +3650,7 @@ def update(self, headers = {'Accept': 'application/json', 'Content-Type': 'application/json', } self._api.do('POST', '/api/2.1/jobs/update', body=body, headers=headers) - def update_job_permissions( + def update_permissions( self, job_id: str, *, diff --git a/databricks/sdk/service/ml.py b/databricks/sdk/service/ml.py index 65641970..67dcbea8 100755 --- a/databricks/sdk/service/ml.py +++ b/databricks/sdk/service/ml.py @@ -2603,38 +2603,6 @@ def get_experiment(self, experiment_id: str) -> GetExperimentResponse: res = self._api.do('GET', '/api/2.0/mlflow/experiments/get', query=query, headers=headers) return GetExperimentResponse.from_dict(res) - def get_experiment_permission_levels(self, experiment_id: str) -> GetExperimentPermissionLevelsResponse: - """Get experiment permission levels. - - Gets the permission levels that a user can have on an object. - - :param experiment_id: str - The experiment for which to get or manage permissions. - - :returns: :class:`GetExperimentPermissionLevelsResponse` - """ - - headers = {'Accept': 'application/json', } - res = self._api.do('GET', - f'/api/2.0/permissions/experiments/{experiment_id}/permissionLevels', - headers=headers) - return GetExperimentPermissionLevelsResponse.from_dict(res) - - def get_experiment_permissions(self, experiment_id: str) -> ExperimentPermissions: - """Get experiment permissions. - - Gets the permissions of an experiment. Experiments can inherit permissions from their root object. - - :param experiment_id: str - The experiment for which to get or manage permissions. - - :returns: :class:`ExperimentPermissions` - """ - - headers = {'Accept': 'application/json', } - res = self._api.do('GET', f'/api/2.0/permissions/experiments/{experiment_id}', headers=headers) - return ExperimentPermissions.from_dict(res) - def get_history(self, metric_key: str, *, @@ -2680,6 +2648,38 @@ def get_history(self, return query['page_token'] = json['next_page_token'] + def get_permission_levels(self, experiment_id: str) -> GetExperimentPermissionLevelsResponse: + """Get experiment permission levels. + + Gets the permission levels that a user can have on an object. + + :param experiment_id: str + The experiment for which to get or manage permissions. + + :returns: :class:`GetExperimentPermissionLevelsResponse` + """ + + headers = {'Accept': 'application/json', } + res = self._api.do('GET', + f'/api/2.0/permissions/experiments/{experiment_id}/permissionLevels', + headers=headers) + return GetExperimentPermissionLevelsResponse.from_dict(res) + + def get_permissions(self, experiment_id: str) -> ExperimentPermissions: + """Get experiment permissions. + + Gets the permissions of an experiment. Experiments can inherit permissions from their root object. + + :param experiment_id: str + The experiment for which to get or manage permissions. + + :returns: :class:`ExperimentPermissions` + """ + + headers = {'Accept': 'application/json', } + res = self._api.do('GET', f'/api/2.0/permissions/experiments/{experiment_id}', headers=headers) + return ExperimentPermissions.from_dict(res) + def get_run(self, run_id: str, *, run_uuid: Optional[str] = None) -> GetRunResponse: """Get a run. @@ -3123,7 +3123,30 @@ def search_runs(self, return body['page_token'] = json['next_page_token'] - def set_experiment_permissions( + def set_experiment_tag(self, experiment_id: str, key: str, value: str): + """Set a tag. + + Sets a tag on an experiment. Experiment tags are metadata that can be updated. + + :param experiment_id: str + ID of the experiment under which to log the tag. Must be provided. + :param key: str + Name of the tag. Maximum size depends on storage backend. All storage backends are guaranteed to + support key values up to 250 bytes in size. + :param value: str + String value of the tag being logged. Maximum size depends on storage backend. All storage backends + are guaranteed to support key values up to 5000 bytes in size. + + + """ + body = {} + if experiment_id is not None: body['experiment_id'] = experiment_id + if key is not None: body['key'] = key + if value is not None: body['value'] = value + headers = {'Accept': 'application/json', 'Content-Type': 'application/json', } + self._api.do('POST', '/api/2.0/mlflow/experiments/set-experiment-tag', body=body, headers=headers) + + def set_permissions( self, experiment_id: str, *, @@ -3149,29 +3172,6 @@ def set_experiment_permissions( headers=headers) return ExperimentPermissions.from_dict(res) - def set_experiment_tag(self, experiment_id: str, key: str, value: str): - """Set a tag. - - Sets a tag on an experiment. Experiment tags are metadata that can be updated. - - :param experiment_id: str - ID of the experiment under which to log the tag. Must be provided. - :param key: str - Name of the tag. Maximum size depends on storage backend. All storage backends are guaranteed to - support key values up to 250 bytes in size. - :param value: str - String value of the tag being logged. Maximum size depends on storage backend. All storage backends - are guaranteed to support key values up to 5000 bytes in size. - - - """ - body = {} - if experiment_id is not None: body['experiment_id'] = experiment_id - if key is not None: body['key'] = key - if value is not None: body['value'] = value - headers = {'Accept': 'application/json', 'Content-Type': 'application/json', } - self._api.do('POST', '/api/2.0/mlflow/experiments/set-experiment-tag', body=body, headers=headers) - def set_tag(self, key: str, value: str, *, run_id: Optional[str] = None, run_uuid: Optional[str] = None): """Set a tag. @@ -3217,7 +3217,7 @@ def update_experiment(self, experiment_id: str, *, new_name: Optional[str] = Non headers = {'Accept': 'application/json', 'Content-Type': 'application/json', } self._api.do('POST', '/api/2.0/mlflow/experiments/update', body=body, headers=headers) - def update_experiment_permissions( + def update_permissions( self, experiment_id: str, *, @@ -3762,8 +3762,7 @@ def get_model_version_download_uri(self, name: str, version: str) -> GetModelVer headers=headers) return GetModelVersionDownloadUriResponse.from_dict(res) - def get_registered_model_permission_levels( - self, registered_model_id: str) -> GetRegisteredModelPermissionLevelsResponse: + def get_permission_levels(self, registered_model_id: str) -> GetRegisteredModelPermissionLevelsResponse: """Get registered model permission levels. Gets the permission levels that a user can have on an object. @@ -3780,7 +3779,7 @@ def get_registered_model_permission_levels( headers=headers) return GetRegisteredModelPermissionLevelsResponse.from_dict(res) - def get_registered_model_permissions(self, registered_model_id: str) -> RegisteredModelPermissions: + def get_permissions(self, registered_model_id: str) -> RegisteredModelPermissions: """Get registered model permissions. Gets the permissions of a registered model. Registered models can inherit permissions from their root @@ -4084,7 +4083,7 @@ def set_model_version_tag(self, name: str, version: str, key: str, value: str): headers = {'Accept': 'application/json', 'Content-Type': 'application/json', } self._api.do('POST', '/api/2.0/mlflow/model-versions/set-tag', body=body, headers=headers) - def set_registered_model_permissions( + def set_permissions( self, registered_model_id: str, *, @@ -4243,7 +4242,7 @@ def update_model_version(self, name: str, version: str, *, description: Optional headers = {'Accept': 'application/json', 'Content-Type': 'application/json', } self._api.do('PATCH', '/api/2.0/mlflow/model-versions/update', body=body, headers=headers) - def update_registered_model_permissions( + def update_permissions( self, registered_model_id: str, *, diff --git a/databricks/sdk/service/pipelines.py b/databricks/sdk/service/pipelines.py index 8fc56a1c..4c9e020e 100755 --- a/databricks/sdk/service/pipelines.py +++ b/databricks/sdk/service/pipelines.py @@ -1265,7 +1265,7 @@ def get(self, pipeline_id: str) -> GetPipelineResponse: res = self._api.do('GET', f'/api/2.0/pipelines/{pipeline_id}', headers=headers) return GetPipelineResponse.from_dict(res) - def get_pipeline_permission_levels(self, pipeline_id: str) -> GetPipelinePermissionLevelsResponse: + def get_permission_levels(self, pipeline_id: str) -> GetPipelinePermissionLevelsResponse: """Get pipeline permission levels. Gets the permission levels that a user can have on an object. @@ -1282,7 +1282,7 @@ def get_pipeline_permission_levels(self, pipeline_id: str) -> GetPipelinePermiss headers=headers) return GetPipelinePermissionLevelsResponse.from_dict(res) - def get_pipeline_permissions(self, pipeline_id: str) -> PipelinePermissions: + def get_permissions(self, pipeline_id: str) -> PipelinePermissions: """Get pipeline permissions. Gets the permissions of a pipeline. Pipelines can inherit permissions from their root object. @@ -1466,7 +1466,7 @@ def reset(self, pipeline_id: str) -> Wait[GetPipelineResponse]: def reset_and_wait(self, pipeline_id: str, timeout=timedelta(minutes=20)) -> GetPipelineResponse: return self.reset(pipeline_id=pipeline_id).result(timeout=timeout) - def set_pipeline_permissions( + def set_permissions( self, pipeline_id: str, *, @@ -1635,7 +1635,7 @@ def update(self, headers = {'Accept': 'application/json', 'Content-Type': 'application/json', } self._api.do('PUT', f'/api/2.0/pipelines/{pipeline_id}', body=body, headers=headers) - def update_pipeline_permissions( + def update_permissions( self, pipeline_id: str, *, diff --git a/databricks/sdk/service/serving.py b/databricks/sdk/service/serving.py index ab6ffe38..7731d834 100755 --- a/databricks/sdk/service/serving.py +++ b/databricks/sdk/service/serving.py @@ -727,8 +727,7 @@ def get(self, name: str) -> ServingEndpointDetailed: res = self._api.do('GET', f'/api/2.0/serving-endpoints/{name}', headers=headers) return ServingEndpointDetailed.from_dict(res) - def get_serving_endpoint_permission_levels( - self, serving_endpoint_id: str) -> GetServingEndpointPermissionLevelsResponse: + def get_permission_levels(self, serving_endpoint_id: str) -> GetServingEndpointPermissionLevelsResponse: """Get serving endpoint permission levels. Gets the permission levels that a user can have on an object. @@ -745,7 +744,7 @@ def get_serving_endpoint_permission_levels( headers=headers) return GetServingEndpointPermissionLevelsResponse.from_dict(res) - def get_serving_endpoint_permissions(self, serving_endpoint_id: str) -> ServingEndpointPermissions: + def get_permissions(self, serving_endpoint_id: str) -> ServingEndpointPermissions: """Get serving endpoint permissions. Gets the permissions of a serving endpoint. Serving endpoints can inherit permissions from their root @@ -805,7 +804,7 @@ def query(self, name: str) -> QueryEndpointResponse: res = self._api.do('POST', f'/serving-endpoints/{name}/invocations', headers=headers) return QueryEndpointResponse.from_dict(res) - def set_serving_endpoint_permissions( + def set_permissions( self, serving_endpoint_id: str, *, @@ -877,7 +876,7 @@ def update_config_and_wait( return self.update_config(name=name, served_models=served_models, traffic_config=traffic_config).result(timeout=timeout) - def update_serving_endpoint_permissions( + def update_permissions( self, serving_endpoint_id: str, *, diff --git a/databricks/sdk/service/settings.py b/databricks/sdk/service/settings.py index 9e533ef1..d422618d 100755 --- a/databricks/sdk/service/settings.py +++ b/databricks/sdk/service/settings.py @@ -1223,7 +1223,7 @@ def get(self, token_id: str) -> TokenInfo: res = self._api.do('GET', f'/api/2.0/token-management/tokens/{token_id}', headers=headers) return TokenInfo.from_dict(res) - def get_token_permission_levels(self) -> GetTokenPermissionLevelsResponse: + def get_permission_levels(self) -> GetTokenPermissionLevelsResponse: """Get token permission levels. Gets the permission levels that a user can have on an object. @@ -1237,7 +1237,7 @@ def get_token_permission_levels(self) -> GetTokenPermissionLevelsResponse: headers=headers) return GetTokenPermissionLevelsResponse.from_dict(res) - def get_token_permissions(self) -> TokenPermissions: + def get_permissions(self) -> TokenPermissions: """Get token permissions. Gets the permissions of all tokens. Tokens can inherit permissions from their root object. @@ -1272,7 +1272,7 @@ def list(self, json = self._api.do('GET', '/api/2.0/token-management/tokens', query=query, headers=headers) return [TokenInfo.from_dict(v) for v in json.get('token_infos', [])] - def set_token_permissions( + def set_permissions( self, *, access_control_list: Optional[List[TokenAccessControlRequest]] = None) -> TokenPermissions: @@ -1291,7 +1291,7 @@ def set_token_permissions( res = self._api.do('PUT', '/api/2.0/permissions/authorization/tokens', body=body, headers=headers) return TokenPermissions.from_dict(res) - def update_token_permissions( + def update_permissions( self, *, access_control_list: Optional[List[TokenAccessControlRequest]] = None) -> TokenPermissions: diff --git a/databricks/sdk/service/sql.py b/databricks/sdk/service/sql.py index c9db3f98..a61d92b2 100755 --- a/databricks/sdk/service/sql.py +++ b/databricks/sdk/service/sql.py @@ -205,6 +205,7 @@ def from_dict(cls, d: Dict[str, any]) -> 'ChannelInfo': class ChannelName(Enum): + """Name of the channel""" CHANNEL_NAME_CURRENT = 'CHANNEL_NAME_CURRENT' CHANNEL_NAME_CUSTOM = 'CHANNEL_NAME_CUSTOM' @@ -403,6 +404,35 @@ def from_dict(cls, d: Dict[str, any]) -> 'CreateWarehouseResponse': return cls(id=d.get('id', None)) +@dataclass +class CreateWidget: + dashboard_id: str + options: 'WidgetOptions' + width: int + id: Optional[str] = None + text: Optional[str] = None + visualization_id: Optional[str] = None + + def as_dict(self) -> dict: + body = {} + if self.dashboard_id is not None: body['dashboard_id'] = self.dashboard_id + if self.id is not None: body['id'] = self.id + if self.options: body['options'] = self.options.as_dict() + if self.text is not None: body['text'] = self.text + if self.visualization_id is not None: body['visualization_id'] = self.visualization_id + if self.width is not None: body['width'] = self.width + return body + + @classmethod + def from_dict(cls, d: Dict[str, any]) -> 'CreateWidget': + return cls(dashboard_id=d.get('dashboard_id', None), + id=d.get('id', None), + options=_from_dict(d, 'options', WidgetOptions), + text=d.get('text', None), + visualization_id=d.get('visualization_id', None), + width=d.get('width', None)) + + @dataclass class Dashboard: """A JSON representing a dashboard containing widgets of visualizations and text boxes.""" @@ -1310,6 +1340,7 @@ class Query: permission_tier: Optional['PermissionLevel'] = None query: Optional[str] = None query_hash: Optional[str] = None + run_as_role: Optional['RunAsRole'] = None tags: Optional['List[str]'] = None updated_at: Optional[str] = None user: Optional['User'] = None @@ -1336,6 +1367,7 @@ def as_dict(self) -> dict: if self.permission_tier is not None: body['permission_tier'] = self.permission_tier.value if self.query is not None: body['query'] = self.query if self.query_hash is not None: body['query_hash'] = self.query_hash + if self.run_as_role is not None: body['run_as_role'] = self.run_as_role.value if self.tags: body['tags'] = [v for v in self.tags] if self.updated_at is not None: body['updated_at'] = self.updated_at if self.user: body['user'] = self.user.as_dict() @@ -1363,6 +1395,7 @@ def from_dict(cls, d: Dict[str, any]) -> 'Query': permission_tier=_enum(d, 'permission_tier', PermissionLevel), query=d.get('query', None), query_hash=d.get('query_hash', None), + run_as_role=_enum(d, 'run_as_role', RunAsRole), tags=d.get('tags', None), updated_at=d.get('updated_at', None), user=_from_dict(d, 'user', User), @@ -1648,6 +1681,7 @@ class QueryPostContent: options: Optional[Any] = None parent: Optional[str] = None query: Optional[str] = None + run_as_role: Optional['RunAsRole'] = None def as_dict(self) -> dict: body = {} @@ -1657,6 +1691,7 @@ def as_dict(self) -> dict: if self.options: body['options'] = self.options if self.parent is not None: body['parent'] = self.parent if self.query is not None: body['query'] = self.query + if self.run_as_role is not None: body['run_as_role'] = self.run_as_role.value return body @classmethod @@ -1666,7 +1701,8 @@ def from_dict(cls, d: Dict[str, any]) -> 'QueryPostContent': name=d.get('name', None), options=d.get('options', None), parent=d.get('parent', None), - query=d.get('query', None)) + query=d.get('query', None), + run_as_role=_enum(d, 'run_as_role', RunAsRole)) class QueryStatementType(Enum): @@ -1813,6 +1849,13 @@ def from_dict(cls, d: Dict[str, any]) -> 'ResultSchema': return cls(column_count=d.get('column_count', None), columns=_repeated(d, 'columns', ColumnInfo)) +class RunAsRole(Enum): + """Run as role""" + + OWNER = 'owner' + VIEWER = 'viewer' + + @dataclass class ServiceError: error_code: Optional['ServiceErrorCode'] = None @@ -2416,35 +2459,64 @@ def from_dict(cls, d: Dict[str, any]) -> 'Widget': @dataclass class WidgetOptions: created_at: Optional[str] = None - dashboard_id: Optional[str] = None + description: Optional[str] = None is_hidden: Optional[bool] = None parameter_mappings: Optional[Any] = None - position: Optional[Any] = None - text: Optional[str] = None + position: Optional['WidgetPosition'] = None + title: Optional[str] = None updated_at: Optional[str] = None def as_dict(self) -> dict: body = {} if self.created_at is not None: body['created_at'] = self.created_at - if self.dashboard_id is not None: body['dashboard_id'] = self.dashboard_id + if self.description is not None: body['description'] = self.description if self.is_hidden is not None: body['isHidden'] = self.is_hidden if self.parameter_mappings: body['parameterMappings'] = self.parameter_mappings - if self.position: body['position'] = self.position - if self.text is not None: body['text'] = self.text + if self.position: body['position'] = self.position.as_dict() + if self.title is not None: body['title'] = self.title if self.updated_at is not None: body['updated_at'] = self.updated_at return body @classmethod def from_dict(cls, d: Dict[str, any]) -> 'WidgetOptions': return cls(created_at=d.get('created_at', None), - dashboard_id=d.get('dashboard_id', None), + description=d.get('description', None), is_hidden=d.get('isHidden', None), parameter_mappings=d.get('parameterMappings', None), - position=d.get('position', None), - text=d.get('text', None), + position=_from_dict(d, 'position', WidgetPosition), + title=d.get('title', None), updated_at=d.get('updated_at', None)) +@dataclass +class WidgetPosition: + """Coordinates of this widget on a dashboard. This portion of the API changes frequently and is + unsupported.""" + + auto_height: Optional[bool] = None + col: Optional[int] = None + row: Optional[int] = None + size_x: Optional[int] = None + size_y: Optional[int] = None + + def as_dict(self) -> dict: + body = {} + if self.auto_height is not None: body['autoHeight'] = self.auto_height + if self.col is not None: body['col'] = self.col + if self.row is not None: body['row'] = self.row + if self.size_x is not None: body['sizeX'] = self.size_x + if self.size_y is not None: body['sizeY'] = self.size_y + return body + + @classmethod + def from_dict(cls, d: Dict[str, any]) -> 'WidgetPosition': + return cls(auto_height=d.get('autoHeight', None), + col=d.get('col', None), + row=d.get('row', None), + size_x=d.get('sizeX', None), + size_y=d.get('sizeY', None)) + + class AlertsAPI: """The alerts API can be used to perform CRUD operations on alerts. An alert is a Databricks SQL object that periodically runs a query, evaluates a condition of its result, and notifies one or more users and/or @@ -2563,6 +2635,91 @@ def update(self, self._api.do('PUT', f'/api/2.0/preview/sql/alerts/{alert_id}', body=body, headers=headers) +class DashboardWidgetsAPI: + """This is an evolving API that facilitates the addition and removal of widgets from existing dashboards + within the Databricks Workspace. Data structures may change over time.""" + + def __init__(self, api_client): + self._api = api_client + + def create(self, + dashboard_id: str, + options: WidgetOptions, + width: int, + *, + text: Optional[str] = None, + visualization_id: Optional[str] = None) -> Widget: + """Add widget to a dashboard. + + :param dashboard_id: str + Dashboard ID returned by :method:dashboards/create. + :param options: :class:`WidgetOptions` + :param width: int + Width of a widget + :param text: str (optional) + If this is a textbox widget, the application displays this text. This field is ignored if the widget + contains a visualization in the `visualization` field. + :param visualization_id: str (optional) + Query Vizualization ID returned by :method:queryvisualizations/create. + + :returns: :class:`Widget` + """ + body = {} + if dashboard_id is not None: body['dashboard_id'] = dashboard_id + if options is not None: body['options'] = options.as_dict() + if text is not None: body['text'] = text + if visualization_id is not None: body['visualization_id'] = visualization_id + if width is not None: body['width'] = width + headers = {'Accept': 'application/json', 'Content-Type': 'application/json', } + res = self._api.do('POST', '/api/2.0/preview/sql/widgets', body=body, headers=headers) + return Widget.from_dict(res) + + def delete(self, id: str): + """Remove widget. + + :param id: str + + + """ + + headers = {'Accept': 'application/json', } + self._api.do('DELETE', f'/api/2.0/preview/sql/widgets/{id}', headers=headers) + + def update(self, + dashboard_id: str, + options: WidgetOptions, + width: int, + id: str, + *, + text: Optional[str] = None, + visualization_id: Optional[str] = None) -> Widget: + """Update existing widget. + + :param dashboard_id: str + Dashboard ID returned by :method:dashboards/create. + :param options: :class:`WidgetOptions` + :param width: int + Width of a widget + :param id: str + :param text: str (optional) + If this is a textbox widget, the application displays this text. This field is ignored if the widget + contains a visualization in the `visualization` field. + :param visualization_id: str (optional) + Query Vizualization ID returned by :method:queryvisualizations/create. + + :returns: :class:`Widget` + """ + body = {} + if dashboard_id is not None: body['dashboard_id'] = dashboard_id + if options is not None: body['options'] = options.as_dict() + if text is not None: body['text'] = text + if visualization_id is not None: body['visualization_id'] = visualization_id + if width is not None: body['width'] = width + headers = {'Accept': 'application/json', 'Content-Type': 'application/json', } + res = self._api.do('POST', f'/api/2.0/preview/sql/widgets/{id}', body=body, headers=headers) + return Widget.from_dict(res) + + class DashboardsAPI: """In general, there is little need to modify dashboards using the API. However, it can be useful to use dashboard objects to look-up a collection of related query IDs. The API can also be used to duplicate @@ -2574,28 +2731,37 @@ def __init__(self, api_client): self._api = api_client def create(self, + name: str, *, + dashboard_filters_enabled: Optional[bool] = None, is_favorite: Optional[bool] = None, - name: Optional[str] = None, parent: Optional[str] = None, + run_as_role: Optional[RunAsRole] = None, tags: Optional[List[str]] = None) -> Dashboard: """Create a dashboard object. + :param name: str + The title of this dashboard that appears in list views and at the top of the dashboard page. + :param dashboard_filters_enabled: bool (optional) + Indicates whether the dashboard filters are enabled :param is_favorite: bool (optional) Indicates whether this query object should appear in the current user's favorites list. The application uses this flag to determine whether or not the "favorite star " should selected. - :param name: str (optional) - The title of this dashboard that appears in list views and at the top of the dashboard page. :param parent: str (optional) The identifier of the workspace folder containing the object. + :param run_as_role: :class:`RunAsRole` (optional) + Run as role :param tags: List[str] (optional) :returns: :class:`Dashboard` """ body = {} + if dashboard_filters_enabled is not None: + body['dashboard_filters_enabled'] = dashboard_filters_enabled if is_favorite is not None: body['is_favorite'] = is_favorite if name is not None: body['name'] = name if parent is not None: body['parent'] = parent + if run_as_role is not None: body['run_as_role'] = run_as_role.value if tags is not None: body['tags'] = [v for v in tags] headers = {'Accept': 'application/json', 'Content-Type': 'application/json', } res = self._api.do('POST', '/api/2.0/preview/sql/dashboards', body=body, headers=headers) @@ -2820,7 +2986,8 @@ def create(self, name: Optional[str] = None, options: Optional[Any] = None, parent: Optional[str] = None, - query: Optional[str] = None) -> Query: + query: Optional[str] = None, + run_as_role: Optional[RunAsRole] = None) -> Query: """Create a new query definition. Creates a new query definition. Queries created with this endpoint belong to the authenticated user @@ -2846,6 +3013,8 @@ def create(self, The identifier of the workspace folder containing the object. :param query: str (optional) The text of the query to be run. + :param run_as_role: :class:`RunAsRole` (optional) + Run as role :returns: :class:`Query` """ @@ -2856,6 +3025,7 @@ def create(self, if options is not None: body['options'] = options if parent is not None: body['parent'] = parent if query is not None: body['query'] = query + if run_as_role is not None: body['run_as_role'] = run_as_role.value headers = {'Accept': 'application/json', 'Content-Type': 'application/json', } res = self._api.do('POST', '/api/2.0/preview/sql/queries', body=body, headers=headers) return Query.from_dict(res) @@ -3048,6 +3218,96 @@ def list(self, query['page_token'] = json['next_page_token'] +class QueryVisualizationsAPI: + """This is an evolving API that facilitates the addition and removal of vizualisations from existing queries + within the Databricks Workspace. Data structures may change over time.""" + + def __init__(self, api_client): + self._api = api_client + + def create(self, + query_id: str, + type: str, + options: Any, + *, + description: Optional[str] = None, + name: Optional[str] = None) -> Visualization: + """Add visualization to a query. + + :param query_id: str + The identifier returned by :method:queries/create + :param type: str + The type of visualization: chart, table, pivot table, and so on. + :param options: Any + The options object varies widely from one visualization type to the next and is unsupported. + Databricks does not recommend modifying visualization settings in JSON. + :param description: str (optional) + A short description of this visualization. This is not displayed in the UI. + :param name: str (optional) + The name of the visualization that appears on dashboards and the query screen. + + :returns: :class:`Visualization` + """ + body = {} + if description is not None: body['description'] = description + if name is not None: body['name'] = name + if options is not None: body['options'] = options + if query_id is not None: body['query_id'] = query_id + if type is not None: body['type'] = type + headers = {'Accept': 'application/json', 'Content-Type': 'application/json', } + res = self._api.do('POST', '/api/2.0/preview/sql/visualizations', body=body, headers=headers) + return Visualization.from_dict(res) + + def delete(self, id: str): + """Remove visualization. + + :param id: str + + + """ + + headers = {'Accept': 'application/json', } + self._api.do('DELETE', f'/api/2.0/preview/sql/visualizations/{id}', headers=headers) + + def update(self, + id: str, + *, + created_at: Optional[str] = None, + description: Optional[str] = None, + name: Optional[str] = None, + options: Optional[Any] = None, + type: Optional[str] = None, + updated_at: Optional[str] = None) -> Visualization: + """Edit existing visualization. + + :param id: str + The UUID for this visualization. + :param created_at: str (optional) + :param description: str (optional) + A short description of this visualization. This is not displayed in the UI. + :param name: str (optional) + The name of the visualization that appears on dashboards and the query screen. + :param options: Any (optional) + The options object varies widely from one visualization type to the next and is unsupported. + Databricks does not recommend modifying visualization settings in JSON. + :param type: str (optional) + The type of visualization: chart, table, pivot table, and so on. + :param updated_at: str (optional) + + :returns: :class:`Visualization` + """ + body = {} + if created_at is not None: body['created_at'] = created_at + if description is not None: body['description'] = description + if name is not None: body['name'] = name + if options is not None: body['options'] = options + if type is not None: body['type'] = type + if updated_at is not None: body['updated_at'] = updated_at + headers = {'Accept': 'application/json', 'Content-Type': 'application/json', } + res = self._api.do('POST', f'/api/2.0/preview/sql/visualizations/{id}', body=body, headers=headers) + return Visualization.from_dict(res) + + class StatementExecutionAPI: """The SQL Statement Execution API manages the execution of arbitrary SQL statements and the fetching of result data. @@ -3781,7 +4041,7 @@ def get(self, id: str) -> GetWarehouseResponse: res = self._api.do('GET', f'/api/2.0/sql/warehouses/{id}', headers=headers) return GetWarehouseResponse.from_dict(res) - def get_warehouse_permission_levels(self, warehouse_id: str) -> GetWarehousePermissionLevelsResponse: + def get_permission_levels(self, warehouse_id: str) -> GetWarehousePermissionLevelsResponse: """Get SQL warehouse permission levels. Gets the permission levels that a user can have on an object. @@ -3798,7 +4058,7 @@ def get_warehouse_permission_levels(self, warehouse_id: str) -> GetWarehousePerm headers=headers) return GetWarehousePermissionLevelsResponse.from_dict(res) - def get_warehouse_permissions(self, warehouse_id: str) -> WarehousePermissions: + def get_permissions(self, warehouse_id: str) -> WarehousePermissions: """Get SQL warehouse permissions. Gets the permissions of a SQL warehouse. SQL warehouses can inherit permissions from their root @@ -3844,11 +4104,11 @@ def list(self, *, run_as_user_id: Optional[int] = None) -> Iterator[EndpointInfo json = self._api.do('GET', '/api/2.0/sql/warehouses', query=query, headers=headers) return [EndpointInfo.from_dict(v) for v in json.get('warehouses', [])] - def set_warehouse_permissions(self, - warehouse_id: str, - *, - access_control_list: Optional[List[WarehouseAccessControlRequest]] = None - ) -> WarehousePermissions: + def set_permissions(self, + warehouse_id: str, + *, + access_control_list: Optional[List[WarehouseAccessControlRequest]] = None + ) -> WarehousePermissions: """Set SQL warehouse permissions. Sets permissions on a SQL warehouse. SQL warehouses can inherit permissions from their root object. @@ -3966,11 +4226,11 @@ def stop(self, id: str) -> Wait[GetWarehouseResponse]: def stop_and_wait(self, id: str, timeout=timedelta(minutes=20)) -> GetWarehouseResponse: return self.stop(id=id).result(timeout=timeout) - def update_warehouse_permissions(self, - warehouse_id: str, - *, - access_control_list: Optional[List[WarehouseAccessControlRequest]] = None - ) -> WarehousePermissions: + def update_permissions(self, + warehouse_id: str, + *, + access_control_list: Optional[List[WarehouseAccessControlRequest]] = None + ) -> WarehousePermissions: """Update SQL warehouse permissions. Updates the permissions on a SQL warehouse. SQL warehouses can inherit permissions from their root diff --git a/databricks/sdk/service/workspace.py b/databricks/sdk/service/workspace.py index 40cdda84..0e6a50e2 100755 --- a/databricks/sdk/service/workspace.py +++ b/databricks/sdk/service/workspace.py @@ -1146,7 +1146,7 @@ def get(self, repo_id: int) -> RepoInfo: res = self._api.do('GET', f'/api/2.0/repos/{repo_id}', headers=headers) return RepoInfo.from_dict(res) - def get_repo_permission_levels(self, repo_id: str) -> GetRepoPermissionLevelsResponse: + def get_permission_levels(self, repo_id: str) -> GetRepoPermissionLevelsResponse: """Get repo permission levels. Gets the permission levels that a user can have on an object. @@ -1161,7 +1161,7 @@ def get_repo_permission_levels(self, repo_id: str) -> GetRepoPermissionLevelsRes res = self._api.do('GET', f'/api/2.0/permissions/repos/{repo_id}/permissionLevels', headers=headers) return GetRepoPermissionLevelsResponse.from_dict(res) - def get_repo_permissions(self, repo_id: str) -> RepoPermissions: + def get_permissions(self, repo_id: str) -> RepoPermissions: """Get repo permissions. Gets the permissions of a repo. Repos can inherit permissions from their root object. @@ -1209,7 +1209,7 @@ def list(self, return query['next_page_token'] = json['next_page_token'] - def set_repo_permissions( + def set_permissions( self, repo_id: str, *, @@ -1263,7 +1263,7 @@ def update(self, headers = {'Accept': 'application/json', 'Content-Type': 'application/json', } self._api.do('PATCH', f'/api/2.0/repos/{repo_id}', body=body, headers=headers) - def update_repo_permissions( + def update_permissions( self, repo_id: str, *, @@ -1656,27 +1656,8 @@ def export(self, path: str, *, format: Optional[ExportFormat] = None) -> ExportR res = self._api.do('GET', '/api/2.0/workspace/export', query=query, headers=headers) return ExportResponse.from_dict(res) - def get_status(self, path: str) -> ObjectInfo: - """Get status. - - Gets the status of an object or a directory. If `path` does not exist, this call returns an error - `RESOURCE_DOES_NOT_EXIST`. - - :param path: str - The absolute path of the notebook or directory. - - :returns: :class:`ObjectInfo` - """ - - query = {} - if path is not None: query['path'] = path - headers = {'Accept': 'application/json', } - res = self._api.do('GET', '/api/2.0/workspace/get-status', query=query, headers=headers) - return ObjectInfo.from_dict(res) - - def get_workspace_object_permission_levels( - self, workspace_object_type: str, - workspace_object_id: str) -> GetWorkspaceObjectPermissionLevelsResponse: + def get_permission_levels(self, workspace_object_type: str, + workspace_object_id: str) -> GetWorkspaceObjectPermissionLevelsResponse: """Get workspace object permission levels. Gets the permission levels that a user can have on an object. @@ -1696,8 +1677,8 @@ def get_workspace_object_permission_levels( headers=headers) return GetWorkspaceObjectPermissionLevelsResponse.from_dict(res) - def get_workspace_object_permissions(self, workspace_object_type: str, - workspace_object_id: str) -> WorkspaceObjectPermissions: + def get_permissions(self, workspace_object_type: str, + workspace_object_id: str) -> WorkspaceObjectPermissions: """Get workspace object permissions. Gets the permissions of a workspace object. Workspace objects can inherit permissions from their @@ -1717,6 +1698,24 @@ def get_workspace_object_permissions(self, workspace_object_type: str, headers=headers) return WorkspaceObjectPermissions.from_dict(res) + def get_status(self, path: str) -> ObjectInfo: + """Get status. + + Gets the status of an object or a directory. If `path` does not exist, this call returns an error + `RESOURCE_DOES_NOT_EXIST`. + + :param path: str + The absolute path of the notebook or directory. + + :returns: :class:`ObjectInfo` + """ + + query = {} + if path is not None: query['path'] = path + headers = {'Accept': 'application/json', } + res = self._api.do('GET', '/api/2.0/workspace/get-status', query=query, headers=headers) + return ObjectInfo.from_dict(res) + def import_(self, path: str, *, @@ -1808,7 +1807,7 @@ def mkdirs(self, path: str): headers = {'Accept': 'application/json', 'Content-Type': 'application/json', } self._api.do('POST', '/api/2.0/workspace/mkdirs', body=body, headers=headers) - def set_workspace_object_permissions( + def set_permissions( self, workspace_object_type: str, workspace_object_id: str, @@ -1838,7 +1837,7 @@ def set_workspace_object_permissions( headers=headers) return WorkspaceObjectPermissions.from_dict(res) - def update_workspace_object_permissions( + def update_permissions( self, workspace_object_type: str, workspace_object_id: str, diff --git a/databricks/sdk/version.py b/databricks/sdk/version.py index f0788a87..32a90a3b 100644 --- a/databricks/sdk/version.py +++ b/databricks/sdk/version.py @@ -1 +1 @@ -__version__ = '0.7.1' +__version__ = '0.8.0' diff --git a/docs/account/log_delivery.rst b/docs/account/log_delivery.rst index 587ef5f3..a75f4275 100644 --- a/docs/account/log_delivery.rst +++ b/docs/account/log_delivery.rst @@ -12,18 +12,18 @@ Log delivery configurations status of log delivery attempts. The high-level flow of billable usage delivery: 1. **Create storage**: In AWS, [create a new AWS S3 bucket] with a specific bucket policy. Using - Databricks APIs, call the Account API to create a [storage configuration - object](#operation/create-storage-config) that uses the bucket name. 2. **Create credentials**: In AWS, - create the appropriate AWS IAM role. For full details, including the required IAM role policies and trust - relationship, see [Billable usage log delivery]. Using Databricks APIs, call the Account API to create a - [credential configuration object](#operation/create-credential-config) that uses the IAM role's ARN. 3. - **Create log delivery configuration**: Using Databricks APIs, call the Account API to [create a log - delivery configuration](#operation/create-log-delivery-config) that uses the credential and storage - configuration objects from previous steps. You can specify if the logs should include all events of that - log type in your account (_Account level_ delivery) or only events for a specific set of workspaces - (_workspace level_ delivery). Account level log delivery applies to all current and future workspaces plus - account level logs, while workspace level log delivery solely delivers logs related to the specified - workspaces. You can create multiple types of delivery configurations per account. + Databricks APIs, call the Account API to create a [storage configuration object](:method:Storage/Create) + that uses the bucket name. 2. **Create credentials**: In AWS, create the appropriate AWS IAM role. For + full details, including the required IAM role policies and trust relationship, see [Billable usage log + delivery]. Using Databricks APIs, call the Account API to create a [credential configuration + object](:method:Credentials/Create) that uses the IAM role"s ARN. 3. **Create log delivery + configuration**: Using Databricks APIs, call the Account API to [create a log delivery + configuration](:method:LogDelivery/Create) that uses the credential and storage configuration objects from + previous steps. You can specify if the logs should include all events of that log type in your account + (_Account level_ delivery) or only events for a specific set of workspaces (_workspace level_ delivery). + Account level log delivery applies to all current and future workspaces plus account level logs, while + workspace level log delivery solely delivers logs related to the specified workspaces. You can create + multiple types of delivery configurations per account. For billable usage delivery: * For more information about billable usage logs, see [Billable usage log delivery]. For the CSV schema, see the [Usage page]. * The delivery location is @@ -88,8 +88,8 @@ Log delivery configurations Creates a new Databricks log delivery configuration to enable delivery of the specified type of logs to your storage location. This requires that you already created a [credential - object](#operation/create-credential-config) (which encapsulates a cross-account service IAM role) and - a [storage configuration object](#operation/create-storage-config) (which encapsulates an S3 bucket). + object](:method:Credentials/Create) (which encapsulates a cross-account service IAM role) and a + [storage configuration object](:method:Storage/Create) (which encapsulates an S3 bucket). For full details, including the required IAM role policies and bucket policies, see [Deliver and access billable usage logs] or [Configure audit logging]. @@ -102,7 +102,7 @@ Log delivery configurations for no more than two delivery configurations per log type. You cannot delete a log delivery configuration, but you can disable it (see [Enable or disable log - delivery configuration](#operation/patch-log-delivery-config-status)). + delivery configuration](:method:LogDelivery/PatchStatus)). [Configure audit logging]: https://docs.databricks.com/administration-guide/account-settings/audit-logs.html [Deliver and access billable usage logs]: https://docs.databricks.com/administration-guide/account-settings/billable-usage-delivery.html @@ -193,7 +193,7 @@ Log delivery configurations Enables or disables a log delivery configuration. Deletion of delivery configurations is not supported, so disable log delivery configurations that are no longer needed. Note that you can't re-enable a delivery configuration if this would violate the delivery configuration limits described - under [Create log delivery](#operation/create-log-delivery-config). + under [Create log delivery](:method:LogDelivery/Create). :param status: :class:`LogDeliveryConfigStatus` Status of log delivery configuration. Set to `ENABLED` (enabled) or `DISABLED` (disabled). Defaults diff --git a/docs/workspace/cluster_policies.rst b/docs/workspace/cluster_policies.rst index 9826482a..a74163de 100644 --- a/docs/workspace/cluster_policies.rst +++ b/docs/workspace/cluster_policies.rst @@ -182,7 +182,7 @@ Cluster Policies # cleanup w.cluster_policies.delete(policy_id=created.policy_id) - Get entity. + Get a cluster policy. Get a cluster policy entity. Creation and editing is available to admins only. @@ -192,7 +192,7 @@ Cluster Policies :returns: :class:`Policy` - .. py:method:: get_cluster_policy_permission_levels(cluster_policy_id) + .. py:method:: get_permission_levels(cluster_policy_id) Get cluster policy permission levels. @@ -204,7 +204,7 @@ Cluster Policies :returns: :class:`GetClusterPolicyPermissionLevelsResponse` - .. py:method:: get_cluster_policy_permissions(cluster_policy_id) + .. py:method:: get_permissions(cluster_policy_id) Get cluster policy permissions. @@ -230,7 +230,7 @@ Cluster Policies all = w.cluster_policies.list(compute.ListClusterPoliciesRequest()) - Get a cluster policy. + List cluster policies. Returns a list of policies accessible by the requesting user. @@ -244,7 +244,7 @@ Cluster Policies :returns: Iterator over :class:`Policy` - .. py:method:: set_cluster_policy_permissions(cluster_policy_id [, access_control_list]) + .. py:method:: set_permissions(cluster_policy_id [, access_control_list]) Set cluster policy permissions. @@ -257,7 +257,7 @@ Cluster Policies :returns: :class:`ClusterPolicyPermissions` - .. py:method:: update_cluster_policy_permissions(cluster_policy_id [, access_control_list]) + .. py:method:: update_permissions(cluster_policy_id [, access_control_list]) Update cluster policy permissions. diff --git a/docs/workspace/clusters.rst b/docs/workspace/clusters.rst index 0af000eb..6b70a6b5 100644 --- a/docs/workspace/clusters.rst +++ b/docs/workspace/clusters.rst @@ -528,7 +528,7 @@ Clusters :returns: :class:`ClusterDetails` - .. py:method:: get_cluster_permission_levels(cluster_id) + .. py:method:: get_permission_levels(cluster_id) Get cluster permission levels. @@ -540,7 +540,7 @@ Clusters :returns: :class:`GetClusterPermissionLevelsResponse` - .. py:method:: get_cluster_permissions(cluster_id) + .. py:method:: get_permissions(cluster_id) Get cluster permissions. @@ -820,7 +820,7 @@ Clusters :returns: `spark_version` compatible string - .. py:method:: set_cluster_permissions(cluster_id [, access_control_list]) + .. py:method:: set_permissions(cluster_id [, access_control_list]) Set cluster permissions. @@ -927,7 +927,7 @@ Clusters - .. py:method:: update_cluster_permissions(cluster_id [, access_control_list]) + .. py:method:: update_permissions(cluster_id [, access_control_list]) Update cluster permissions. diff --git a/docs/workspace/dashboard_widgets.rst b/docs/workspace/dashboard_widgets.rst new file mode 100644 index 00000000..9363978d --- /dev/null +++ b/docs/workspace/dashboard_widgets.rst @@ -0,0 +1,52 @@ +Dashboard Widgets +================= +.. py:class:: DashboardWidgetsAPI + + This is an evolving API that facilitates the addition and removal of widgets from existing dashboards + within the Databricks Workspace. Data structures may change over time. + + .. py:method:: create(dashboard_id, options, width [, text, visualization_id]) + + Add widget to a dashboard. + + :param dashboard_id: str + Dashboard ID returned by :method:dashboards/create. + :param options: :class:`WidgetOptions` + :param width: int + Width of a widget + :param text: str (optional) + If this is a textbox widget, the application displays this text. This field is ignored if the widget + contains a visualization in the `visualization` field. + :param visualization_id: str (optional) + Query Vizualization ID returned by :method:queryvisualizations/create. + + :returns: :class:`Widget` + + + .. py:method:: delete(id) + + Remove widget. + + :param id: str + + + + + .. py:method:: update(dashboard_id, options, width, id [, text, visualization_id]) + + Update existing widget. + + :param dashboard_id: str + Dashboard ID returned by :method:dashboards/create. + :param options: :class:`WidgetOptions` + :param width: int + Width of a widget + :param id: str + :param text: str (optional) + If this is a textbox widget, the application displays this text. This field is ignored if the widget + contains a visualization in the `visualization` field. + :param visualization_id: str (optional) + Query Vizualization ID returned by :method:queryvisualizations/create. + + :returns: :class:`Widget` + \ No newline at end of file diff --git a/docs/workspace/dashboards.rst b/docs/workspace/dashboards.rst index 04852edd..9dbbb577 100644 --- a/docs/workspace/dashboards.rst +++ b/docs/workspace/dashboards.rst @@ -8,7 +8,7 @@ Dashboards to create a new one. Dashboards can be scheduled using the `sql_task` type of the Jobs API, e.g. :method:jobs/create. - .. py:method:: create( [, is_favorite, name, parent, tags]) + .. py:method:: create(name [, dashboard_filters_enabled, is_favorite, parent, run_as_role, tags]) Usage: @@ -27,13 +27,17 @@ Dashboards Create a dashboard object. + :param name: str + The title of this dashboard that appears in list views and at the top of the dashboard page. + :param dashboard_filters_enabled: bool (optional) + Indicates whether the dashboard filters are enabled :param is_favorite: bool (optional) Indicates whether this query object should appear in the current user's favorites list. The application uses this flag to determine whether or not the "favorite star " should selected. - :param name: str (optional) - The title of this dashboard that appears in list views and at the top of the dashboard page. :param parent: str (optional) The identifier of the workspace folder containing the object. + :param run_as_role: :class:`RunAsRole` (optional) + Run as role :param tags: List[str] (optional) :returns: :class:`Dashboard` diff --git a/docs/workspace/experiments.rst b/docs/workspace/experiments.rst index 7ea3b623..d824e742 100644 --- a/docs/workspace/experiments.rst +++ b/docs/workspace/experiments.rst @@ -195,30 +195,6 @@ Experiments :returns: :class:`GetExperimentResponse` - .. py:method:: get_experiment_permission_levels(experiment_id) - - Get experiment permission levels. - - Gets the permission levels that a user can have on an object. - - :param experiment_id: str - The experiment for which to get or manage permissions. - - :returns: :class:`GetExperimentPermissionLevelsResponse` - - - .. py:method:: get_experiment_permissions(experiment_id) - - Get experiment permissions. - - Gets the permissions of an experiment. Experiments can inherit permissions from their root object. - - :param experiment_id: str - The experiment for which to get or manage permissions. - - :returns: :class:`ExperimentPermissions` - - .. py:method:: get_history(metric_key [, max_results, page_token, run_id, run_uuid]) Get history of a given metric within a run. @@ -241,6 +217,30 @@ Experiments :returns: Iterator over :class:`Metric` + .. py:method:: get_permission_levels(experiment_id) + + Get experiment permission levels. + + Gets the permission levels that a user can have on an object. + + :param experiment_id: str + The experiment for which to get or manage permissions. + + :returns: :class:`GetExperimentPermissionLevelsResponse` + + + .. py:method:: get_permissions(experiment_id) + + Get experiment permissions. + + Gets the permissions of an experiment. Experiments can inherit permissions from their root object. + + :param experiment_id: str + The experiment for which to get or manage permissions. + + :returns: :class:`ExperimentPermissions` + + .. py:method:: get_run(run_id [, run_uuid]) Get a run. @@ -542,19 +542,6 @@ Experiments :returns: Iterator over :class:`Run` - .. py:method:: set_experiment_permissions(experiment_id [, access_control_list]) - - Set experiment permissions. - - Sets permissions on an experiment. Experiments can inherit permissions from their root object. - - :param experiment_id: str - The experiment for which to get or manage permissions. - :param access_control_list: List[:class:`ExperimentAccessControlRequest`] (optional) - - :returns: :class:`ExperimentPermissions` - - .. py:method:: set_experiment_tag(experiment_id, key, value) Set a tag. @@ -573,6 +560,19 @@ Experiments + .. py:method:: set_permissions(experiment_id [, access_control_list]) + + Set experiment permissions. + + Sets permissions on an experiment. Experiments can inherit permissions from their root object. + + :param experiment_id: str + The experiment for which to get or manage permissions. + :param access_control_list: List[:class:`ExperimentAccessControlRequest`] (optional) + + :returns: :class:`ExperimentPermissions` + + .. py:method:: set_tag(key, value [, run_id, run_uuid]) Set a tag. @@ -625,7 +625,7 @@ Experiments - .. py:method:: update_experiment_permissions(experiment_id [, access_control_list]) + .. py:method:: update_permissions(experiment_id [, access_control_list]) Update experiment permissions. diff --git a/docs/workspace/instance_pools.rst b/docs/workspace/instance_pools.rst index fcc64966..acfb050b 100644 --- a/docs/workspace/instance_pools.rst +++ b/docs/workspace/instance_pools.rst @@ -212,7 +212,7 @@ Instance Pools :returns: :class:`GetInstancePool` - .. py:method:: get_instance_pool_permission_levels(instance_pool_id) + .. py:method:: get_permission_levels(instance_pool_id) Get instance pool permission levels. @@ -224,7 +224,7 @@ Instance Pools :returns: :class:`GetInstancePoolPermissionLevelsResponse` - .. py:method:: get_instance_pool_permissions(instance_pool_id) + .. py:method:: get_permissions(instance_pool_id) Get instance pool permissions. @@ -256,7 +256,7 @@ Instance Pools :returns: Iterator over :class:`InstancePoolAndStats` - .. py:method:: set_instance_pool_permissions(instance_pool_id [, access_control_list]) + .. py:method:: set_permissions(instance_pool_id [, access_control_list]) Set instance pool permissions. @@ -269,7 +269,7 @@ Instance Pools :returns: :class:`InstancePoolPermissions` - .. py:method:: update_instance_pool_permissions(instance_pool_id [, access_control_list]) + .. py:method:: update_permissions(instance_pool_id [, access_control_list]) Update instance pool permissions. diff --git a/docs/workspace/jobs.rst b/docs/workspace/jobs.rst index 8323bb1d..c29c1308 100644 --- a/docs/workspace/jobs.rst +++ b/docs/workspace/jobs.rst @@ -334,7 +334,7 @@ Jobs :returns: :class:`Job` - .. py:method:: get_job_permission_levels(job_id) + .. py:method:: get_permission_levels(job_id) Get job permission levels. @@ -346,7 +346,7 @@ Jobs :returns: :class:`GetJobPermissionLevelsResponse` - .. py:method:: get_job_permissions(job_id) + .. py:method:: get_permissions(job_id) Get job permissions. @@ -828,7 +828,7 @@ Jobs See :method:wait_get_run_job_terminated_or_skipped for more details. - .. py:method:: set_job_permissions(job_id [, access_control_list]) + .. py:method:: set_permissions(job_id [, access_control_list]) Set job permissions. @@ -982,7 +982,7 @@ Jobs - .. py:method:: update_job_permissions(job_id [, access_control_list]) + .. py:method:: update_permissions(job_id [, access_control_list]) Update job permissions. diff --git a/docs/workspace/model_registry.rst b/docs/workspace/model_registry.rst index 4d2ff447..ebea5bd5 100644 --- a/docs/workspace/model_registry.rst +++ b/docs/workspace/model_registry.rst @@ -416,7 +416,7 @@ Model Registry :returns: :class:`GetModelVersionDownloadUriResponse` - .. py:method:: get_registered_model_permission_levels(registered_model_id) + .. py:method:: get_permission_levels(registered_model_id) Get registered model permission levels. @@ -428,7 +428,7 @@ Model Registry :returns: :class:`GetRegisteredModelPermissionLevelsResponse` - .. py:method:: get_registered_model_permissions(registered_model_id) + .. py:method:: get_permissions(registered_model_id) Get registered model permissions. @@ -634,7 +634,7 @@ Model Registry - .. py:method:: set_registered_model_permissions(registered_model_id [, access_control_list]) + .. py:method:: set_permissions(registered_model_id [, access_control_list]) Set registered model permissions. @@ -799,7 +799,7 @@ Model Registry - .. py:method:: update_registered_model_permissions(registered_model_id [, access_control_list]) + .. py:method:: update_permissions(registered_model_id [, access_control_list]) Update registered model permissions. diff --git a/docs/workspace/pipelines.rst b/docs/workspace/pipelines.rst index 0d9a34e2..a58e6656 100644 --- a/docs/workspace/pipelines.rst +++ b/docs/workspace/pipelines.rst @@ -144,7 +144,7 @@ Pipelines :returns: :class:`GetPipelineResponse` - .. py:method:: get_pipeline_permission_levels(pipeline_id) + .. py:method:: get_permission_levels(pipeline_id) Get pipeline permission levels. @@ -156,7 +156,7 @@ Pipelines :returns: :class:`GetPipelinePermissionLevelsResponse` - .. py:method:: get_pipeline_permissions(pipeline_id) + .. py:method:: get_permissions(pipeline_id) Get pipeline permissions. @@ -313,7 +313,7 @@ Pipelines See :method:wait_get_pipeline_running for more details. - .. py:method:: set_pipeline_permissions(pipeline_id [, access_control_list]) + .. py:method:: set_permissions(pipeline_id [, access_control_list]) Set pipeline permissions. @@ -456,7 +456,7 @@ Pipelines - .. py:method:: update_pipeline_permissions(pipeline_id [, access_control_list]) + .. py:method:: update_permissions(pipeline_id [, access_control_list]) Update pipeline permissions. diff --git a/docs/workspace/queries.rst b/docs/workspace/queries.rst index bf6e3c21..a5bf4698 100644 --- a/docs/workspace/queries.rst +++ b/docs/workspace/queries.rst @@ -6,7 +6,7 @@ Queries / Results SQL warehouse, query text, name, description, tags, parameters, and visualizations. Queries can be scheduled using the `sql_task` type of the Jobs API, e.g. :method:jobs/create. - .. py:method:: create( [, data_source_id, description, name, options, parent, query]) + .. py:method:: create( [, data_source_id, description, name, options, parent, query, run_as_role]) Usage: @@ -53,6 +53,8 @@ Queries / Results The identifier of the workspace folder containing the object. :param query: str (optional) The text of the query to be run. + :param run_as_role: :class:`RunAsRole` (optional) + Run as role :returns: :class:`Query` diff --git a/docs/workspace/query_visualizations.rst b/docs/workspace/query_visualizations.rst new file mode 100644 index 00000000..240e1f63 --- /dev/null +++ b/docs/workspace/query_visualizations.rst @@ -0,0 +1,55 @@ +Query Visualizations +==================== +.. py:class:: QueryVisualizationsAPI + + This is an evolving API that facilitates the addition and removal of vizualisations from existing queries + within the Databricks Workspace. Data structures may change over time. + + .. py:method:: create(query_id, type, options [, description, name]) + + Add visualization to a query. + + :param query_id: str + The identifier returned by :method:queries/create + :param type: str + The type of visualization: chart, table, pivot table, and so on. + :param options: Any + The options object varies widely from one visualization type to the next and is unsupported. + Databricks does not recommend modifying visualization settings in JSON. + :param description: str (optional) + A short description of this visualization. This is not displayed in the UI. + :param name: str (optional) + The name of the visualization that appears on dashboards and the query screen. + + :returns: :class:`Visualization` + + + .. py:method:: delete(id) + + Remove visualization. + + :param id: str + + + + + .. py:method:: update(id [, created_at, description, name, options, type, updated_at]) + + Edit existing visualization. + + :param id: str + The UUID for this visualization. + :param created_at: str (optional) + :param description: str (optional) + A short description of this visualization. This is not displayed in the UI. + :param name: str (optional) + The name of the visualization that appears on dashboards and the query screen. + :param options: Any (optional) + The options object varies widely from one visualization type to the next and is unsupported. + Databricks does not recommend modifying visualization settings in JSON. + :param type: str (optional) + The type of visualization: chart, table, pivot table, and so on. + :param updated_at: str (optional) + + :returns: :class:`Visualization` + \ No newline at end of file diff --git a/docs/workspace/repos.rst b/docs/workspace/repos.rst index e4d36eb9..a64a9f23 100644 --- a/docs/workspace/repos.rst +++ b/docs/workspace/repos.rst @@ -94,7 +94,7 @@ Repos :returns: :class:`RepoInfo` - .. py:method:: get_repo_permission_levels(repo_id) + .. py:method:: get_permission_levels(repo_id) Get repo permission levels. @@ -106,7 +106,7 @@ Repos :returns: :class:`GetRepoPermissionLevelsResponse` - .. py:method:: get_repo_permissions(repo_id) + .. py:method:: get_permissions(repo_id) Get repo permissions. @@ -145,7 +145,7 @@ Repos :returns: Iterator over :class:`RepoInfo` - .. py:method:: set_repo_permissions(repo_id [, access_control_list]) + .. py:method:: set_permissions(repo_id [, access_control_list]) Set repo permissions. @@ -199,7 +199,7 @@ Repos - .. py:method:: update_repo_permissions(repo_id [, access_control_list]) + .. py:method:: update_permissions(repo_id [, access_control_list]) Update repo permissions. diff --git a/docs/workspace/serving_endpoints.rst b/docs/workspace/serving_endpoints.rst index 47e5ea8a..f628967d 100644 --- a/docs/workspace/serving_endpoints.rst +++ b/docs/workspace/serving_endpoints.rst @@ -77,7 +77,7 @@ Serving endpoints :returns: :class:`ServingEndpointDetailed` - .. py:method:: get_serving_endpoint_permission_levels(serving_endpoint_id) + .. py:method:: get_permission_levels(serving_endpoint_id) Get serving endpoint permission levels. @@ -89,7 +89,7 @@ Serving endpoints :returns: :class:`GetServingEndpointPermissionLevelsResponse` - .. py:method:: get_serving_endpoint_permissions(serving_endpoint_id) + .. py:method:: get_permissions(serving_endpoint_id) Get serving endpoint permissions. @@ -133,7 +133,7 @@ Serving endpoints :returns: :class:`QueryEndpointResponse` - .. py:method:: set_serving_endpoint_permissions(serving_endpoint_id [, access_control_list]) + .. py:method:: set_permissions(serving_endpoint_id [, access_control_list]) Set serving endpoint permissions. @@ -168,7 +168,7 @@ Serving endpoints See :method:wait_get_serving_endpoint_not_updating for more details. - .. py:method:: update_serving_endpoint_permissions(serving_endpoint_id [, access_control_list]) + .. py:method:: update_permissions(serving_endpoint_id [, access_control_list]) Update serving endpoint permissions. diff --git a/docs/workspace/token_management.rst b/docs/workspace/token_management.rst index 5469bc40..38880328 100644 --- a/docs/workspace/token_management.rst +++ b/docs/workspace/token_management.rst @@ -91,7 +91,7 @@ Token management :returns: :class:`TokenInfo` - .. py:method:: get_token_permission_levels() + .. py:method:: get_permission_levels() Get token permission levels. @@ -100,7 +100,7 @@ Token management :returns: :class:`GetTokenPermissionLevelsResponse` - .. py:method:: get_token_permissions() + .. py:method:: get_permissions() Get token permissions. @@ -134,7 +134,7 @@ Token management :returns: Iterator over :class:`TokenInfo` - .. py:method:: set_token_permissions( [, access_control_list]) + .. py:method:: set_permissions( [, access_control_list]) Set token permissions. @@ -145,7 +145,7 @@ Token management :returns: :class:`TokenPermissions` - .. py:method:: update_token_permissions( [, access_control_list]) + .. py:method:: update_permissions( [, access_control_list]) Update token permissions. diff --git a/docs/workspace/users.rst b/docs/workspace/users.rst index 903f4742..287186f2 100644 --- a/docs/workspace/users.rst +++ b/docs/workspace/users.rst @@ -109,7 +109,7 @@ Users :returns: :class:`User` - .. py:method:: get_password_permission_levels() + .. py:method:: get_permission_levels() Get password permission levels. @@ -118,7 +118,7 @@ Users :returns: :class:`GetPasswordPermissionLevelsResponse` - .. py:method:: get_password_permissions() + .. py:method:: get_permissions() Get password permissions. @@ -208,7 +208,7 @@ Users - .. py:method:: set_password_permissions( [, access_control_list]) + .. py:method:: set_permissions( [, access_control_list]) Set password permissions. @@ -244,7 +244,7 @@ Users - .. py:method:: update_password_permissions( [, access_control_list]) + .. py:method:: update_permissions( [, access_control_list]) Update password permissions. diff --git a/docs/workspace/volumes.rst b/docs/workspace/volumes.rst index e22e884c..2c3e4053 100644 --- a/docs/workspace/volumes.rst +++ b/docs/workspace/volumes.rst @@ -9,7 +9,7 @@ Volumes arbitrary formats such as .whl or .txt centrally and providing secure access across workspaces to it, or transforming and querying non-tabular data files in ETL. - .. py:method:: create(catalog_name, name, schema_name, volume_type [, comment, storage_location]) + .. py:method:: create(catalog_name, schema_name, name, volume_type [, comment, storage_location]) Usage: @@ -69,10 +69,10 @@ Volumes :param catalog_name: str The name of the catalog where the schema and the volume are - :param name: str - The name of the volume :param schema_name: str The name of the schema where the volume is + :param name: str + The name of the volume :param volume_type: :class:`VolumeType` :param comment: str (optional) The comment attached to the volume diff --git a/docs/workspace/warehouses.rst b/docs/workspace/warehouses.rst index 510de4f6..b47412e7 100644 --- a/docs/workspace/warehouses.rst +++ b/docs/workspace/warehouses.rst @@ -225,7 +225,7 @@ SQL Warehouses :returns: :class:`GetWarehouseResponse` - .. py:method:: get_warehouse_permission_levels(warehouse_id) + .. py:method:: get_permission_levels(warehouse_id) Get SQL warehouse permission levels. @@ -237,7 +237,7 @@ SQL Warehouses :returns: :class:`GetWarehousePermissionLevelsResponse` - .. py:method:: get_warehouse_permissions(warehouse_id) + .. py:method:: get_permissions(warehouse_id) Get SQL warehouse permissions. @@ -283,7 +283,7 @@ SQL Warehouses :returns: Iterator over :class:`EndpointInfo` - .. py:method:: set_warehouse_permissions(warehouse_id [, access_control_list]) + .. py:method:: set_permissions(warehouse_id [, access_control_list]) Set SQL warehouse permissions. @@ -356,7 +356,7 @@ SQL Warehouses See :method:wait_get_warehouse_stopped for more details. - .. py:method:: update_warehouse_permissions(warehouse_id [, access_control_list]) + .. py:method:: update_permissions(warehouse_id [, access_control_list]) Update SQL warehouse permissions. diff --git a/docs/workspace/workspace-sql.rst b/docs/workspace/workspace-sql.rst index bd49e65d..3d1053f4 100644 --- a/docs/workspace/workspace-sql.rst +++ b/docs/workspace/workspace-sql.rst @@ -8,10 +8,12 @@ Manage Databricks SQL assets, including warehouses, dashboards, queries and quer :maxdepth: 1 alerts + dashboard_widgets dashboards data_sources dbsql_permissions queries query_history + query_visualizations statement_execution warehouses \ No newline at end of file diff --git a/docs/workspace/workspace.rst b/docs/workspace/workspace.rst index a974b5bf..967696cc 100644 --- a/docs/workspace/workspace.rst +++ b/docs/workspace/workspace.rst @@ -104,34 +104,7 @@ Workspace :returns: :class:`ExportResponse` - .. py:method:: get_status(path) - - Usage: - - .. code-block:: - - import time - - from databricks.sdk import WorkspaceClient - - w = WorkspaceClient() - - notebook_path = f'/Users/{w.current_user.me().user_name}/sdk-{time.time_ns()}' - - obj = w.workspace.get_status(path=notebook_path) - - Get status. - - Gets the status of an object or a directory. If `path` does not exist, this call returns an error - `RESOURCE_DOES_NOT_EXIST`. - - :param path: str - The absolute path of the notebook or directory. - - :returns: :class:`ObjectInfo` - - - .. py:method:: get_workspace_object_permission_levels(workspace_object_type, workspace_object_id) + .. py:method:: get_permission_levels(workspace_object_type, workspace_object_id) Get workspace object permission levels. @@ -145,7 +118,7 @@ Workspace :returns: :class:`GetWorkspaceObjectPermissionLevelsResponse` - .. py:method:: get_workspace_object_permissions(workspace_object_type, workspace_object_id) + .. py:method:: get_permissions(workspace_object_type, workspace_object_id) Get workspace object permissions. @@ -160,6 +133,33 @@ Workspace :returns: :class:`WorkspaceObjectPermissions` + .. py:method:: get_status(path) + + Usage: + + .. code-block:: + + import time + + from databricks.sdk import WorkspaceClient + + w = WorkspaceClient() + + notebook_path = f'/Users/{w.current_user.me().user_name}/sdk-{time.time_ns()}' + + obj = w.workspace.get_status(path=notebook_path) + + Get status. + + Gets the status of an object or a directory. If `path` does not exist, this call returns an error + `RESOURCE_DOES_NOT_EXIST`. + + :param path: str + The absolute path of the notebook or directory. + + :returns: :class:`ObjectInfo` + + .. py:method:: import_(path [, content, format, language, overwrite]) Usage: @@ -257,7 +257,7 @@ Workspace - .. py:method:: set_workspace_object_permissions(workspace_object_type, workspace_object_id [, access_control_list]) + .. py:method:: set_permissions(workspace_object_type, workspace_object_id [, access_control_list]) Set workspace object permissions. @@ -273,7 +273,7 @@ Workspace :returns: :class:`WorkspaceObjectPermissions` - .. py:method:: update_workspace_object_permissions(workspace_object_type, workspace_object_id [, access_control_list]) + .. py:method:: update_permissions(workspace_object_type, workspace_object_id [, access_control_list]) Update workspace object permissions.