workspace
Creates, updates, deletes, gets or lists a workspace resource.
Overview
| Name | workspace |
| Type | Resource |
| Id | databricks_workspace.workspace.workspace |
Fields
The following fields are returned by SELECT queries:
- list
| Name | Datatype | Description |
|---|---|---|
object_id | integer | Unique identifier for the object. |
resource_id | string | A unique identifier for the object that is consistent across all Databricks APIs. |
created_at | integer | Only applicable to files. The creation UTC timestamp. |
language | string | The language of the object. This value is set only if the object type is ``NOTEBOOK``. (PYTHON, R, SCALA, SQL) |
modified_at | integer | Only applicable to files, the last modified UTC timestamp. |
object_type | string | The type of the object in workspace. - `NOTEBOOK`: document that contains runnable code, visualizations, and explanatory text. - `DIRECTORY`: directory - `LIBRARY`: library - `FILE`: file - `REPO`: repository - `DASHBOARD`: Lakeview dashboard (DASHBOARD, DIRECTORY, FILE, LIBRARY, NOTEBOOK, REPO) |
path | string | The absolute path of the object. |
size | integer | Only applicable to files. The file size in bytes can be returned. |
Methods
The following methods are available for this resource:
| Name | Accessible by | Required Params | Optional Params | Description |
|---|---|---|---|---|
list | select | path, deployment_name | notebooks_modified_after | Lists the contents of a directory, or the object if it is not a directory. If the input path does not |
delete | exec | deployment_name, path | Deletes an object or a directory (and optionally recursively deletes all objects in the directory). * | |
export | exec | path, deployment_name | format | Exports an object or the contents of an entire directory. |
import | exec | deployment_name, path | Imports a workspace object (for example, a notebook or file) or the contents of an entire directory. | |
mkdirs | exec | deployment_name, path | Creates the specified directory (and necessary parent directories if they do not exist). If there is |
Parameters
Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.
| Name | Datatype | Description |
|---|---|---|
deployment_name | string | The Databricks Workspace Deployment Name (default: dbc-abcd0123-a1bc) |
path | string | The absolute path of the object or directory. Exporting a directory is only supported for the DBC, SOURCE, and AUTO format. |
format | string | This specifies the format of the exported file. By default, this is SOURCE. The value is case sensitive. - SOURCE: The notebook is exported as source code. Directory exports will not include non-notebook entries. - HTML: The notebook is exported as an HTML file. - JUPYTER: The notebook is exported as a Jupyter/IPython Notebook file. - DBC: The notebook is exported in Databricks archive format. Directory exports will not include non-notebook entries. - R_MARKDOWN: The notebook is exported to R Markdown format. - AUTO: The object or directory is exported depending on the objects type. Directory exports will include notebooks and workspace files. |
notebooks_modified_after | integer | UTC timestamp in milliseconds |
SELECT examples
- list
Lists the contents of a directory, or the object if it is not a directory. If the input path does not
SELECT
object_id,
resource_id,
created_at,
language,
modified_at,
object_type,
path,
size
FROM databricks_workspace.workspace.workspace
WHERE path = '{{ path }}' -- required
AND deployment_name = '{{ deployment_name }}' -- required
AND notebooks_modified_after = '{{ notebooks_modified_after }}'
;
Lifecycle Methods
- delete
- export
- import
- mkdirs
Deletes an object or a directory (and optionally recursively deletes all objects in the directory). *
EXEC databricks_workspace.workspace.workspace.delete
@deployment_name='{{ deployment_name }}' --required
@@json=
'{
"path": "{{ path }}",
"recursive": {{ recursive }}
}'
;
Exports an object or the contents of an entire directory.
EXEC databricks_workspace.workspace.workspace.export
@path='{{ path }}' --required,
@deployment_name='{{ deployment_name }}' --required,
@format='{{ format }}'
;
Imports a workspace object (for example, a notebook or file) or the contents of an entire directory.
EXEC databricks_workspace.workspace.workspace.import
@deployment_name='{{ deployment_name }}' --required
@@json=
'{
"path": "{{ path }}",
"content": "{{ content }}",
"format": "{{ format }}",
"language": "{{ language }}",
"overwrite": {{ overwrite }}
}'
;
Creates the specified directory (and necessary parent directories if they do not exist). If there is
EXEC databricks_workspace.workspace.workspace.mkdirs
@deployment_name='{{ deployment_name }}' --required
@@json=
'{
"path": "{{ path }}"
}'
;