http_storage
Base class for HTTP based stores.
API_PREFIX = settings.API_PREFIX
module-attribute
API URL prefix.
HttpStorage
Bases: Storage
An HTTP base storage for a given resource type.
Source code in mlte/store/common/http_storage.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 |
|
clean_url = uri.uri
instance-attribute
Store the clean URL without credentials.
client = client
instance-attribute
The client for requests.
resource_url = self.build_resource_url(resource_type.value)
instance-attribute
Set the base URL for all calls to this resource.
delete(id, groups=OrderedDict())
Delete method, to remove resource.
Source code in mlte/store/common/http_storage.py
75 76 77 78 79 |
|
get(id=None, groups=OrderedDict(), query_args={})
Get method, to read resource.
Source code in mlte/store/common/http_storage.py
64 65 66 67 68 69 70 71 72 73 |
|
post(json, groups=OrderedDict())
Post method, to create resource.
Source code in mlte/store/common/http_storage.py
52 53 54 55 56 |
|
put(json, groups=OrderedDict())
Put method, to update resource.
Source code in mlte/store/common/http_storage.py
58 59 60 61 62 |
|
send_command(method, groups=OrderedDict(), id=None, query_args={}, json=None, resource_type=None)
Sends an HTTP command request to the backend API, and returns a JSON response from it. Commonly not used directly, as it is expected for callers to use the post(), put(), read() and delete() method, but can be used when a non-standard command, which does not properly match the arguments of the previous 4 methods, needs to be sent.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
method
|
MethodType
|
what HTTP method to use, from MethodType |
required |
groups
|
OrderedDict[str, str]
|
a dict of groups to prepend to the request path, where the key is the id of the given group, and the value is the string used to denote the beginning of the next nested level (e.g., {"model1": "version"}, with model1 being a model id, and "version" being the keyword for the next level). |
OrderedDict()
|
id
|
Optional[str]
|
the id of a given resource. |
None
|
query_args
|
dict[str, str]
|
dictionary of query args to append. |
{}
|
json
|
Optional[Any]
|
json payload to send, only for POST and PUT commands. |
None
|
resource_type
|
Optional[str]
|
optional param to overwride the default resource type set up when creating this storage; string to be used as the first item in the URL's path. |
None
|
Source code in mlte/store/common/http_storage.py
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 |
|
start_session()
Perform authentication.
Source code in mlte/store/common/http_storage.py
48 49 50 |
|