Attributes¶
brickflow_plugins.databricks.box_operator.formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
module-attribute
¶
brickflow_plugins.databricks.box_operator.logger = logging.getLogger('Box Operator')
module-attribute
¶
brickflow_plugins.databricks.box_operator.stream_handler = logging.StreamHandler()
module-attribute
¶
Classes¶
brickflow_plugins.databricks.box_operator.BoxAuthenticator(**kwargs)
¶
A base class that provides methods for authenticating to Box.
Initialize the BoxAuthenticator with the given parameters.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
secret_scope |
str
|
The scope for secret management. |
required |
cerberus_client_url |
str
|
The URL for Cerberus client. |
required |
Source code in brickflow_plugins/databricks/box_operator.py
Attributes¶
cerberus_client_url = kwargs.get('cerberus_client_url')
instance-attribute
¶
client = self.box_authentication()
instance-attribute
¶
logger = logger
instance-attribute
¶
secret_scope = kwargs.get('secret_scope')
instance-attribute
¶
Functions¶
box_authentication()
¶
Authenticate with Box using JWT authentication.
Returns:
Name | Type | Description |
---|---|---|
Client |
An authenticated Box client. |
Source code in brickflow_plugins/databricks/box_operator.py
get_box_cerberus_dtl(secret_scope, cerberus_client_url)
¶
Get credentials from Cerberus.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
secret_scope |
str
|
The scope for secret management. |
required |
cerberus_client_url |
str
|
The URL for Cerberus client. |
required |
Returns:
Name | Type | Description |
---|---|---|
dict |
A dictionary containing Box authentication details. |
Source code in brickflow_plugins/databricks/box_operator.py
get_box_connection(secret_scope, cerberus_client_url)
¶
Get connection details for Box authentication.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
secret_scope |
str
|
The scope for secret management. |
required |
cerberus_client_url |
str
|
The URL for Cerberus client. |
required |
Returns:
Name | Type | Description |
---|---|---|
dict |
A dictionary containing Box authentication details. |
Raises:
Type | Description |
---|---|
BoxOperatorException
|
If credentials cannot be retrieved. |
Source code in brickflow_plugins/databricks/box_operator.py
get_box_dbutils_dtl(secret_scope)
¶
Get credentials from dbutils.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
secret_scope |
str
|
The scope for secret management. |
required |
Returns:
Name | Type | Description |
---|---|---|
dict |
A dictionary containing Box authentication details. |
Source code in brickflow_plugins/databricks/box_operator.py
brickflow_plugins.databricks.box_operator.BoxOperator(**kwargs)
¶
Bases: BoxAuthenticator
A class that provides methods for authenticating, downloading, and uploading to Box.
Initialize the BoxOperator with the given parameters.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
folder_id |
str
|
The ID of the Box folder. |
required |
volume_path |
str
|
The local volume path. |
required |
file_names |
list
|
List of file names to download/upload. |
required |
file_id |
str
|
The ID of a specific file to download. |
required |
file_pattern |
str
|
The pattern to match file names. |
required |
operation |
str
|
The operation to perform ('download' or 'upload'). |
required |
Source code in brickflow_plugins/databricks/box_operator.py
Attributes¶
file_id = kwargs.get('file_id')
instance-attribute
¶
file_names = kwargs.get('file_names', [])
instance-attribute
¶
file_pattern = kwargs.get('file_pattern')
instance-attribute
¶
folder_id = kwargs.get('folder_id')
instance-attribute
¶
operation = kwargs.get('operation')
instance-attribute
¶
volume_path = kwargs.get('volume_path')
instance-attribute
¶
Functions¶
execute()
¶
Execute the specified operation ('download' or 'upload').
Raises:
Type | Description |
---|---|
ValueError
|
If the operation is invalid. |
BoxOperatorException
|
If the operation fails. |
Source code in brickflow_plugins/databricks/box_operator.py
brickflow_plugins.databricks.box_operator.BoxOperatorException
¶
Bases: Exception
Custom exception class for Box Operator errors.
brickflow_plugins.databricks.box_operator.BoxOperatorTimeOutException
¶
Bases: TimeoutError
Custom exception class for Box Operator timeouts.
brickflow_plugins.databricks.box_operator.BoxToVolumesOperator(**kwargs)
¶
Bases: BoxAuthenticator
A class that provides methods to download files from a Box folder to a local volume.
Initialize the BoxToVolumesOperator with the given parameters.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
folder_id |
str
|
The ID of the Box folder. |
required |
volume_path |
str
|
The local volume path. |
required |
file_names |
list
|
List of file names to download. |
required |
file_id |
str
|
The ID of a specific file to download. |
required |
file_pattern |
str
|
The pattern to match file names. |
required |
Source code in brickflow_plugins/databricks/box_operator.py
Attributes¶
downloaded_files = []
instance-attribute
¶
file_id = kwargs.get('file_id')
instance-attribute
¶
file_names = kwargs.get('file_names', [])
instance-attribute
¶
file_pattern = kwargs.get('file_pattern')
instance-attribute
¶
folder_id = kwargs.get('folder_id')
instance-attribute
¶
volume_path = kwargs.get('volume_path')
instance-attribute
¶
Functions¶
download_file(item, volume_path)
¶
Download a file from Box to a local volume.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
item |
Item
|
The Box item to download. |
required |
volume_path |
str
|
The local volume path. |
required |
Source code in brickflow_plugins/databricks/box_operator.py
download_folder(folder_id, volume_path)
¶
Download the contents of a Box folder, including subfolders, to a local volume.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
folder_id |
str
|
The ID of the Box folder. |
required |
volume_path |
str
|
The local volume path. |
required |
Source code in brickflow_plugins/databricks/box_operator.py
execute()
¶
Download files from a Box folder to a local volume based on the specified criteria.
Source code in brickflow_plugins/databricks/box_operator.py
get_items(folder_id)
¶
Retrieve items from a Box folder.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
folder_id |
str
|
The ID of the Box folder. |
required |
Returns:
Name | Type | Description |
---|---|---|
list |
A list of items in the Box folder. |
Source code in brickflow_plugins/databricks/box_operator.py
brickflow_plugins.databricks.box_operator.VolumesToBoxOperator(**kwargs)
¶
Bases: BoxAuthenticator
A class for uploading files from a local volume to a Box folder.
Initialize the VolumesToBoxOperator with the given parameters.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
folder_id |
str
|
The ID of the Box folder. |
required |
volume_path |
str
|
The local volume path. |
required |
file_names |
list
|
List of file names to upload. |
required |
file_pattern |
str
|
The pattern to match file names. |
required |
Source code in brickflow_plugins/databricks/box_operator.py
Attributes¶
file_names = kwargs.get('file_names', [])
instance-attribute
¶
file_pattern = kwargs.get('file_pattern')
instance-attribute
¶
folder_id = kwargs.get('folder_id')
instance-attribute
¶
uploaded_files = []
instance-attribute
¶
volume_path = kwargs.get('volume_path')
instance-attribute
¶
Functions¶
create_folder(parent_folder_id, folder_name)
¶
Create a folder in Box.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
parent_folder_id |
str
|
The ID of the parent Box folder. |
required |
folder_name |
str
|
The name of the new folder. |
required |
Returns:
Name | Type | Description |
---|---|---|
str |
The ID of the created folder. |
Source code in brickflow_plugins/databricks/box_operator.py
execute()
¶
Upload files from a local volume to a Box folder.
Source code in brickflow_plugins/databricks/box_operator.py
get_existing_file_id(folder_id, file_name)
¶
Get the ID of an existing file in a Box folder.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
folder_id |
str
|
The ID of the Box folder. |
required |
file_name |
str
|
The name of the file. |
required |
Returns:
Name | Type | Description |
---|---|---|
str |
The ID of the existing file, or None if not found. |
Source code in brickflow_plugins/databricks/box_operator.py
get_existing_folder_id(parent_folder_id, folder_name)
¶
Get the ID of an existing folder in a Box folder.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
parent_folder_id |
str
|
The ID of the parent Box folder. |
required |
folder_name |
str
|
The name of the folder. |
required |
Returns:
Name | Type | Description |
---|---|---|
str |
The ID of the existing folder, or None if not found. |
Source code in brickflow_plugins/databricks/box_operator.py
update_file(file_id, file_path)
¶
Update the contents of a file in a Box folder.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
file_id |
str
|
The ID of the file in Box. |
required |
file_path |
str
|
The local file path. |
required |
Source code in brickflow_plugins/databricks/box_operator.py
upload_file(folder_id, file_path)
¶
Upload a file to a Box folder.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
folder_id |
str
|
The ID of the Box folder. |
required |
file_path |
str
|
The local file path. |
required |
Source code in brickflow_plugins/databricks/box_operator.py
upload_folder(parent_folder_id, local_folder_path)
¶
Upload the contents of a local folder to a Box folder recursively.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
parent_folder_id |
str
|
The ID of the parent Box folder. |
required |
local_folder_path |
str
|
The local folder path. |
required |