importModel method
Creates a new custom model that replicates a source custom model that you import. The source model can be in your Amazon Web Services account or another one.
If the source model is in another Amazon Web Services account, then it must have a resource-based policy that authorizes you to import it.
The source model must be in the same Amazon Web Services Region that you're using when you import. You can't import a model that's in a different Region.
May throw InternalServerException.
May throw InvalidRequestException.
May throw KmsKeyValidationException.
May throw ResourceInUseException.
May throw ResourceLimitExceededException.
May throw ResourceNotFoundException.
May throw ResourceUnavailableException.
May throw TooManyRequestsException.
May throw TooManyTagsException.
Parameter sourceModelArn :
The Amazon Resource Name (ARN) of the custom model to import.
Parameter dataAccessRoleArn :
The Amazon Resource Name (ARN) of the IAM role that grants Amazon
Comprehend permission to use Amazon Key Management Service (KMS) to
encrypt or decrypt the custom model.
Parameter modelKmsKeyId :
ID for the KMS key that Amazon Comprehend uses to encrypt trained custom
models. The ModelKmsKeyId can be either of the following formats:
-
KMS Key ID:
"1234abcd-12ab-34cd-56ef-1234567890ab" -
Amazon Resource Name (ARN) of a KMS Key:
"arn:aws:kms:us-west-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab"
Parameter modelName :
The name to assign to the custom model that is created in Amazon
Comprehend by this import.
Parameter tags :
Tags to associate with the custom model that is created by this import. A
tag is a key-value pair that adds as a metadata to a resource used by
Amazon Comprehend. For example, a tag with "Sales" as the key might be
added to a resource to indicate its use by the sales department.
Parameter versionName :
The version name given to the custom model that is created by this import.
Version names can have a maximum of 256 characters. Alphanumeric
characters, hyphens (-) and underscores (_) are allowed. The version name
must be unique among all models with the same classifier name in the
account/Region.
Implementation
Future<ImportModelResponse> importModel({
required String sourceModelArn,
String? dataAccessRoleArn,
String? modelKmsKeyId,
String? modelName,
List<Tag>? tags,
String? versionName,
}) async {
final headers = <String, String>{
'Content-Type': 'application/x-amz-json-1.1',
'X-Amz-Target': 'Comprehend_20171127.ImportModel'
};
final jsonResponse = await _protocol.send(
method: 'POST',
requestUri: '/',
exceptionFnMap: _exceptionFns,
// TODO queryParams
headers: headers,
payload: {
'SourceModelArn': sourceModelArn,
if (dataAccessRoleArn != null) 'DataAccessRoleArn': dataAccessRoleArn,
if (modelKmsKeyId != null) 'ModelKmsKeyId': modelKmsKeyId,
if (modelName != null) 'ModelName': modelName,
if (tags != null) 'Tags': tags,
if (versionName != null) 'VersionName': versionName,
},
);
return ImportModelResponse.fromJson(jsonResponse.body);
}