createAlias method
Creates an alias, or a friendly name, for an Amazon Web Services Payment Cryptography key. You can use an alias to identify a key in the console and when you call cryptographic operations such as EncryptData or DecryptData.
You can associate the alias with any key in the same Amazon Web Services Region. Each alias is associated with only one key at a time, but a key can have multiple aliases. You can't create an alias without a key. The alias must be unique in the account and Amazon Web Services Region, but you can create another alias with the same name in a different Amazon Web Services Region.
To change the key that's associated with the alias, call UpdateAlias. To delete the alias, call DeleteAlias. These operations don't affect the underlying key. To get the alias that you created, call ListAliases.
Cross-account use: This operation can't be used across different Amazon Web Services accounts.
Related operations:
May throw AccessDeniedException.
May throw ConflictException.
May throw InternalServerException.
May throw ResourceNotFoundException.
May throw ServiceQuotaExceededException.
May throw ServiceUnavailableException.
May throw ThrottlingException.
May throw ValidationException.
Parameter aliasName :
A friendly name that you can use to refer to a key. An alias must begin
with alias/ followed by a name, for example
alias/ExampleAlias. It can contain only alphanumeric
characters, forward slashes (/), underscores (_), and dashes (-).
Parameter keyArn :
The KeyARN of the key to associate with the alias.
Implementation
Future<CreateAliasOutput> createAlias({
required String aliasName,
String? keyArn,
}) async {
final headers = <String, String>{
'Content-Type': 'application/x-amz-json-1.0',
'X-Amz-Target': 'PaymentCryptographyControlPlane.CreateAlias'
};
final jsonResponse = await _protocol.send(
method: 'POST',
requestUri: '/',
exceptionFnMap: _exceptionFns,
// TODO queryParams
headers: headers,
payload: {
'AliasName': aliasName,
if (keyArn != null) 'KeyArn': keyArn,
},
);
return CreateAliasOutput.fromJson(jsonResponse.body);
}