Parameter

rapyuta.io lets you upload and manage configurations

Client Module

class Client(auth_token, project=None)

Client class provides access to device, package, volume and deployment classes.

__init__(auth_token, project=None)

Get new client object

Parameters
  • auth_token (string) – Authentication token

  • project (string) – project_guid of the user

download_configurations(rootdir, tree_names=None, delete_existing_trees=False)

Download all configurations to rootdir following the same directory structure. If rootdir does not exist, it is created.

Parameters
  • rootdir (str) – Path to directory to store downloaded configurations

  • tree_names (list[str], optional) – List of specific configuration trees to download. If None, all trees are downloaded

  • delete_existing_trees (bool, optional) – For each tree to download, delete existing tree on the filesystem. Defaults to False

Following example demonstrates how to use download_configurations and handle errors.

>>> from rapyuta_io import Client
>>> from rapyuta_io.utils.error import APIError, InternalServerError, ConfigNotFoundException
>>> client = Client(auth_token='auth_token', project='project_guid')
>>> try:
...     client.download_configurations('path/to/destination_dir',
...                                    tree_names=['config_tree1', 'config_tree2'],
...                                    delete_existing_trees=True)
... except (APIError, InternalServerError) as e:
...     print('failed API request', e.tree_path, e)
    except ConfigNotFoundException as e:
        print ('config not found')
... except (IOError, OSError) as e:
...     print('failed file/directory creation', e)
upload_configurations(rootdir, tree_names=None, delete_existing_trees=False, as_folder=False)

Traverses rootdir and uploads configurations following the same directory structure.

Parameters
  • rootdir (str) – Path to directory containing configurations

  • tree_names (list[str], optional) – List of specific configuration trees to upload. If None, all trees under rootdir are uploaded

  • delete_existing_trees (bool, optional) – For each tree to upload, delete existing tree at the server. Defaults to False

  • as_folder – For each tree to upload, upload as an folder hierarchy

As_folder

bool, optional

Following example demonstrates how to use upload_configurations and handle errors.

>>> from rapyuta_io import Client
>>> from rapyuta_io.utils.error import BadRequestError, InternalServerError
>>> client = Client(auth_token='auth_token', project='project_guid')
>>> try:
...     client.upload_configurations('path/to/configs/source_dir',
...                                  tree_names=['config_tree1', 'config_tree2'],
...                                  delete_existing_trees=True)
... except (BadRequestError, InternalServerError) as e:
...     print 'failed API request', e.tree_path, e
... except (IOError, OSError) as e:
...     print 'failed file/directory read', e