Pyjo.AWS.Protocol.JSON - Call of the JSON protocol of AWS

from Pyjo.AWS.Client import Client
from Pyjo.AWS.Protocol.JSON import JSON

tables = Client(service='dynamodb').call(JSON('DynamoDB_20120810.ListTables', {'Limit': 10}, version='1.0'))
print(tables['TableNames'])

# Or import the module, as in Google Python Style Guide

import Pyjo.AWS.Client
import Pyjo.AWS.Protocol.JSON

secrets = Pyjo.AWS.Client.new(service='secretsmanager', region='eu-central-1')
call = Pyjo.AWS.Protocol.JSON.new('secretsmanager.GetSecretValue', {'SecretId': 'database'})
secrets.call_p(call).then(lambda secret: print(secret['SecretString'])).wait()

Pyjo.AWS.Protocol.JSON is a call of the JSON protocol of AWS, of the APIs of DynamoDB, KMS, Secrets Manager, CloudWatch Logs, ECR and others: the JSON of the parameters posted to the endpoint, with the target of the operation in the header X-Amz-Target, as DynamoDB_20120810.ListTables, and the version of the protocol in the type of the content, application/x-amz-json-1.1 by default, or 1.0, as the model of the API has it. The result is the JSON of the response.

The error of the response is the code of the header X-Amzn-ErrorType or of the field __type, and the message of the field message.

See also

Pyjo.AWS.Protocol, Pyjo.AWS.Client, https://smithy.io/2.0/aws/protocols/aws-json-1_1-protocol.html.

Classes

class Pyjo.AWS.Protocol.JSON.Pyjo_AWS_Protocol_JSON(target: str, params: Mapping[str, Any] | None = None, *, version: str = '1.1')[source]

Pyjo.AWS.Protocol.JSON inherits all attributes and methods from Pyjo.AWS.Protocol and implements the following new ones.

__init__(target: str, params: Mapping[str, Any] | None = None, *, version: str = '1.1') → None[source]
call = Pyjo.AWS.Protocol.JSON.new('secretsmanager.ListSecrets')
call = Pyjo.AWS.Protocol.JSON.new('DynamoDB_20120810.GetItem', {'TableName': 'users', 'Key': key},
                                  version='1.0')

Construct a new Pyjo.AWS.Protocol.JSON object.

build_tx(ua: Pyjo_UserAgent, url: Pyjo_URL) → Pyjo_Transaction_HTTP[source]
tx = call.build_tx(ua, url)

The transaction of the JSON posted to the endpoint.

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

The error of the JSON of the response.

params
params = call.params

The parameters of the operation, as its JSON.

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

The JSON of the response, or None without a body.

target
target = call.target

The target of the operation, the prefix of the API and the name of the operation, as DynamoDB_20120810.ListTables.

version
version = call.version

The version of the protocol, 1.1 by default, or 1.0.