robocorp-storage

module robocorp.storage

Source: __init__.py:0


function list_assets

Source: __init__.py:45

list_assets() โ†’ list[str]

List all the existing assets.

Returns: A list of available assets' names


function delete_asset

Source: __init__.py:54

delete_asset(name: str)

Delete an asset by providing its name.

This operation cannot be undone.

Args:

  • name: Asset to delete

Raises:

  • AssetNotFound: Asset with the given name does not exist

function get_text

Source: __init__.py:94

get_text(name: str) โ†’ str

Return the given asset as text.

Arguments:

  • name: Name of asset

Returns: Asset content as text

Raises:

  • AssetNotFound: No asset defined with given name

function get_json

Source: __init__.py:110

get_json( name: str, **kwargs ) โ†’ Union[dict[str, 'JSON'], list['JSON'], str, int, float, bool, NoneType]

Return the given asset as a deserialized JSON object.

Arguments:

  • name: Name of asset
  • **kwargs: Additional parameters for json.loads

Returns: Asset content as a Python object (dict, list etc.)

Raises:

  • AssetNotFound: No asset defined with given name
  • JSONDecodeError: Asset was not valid JSON

function get_file

Source: __init__.py:128

get_file(name: str, path: Union[PathLike, str], exist_ok=False) โ†’ Path

Fetch the given asset and store it in a file.

Arguments:

  • name: Name of asset
  • path: Destination path for downloaded file
  • exist_ok: Overwrite file if it already exists

Returns: Path to created file

Raises:

  • AssetNotFound: No asset defined with given name
  • FileExistsError: Destination already exists

function get_bytes

Source: __init__.py:153

get_bytes(name: str) โ†’ bytes

Return the given asset as bytes.

Arguments:

  • name: Name of asset

Returns: Asset content as bytes

Raises:

  • AssetNotFound: No asset defined with given name

function set_text

Source: __init__.py:184

set_text(name: str, text: str, wait: bool = True)

Create or update an asset to contain the given string.

Arguments:

  • name: Name of asset
  • text: Text content for asset
  • wait: Wait for asset to update

function set_json

Source: __init__.py:197

set_json( name: str, value: Optional[dict[str, 'JSON'], list['JSON'], str, int, float, bool], wait: bool = True, **kwargs )

Create or update an asset to contain the given object, serialized as JSON.

Arguments:

  • name: Name of asset
  • value: Value for asset, e.g. dict or list
  • wait: Wait for asset to update
  • **kwargs: Additional arguments for json.dumps

function set_file

Source: __init__.py:211

set_file( name: str, path: Union[PathLike, str], content_type: Optional[str] = None, wait: bool = True )

Create or update an asset to contain the contents of the given file.

Arguments:

  • name: Name of asset
  • path: Path to file
  • content_type: Content type (or mimetype) of file, detected automatically from file extension if not defined
  • wait: Wait for asset to update

function set_bytes

Source: __init__.py:241

set_bytes( name: str, data: bytes, content_type='application/octet-stream', wait: bool = True )

Create or update an asset to contain the given bytes.

Arguments:

  • name: Name of asset
  • data: Raw content
  • content_type: Content type (or mimetype) of asset
  • wait: Wait for asset to update

exception AssetNotFound

Source: _client.py:30

No asset with given name/id found.


exception AssetUploadFailed

Source: _client.py:34

There was an unexpected error while uploading an asset.