robocorp-storage

module robocorp.storage

Functions


list_assets

List all the existing assets.

Returns: A list of available assets' names

Link to source

list_assets() โ†’ List[str]

delete_asset

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

Link to source

delete_asset(name: str)

get_text

Return the given asset as text.

Arguments:

  • name: Name of asset

Returns: Asset content as text

Raises:

  • AssetNotFound: No asset defined with given name

Link to source

get_text(name: str) โ†’ str

get_json

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

Link to source

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

get_file

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

Link to source

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

get_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

Link to source

get_bytes(name: str) โ†’ bytes

set_text

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

Link to source

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

set_json

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

Link to source

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

set_file

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

Link to source

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

set_bytes

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

Link to source

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

Exceptions


AssetNotFound

No asset with given name/id found.


AssetUploadFailed

There was an unexpected error while uploading an asset.