executeTransaction method

Future<ExecuteTransactionOutput> executeTransaction({
  1. required List<ParameterizedStatement> transactStatements,
  2. String? clientRequestToken,
  3. ReturnConsumedCapacity? returnConsumedCapacity,
})

This operation allows you to perform transactional reads or writes on data stored in DynamoDB, using PartiQL.

May throw IdempotentParameterMismatchException. May throw InternalServerError. May throw ProvisionedThroughputExceededException. May throw RequestLimitExceeded. May throw ResourceNotFoundException. May throw ThrottlingException. May throw TransactionCanceledException. May throw TransactionInProgressException.

Parameter transactStatements : The list of PartiQL statements representing the transaction to run.

Parameter clientRequestToken : Set this value to get remaining results, if NextToken was returned in the statement response.

Parameter returnConsumedCapacity : Determines the level of detail about either provisioned or on-demand throughput consumption that is returned in the response. For more information, see TransactGetItems and TransactWriteItems.

Implementation

Future<ExecuteTransactionOutput> executeTransaction({
  required List<ParameterizedStatement> transactStatements,
  String? clientRequestToken,
  ReturnConsumedCapacity? returnConsumedCapacity,
}) async {
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.0',
    'X-Amz-Target': 'DynamoDB_20120810.ExecuteTransaction'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'TransactStatements': transactStatements,
      'ClientRequestToken':
          clientRequestToken ?? _s.generateIdempotencyToken(),
      if (returnConsumedCapacity != null)
        'ReturnConsumedCapacity': returnConsumedCapacity.value,
    },
  );

  return ExecuteTransactionOutput.fromJson(jsonResponse.body);
}