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:
Pyjo.AWS.Protocol.Query, of the form of an action and the XML of its response, as STS, IAM, SQS and SNS have it;Pyjo.AWS.Protocol.JSON, of the JSON of an operation ofX-Amz-Target, as DynamoDB, KMS and Secrets Manager have it;Pyjo.AWS.Protocol.RestJSON, of the JSON of a method and a path, as Lambda, SSO and API Gateway have it;Pyjo.AWS.Protocol.RestXML, of the XML of a method and a path, as S3 and Route 53 have it.
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.Protocolinherits all attributes and methods fromPyjo.Baseand implements the following new ones, withT, 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.URLobject, 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-ErrorTypeor of the field__typeorcode, without the namespace before#, and the message of the fieldmessage, orerror_descriptionof 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.Errorobject 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 thePyjo.AWS.Erroroferror()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.DOMobject with the semantics of XML, whose tags have the case of AWS, asArn.
- 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
CodeandMessageofError, andRequestId.
- 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 ofvalue_of()are added to those of the path.