pystapi-client
A Python client for working with STAPI servers.
API
Client
A Client for interacting with the root of a STAPI
Instances of the Client
class provide a convenient way of interacting
with STAPI APIs that conform to the STAPI API spec.
Source code in pystapi-client/src/pystapi_client/client.py
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 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 187 188 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 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 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 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 |
|
add_conforms_to(name)
Add "conformsTo"
by name.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
Name of :py:class: |
required |
Source code in pystapi-client/src/pystapi_client/client.py
218 219 220 221 222 223 224 225 226 227 |
|
clear_conforms_to()
Clear list of "conformsTo"
urls
Removes the entire list, so :py:meth:has_conforms_to
will
return False after using this method.
Source code in pystapi-client/src/pystapi_client/client.py
210 211 212 213 214 215 216 |
|
create_product_order(product_id, order_parameters)
Create an order for a product
Parameters:
Name | Type | Description | Default |
---|---|---|---|
product_id
|
str
|
The Product ID to place an order for |
required |
order_parameters
|
OrderPayload
|
The parameters for the order |
required |
Source code in pystapi-client/src/pystapi_client/client.py
351 352 353 354 355 356 357 358 359 360 361 362 363 364 |
|
get_conforms_to()
List of "conformsTo"
URIs
Return
List of URIs that the server conforms to
Source code in pystapi-client/src/pystapi_client/client.py
194 195 196 197 198 199 200 |
|
get_order(order_id)
Get a single order from this STAPI API
Parameters:
Name | Type | Description | Default |
---|---|---|---|
order_id
|
str
|
The Order ID to get |
required |
Returns:
Name | Type | Description |
---|---|---|
Order |
Order
|
A STAPI Order |
Raises:
Type | Description |
---|---|
ValueError
|
When the specified order_id does not exist |
Source code in pystapi-client/src/pystapi_client/client.py
419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 |
|
get_orders(limit=None)
Get orders from this STAPI API
Parameters:
Name | Type | Description | Default |
---|---|---|---|
limit
|
int | None
|
Optional limit on the number of orders to return |
None
|
Returns:
Type | Description |
---|---|
Iterator[Order]
|
Iterator[Order]: An iterator of STAPI Orders |
Source code in pystapi-client/src/pystapi_client/client.py
396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 |
|
get_product(product_id)
Get a single product from this STAPI API
Parameters:
Name | Type | Description | Default |
---|---|---|---|
product_id
|
str
|
The Product ID to get |
required |
Returns:
Name | Type | Description |
---|---|---|
Product |
Product
|
A STAPI Product |
Source code in pystapi-client/src/pystapi_client/client.py
287 288 289 290 291 292 293 294 295 296 297 298 |
|
get_product_opportunities(product_id, date_range, geometry, cql2_filter=None, limit=10)
Get all opportunities for a product from this STAPI API Args: product_id: The Product ID to get opportunities for opportunity_parameters: The parameters for the opportunities
Returns:
Type | Description |
---|---|
Iterator[Opportunity]
|
Iterator[Opportunity]: An iterator of STAPI Opportunities |
Source code in pystapi-client/src/pystapi_client/client.py
300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 |
|
get_products(limit=None)
Get all products from this STAPI API
Returns:
Type | Description |
---|---|
Iterator[Product]
|
Iterator[Product]: An iterator of STAPI Products |
Source code in pystapi-client/src/pystapi_client/client.py
268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 |
|
get_single_link(rel=None, media_type=None)
Get a single :class:~stapi_pydantic.Link
instance associated with this object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
rel
|
str | None
|
Optional relationship filter. If set, only links matching this relationship are considered. |
None
|
media_type
|
str | Iterable[str] | None
|
Optional media type filter. If set, only links matching this media type are considered. Can be a single value or an iterable of values. |
None
|
Returns:
Type | Description |
---|---|
Link | None
|
class: |
Source code in pystapi-client/src/pystapi_client/client.py
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 |
|
has_conformance(conformance_class)
Checks whether the API conforms to the given standard.
This method only checks
against the "conformsTo"
property from the API landing page and does not
make any additional calls to a /conformance
endpoint even if the API
provides such an endpoint.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
conformance_class
|
ConformanceClasses | str
|
Either a ConformanceClasses enum member or a string name of a conformance class to check against |
required |
Return
Indicates if the API conforms to the given spec or URI.
Source code in pystapi-client/src/pystapi_client/client.py
239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 |
|
has_conforms_to()
Whether server contains list of "conformsTo"
URIs
Return
Whether the server contains list of "conformsTo"
URIs
Source code in pystapi-client/src/pystapi_client/client.py
186 187 188 189 190 191 192 |
|
open(url, headers=None, parameters=None, request_modifier=None, timeout=None)
classmethod
Opens a STAPI API client.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
url
|
str
|
The URL of a STAPI API |
required |
headers
|
dict[str, str] | None
|
Optional dictionary of additional headers to use in all requests made to any part of this STAPI API |
None
|
parameters
|
dict[str, Any] | None
|
Optional dictionary of query string parameters to include in all requests |
None
|
request_modifier
|
Callable[[Request], Request] | None
|
Optional callable that modifies a Request instance or
returns a new one. This can be useful for injecting Authentication
headers and/or signing fully-formed requests (e.g. signing requests
using AWS SigV4).
The callable should expect a single argument, which will be an instance
of :class: |
None
|
timeout
|
TimeoutTypes | None
|
Optional timeout configuration. Can be:
- None to disable timeouts
- float for a default timeout
- tuple of (connect, read, write, pool) timeouts, each being float or None
- httpx.Timeout instance for fine-grained control
See |
None
|
Returns:
Name | Type | Description |
---|---|---|
Client |
Client
|
A :class: |
Source code in pystapi-client/src/pystapi_client/client.py
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 |
|
read_conformance()
Read the API conformance from the root of the STAPI API.
The conformance is stored in Client.conforms_to
. This method attempts to read
from "/conformance" endpoint first, then falls back to the root endpoint "/".
Note
This method silently continues if endpoints return APIError, no exceptions are raised.
Source code in pystapi-client/src/pystapi_client/client.py
165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 |
|
read_links()
Read the API links from the root of the STAPI API
The links are stored in Client._links
.
Source code in pystapi-client/src/pystapi_client/client.py
147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 |
|
remove_conforms_to(name)
Remove "conformsTo"
by name.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
Name of :py:class: |
required |
Source code in pystapi-client/src/pystapi_client/client.py
229 230 231 232 233 234 235 236 237 |
|
set_conforms_to(conformance_uris)
Set list of "conformsTo"
URIs
Parameters:
Name | Type | Description | Default |
---|---|---|---|
conformance_uris
|
list[str]
|
URIs indicating what the server conforms to |
required |
Source code in pystapi-client/src/pystapi_client/client.py
202 203 204 205 206 207 208 |
|
ConformanceClasses
Bases: Enum
Enumeration class for Conformance Classes
Source code in pystapi-client/src/pystapi_client/conformance.py
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
|