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:74

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:114

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:130

get_json( name: str, **kwargs ) โ†’ Union[Dict[str, ForwardRef('JSON')], List[ForwardRef('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:148

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:173

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:204

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:217

set_json( name: str, value: Optional[Dict[str, ForwardRef('JSON')], List[ForwardRef('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:231

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:261

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.