avocado.core.restclient package

Submodules

avocado.core.restclient.connection module

This module provides connection classes the avocado server.

A connection is a simple wrapper around a HTTP request instance. It is this basic object that allows methods to be called on the remote server.

avocado.core.restclient.connection.get_default()

Returns the global, default connection to avocado-server

Returns:an avocado.core.restclient.connection.Connection instance
class avocado.core.restclient.connection.Connection(hostname=None, port=None, username=None, password=None)

Bases: object

Connection to the avocado server

Initializes a connection to an avocado-server instance

Parameters:
  • hostname (str) – the hostname or IP address to connect to
  • port (int) – the port number where avocado-server is running
  • username (str) – the name of the user to be authenticated as
  • password (str) – the password to use for authentication
check_min_version(data=None)

Checks the minimum server version

get_api_list()

Gets the list of APIs the server makes available to the current user

get_url(path=None)

Returns a representation of the current connection as an HTTP URL

ping()

Tests connectivity to the currently set avocado-server

This is intentionally a simple method that will only return True if a request is made, and a response is received from the server.

request(path, method=<function get>, check_status=True, **data)

Performs a request to the server

This method is heavily used by upper level API methods, and more often than not, those upper level API methods should be used instead.

Parameters:
  • path (str) – the path on the server where the resource lives
  • method – the method you want to call on the remote server, defaults to a HTTP GET
  • check_status – whether to check the HTTP status code that comes with the response. If set to True, it will depend on the method chosen. If set to False, no check will be performed. If an integer is given then that specific status will be checked for.
  • data – keyword arguments to be passed to the remote method
Returns:

JSON data

avocado.core.restclient.response module

Module with base model functions to manipulate JSON data

class avocado.core.restclient.response.BaseResponse(json_data)

Bases: object

Base class that provides commonly used features for response handling

REQUIRED_DATA = []
exception avocado.core.restclient.response.InvalidJSONError

Bases: exceptions.Exception

Data given to a loader/decoder is not valid JSON

exception avocado.core.restclient.response.InvalidResultResponseError

Bases: exceptions.Exception

Returned result response does not conform to expectation

Even though the result may be a valid json, it may not have the required or expected information that would normally be sent by avocado-server.

class avocado.core.restclient.response.ResultResponse(json_data)

Bases: avocado.core.restclient.response.BaseResponse

Provides a wrapper around an ideal result response

This class should be instantiated with the JSON data received from an avocado-server, and will check if the required data members are present and thus the response is well formed.

REQUIRED_DATA = ['count', 'next', 'previous', 'results']

Module contents