glare.api.v1 package

Submodules

glare.api.v1.api_version_request module

class glare.api.v1.api_version_request.APIVersionRequest(version_string)[source]

Bases: object

This class represents an API Version Request with convenience methods for manipulation and comparison of version numbers that we need to do to implement microversions.

classmethod default_version()[source]

Default api version if no version in request.

get_string()[source]

Converts object to string representation which is used to create an APIVersionRequest object results in the same version request.

matches(min_version, max_version)[source]

Returns whether the version object represents a version greater than or equal to the minimum version and less than or equal to the maximum version.

Parameters:
  • min_version – Minimum acceptable version.
  • max_version – Maximum acceptable version.
Returns:

boolean

classmethod max_version()[source]

Maximal allowed api version.

classmethod min_version()[source]

Minimal allowed api version.

glare.api.v1.api_versioning module

class glare.api.v1.api_versioning.VersionedMethod(name, start_version, end_version, func)[source]

Bases: object

class glare.api.v1.api_versioning.VersionedResource[source]

Bases: object

Versioned mixin that provides ability to define versioned methods and return appropriate methods based on user request.

VER_METHODS_ATTR_PREFIX = 'versioned_methods_'
static check_for_versions_intersection(func_list)[source]

Determines whether function list contains version intervals intersections or not. General algorithm: https://en.wikipedia.org/wiki/Intersection_algorithm

Parameters:func_list – list of VersionedMethod objects
Returns:boolean
classmethod supported_versions(min_ver, max_ver=None)[source]

Decorator for versioning api methods.

Add the decorator to any method which takes a request object as the first parameter and belongs to a class which inherits from wsgi.Controller. The implementation inspired by Nova.

Parameters:
  • min_ver – string representing minimum version
  • max_ver – optional string representing maximum version
versioned_methods_VersionedResource = {'create': [<glare.api.v1.api_versioning.VersionedMethod object>], 'delete': [<glare.api.v1.api_versioning.VersionedMethod object>], 'delete_external_blob': [<glare.api.v1.api_versioning.VersionedMethod object>], 'download_blob': [<glare.api.v1.api_versioning.VersionedMethod object>], 'list': [<glare.api.v1.api_versioning.VersionedMethod object>], 'list_all_quotas': [<glare.api.v1.api_versioning.VersionedMethod object>], 'list_project_quotas': [<glare.api.v1.api_versioning.VersionedMethod object>], 'list_schemas': [<glare.api.v1.api_versioning.VersionedMethod object>], 'log_decorator': [<glare.api.v1.api_versioning.VersionedMethod object>], 'set_quotas': [<glare.api.v1.api_versioning.VersionedMethod object>], 'show': [<glare.api.v1.api_versioning.VersionedMethod object>], 'update': [<glare.api.v1.api_versioning.VersionedMethod object>], 'upload_blob': [<glare.api.v1.api_versioning.VersionedMethod object>]}

glare.api.v1.resource module

WSGI Resource definition for Glare. Defines Glare API and serialization/ deserialization of incoming requests.

class glare.api.v1.resource.ArtifactsController[source]

Bases: glare.api.v1.api_versioning.VersionedResource

API controller for Glare Artifacts.

Artifact Controller prepares incoming data for Glare Engine and redirects data to the appropriate engine method. Once the response data is returned from the engine Controller passes it next to Response Serializer.

create(req, *args, **kwargs)[source]
delete(req, *args, **kwargs)[source]
delete_external_blob(req, *args, **kwargs)[source]
download_blob(req, *args, **kwargs)[source]
list(req, *args, **kwargs)[source]
list_all_quotas(req, *args, **kwargs)[source]
list_project_quotas(req, *args, **kwargs)[source]
list_type_schemas(req, *args, **kwargs)[source]
set_quotas(req, *args, **kwargs)[source]
show(req, *args, **kwargs)[source]
show_type_schema(req, *args, **kwargs)[source]
update(req, *args, **kwargs)[source]
upload_blob(req, *args, **kwargs)[source]
class glare.api.v1.resource.RequestDeserializer[source]

Bases: glare.api.v1.api_versioning.VersionedResource, glare.common.wsgi.JSONRequestDeserializer

Glare deserializer for incoming webob requests.

Deserializer checks and converts incoming request into a bunch of Glare primitives. So other service components don’t work with requests at all. Deserializer also performs primary API validation without any knowledge about concrete artifact type structure.

ALLOWED_LOCATION_TYPES = ('external', 'internal')
create(req)[source]
list(req)[source]
set_quotas(req)[source]
update(req)[source]
upload_blob(req)[source]
class glare.api.v1.resource.ResponseSerializer[source]

Bases: glare.api.v1.api_versioning.VersionedResource, glare.common.wsgi.JSONResponseSerializer

Glare serializer for outgoing responses.

Converts data received from the engine to WSGI responses. It also specifies proper response status and content type as declared in the API.

create(response, artifact)[source]
delete(response, result)[source]
delete_external_blob(response, result)[source]
download_blob(response, result)[source]
list(response, af_list)[source]
list_all_quotas(response, quotas)[source]
list_project_quotas(response, quotas)[source]
list_schemas(response, type_list)[source]
list_type_schemas(response, type_schemas)[source]
show(response, artifact)[source]
show_type_schema(response, type_schema)[source]
update(response, artifact)[source]
upload_blob(response, artifact)[source]
glare.api.v1.resource.create_resource()[source]

Artifact resource factory method.

glare.api.v1.resource.log_request_progress(f)[source]

glare.api.v1.router module

class glare.api.v1.router.API(mapper)[source]

Bases: glare.common.wsgi.Router

WSGI router for Glare v1 API requests.

API Router redirects incoming requests to appropriate WSGI resource method.

Module contents