Package module

A package is a fundamental rapyuta.io resource that represents a declaration of your application. It is the smallest unit of deployment in rapyuta.io, and it can be deployed either on a device or the cloud or both.

To make this possible a package must encapsulate any information about how it should be built, its compatibility and runtime requirements, network endpoints and ROS interfaces it exposes, and any configuration information it may require.

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

create_package(manifest, retry_limit=0)

Create package from manifest dict.

Parameters
  • manifest (dict) – dict containing package details

  • retry_limit (int) – No of retry attempts to be carried out if any failures occurs during the API call.

Raises

ConflictError: Package already exists.

Raises

BadRequestError: Invalid package details.

Returns

dict containing package details

Following example demonstrates how to use create_package.

>>> manifest = {'packageVersion': 'v1.0.0',
     'plans': [{'includePackages': [],
     'singleton': False,
     'name': 'default',
     'inboundROSInterfaces': {'services': [], 'topics': [], 'actions': []},
     'dependentDeployments': [],
     'components': [{'executables': [{'cmd': ['roslaunch listener listener.launch'],
         'name': 'listenerExec'}],
         'name': 'default',
         'parameters': [],
         'architecture': 'arm32v7',
         'requiredRuntime': 'device',
         'ros': {'services': [], 'topics': [], 'isROS': True, 'actions': []},
         'description': ''}],
         'exposedParameters': [],
         'metadata': {}}],
     'name': 'listener',
     'apiVersion': 'v1.0.0',
     'description': 'listener arm32v7 sdk test package'}
>>> from rapyuta_io import Client
>>> client = Client(auth_token='auth_token', project='project_guid')
>>> package_details = client.create_package(manifest)
create_package_from_manifest(manifest_filepath, retry_limit=0)

Create package from a manifest file

Parameters
  • manifest_filepath (string) – File path of the manifest

  • retry_limit (int) – No of retry attempts to be carried out if any failures occurs during the API call.

Raises

ConflictError: Package already exists.

Raises

BadRequestError: Invalid package details.

Returns

dict containing package details

Copy the below json to listener.json file

Following example demonstrates how to use create_package_from_manifest.

{ "packageVersion": "v1.0.0", "plans": [{"includePackages": [], "singleton": false,
"name": "default", "inboundROSInterfaces": {"services": [], "topics": [],
"actions": []}, "dependentDeployments": [], "components": [{"executables": [{"cmd":
["roslaunch listener listener.launch"], "name": "listenerExec"}],
"name": "default", "parameters": [], "architecture": "arm32v7", "requiredRuntime":
 "device", "ros": {"services": [], "topics": [], "isROS": true, "actions": []},
  "description": ""}], "exposedParameters": [], "metadata": {}}], "name": "listener",
  "apiVersion": "v1.0.0", "description": "listener arm32v7 sdk test package" }
>>> from rapyuta_io import Client
>>> client = Client(auth_token='auth_token', project='project_guid')
>>> package_details = client.create_package_from_manifest('listener.json')
delete_package(package_id)

Delete a package.

Parameters

package_id (str) – ID of the package to be deleted.

Following example demonstrates how to delete a package.

>>> from rapyuta_io import Client
>>> client = Client(auth_token='auth_token', project='project_guid')
>>> client.delete_package('package_id')
get_all_packages(retry_limit=0)

Get list of all packages created by the user.

Parameters

retry_limit (int) – Number of retry attempts to be carried out if any failures occurs during the API call.

Returns

List of all packages. Each package is an instance of Package class.

Raises

APIError: If the API returns an error, a status code of anything other than 200/201 is returned.

Following example demonstrates how to get the packages

>>> from rapyuta_io import Client
>>> client = Client(auth_token='auth_token', project='project_guid')
>>> package_list = client.get_all_packages()
get_package(package_id, retry_limit=0)

Get package class

Parameters
  • package_id (string) – Package ID

  • retry_limit (int) – Number of retry attempts to be carried out if any failures occurs during the API call.

Returns

an instance of Package class.

Raises

PackageNotFound: If the given package id is not found.

Raises

ComponentNotFoundException: If the plan inside the package does not have components.

Raises

APIError: If the API returns an error, a status code of anything other than 200/201 is returned.

Following example demonstrates how to get the packages

>>> from rapyuta_io import Client
>>> client = Client(auth_token='auth_token', project='project_guid')
>>> package = client.get_package('test_package_id')

Package Module

class Package(*args, **kwargs)

Package class represents a service package. It contains method to provision an instance of the package on cloud or on device. Additionally, it provides other utility method.

Variables
  • packageId – Id of the package.

  • packageName – Package name.

  • packageVersion – Version of the package.

  • description – Description of the package.

  • plans – List of plans associated with the package.

  • isPublic – Boolean denoting whether the package is public or not.

  • status – Status of the package.

  • tags – Tags associated with the package.

  • buildGeneration – Build generation.

delete()

Delete the package using the package object.

Following example demonstrates how to delete a package using package object:

>>> from rapyuta_io import Client
>>> client = Client(auth_token='auth_token', project='project_guid')
>>> package = client.get_package(package_id='package_id')
>>> package.delete()
deployments(phases=None, retry_limit=0)

Get all the deployments of the package

Parameters
  • phases (list(DeploymentPhaseConstants)) – optional parameter to filter out the deployments based on current deployment

  • retry_limit (int) – Optional parameter to specify the number of retry attempts to be carried out if any failures occurs during the API call.

Returns

list of instance of class Deployment:

Raises

APIError: If deployment info api return an error, the status code is anything other than 200/201

Following example demonstrates how to the deployment list

>>> from rapyuta_io import Client, DeploymentPhaseConstants
>>> client = Client(auth_token='auth_token', project='project')
>>> package = client.get_package('test_package_id')
>>> package.deployments()
>>> deployments_list_filtered_by_phase = package.deployments(phases=
>>>   [DeploymentPhaseConstants.SUCCEEDED, DeploymentPhaseConstants.PROVISIONING])
get_provision_configuration(plan_id=None)

Get provision configuration payload for package provision request.

Parameters

plan_id (string) – Plan Id

Returns

return instance of class ProvisionConfiguration:

provision(deployment_name, provision_configuration, retry_limit=0)

Provision the package (represented by the package class). Package can be deployed on device or cloud. If the required runtime of the package is device, then specify the device in the package config.

Parameters
  • deployment_name (string) – Deployment Name

  • provision_configuration (ProvisionConfiguration:) – Provision payload

  • retry_limit (int) – Optional parameter to specify the number of retry attempts to be carried out if any failures occurs during the API call.

Returns

Instance of class Deployment:

Raises

APIError: If the API returns an error, a status code of anything other than 200/201 is returned.

Raises

OperationNotAllowedError: If the provision request is invalid

class ProvisionConfiguration(package_id, plan, *args, **kwargs)

ProvisionConfiguration class that contains the component configuration for a package deployment.

add_dependent_deployment(deployment)

Add dependent deployments

Parameters

deployment (class Deployment:) – Deployment

Returns

Updated instance of class ProvisionConfiguration:

add_device(component_name, device, ignore_device_config=None)

Map component configuration with a device. ie, Setting the component is going to deploy on the given device.

Parameters
  • component_name (string) – Component name

  • device (instance of class Device:) – Device

  • ignore_device_config (list) – optional parameter to ignore the device config variables

Returns

Updated instance of class ProvisionConfiguration:

Raises

OperationNotAllowedError: If the device is not online

>>> from rapyuta_io import Client
>>> client = Client(auth_token='auth_token', project='project')
>>> package = client.get_package('test_package_id')
>>> package_provision_config = package.get_provision_configuration('test_plan_id')
>>> # ros_workspace will be ignored while adding device to provision configuration
>>> package_provision_config.add_device('test_component_name', 'test_device_id',
>>>                                     ignore_device_config=['ros_workspace'])
>>> package.provision(deployment_name, package_provision_config)
add_label(key, value)

Add labels

Parameters
  • key (string) – Key

  • value (string) – Value

Returns

Updated instance of class ProvisionConfiguration:

add_native_network(native_network)

Add Native Network

Parameters

native_network (instance of NativeNetwork) – NativeNetwork

Returns

Updated instance of class ProvisionConfiguration

Raises

OperationNotAllowedError: If native network is not of cloud runtime

>>> from rapyuta_io import Client
>>> from rapyuta_io.clients.package import ROSDistro, Runtime
>>> from rapyuta_io.clients.native_network import NativeNetwork
>>> client = Client(auth_token='auth_token', project='project')
>>> native_network = NativeNetwork("native_network_name", Runtime.CLOUD,
                                   ROSDistro.KINETIC)
>>> native_network = client.create_native_network(native_network)
>>> native_network.poll_native_network_till_ready()
>>> package = client.get_package('test_package_id')
>>> package_provision_config = package.get_provision_configuration('test_plan_id')
>>> package_provision_config.add_native_network(native_network)
>>> package.provision('deployment_name', package_provision_config)
add_native_networks(native_networks)

Add Native Networks

Parameters

native_networks (list) – list of native network NativeNetwork

Returns

Updated instance of class ProvisionConfiguration

>>> from rapyuta_io import Client
>>> from rapyuta_io.clients.package import ROSDistro, Runtime
>>> from rapyuta_io.clients.native_network import NativeNetwork
>>> client = Client(auth_token='auth_token', project='project')
>>> native_network = NativeNetwork("native_network_name", Runtime.CLOUD,
                                   ROSDistro.KINETIC)
>>> native_network = client.create_native_network(native_network)
>>> native_network.poll_native_network_till_ready()
>>> package = client.get_package('test_package_id')
>>> package_provision_config = package.get_provision_configuration('test_plan_id')
>>> package_provision_config.add_native_networks([native_network])
>>> package.provision('deployment_name', package_provision_config)

add_parameter(component_name, key, value)

Add component parameters

Parameters
  • component_name (string) – Component name

  • key (string) – Parameter key

  • value (string) – Parameter value

Returns

Updated instance of class ProvisionConfiguration:

add_restart_policy(component_name, restart_policy)

Add RestartPolicy for the component

Parameters
  • component_name (string) – Component name

  • restart_policy (enum RestartPolicy) – one of RestartPolicy enums

Returns

Updated instance of class ProvisionConfiguration

Raises

InvalidParameterException: If restart policy is not invalid

add_rosbag_job(component_name, rosbag_job)

Add rosbag for a component

Parameters
  • component_name (string) – Component name

  • rosbag_job (ROSBagJob) – instance of ROSBagJob

Returns

Updated instance of class ProvisionConfiguration

Raises

InvalidParameterException: If rosbag_job is not instance of ROSBagJob

Raises

OperationNotAllowedError: If component is non ros or is a device component

add_routed_network(routed_network, network_interface=None)

Add Routed Network

Parameters
  • routed_network (instance of RoutedNetwork) – RoutedNetwork

  • network_interface (string) – interface to which current deployment to bind

Returns

Updated instance of class ProvisionConfiguration

Raises

InvalidParameterException: If routed network is not valid

Raises

OperationNotAllowedError: If network interface given for cloud runtime

add_routed_networks(routed_networks)
Parameters

routed_networks (list) – list of routed network RoutedNetwork

Returns

Updated instance of class ProvisionConfiguration

>>> from rapyuta_io import Client
>>> from rapyuta_io.clients.package import ROSDistro
>>> client = Client(auth_token='auth_token', project='project')
>>> routed_network = client.create_cloud_routed_network('network_name',
                     ROSDistro.KINETIC, True)
>>> routed_network.poll_routed_network_till_ready()
>>> package = client.get_package('test_package_id')
>>> package_provision_config = package.get_provision_configuration('test_plan_id')
>>> package_provision_config.add_routed_networks([routed_network])
>>> package.provision(deployment_name, package_provision_config)

add_static_route(component_name, endpoint_name, static_route)

Add static route to a component in a package

Parameters
  • component_name – Name of the component to add static route to

  • endpoint_name – Name of the endpoint (Should be exposed externally)

  • static_route – class StaticRoute:

Returns

Updated instance of class ProvisionConfiguration:

bind_to_local_broker(local_broker_instance, network_interface=None)

Adds the local communication broker as a dependent deployment

Parameters
  • local_broker_instance (Deployment) – Provisioned local communication broker instance

  • network_interface (string) – interface to which current deployment to bind

Returns

Updated instance of class ProvisionConfiguration:

mount_volume(component_name, volume_instance, mount_path)

To mount a volume instance

Parameters
  • component_name (string) – Component name

  • volume_instance (instance of class VolumeInstance:) – VolumeInstance class

  • mount_path (string) – Mount path

Returns

Updated instance of class ProvisionConfiguration:

set_component_alias(component_name, alias='')

Set an alias for the selected component. This is used in scoping and targeting. It defaults to the component name.

Note: In typical scenarios in the case of a cloud deplyment cloud this is set to the component name (or some derivation thereof) and on the device it is set to the device name. But it is left to the user. All set aliases in a deployment and its dependent deployments are required to be unique

Parameters
  • component_name (string) – Component name

  • alias (string) – alias for component

Returns

Updated instance of class ProvisionConfiguration:

class ROSDistro(value)

Enumeration variables for the Supported ROS Distros. ROS Distro may be ‘kinetic’, or ‘melodic’

ROSDistro.KINETIC

ROSDistro.MELODIC

class RestartPolicy(value)

Enumeration variables for the Restart Policy. Restart Policy may be ‘Always’, ‘Never’ or ‘OnFailure’

RestartPolicy.Always

RestartPolicy.Never

RestartPolicy.OnFailure

class Runtime(value)

Enumeration variables for the Supported Runtimes. Runtime may be ‘cloud’, or ‘device’

Runtime.CLOUD

Runtime.DEVICE