Module ogc_api_processes_client.rest
A sample API conforming to the OGC API - Processes - Part 1 standard
This document is an API definition document provided alongside the OGC API - Processes standard. The OGC API - Processes Standard specifies a processing interface to communicate over a RESTful protocol using JavaScript Object Notation (JSON) encodings. The specification allows for the wrapping of computational tasks into executable processes that can be offered by a server and be invoked by a client application.
The version of the OpenAPI document: 1.0.0 Contact: standards-team@ogc.org Generated by OpenAPI Generator (https://openapi-generator.tech)
Do not edit the class manually.
Variables
SUPPORTED_SOCKS_PROXIES
Functions
is_socks_proxy_url
def is_socks_proxy_url(
url
)
Classes
RESTClientObject
class RESTClientObject(
configuration
)
Methods
request
def request(
self,
method,
url,
headers=None,
body=None,
post_params=None,
_request_timeout=None
)
Perform requests.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
| method | None | http request method | None |
| url | None | http request url | None |
| headers | None | http request headers | None |
| body | None | request json body, for application/json |
None |
| post_params | None | request post parameters,application/x-www-form-urlencodedand multipart/form-data |
None |
| _request_timeout | None | timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of (connection, read) timeouts. |
None |
RESTResponse
class RESTResponse(
resp
)
The abstract base class for all I/O classes.
This class provides dummy implementations for many methods that derived classes can override selectively; the default implementations represent a file that cannot be read, written or seeked.
Even though IOBase does not declare read, readinto, or write because their signatures will vary, implementations and clients should consider those methods part of the interface. Also, implementations may raise UnsupportedOperation when operations they do not support are called.
The basic type used for binary data read from or written to a file is bytes. Other bytes-like objects are accepted as method arguments too. In some cases (such as readinto), a writable object is required. Text I/O classes work with str data.
Note that calling any method (except additional calls to close(), which are ignored) on a closed stream should raise a ValueError.
IOBase (and its subclasses) support the iterator protocol, meaning that an IOBase object can be iterated over yielding the lines in a stream.
IOBase also supports the :keyword:with statement. In this example,
fp is closed after the suite of the with statement is complete:
with open('spam.txt', 'r') as fp: fp.write('Spam and eggs!')
Ancestors (in MRO)
- io.IOBase
- _io._IOBase
Class variables
closed
Methods
close
def close(
self,
/
)
Flush and close the IO object.
This method has no effect if the file is already closed.
fileno
def fileno(
self,
/
)
Return underlying file descriptor if one exists.
Raise OSError if the IO object does not use a file descriptor.
flush
def flush(
self,
/
)
Flush write buffers, if applicable.
This is not implemented for read-only and non-blocking streams.
getheader
def getheader(
self,
name,
default=None
)
Returns a given response header.
getheaders
def getheaders(
self
)
Returns a dictionary of the response headers.
isatty
def isatty(
self,
/
)
Return whether this is an 'interactive' stream.
Return False if it can't be determined.
read
def read(
self
)
readable
def readable(
self,
/
)
Return whether object was opened for reading.
If False, read() will raise OSError.
readline
def readline(
self,
size=-1,
/
)
Read and return a line from the stream.
If size is specified, at most size bytes will be read.
The line terminator is always b'\n' for binary files; for text files, the newlines argument to open can be used to select the line terminator(s) recognized.
readlines
def readlines(
self,
hint=-1,
/
)
Return a list of lines from the stream.
hint can be specified to control the number of lines read: no more lines will be read if the total size (in bytes/characters) of all lines so far exceeds hint.
seek
def seek(
self,
offset,
whence=0,
/
)
Change the stream position to the given byte offset.
offset The stream position, relative to 'whence'. whence The relative position to seek from.
The offset is interpreted relative to the position indicated by whence. Values for whence are:
- os.SEEK_SET or 0 -- start of stream (the default); offset should be zero or positive
- os.SEEK_CUR or 1 -- current stream position; offset may be negative
- os.SEEK_END or 2 -- end of stream; offset is usually negative
Return the new absolute position.
seekable
def seekable(
self,
/
)
Return whether object supports random access.
If False, seek(), tell() and truncate() will raise OSError. This method may need to do a test seek().
tell
def tell(
self,
/
)
Return current stream position.
truncate
def truncate(
self,
size=None,
/
)
Truncate file to size bytes.
File pointer is left unchanged. Size defaults to the current IO position as reported by tell(). Return the new size.
writable
def writable(
self,
/
)
Return whether object was opened for writing.
If False, write() will raise OSError.
writelines
def writelines(
self,
lines,
/
)
Write a list of lines to stream.
Line separators are not added, so it is usual for each of the lines provided to have a line separator at the end.
RESTResponseType
class RESTResponseType(
body: '_TYPE_BODY' = '',
headers: 'typing.Mapping[str, str] | typing.Mapping[bytes, bytes] | None' = None,
status: 'int' = 0,
version: 'int' = 0,
version_string: 'str' = 'HTTP/?',
reason: 'str | None' = None,
preload_content: 'bool' = True,
decode_content: 'bool' = True,
original_response: '_HttplibHTTPResponse | None' = None,
pool: 'HTTPConnectionPool | None' = None,
connection: 'HTTPConnection | None' = None,
msg: '_HttplibHTTPMessage | None' = None,
retries: 'Retry | None' = None,
enforce_content_length: 'bool' = True,
request_method: 'str | None' = None,
request_url: 'str | None' = None,
auto_close: 'bool' = True,
sock_shutdown: 'typing.Callable[[int], None] | None' = None
)
HTTP Response container.
Backwards-compatible with :class:http.client.HTTPResponse but the response body is
loaded and decoded on-demand when the data property is accessed. This
class is also compatible with the Python standard library's :mod:io
module, and can hence be treated as a readable object in the context of that
framework.
Extra parameters for behaviour not present in :class:http.client.HTTPResponse:
Attributes
| Name | Type | Description | Default |
|---|---|---|---|
| preload_content | None | If True, the response's body will be preloaded during construction. | None |
| decode_content | None | If True, will attempt to decode the body based on the 'content-encoding' header. |
None |
| original_response | None | When this HTTPResponse wrapper is generated from an :class:http.client.HTTPResponseobject, it's convenient to include the original for debug purposes. It's otherwise unused. |
None |
| retries | None | The retries contains the last :class:~urllib3.util.retry.Retry thatwas used during the request. |
None |
| enforce_content_length | None | Enforce content length checking. Body returned by server must match value of Content-Length header, if present. Otherwise, raise error. |
None |
Ancestors (in MRO)
- urllib3.response.BaseHTTPResponse
- io.IOBase
- _io._IOBase
Class variables
CONTENT_DECODERS
DECODER_ERROR_CLASSES
REDIRECT_STATUSES
Instance variables
closed
connection
data
retries
url
Returns the URL that was the source of this response.
If the request that generated this response redirected, this method will return the final redirect location.
Methods
close
def close(
self
) -> 'None'
Flush and close the IO object.
This method has no effect if the file is already closed.
drain_conn
def drain_conn(
self
) -> 'None'
Read and discard any remaining HTTP response data in the response connection.
Unread data in the HTTPResponse connection blocks the connection from being released back to the pool.
fileno
def fileno(
self
) -> 'int'
Return underlying file descriptor if one exists.
Raise OSError if the IO object does not use a file descriptor.
flush
def flush(
self
) -> 'None'
Flush write buffers, if applicable.
This is not implemented for read-only and non-blocking streams.
get_redirect_location
def get_redirect_location(
self
) -> 'str | None | typing.Literal[False]'
Should we redirect and where to?
Returns:
| Type | Description |
|---|---|
| None | Truthy redirect location string if we got a redirect status code and valid location. None if redirect status and nolocation. False if not a redirect status code. |
getheader
def getheader(
self,
name: 'str',
default: 'str | None' = None
) -> 'str | None'
getheaders
def getheaders(
self
) -> 'HTTPHeaderDict'
geturl
def geturl(
self
) -> 'str | None'
info
def info(
self
) -> 'HTTPHeaderDict'
isatty
def isatty(
self,
/
)
Return whether this is an 'interactive' stream.
Return False if it can't be determined.
isclosed
def isclosed(
self
) -> 'bool'
json
def json(
self
) -> 'typing.Any'
Deserializes the body of the HTTP response as a Python object.
The body of the HTTP response must be encoded using UTF-8, as per
RFC 8529 Section 8.1 <https://www.rfc-editor.org/rfc/rfc8259#section-8.1>_.
To use a custom JSON decoder pass the result of :attr:HTTPResponse.data to
your custom decoder instead.
If the body of the HTTP response is not decodable to UTF-8, a
UnicodeDecodeError will be raised. If the body of the HTTP response is not a
valid JSON document, a json.JSONDecodeError will be raised.
Read more :ref:here <json_content>.
Returns:
| Type | Description |
|---|---|
| None | The body of the HTTP response as a Python object. |
read
def read(
self,
amt: 'int | None' = None,
decode_content: 'bool | None' = None,
cache_content: 'bool' = False
) -> 'bytes'
Similar to :meth:http.client.HTTPResponse.read, but with two additional
parameters: decode_content and cache_content.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
| amt | None | How much of the content to read. If specified, caching is skipped because it doesn't make sense to cache partial content as the full response. |
None |
| decode_content | None | If True, will attempt to decode the body based on the 'content-encoding' header. |
None |
| cache_content | None | If True, will save the returned data such that the same result is returned despite of the state of the underlying file object. This is useful if you want the .data property to continue workingafter having .read() the file object. (Overridden if amt isset.) |
None |
read1
def read1(
self,
amt: 'int | None' = None,
decode_content: 'bool | None' = None
) -> 'bytes'
Similar to http.client.HTTPResponse.read1 and documented
in :meth:io.BufferedReader.read1, but with an additional parameter:
decode_content.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
| amt | None | How much of the content to read. | None |
| decode_content | None | If True, will attempt to decode the body based on the 'content-encoding' header. |
None |
read_chunked
def read_chunked(
self,
amt: 'int | None' = None,
decode_content: 'bool | None' = None
) -> 'typing.Generator[bytes]'
Similar to :meth:HTTPResponse.read, but with an additional
parameter: decode_content.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
| amt | None | How much of the content to read. If specified, caching is skipped because it doesn't make sense to cache partial content as the full response. |
None |
| decode_content | None | If True, will attempt to decode the body based on the 'content-encoding' header. |
None |
readable
def readable(
self
) -> 'bool'
Return whether object was opened for reading.
If False, read() will raise OSError.
readinto
def readinto(
self,
b: 'bytearray | memoryview[int]'
) -> 'int'
readline
def readline(
self,
size=-1,
/
)
Read and return a line from the stream.
If size is specified, at most size bytes will be read.
The line terminator is always b'\n' for binary files; for text files, the newlines argument to open can be used to select the line terminator(s) recognized.
readlines
def readlines(
self,
hint=-1,
/
)
Return a list of lines from the stream.
hint can be specified to control the number of lines read: no more lines will be read if the total size (in bytes/characters) of all lines so far exceeds hint.
release_conn
def release_conn(
self
) -> 'None'
seek
def seek(
self,
offset,
whence=0,
/
)
Change the stream position to the given byte offset.
offset The stream position, relative to 'whence'. whence The relative position to seek from.
The offset is interpreted relative to the position indicated by whence. Values for whence are:
- os.SEEK_SET or 0 -- start of stream (the default); offset should be zero or positive
- os.SEEK_CUR or 1 -- current stream position; offset may be negative
- os.SEEK_END or 2 -- end of stream; offset is usually negative
Return the new absolute position.
seekable
def seekable(
self,
/
)
Return whether object supports random access.
If False, seek(), tell() and truncate() will raise OSError. This method may need to do a test seek().
shutdown
def shutdown(
self
) -> 'None'
stream
def stream(
self,
amt: 'int | None' = 65536,
decode_content: 'bool | None' = None
) -> 'typing.Generator[bytes]'
A generator wrapper for the read() method. A call will block until
amt bytes have been read from the connection or until the
connection is closed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
| amt | None | How much of the content to read. The generator will return up to much data per iteration, but may return less. This is particularly likely when using compressed data. However, the empty string will never be returned. |
None |
| decode_content | None | If True, will attempt to decode the body based on the 'content-encoding' header. |
None |
supports_chunked_reads
def supports_chunked_reads(
self
) -> 'bool'
Checks if the underlying file-like object looks like a
tell
def tell(
self
) -> 'int'
Obtain the number of bytes pulled over the wire so far. May differ from
the amount of content returned by :meth:HTTPResponse.read
if bytes are encoded on the wire (e.g, compressed).
truncate
def truncate(
self,
size=None,
/
)
Truncate file to size bytes.
File pointer is left unchanged. Size defaults to the current IO position as reported by tell(). Return the new size.
writable
def writable(
self,
/
)
Return whether object was opened for writing.
If False, write() will raise OSError.
writelines
def writelines(
self,
lines,
/
)
Write a list of lines to stream.
Line separators are not added, so it is usual for each of the lines provided to have a line separator at the end.