createKeyPair method
Creates a custom SSH key pair that you can use with an Amazon Lightsail
instance.
The create key pair operation supports tag-based access
control via request tags. For more information, see the Amazon
Lightsail Developer Guide.
May throw AccessDeniedException.
May throw AccountSetupInProgressException.
May throw InvalidInputException.
May throw NotFoundException.
May throw OperationFailureException.
May throw RegionSetupInProgressException.
May throw ServiceException.
May throw UnauthenticatedException.
Parameter keyPairName :
The name for your new key pair.
Parameter tags :
The tag keys and optional values to add to the resource during create.
Use the TagResource action to tag a resource after it's
created.
Implementation
Future<CreateKeyPairResult> createKeyPair({
required String keyPairName,
List<Tag>? tags,
}) async {
final headers = <String, String>{
'Content-Type': 'application/x-amz-json-1.1',
'X-Amz-Target': 'Lightsail_20161128.CreateKeyPair'
};
final jsonResponse = await _protocol.send(
method: 'POST',
requestUri: '/',
exceptionFnMap: _exceptionFns,
// TODO queryParams
headers: headers,
payload: {
'keyPairName': keyPairName,
if (tags != null) 'tags': tags,
},
);
return CreateKeyPairResult.fromJson(jsonResponse.body);
}