swapAlias method

Future<bool> swapAlias({
  1. required String alias,
  2. required String from,
  3. required String to,
})

Changes alias instead of pointing to from, it will point to to.

Implementation

Future<bool> swapAlias({
  required String alias,
  required String from,
  required String to,
}) async {
  final requestBody = {
    'actions': [
      {
        'remove': {'index': from, 'alias': alias}
      },
      {
        'add': {'index': to, 'alias': alias}
      }
    ]
  };
  final rs = await _transport.send(
    Request('POST', ['_aliases'], bodyMap: requestBody),
  );
  return rs.statusCode == 200;
}