Skip to content

Commit

Permalink
refactor: removes v1 clients
Browse files Browse the repository at this point in the history
  • Loading branch information
smrutisenapati committed Sep 27, 2024
1 parent 3048dff commit c46291b
Show file tree
Hide file tree
Showing 79 changed files with 326 additions and 6,776 deletions.
29 changes: 17 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@ command.
python setup.py install
```

## Development

Create a python virtual environment, having version less than 3.11

```bash
pipenv install --dev
```

## Getting Started

Before using the SDK, you need the Rapyuta Token. You can get it from
Expand All @@ -40,17 +48,14 @@ from rapyuta_io import Project

project = client.create_project(Project("python-sdk"))
client.set_project(project.guid)

# Create a Build
from rapyuta_io import Build, StrategyType, DeviceArch

client.create_build(
Build(
"dummy",
StrategyType.DOCKER,
"https://github.com/ankitrgadiya/dummy-package",
DeviceArch.AMD64,
)
)
```

## SDK Test

`RIO_CONFIG` environment variable pointing to the config.json must be sourced to
run the sdk integration test. The sample config is present in `sdk_test` directory.
Run `run_rio_sdk_test.py` to start the sdk tests.

Currently only one docker compose device is needed to be created and added to the config,
SDK Test will add the device to the newly created project and onboard it and run tests.

5 changes: 1 addition & 4 deletions rapyuta_io/__init__.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
from __future__ import absolute_import
from .clients.deployment import DeploymentPhaseConstants, DeploymentStatusConstants
from .clients.device import TopicKind, DeviceStatus, TopicQOS, QoS
from .clients.device import TopicKind, DeviceStatus, TopicQOS, QoS, DeploymentPhaseConstants, ROSDistro
from .clients.model import Label, Command, DeviceConfig, TopicsStatus
from .clients.persistent_volumes import DiskType
from rapyuta_io.utils import error
from .rio_client import Client
from .clients.package import ROSDistro
from .clients.device_manager import DeviceArch
from .clients.project import Project
from .clients.secret import Secret, SecretConfigDocker
Expand Down
4 changes: 1 addition & 3 deletions rapyuta_io/clients/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
from .device_manager import DeviceManagerClient, DeviceArch
from .model import *
from .provision_client import ProvisionClient
from .paramserver import _ParamserverClient
from .package import ROSDistro
from .device import Device
from .device import Device, ROSDistro
from .user_group import UserGroup
141 changes: 3 additions & 138 deletions rapyuta_io/clients/catalog_client.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
# encoding: utf-8
from __future__ import absolute_import

import os
import re

import six
from rapyuta_io.clients.api_client import CatalogConfig
from rapyuta_io.clients.package import Package
from rapyuta_io.clients.persistent_volumes import PersistentVolumes
from rapyuta_io.utils import RestClient, PackageNotFound, to_objdict, APIError
from rapyuta_io.utils import RestClient, PackageNotFound
from rapyuta_io.utils.rest_client import HttpMethod
from rapyuta_io.utils.settings import CATALOG_API_PATH, VOLUME_PACKAGE_ID
from rapyuta_io.utils.settings import CATALOG_API_PATH
from rapyuta_io.utils.utils import response_validator
from six.moves import map
from rapyuta_io.utils.partials import PartialMixin


class CatalogClient(CatalogConfig):
Expand All @@ -34,117 +30,6 @@ def _get_service(self, package_id, retry_limit=0):
url = self._get_api_path() + "?package_uid=%s" % package_id
return self._execute(url, HttpMethod.GET, retry_limit)

@response_validator(True)
def get_all_packages(self, retry_limit):
url = self._catalog_api_host + '/v2/catalog'
return self._execute(url, HttpMethod.GET, retry_limit)

def get_package(self, package_id, retry_limit):
package = self._get_service(package_id, retry_limit)
try:
package = package['packageInfo']
except Exception:
raise APIError("packageInfo not present in the package")
if package_id == VOLUME_PACKAGE_ID:
pkg = PersistentVolumes(to_objdict(package))
pkg.planId = 'default'
else:
# PARTIAL_ATTR set before initializing Package: Package._post_init() depends on is_partial
package[PartialMixin.PARTIAL_ATTR] = False
pkg = Package(to_objdict(package))
setattr(pkg, 'packageId', package_id)
return pkg

def delete_package(self, package_id):
path = '/serviceclass/delete?package_uid={}'.format(package_id)
url = self._catalog_api_host + path
return self._execute(url, HttpMethod.DELETE)

@response_validator(True)
def get_deployment(self, deployment_id, retry_limit):
path = '/serviceinstance/{}'.format(deployment_id)
url = self._catalog_api_host + path
return self._execute(url, HttpMethod.GET, retry_limit)

@response_validator(True)
def update_deployment(self, payload, retry_limit):
path = '/v2/service_instances/{}'.format(payload['deployment_id'])
url = self._catalog_api_host + path
return self._execute(url, HttpMethod.PATCH, retry_limit, payload=payload)

@response_validator(True)
def deployment_list(self, phases, device_id, retry_limit):
url = self._catalog_api_host + '/deployment/list'
query_params = {}
if phases:
query_params = {'phase': list(map(str, phases))}
if device_id:
query_params['device_uid'] = device_id

return self._execute(url, HttpMethod.GET, retry_limit, query_params=query_params)

@response_validator(True)
def create_package(self, package_payload, retry_limit):
url = self._catalog_api_host + '/serviceclass/add'
return self._execute(url, HttpMethod.POST, retry_limit, package_payload)

@response_validator(True)
def create_routed_network(self, **network_payload):
url = self._catalog_api_host + '/routednetwork'
routed_network = self._execute(url, HttpMethod.POST, retry_count=0, payload=network_payload)
return routed_network

@response_validator(True)
def get_routed_network(self, network_guid):
url = self._catalog_api_host + '/routednetwork/{}'.format(network_guid)
return self._execute(url, HttpMethod.GET)

@response_validator(True)
def delete_routed_network(self, network_guid):
url = self._catalog_api_host + '/routednetwork/{}'.format(network_guid)
return self._execute(url, HttpMethod.DELETE)

@response_validator(True)
def list_routed_network(self):
url = self._catalog_api_host + '/routednetwork'
return self._execute(url, HttpMethod.GET)

@response_validator(True)
def create_build(self, build):
url = self._catalog_api_host + '/build'
return self._execute(url, HttpMethod.POST, payload=build._serialize())

@response_validator(True)
def get_build(self, guid, include_build_requests):
url = self._catalog_api_host + '/build/{}'.format(guid)
query_params = None
if include_build_requests:
query_params = {'include_build_requests': include_build_requests}
return self._execute(url, HttpMethod.GET, query_params=query_params)

@response_validator(True)
def list_builds(self, statuses):
url = self._catalog_api_host + '/build'
query_params = None
if statuses:
query_params = {'status': statuses}

return self._execute(url, HttpMethod.GET, query_params=query_params)

def delete_build(self, guid):
url = self._catalog_api_host + '/build/{}'.format(guid)
return self._execute(url, HttpMethod.DELETE)

@response_validator(True)
def trigger_build(self, buildOperation):
url = self._catalog_api_host + '/build/operation/trigger'
return self._execute(url, HttpMethod.PUT, payload=buildOperation)

@response_validator(True)
def rollback_build(self, buildOperation):
url = self._catalog_api_host + '/build/operation/rollback'
return self._execute(url, HttpMethod.PUT, payload=buildOperation)

@response_validator(True)
def get_rosbag_job(self, guid):
url = self._catalog_api_host + '/rosbag-jobs/job/{}'.format(guid)
Expand Down Expand Up @@ -222,23 +107,3 @@ def download_blob(signed_url, filename, download_dir):
def delete_rosbag_blob(self, guid):
url = self._catalog_api_host + '/rosbag-blobs/{}'.format(guid)
return self._execute(url, HttpMethod.DELETE)

@response_validator(True)
def create_native_network(self, network_payload):
url = self._catalog_api_host + '/nativenetwork'
return self._execute(url, HttpMethod.POST, retry_count=0, payload=network_payload.serialize())

@response_validator(True)
def get_native_network(self, network_guid):
url = self._catalog_api_host + '/nativenetwork/{}'.format(network_guid)
return self._execute(url, HttpMethod.GET)

@response_validator(True)
def delete_native_network(self, network_guid):
url = self._catalog_api_host + '/nativenetwork/{}'.format(network_guid)
return self._execute(url, HttpMethod.DELETE)

@response_validator(True)
def list_native_network(self):
url = self._catalog_api_host + '/nativenetwork'
return self._execute(url, HttpMethod.GET)
81 changes: 0 additions & 81 deletions rapyuta_io/clients/common_models.py

This file was deleted.

Loading

0 comments on commit c46291b

Please sign in to comment.