createKeyPair method
Creates an SSH key pair.
The create key pair
operation supports tag-based access
control via request tags. For more information, see the Lightsail
Dev Guide.
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 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 {
ArgumentError.checkNotNull(keyPairName, 'keyPairName');
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);
}