QLDBSession

Client

class QLDBSession.Client

A low-level client representing Amazon QLDB Session

The transactional data APIs for Amazon QLDB

Note

Instead of interacting directly with this API, we recommend that you use the Amazon QLDB Driver or the QLDB Shell to execute data transactions on a ledger.

  • If you are working with an AWS SDK, use the QLDB Driver. The driver provides a high-level abstraction layer above this qldbsession data plane and manages SendCommand API calls for you. For information and a list of supported programming languages, see Getting started with the driver in the Amazon QLDB Developer Guide .
  • If you are working with the AWS Command Line Interface (AWS CLI), use the QLDB Shell. The shell is a command line interface that uses the QLDB Driver to interact with a ledger. For information, see Accessing Amazon QLDB using the QLDB Shell .
client = session.create_client('qldb-session')

These are the available methods:

can_paginate(operation_name)

Check if an operation can be paginated.

Parameters
operation_name (string) -- The operation name. This is the same name as the method name on the client. For example, if the method name is create_foo, and you'd normally invoke the operation as client.create_foo(**kwargs), if the create_foo operation can be paginated, you can use the call client.get_paginator("create_foo").
Returns
True if the operation can be paginated, False otherwise.
generate_presigned_url(ClientMethod, Params=None, ExpiresIn=3600, HttpMethod=None)

Generate a presigned url given a client, its method, and arguments

Parameters
  • ClientMethod (string) -- The client method to presign for
  • Params (dict) -- The parameters normally passed to ClientMethod.
  • ExpiresIn (int) -- The number of seconds the presigned url is valid for. By default it expires in an hour (3600 seconds)
  • HttpMethod (string) -- The http method to use on the generated url. By default, the http method is whatever is used in the method's model.
Returns

The presigned url

get_paginator(operation_name)

Create a paginator for an operation.

Parameters
operation_name (string) -- The operation name. This is the same name as the method name on the client. For example, if the method name is create_foo, and you'd normally invoke the operation as client.create_foo(**kwargs), if the create_foo operation can be paginated, you can use the call client.get_paginator("create_foo").
Raises OperationNotPageableError
Raised if the operation is not pageable. You can use the client.can_paginate method to check if an operation is pageable.
Return type
L{botocore.paginate.Paginator}
Returns
A paginator object.
get_waiter(waiter_name)

Returns an object that can wait for some condition.

Parameters
waiter_name (str) -- The name of the waiter to get. See the waiters section of the service docs for a list of available waiters.
Returns
The specified waiter object.
Return type
botocore.waiter.Waiter
send_command(**kwargs)

Sends a command to an Amazon QLDB ledger.

Note

Instead of interacting directly with this API, we recommend that you use the Amazon QLDB Driver or the QLDB Shell to execute data transactions on a ledger.

  • If you are working with an AWS SDK, use the QLDB Driver. The driver provides a high-level abstraction layer above this qldbsession data plane and manages SendCommand API calls for you. For information and a list of supported programming languages, see Getting started with the driver in the Amazon QLDB Developer Guide .
  • If you are working with the AWS Command Line Interface (AWS CLI), use the QLDB Shell. The shell is a command line interface that uses the QLDB Driver to interact with a ledger. For information, see Accessing Amazon QLDB using the QLDB Shell .

See also: AWS API Documentation

Request Syntax

response = client.send_command(
    SessionToken='string',
    StartSession={
        'LedgerName': 'string'
    },
    StartTransaction={}
    ,
    EndSession={}
    ,
    CommitTransaction={
        'TransactionId': 'string',
        'CommitDigest': b'bytes'
    },
    AbortTransaction={}
    ,
    ExecuteStatement={
        'TransactionId': 'string',
        'Statement': 'string',
        'Parameters': [
            {
                'IonBinary': b'bytes',
                'IonText': 'string'
            },
        ]
    },
    FetchPage={
        'TransactionId': 'string',
        'NextPageToken': 'string'
    }
)
Parameters
  • SessionToken (string) --

    Specifies the session token for the current command. A session token is constant throughout the life of the session.

    To obtain a session token, run the StartSession command. This SessionToken is required for every subsequent command that is issued during the current session.

  • StartSession (dict) --

    Command to start a new session. A session token is obtained as part of the response.

    • LedgerName (string) -- [REQUIRED]

      The name of the ledger to start a new session against.

  • StartTransaction (dict) -- Command to start a new transaction.
  • EndSession (dict) -- Command to end the current session.
  • CommitTransaction (dict) --

    Command to commit the specified transaction.

    • TransactionId (string) -- [REQUIRED]

      Specifies the transaction ID of the transaction to commit.

    • CommitDigest (bytes) -- [REQUIRED]

      Specifies the commit digest for the transaction to commit. For every active transaction, the commit digest must be passed. QLDB validates CommitDigest and rejects the commit with an error if the digest computed on the client does not match the digest computed by QLDB.

  • AbortTransaction (dict) -- Command to abort the current transaction.
  • ExecuteStatement (dict) --

    Command to execute a statement in the specified transaction.

    • TransactionId (string) -- [REQUIRED]

      Specifies the transaction ID of the request.

    • Statement (string) -- [REQUIRED]

      Specifies the statement of the request.

    • Parameters (list) --

      Specifies the parameters for the parameterized statement in the request.

      • (dict) --

        A structure that can contain an Amazon Ion value in multiple encoding formats.

        • IonBinary (bytes) --

          An Amazon Ion binary value contained in a ValueHolder structure.

        • IonText (string) --

          An Amazon Ion plaintext value contained in a ValueHolder structure.

  • FetchPage (dict) --

    Command to fetch a page.

    • TransactionId (string) -- [REQUIRED]

      Specifies the transaction ID of the page to be fetched.

    • NextPageToken (string) -- [REQUIRED]

      Specifies the next page token of the page to be fetched.

Return type

dict

Returns

Response Syntax

{
    'StartSession': {
        'SessionToken': 'string'
    },
    'StartTransaction': {
        'TransactionId': 'string'
    },
    'EndSession': {},
    'CommitTransaction': {
        'TransactionId': 'string',
        'CommitDigest': b'bytes'
    },
    'AbortTransaction': {},
    'ExecuteStatement': {
        'FirstPage': {
            'Values': [
                {
                    'IonBinary': b'bytes',
                    'IonText': 'string'
                },
            ],
            'NextPageToken': 'string'
        }
    },
    'FetchPage': {
        'Page': {
            'Values': [
                {
                    'IonBinary': b'bytes',
                    'IonText': 'string'
                },
            ],
            'NextPageToken': 'string'
        }
    }
}

Response Structure

  • (dict) --

    • StartSession (dict) --

      Contains the details of the started session that includes a session token. This SessionToken is required for every subsequent command that is issued during the current session.

      • SessionToken (string) --

        Session token of the started session. This SessionToken is required for every subsequent command that is issued during the current session.

    • StartTransaction (dict) --

      Contains the details of the started transaction.

      • TransactionId (string) --

        The transaction ID of the started transaction.

    • EndSession (dict) --

      Contains the details of the ended session.

    • CommitTransaction (dict) --

      Contains the details of the committed transaction.

      • TransactionId (string) --

        The transaction ID of the committed transaction.

      • CommitDigest (bytes) --

        The commit digest of the committed transaction.

    • AbortTransaction (dict) --

      Contains the details of the aborted transaction.

    • ExecuteStatement (dict) --

      Contains the details of the executed statement.

      • FirstPage (dict) --

        Contains the details of the first fetched page.

        • Values (list) --

          A structure that contains values in multiple encoding formats.

          • (dict) --

            A structure that can contain an Amazon Ion value in multiple encoding formats.

            • IonBinary (bytes) --

              An Amazon Ion binary value contained in a ValueHolder structure.

            • IonText (string) --

              An Amazon Ion plaintext value contained in a ValueHolder structure.

        • NextPageToken (string) --

          The token of the next page.

    • FetchPage (dict) --

      Contains the details of the fetched page.

      • Page (dict) --

        Contains details of the fetched page.

        • Values (list) --

          A structure that contains values in multiple encoding formats.

          • (dict) --

            A structure that can contain an Amazon Ion value in multiple encoding formats.

            • IonBinary (bytes) --

              An Amazon Ion binary value contained in a ValueHolder structure.

            • IonText (string) --

              An Amazon Ion plaintext value contained in a ValueHolder structure.

        • NextPageToken (string) --

          The token of the next page.

Exceptions

Client Exceptions

Client exceptions are available on a client instance via the exceptions property. For more detailed instructions and examples on the exact usage of client exceptions, see the error handling user guide.

The available client exceptions are:

class QLDBSession.Client.exceptions.BadRequestException

Returned if the request is malformed or contains an error such as an invalid parameter value or a missing required parameter.

Example

try:
  ...
except client.exceptions.BadRequestException as e:
  print(e.response)
response

The parsed error response. All exceptions have a top level Error key that provides normalized access to common exception atrributes. All other keys are specific to this service or exception class.

Syntax

{
    'Message': 'string',
    'Code': 'string',
    'Error': {
        'Code': 'string',
        'Message': 'string'
    }
}

Structure

  • (dict) --

    Returned if the request is malformed or contains an error such as an invalid parameter value or a missing required parameter.

    • Message (string) --
    • Code (string) --
    • Error (dict) -- Normalized access to common exception attributes.
      • Code (string) -- An identifier specifying the exception type.
      • Message (string) -- A descriptive message explaining why the exception occured.
class QLDBSession.Client.exceptions.InvalidSessionException

Returned if the session doesn't exist anymore because it timed out or expired.

Example

try:
  ...
except client.exceptions.InvalidSessionException as e:
  print(e.response)
response

The parsed error response. All exceptions have a top level Error key that provides normalized access to common exception atrributes. All other keys are specific to this service or exception class.

Syntax

{
    'Message': 'string',
    'Code': 'string',
    'Error': {
        'Code': 'string',
        'Message': 'string'
    }
}

Structure

  • (dict) --

    Returned if the session doesn't exist anymore because it timed out or expired.

    • Message (string) --
    • Code (string) --
    • Error (dict) -- Normalized access to common exception attributes.
      • Code (string) -- An identifier specifying the exception type.
      • Message (string) -- A descriptive message explaining why the exception occured.
class QLDBSession.Client.exceptions.LimitExceededException

Returned if a resource limit such as number of active sessions is exceeded.

Example

try:
  ...
except client.exceptions.LimitExceededException as e:
  print(e.response)
response

The parsed error response. All exceptions have a top level Error key that provides normalized access to common exception atrributes. All other keys are specific to this service or exception class.

Syntax

{
    'Message': 'string',
    'Error': {
        'Code': 'string',
        'Message': 'string'
    }
}

Structure

  • (dict) --

    Returned if a resource limit such as number of active sessions is exceeded.

    • Message (string) --
    • Error (dict) -- Normalized access to common exception attributes.
      • Code (string) -- An identifier specifying the exception type.
      • Message (string) -- A descriptive message explaining why the exception occured.
class QLDBSession.Client.exceptions.OccConflictException

Returned when a transaction cannot be written to the journal due to a failure in the verification phase of optimistic concurrency control (OCC).

Example

try:
  ...
except client.exceptions.OccConflictException as e:
  print(e.response)
response

The parsed error response. All exceptions have a top level Error key that provides normalized access to common exception atrributes. All other keys are specific to this service or exception class.

Syntax

{
    'Message': 'string',
    'Error': {
        'Code': 'string',
        'Message': 'string'
    }
}

Structure

  • (dict) --

    Returned when a transaction cannot be written to the journal due to a failure in the verification phase of optimistic concurrency control (OCC).

    • Message (string) --
    • Error (dict) -- Normalized access to common exception attributes.
      • Code (string) -- An identifier specifying the exception type.
      • Message (string) -- A descriptive message explaining why the exception occured.
class QLDBSession.Client.exceptions.RateExceededException

Returned when the rate of requests exceeds the allowed throughput.

Example

try:
  ...
except client.exceptions.RateExceededException as e:
  print(e.response)
response

The parsed error response. All exceptions have a top level Error key that provides normalized access to common exception atrributes. All other keys are specific to this service or exception class.

Syntax

{
    'Message': 'string',
    'Error': {
        'Code': 'string',
        'Message': 'string'
    }
}

Structure

  • (dict) --

    Returned when the rate of requests exceeds the allowed throughput.

    • Message (string) --
    • Error (dict) -- Normalized access to common exception attributes.
      • Code (string) -- An identifier specifying the exception type.
      • Message (string) -- A descriptive message explaining why the exception occured.

Paginators

The available paginators are: