failoverDBCluster method

Future<FailoverDBClusterResult> failoverDBCluster({
  1. String? dBClusterIdentifier,
  2. String? targetDBInstanceIdentifier,
})

Forces a failover for a cluster.

A failover for a cluster promotes one of the Amazon DocumentDB replicas (read-only instances) in the cluster to be the primary instance (the cluster writer).

If the primary instance fails, Amazon DocumentDB automatically fails over to an Amazon DocumentDB replica, if one exists. You can force a failover when you want to simulate a failure of a primary instance for testing.

May throw DBClusterNotFoundFault. May throw InvalidDBClusterStateFault. May throw InvalidDBInstanceStateFault.

Parameter dBClusterIdentifier : A cluster identifier to force a failover for. This parameter is not case sensitive.

Constraints:

  • Must match the identifier of an existing DBCluster.

Parameter targetDBInstanceIdentifier : The name of the instance to promote to the primary instance.

You must specify the instance identifier for an Amazon DocumentDB replica in the cluster. For example, mydbcluster-replica1.

Implementation

Future<FailoverDBClusterResult> failoverDBCluster({
  String? dBClusterIdentifier,
  String? targetDBInstanceIdentifier,
}) async {
  final $request = <String, dynamic>{};
  dBClusterIdentifier?.also((arg) => $request['DBClusterIdentifier'] = arg);
  targetDBInstanceIdentifier
      ?.also((arg) => $request['TargetDBInstanceIdentifier'] = arg);
  final $result = await _protocol.send(
    $request,
    action: 'FailoverDBCluster',
    version: '2014-10-31',
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    shape: shapes['FailoverDBClusterMessage'],
    shapes: shapes,
    resultWrapper: 'FailoverDBClusterResult',
  );
  return FailoverDBClusterResult.fromXml($result);
}