createLedger method

Future<CreateLedgerResponse> createLedger({
  1. required String name,
  2. required PermissionsMode permissionsMode,
  3. bool? deletionProtection,
  4. Map<String, String>? tags,
})

Creates a new ledger in your AWS account.

May throw InvalidParameterException. May throw ResourceAlreadyExistsException. May throw LimitExceededException. May throw ResourceInUseException.

Parameter name : The name of the ledger that you want to create. The name must be unique among all of your ledgers in the current AWS Region.

Naming constraints for ledger names are defined in Quotas in Amazon QLDB in the Amazon QLDB Developer Guide.

Parameter permissionsMode : The permissions mode to assign to the ledger that you want to create.

Parameter deletionProtection : The flag that prevents a ledger from being deleted by any user. If not provided on ledger creation, this feature is enabled (true) by default.

If deletion protection is enabled, you must first disable it before you can delete the ledger using the QLDB API or the AWS Command Line Interface (AWS CLI). You can disable it by calling the UpdateLedger operation to set the flag to false. The QLDB console disables deletion protection for you when you use it to delete a ledger.

Parameter tags : The key-value pairs to add as tags to the ledger that you want to create. Tag keys are case sensitive. Tag values are case sensitive and can be null.

Implementation

Future<CreateLedgerResponse> createLedger({
  required String name,
  required PermissionsMode permissionsMode,
  bool? deletionProtection,
  Map<String, String>? tags,
}) async {
  ArgumentError.checkNotNull(name, 'name');
  _s.validateStringLength(
    'name',
    name,
    1,
    32,
    isRequired: true,
  );
  ArgumentError.checkNotNull(permissionsMode, 'permissionsMode');
  final $payload = <String, dynamic>{
    'Name': name,
    'PermissionsMode': permissionsMode.toValue(),
    if (deletionProtection != null) 'DeletionProtection': deletionProtection,
    if (tags != null) 'Tags': tags,
  };
  final response = await _protocol.send(
    payload: $payload,
    method: 'POST',
    requestUri: '/ledgers',
    exceptionFnMap: _exceptionFns,
  );
  return CreateLedgerResponse.fromJson(response);
}