Dummy
Dummy adapter classes for the ODIN server.
The DummyAdapter class implements a dummy adapter for the ODIN server, demonstrating the basic adapter implementation and providing a loadable adapter for testing
The IacDummyAdapter class implements a dummy adapter for the ODIN server that can demonstrate the inter adapter communication, and how an adapter might use the dictionary of loaded adapters to communicate with them.
Tim Nicholls, STFC Application Engineering
DummyAdapter
Bases: ApiAdapter
Dummy adapter class for the ODIN server.
This dummy adapter implements the basic operation of an adapter including initialisation and HTTP verb methods (GET, PUT, DELETE) with various request and response types allowed.
Source code in src/odin_control/adapters/dummy.py
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 | |
__init__(**kwargs)
Initialize the DummyAdapter object.
This constructor Initializes the DummyAdapter object, including launching a background task if enabled by the adapter options passed as arguments.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
kwargs
|
keyword arguments specifying options |
{}
|
Source code in src/odin_control/adapters/dummy.py
background_task_callback()
Run the adapter background task.
This callback simply increments the background task counter.
Source code in src/odin_control/adapters/dummy.py
cleanup()
Clean up the state of the adapter.
This method cleans up the state of the adapter, which in this case is trivially setting the background task counter back to zero for test purposes.
Source code in src/odin_control/adapters/dummy.py
delete(path, request)
Handle an HTTP DELETE request.
This method handles an HTTP DELETE request, returning a JSON response.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
URI path of request |
required | |
request
|
HTTP request object |
required |
Returns:
| Type | Description |
|---|---|
|
an ApiAdapterResponse object containing the appropriate response |
Source code in src/odin_control/adapters/dummy.py
get(path, request)
Handle an HTTP GET request.
This method handles an HTTP GET request, returning a JSON response. To facilitate testing of the background task, if the URI path is set appropriately, the task counter is returned in the JSON response.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
URI path of request |
required | |
request
|
HTTP request object |
required |
Returns:
| Type | Description |
|---|---|
|
an ApiAdapterResponse object containing the appropriate response |
Source code in src/odin_control/adapters/dummy.py
put(path, request)
Handle an HTTP PUT request.
This method handles an HTTP PUT request, returning a JSON response.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
URI path of request |
required | |
request
|
HTTP request object |
required |
Returns:
| Type | Description |
|---|---|
|
an ApiAdapterResponse object containing the appropriate response |
Source code in src/odin_control/adapters/dummy.py
IacDummyAdapter
Bases: ApiAdapter
Dummy adapter class for the Inter Adapter Communication changes.
This dummy adapter impelements the basic operations of GET and PUT, and allows another adapter to interact with it via these methods.
Source code in src/odin_control/adapters/dummy.py
__init__(**kwargs)
Initialize the dummy target adapter.
Create the adapter using the base adapter class. Create an empty dictionary to store the references to other loaded adapters.
Source code in src/odin_control/adapters/dummy.py
get(path, request)
Handle a HTTP GET Request
Call the get method of each other adapter that is loaded and return the responses in a dictionary.
Source code in src/odin_control/adapters/dummy.py
initialize(adapters)
Initialize the adapter after it has been loaded.
Receive a dictionary of all loaded adapters so that they may be accessed by this adapter. Remove itself from the dictionary so that it does not reference itself, as doing so could end with an endless recursive loop.
Source code in src/odin_control/adapters/dummy.py
put(path, request)
Handle a HTTP PUT request.
Calls the put method of each other adapter that has been loaded, and returns the responses in a dictionary.