Orchestra-orm (aka Orchestra Object REST Mapper or Orchestra Object Resource Mapper) is a high level Python library for easily interacting with django-orchestra REST API using object oriented concepts.
pip install orchestra-orm
The main goal of this library is to provide fast and easy access to Orchestra REST API: Open a Python interpreter and start interacting right away.
To achieve this goal we have borrowed some ideas from traditional SQL object relational mappers and applied them to an hypermedia-driven resource-oriented architecture (Orchestra).
This library has been heavily inspired by Django's ORM implementation; also using an Active Record like pattern, plus concurrency based on asynchronous non-blocking I/O and caching based on Identity Mapping.
Orchestra-orm leverages the HATEOAS discoverability of Orchestra's API; rather than relying on a predefined knowledge, resources and methods are autodiscovered on the fly, while browsing the API.
Our hope is that you can use this library to produce brief, readable and efficient code in a fun and effortless way :)
The following diagram illustrates the classes used to model Orchestra REST API and how they relate to each other.
Api
is a good starting point for browsing. It represents theBase
resource of an API and it haslinks
toManager
andAction
. These relations are discovered from the Link header of the HTTP response.Manager
is used for accessing linkedCollections
andResources
.Actions
are used to represent action-like endpoints (i.e.get-auth-token
). Actions are special methods that are not expressed using HTTP verbs (POST
,GET
, etc).Collection
is a list of uniform resources; all resources share the same media type (i.e. all registered nodes). For convinience it maintains alink
back to its manager in order to proxy its methods.Resource
is a local representation of a remote resource (i.e. a node), basically aResource
is an object with a URI. It may contain nested resources, orRelatedCollections
.RelatedCollection
is a subcollection that all its resources are related to the sameparent
(i.e. all slivers of a particular node). ARelatedCollection
is able to construct alookup
for discovering its relatedManager
, therefore it is able to proxy its methods.ResourceSet
is a set container that can be used to perform concurrent operations over a set of non-uniform resources.