importHostKey method

Future<ImportHostKeyResponse> importHostKey({
  1. required String hostKeyBody,
  2. required String serverId,
  3. String? description,
  4. List<Tag>? tags,
})

Adds a host key to the server that's specified by the ServerId parameter.

May throw InternalServiceError. May throw InvalidRequestException. May throw ResourceExistsException. May throw ResourceNotFoundException. May throw ServiceUnavailableException. May throw ThrottlingException.

Parameter hostKeyBody : The private key portion of an SSH key pair.

Transfer Family accepts RSA, ECDSA, and ED25519 keys.

Parameter serverId : The identifier of the server that contains the host key that you are importing.

Parameter description : The text description that identifies this host key.

Parameter tags : Key-value pairs that can be used to group and search for host keys.

Implementation

Future<ImportHostKeyResponse> importHostKey({
  required String hostKeyBody,
  required String serverId,
  String? description,
  List<Tag>? tags,
}) async {
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'TransferService.ImportHostKey'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'HostKeyBody': hostKeyBody,
      'ServerId': serverId,
      if (description != null) 'Description': description,
      if (tags != null) 'Tags': tags,
    },
  );

  return ImportHostKeyResponse.fromJson(jsonResponse.body);
}