Reference
clients.base.BaseClient
Client mixin.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
url
|
str
|
base url for requests |
required |
trailing
|
str
|
trailing chars (e.g. /) appended to the url |
''
|
**attrs
|
additional Session attributes |
{}
|
Source code in clients/base.py
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 | |
__truediv__(path)
Return a cloned client with appended path.
Source code in clients/base.py
47 48 49 | |
delete(path='', **kwargs)
DELETE request with optional path.
Source code in clients/base.py
89 90 91 | |
get(path='', **kwargs)
GET request with optional path.
Source code in clients/base.py
65 66 67 | |
head(path='', **kwargs)
HEAD request with optional path.
Source code in clients/base.py
73 74 75 | |
options(path='', **kwargs)
OPTIONS request with optional path.
Source code in clients/base.py
69 70 71 | |
patch(path='', json=None, **kwargs)
PATCH request with optional path and json body.
Source code in clients/base.py
85 86 87 | |
post(path='', json=None, **kwargs)
POST request with optional path and json body.
Source code in clients/base.py
77 78 79 | |
put(path='', json=None, **kwargs)
PUT request with optional path and json body.
Source code in clients/base.py
81 82 83 | |
request(method, path, **kwargs)
Send request with relative or absolute path and return response.
Source code in clients/base.py
60 61 62 63 | |
clients.Client
Bases: BaseClient, Client
Source code in clients/base.py
94 95 96 97 98 | |
stream(method, path, **kwargs)
Send request with relative or absolute path and stream response.
Source code in clients/base.py
95 96 97 98 | |
clients.Resource
Bases: Client
A Client which returns json content and has syntactic support for requests.
Source code in clients/base.py
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 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 | |
__call__(path='', **params)
GET request with params.
Source code in clients/base.py
140 141 142 | |
__contains__(path)
Return whether endpoint exists according to HEAD request.
Source code in clients/base.py
136 137 138 | |
authorize(path='', **kwargs)
Acquire oauth access token and set Authorization header.
Source code in clients/base.py
181 182 183 184 185 186 | |
create(path='', json=None, **kwargs)
POST request and return location.
Source code in clients/base.py
170 171 172 173 | |
download(file, path='', **kwargs)
Output streamed GET request to file.
Source code in clients/base.py
175 176 177 178 179 | |
request(method, path, **kwargs)
Send request with path and return processed content.
Source code in clients/base.py
113 114 115 116 117 118 119 120 121 | |
stream(method='GET', path='', **kwargs)
Iterate lines or chunks from streamed request.
Source code in clients/base.py
123 124 125 126 127 128 129 130 131 132 | |
update(path='', callback=None, **json)
PATCH request with json params.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
callback
|
Callable | None
|
optionally update with GET and validated PUT.
|
None
|
Source code in clients/base.py
157 158 159 160 161 162 163 164 165 166 167 168 | |
updating(path='', **kwargs)
Context manager to GET and conditionally PUT json data.
Source code in clients/base.py
149 150 151 152 153 154 155 | |
clients.Remote
Bases: Client
A Client which defaults to posts with json bodies, i.e., RPC.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
url
|
str
|
base url for requests |
required |
json
|
Mapping
|
default json body for all calls |
{}
|
**kwargs
|
same options as |
{}
|
Source code in clients/base.py
189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 | |
__call__(path='', **json)
POST request with json body and check result.
Source code in clients/base.py
209 210 211 212 | |
check(result)
staticmethod
Override to return result or raise error, for APIs which don't use status codes.
Source code in clients/base.py
214 215 216 217 | |
clients.Graph
Bases: Remote
A Remote client which executes GraphQL queries.
Source code in clients/base.py
220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 | |
check(result)
classmethod
Return data or raise errors.
Source code in clients/base.py
225 226 227 228 229 230 | |
execute(query, **variables)
Execute query over POST.
Source code in clients/base.py
232 233 234 | |
clients.Proxy
Bases: Client
An extensible embedded proxy client to multiple hosts.
The default implementation provides load balancing based on active connections. It does not provide error handling or retrying.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*urls
|
str
|
base urls for requests |
()
|
**kwargs
|
same options as |
{}
|
Source code in clients/base.py
259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 | |
choice(method)
Return chosen url according to priority.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
method
|
str
|
placeholder for extensions which distinguish read/write requests |
required |
Source code in clients/base.py
290 291 292 293 294 295 296 297 298 299 300 | |
priority(url)
Return comparable priority for url.
Minimizes errors, failures (500s), and active connections. None may be used to eliminate from consideration.
Source code in clients/base.py
281 282 283 284 285 286 287 288 | |
request(method, path, **kwargs)
Send request with relative or absolute path and return response.
Source code in clients/base.py
302 303 304 305 306 307 308 | |
clients.AsyncClient
Bases: BaseClient, AsyncClient
Source code in clients/aio.py
13 14 15 16 | |
run(name, *args, **kwargs)
Synchronously call method and run coroutine.
Source code in clients/aio.py
14 15 16 | |
clients.AsyncResource
Bases: AsyncClient
An AsyncClient which returns json content and has syntactic support for requests.
Source code in clients/aio.py
19 20 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 | |
authorize(path='', **kwargs)
async
Acquire oauth access token and set Authorization header.
Source code in clients/aio.py
64 65 66 67 68 69 70 | |
request(method, path, **kwargs)
async
Send request with path and return processed content.
Source code in clients/aio.py
28 29 30 31 32 33 34 35 36 | |
update(path='', callback=None, **json)
async
PATCH request with json params.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
callback
|
Callable | None
|
optionally update with GET and validated PUT.
|
None
|
Source code in clients/aio.py
51 52 53 54 55 56 57 58 59 60 61 62 | |
updating(path='', **kwargs)
async
Context manager to GET and conditionally PUT json data.
Source code in clients/aio.py
43 44 45 46 47 48 49 | |
clients.AsyncRemote
Bases: AsyncClient
An AsyncClient which defaults to posts with json bodies, i.e., RPC.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
url
|
str
|
base url for requests |
required |
json
|
Mapping
|
default json body for all calls |
{}
|
**kwargs
|
same options as |
{}
|
Source code in clients/aio.py
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 | |
__call__(path='', **json)
async
POST request with json body and check result.
Source code in clients/aio.py
94 95 96 97 | |
clients.AsyncGraph
Bases: AsyncRemote
An AsyncRemote client which executes GraphQL queries.
Source code in clients/aio.py
100 101 102 103 104 105 | |
clients.AsyncProxy
Bases: AsyncClient
An extensible embedded proxy client to multiple hosts.
The default implementation provides load balancing based on active connections. It does not provide error handling or retrying.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*urls
|
str
|
base urls for requests |
()
|
**kwargs
|
same options as |
{}
|
Source code in clients/aio.py
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 | |
request(method, path, **kwargs)
async
Send request with relative or absolute path and return response.
Source code in clients/aio.py
132 133 134 135 136 137 138 | |
clients.singleton(*args, **kwargs)
Return a decorator for singleton class instances.
Source code in clients/__init__.py
5 6 7 | |