Adapter
To use this library you need adapter classes. Adapter classes are used to connect the lab orchestrator lib to your database.
Take a look at the controller references to see which adapters you need when you want to use only a few controllers. But to use all features of the library you need to implement all adapters:
Note
When you use django there is already one library that contains all adapters to use the lab orchestrator lib with django: LabOrchestratorLib-DjangoAdapter. This library also contains an example Django API. On how to use this adapter take a look at the documentation in the link.
Note
The LabOrchestratorLib-FlaskSQLAlchemyAdapter project is not maintained and not working, but if you need an adapter for Flask-SQLAlchemy you can base them on this project.
After implementing the adapters you can create a controller collection by passing instances of the adapters to the lab_orchestrator_lib.controllers.controller_collection.create_controller_collection(...)
function. This function takes all adapters, one api registry and a secret key. More about this is part of Controller documentation.
User Adapter Interface
- class lab_orchestrator_lib.database.adapter.UserAdapterInterface
Adapter that is used to connect the user model to the database.
Contains only get methods, because the lab_controller_lib won’t create or delete users.
Methods
- get(identifier)
Gives a specific user.
- Parameters
- Return type
- Returns
A specific user.
- Raises
NotImplementedError – Method needs to be implemented.
- get_all()
Gives a list of all users.
- Return type
- Returns
A list of all users.
- Raises
NotImplementedError – Method needs to be implemented.
Docker Image Adapter Interface
- class lab_orchestrator_lib.database.adapter.DockerImageAdapterInterface
Adapter that is used to connect the docker image model to the database.
Methods
- create(name, description, url)
Creates a docker image and saves it to the database.
- Parameters
- Return type
- Returns
A newly added docker image.
- Raises
NotImplementedError – Method needs to be implemented.
- delete(identifier)
Deletes a specific docker image.
- Parameters
identifier (
Union
[str
,int
]) – The identifier of the docker image.- Return type
- Returns
None
- Raises
NotImplementedError – Method needs to be implemented.
- filter(**kwargs)
Filters the docker images and returns all docker images that matches the filter criteria.
The database should be filtered by the attributes and belonging values that are given in the kwargs dictionary.
- Parameters
- Return type
- Returns
All docker images that matches the filters.
- Raises
NotImplementedError – Method needs to be implemented.
- get(identifier)
Gives a specific docker image.
- Parameters
identifier (
Union
[str
,int
]) – The identifier of the docker image.- Return type
- Returns
The specific docker image.
- Raises
NotImplementedError – Method needs to be implemented.
- get_all()
Gives all docker images.
- Return type
- Returns
A list of all docker images.
- Raises
NotImplementedError – Method needs to be implemented.
- save(obj)
Saves changes of the docker image to the database.
- Parameters
obj (
DockerImage
) – The docker image object that contains changes.- Return type
- Returns
The docker image.
- Raises
NotImplementedError – Method needs to be implemented.
Lab Docker Image Adapter Interface
- class lab_orchestrator_lib.database.adapter.LabDockerImageAdapterInterface
Adapter that is used to connect the lab docker image model to the database.
Methods
- create(lab_id, docker_image_id, docker_image_name)
Creates a lab docker image and saves it to the database.
- Parameters
- Return type
- Returns
A newly added lab docker image.
- Raises
NotImplementedError – Method needs to be implemented.
- delete(identifier)
Deletes a specific lab docker image.
- Parameters
identifier (
Union
[str
,int
]) – The identifier of the lab docker image.- Return type
- Returns
None
- Raises
NotImplementedError – Method needs to be implemented.
- filter(**kwargs)
Filters the lab docker images and returns all lab docker images that matches the filter criteria.
The database should be filtered by the attributes and belonging values that are given in the kwargs dictionary.
- Parameters
- Return type
- Returns
All lab docker images that matches the filters.
- Raises
NotImplementedError – Method needs to be implemented.
- get(identifier)
Gives a specific lab docker image.
- Parameters
identifier (
Union
[str
,int
]) – The identifier of the lab docker image.- Return type
- Returns
The specific lab docker image.
- Raises
NotImplementedError – Method needs to be implemented.
- get_all()
Gives all lab docker images.
- Return type
- Returns
A list of all lab docker images.
- Raises
NotImplementedError – Method needs to be implemented.
- save(obj)
Saves changes of the lab docker image to the database.
- Parameters
obj (
LabDockerImage
) – The lab docker image object that contains changes.- Return type
- Returns
The lab docker image.
- Raises
NotImplementedError – Method needs to be implemented.
Lab Adapter Interface
- class lab_orchestrator_lib.database.adapter.LabAdapterInterface
Adapter that is used to connect the lab model to the database.
Methods
- create(name, namespace_prefix, description)
Creates a lab and saves it to the database.
- Parameters
- Return type
- Returns
A newly added lab.
- Raises
NotImplementedError – Method needs to be implemented.
- delete(identifier)
Deletes a specific lab.
- Parameters
- Return type
- Returns
None
- Raises
NotImplementedError – Method needs to be implemented.
- filter(**kwargs)
Filters the labs and returns all labs that matches the filter criteria.
The database should be filtered by the attributes and belonging values that are given in the kwargs dictionary.
- get(identifier)
Gives a specific lab.
- Parameters
- Return type
- Returns
The specific lab.
- Raises
NotImplementedError – Method needs to be implemented.
- get_all()
Gives all labs.
- Return type
- Returns
A list of all labs.
- Raises
NotImplementedError – Method needs to be implemented.
- save(obj)
Saves changes of the lab to the database.
- Parameters
obj (
Lab
) – The lab object that contains changes.- Return type
- Returns
The lab.
- Raises
NotImplementedError – Method needs to be implemented.
Lab Instance Adapter Interface
- class lab_orchestrator_lib.database.adapter.LabInstanceAdapterInterface
Adapter that is used to connect the lab instance model to the database.
Methods
- create(lab_id, user_id)
Creates a lab instance and saves it to the database.
- Parameters
- Return type
- Returns
A newly added lab instance.
- Raises
NotImplementedError – Method needs to be implemented.
- delete(identifier)
Deletes a specific lab instance.
- Parameters
identifier (
Union
[str
,int
]) – The identifier of the lab instance.- Return type
- Returns
None
- Raises
NotImplementedError – Method needs to be implemented.
- filter(**kwargs)
Filters the lab instances and returns all lab instances that matches the filter criteria.
The database should be filtered by the attributes and belonging values that are given in the kwargs dictionary.
- Parameters
- Return type
- Returns
All lab instances that matches the filters.
- Raises
NotImplementedError – Method needs to be implemented.
- get(identifier)
Gives a specific lab instance.
- Parameters
identifier (
Union
[str
,int
]) – The identifier of the lab instance.- Return type
- Returns
The specific lab instance.
- Raises
NotImplementedError – Method needs to be implemented.
- get_all()
Gives all lab instances.
- Return type
- Returns
A list of all lab instances.
- Raises
NotImplementedError – Method needs to be implemented.
- save(obj)
Saves changes of the lab instance to the database.
- Parameters
obj (
LabInstance
) – The lab instance object that contains changes.- Return type
- Returns
The lab instance.
- Raises
NotImplementedError – Method needs to be implemented.