Api package

Api

class api.Api(volume_manager, context)

Bases: utils.service.Service

API service responsible for processing requests given by the client.

static _create_app(volume_manager, testing=False)

Factory method to create the Flask app and register all dependencies.

Parameters:
  • volume_manager (VolumeManager) – The volume manager to be used withing the API controller
  • testing (bool) – Whether or not to set the TESTING flag on the newly generated Flask application
Returns:

The application with all the needed dependencies bootstrapped

Return type:

Flask

static _register_resources(api)

Utility method to inject the resources and their endpoints.

Parameters:api (flask_restful.API) – The API instance that needs to have the resources added.
start()

Responsible for spawning the coroutines that run the flask server.

Returns:A list of greenlets to join in the caller
Return type:[Greenlet]
stop()

A means of stopping the service gracefully.

Returns:Whether the code needed stopping or not
Return type:bool

Volume

class api.Volume

Bases: flask_restful.Resource

FlaskRestful API controller and resource handler for one specific volume.

static delete(volume_id)

Deletes the volume pointed by the id.

Parameters:volume_id (str) – The id parsed from the URL
Returns:payload, http status code, headers
Return type:tuple
static get(volume_id)

Returns a volume dict as a json response or 404 if not found.

Parameters:volume_id (str) – The id parsed from the URL
Returns:payload, http status code
Return type:tuple
static put(volume_id)

Edits a volume dict based on the given representation.

Expects to receive a json payload with a complete new version of the volume to be edited

Parameters:volume_id (str) – The id parsed from the URL
Returns:payload, http status code, headers
Return type:tuple

VolumeList

class api.VolumeList

Bases: flask_restful.Resource

FlaskRestful API controller and resource handler for the entire volume endpoint.

static get()

It will return a list of all the volumes

Returns:payload, http status code
Return type:tuple
static post()

It will create a volume with the given input as a starting point.

Returns:payload, http status code, headers
Return type:tuple