Pyjo.AWS.Protocol - Base class of the calls of the protocols of AWS

from Pyjo.AWS.Protocol import Protocol

class Ping(Protocol):
    def build_tx(self, ua, url):
        url.path = '/ping'
        return ua.build_tx('GET', url)

    def parse(self, tx):
        return tx.res.text

Pyjo.AWS.Protocol is the base class of a call of an operation of an API of AWS in one of its protocols, which Pyjo.AWS.Client makes: the call builds the transaction of the request for the endpoint of the client, which the client signs and starts, and reads the result of its response, or the Pyjo.AWS.Error that AWS responds with.

The protocols of AWS are those of the models of its APIs, which the SDKs of AWS are generated from:

Without the models of the APIs, a call takes the names and the structure of the API as its documentation has them, and gives the result as the response has it.

See also

Pyjo.AWS.Client, Pyjo.AWS.Error, https://smithy.io/2.0/aws/protocols/index.html.

Classes

class Pyjo.AWS.Protocol.Pyjo_AWS_Protocol[source]

Pyjo.AWS.Protocol inherits all attributes and methods from Pyjo.Base and implements the following new ones, with T, the type of the result of a call.

__weakref__

list of weak references to the object

build_tx(ua: Pyjo_UserAgent, url: Pyjo_URL) → Pyjo_Transaction_HTTP[source]
tx = call.build_tx(ua, Pyjo.URL.new('https://sts.eu-central-1.amazonaws.com'))

The transaction of the request of the call to an endpoint, of a new Pyjo.URL object, which it may change. A subclass implements it.

error(tx: Pyjo_Transaction_HTTP) → Pyjo_AWS_Error[source]
e = call.error(tx)

The error of a response with an error status, with the status as its code and its message, which a subclass reads of the body.

json_error(tx: Pyjo_Transaction_HTTP) → Pyjo_AWS_Error[source]
e = call.json_error(tx)

The error of a response of JSON, of the protocols of JSON: the code of the header X-Amzn-ErrorType or of the field __type or code, without the namespace before #, and the message of the field message, or error_description of OAuth, as SSO OIDC has it.

new_error(tx: Pyjo_Transaction_HTTP, code: str | None, message: str | None) → Pyjo_AWS_Error[source]
e = call.new_error(tx, 'AccessDenied', 'Not authorized')

A new Pyjo.AWS.Error object of a response, with its status and the ID of its request, of the status if the code is empty.

parse(tx: Pyjo_Transaction_HTTP) → T[source]
result = call.parse(tx)

The result of a response with a successful status. A subclass implements it.

result(tx: Pyjo_Transaction_HTTP) → T[source]
result = call.result(tx)

The result of the response of the call, of parse(), or the Pyjo.AWS.Error of error() raised for an error status.

xml(tx: Pyjo_Transaction_HTTP) → Pyjo_DOM[source]
dom = call.xml(tx)

The XML of a response, as a Pyjo.DOM object with the semantics of XML, whose tags have the case of AWS, as Arn.

xml_error(tx: Pyjo_Transaction_HTTP) → Pyjo_AWS_Error[source]
e = call.xml_error(tx)

The error of a response of XML, of the protocols of XML: the elements Code and Message of Error, and RequestId.

Pyjo.AWS.Protocol.url_for(url: Pyjo_URL, path: str, query: Mapping[str, Any] | None = None) → Pyjo_URL[source]
url = Pyjo.AWS.Protocol.url_for(url, '/2018-10-31/layers', {'MaxItems': 50})

The URL of the path of a call, after the path of an endpoint, with a path that is percent-encoded already, as /a%2Fb, and the parameters of a query, whose values of value_of() are added to those of the path.

Pyjo.AWS.Protocol.value_of(value: Any) → str[source]
string = Pyjo.AWS.Protocol.value_of(True)

A value of a parameter as AWS reads it, true or false of a boolean, and the string of anything else.