importKeyPair method

Future<ImportKeyPairResult> importKeyPair({
  1. required String keyPairName,
  2. required String publicKeyBase64,
})

Imports a public SSH key from a specific key pair.

May throw ServiceException. May throw InvalidInputException. May throw NotFoundException. May throw OperationFailureException. May throw AccessDeniedException. May throw AccountSetupInProgressException. May throw UnauthenticatedException.

Parameter keyPairName : The name of the key pair for which you want to import the public key.

Parameter publicKeyBase64 : A base64-encoded public key of the ssh-rsa type.

Implementation

Future<ImportKeyPairResult> importKeyPair({
  required String keyPairName,
  required String publicKeyBase64,
}) async {
  ArgumentError.checkNotNull(keyPairName, 'keyPairName');
  ArgumentError.checkNotNull(publicKeyBase64, 'publicKeyBase64');
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'Lightsail_20161128.ImportKeyPair'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'keyPairName': keyPairName,
      'publicKeyBase64': publicKeyBase64,
    },
  );

  return ImportKeyPairResult.fromJson(jsonResponse.body);
}