createAdapter method
Creates an adapter, which can be fine-tuned for enhanced performance on
user provided documents. Takes an AdapterName and FeatureType. Currently
the only supported feature type is QUERIES. You can also
provide a Description, Tags, and a ClientRequestToken. You can choose
whether or not the adapter should be AutoUpdated with the AutoUpdate
argument. By default, AutoUpdate is set to DISABLED.
May throw AccessDeniedException.
May throw ConflictException.
May throw IdempotentParameterMismatchException.
May throw InternalServerError.
May throw InvalidParameterException.
May throw LimitExceededException.
May throw ProvisionedThroughputExceededException.
May throw ServiceQuotaExceededException.
May throw ThrottlingException.
May throw ValidationException.
Parameter adapterName :
The name to be assigned to the adapter being created.
Parameter featureTypes :
The type of feature that the adapter is being trained on. Currrenly,
supported feature types are: QUERIES
Parameter autoUpdate :
Controls whether or not the adapter should automatically update.
Parameter clientRequestToken :
Idempotent token is used to recognize the request. If the same token is
used with multiple CreateAdapter requests, the same session is returned.
This token is employed to avoid unintentionally creating the same session
multiple times.
Parameter description :
The description to be assigned to the adapter being created.
Parameter tags :
A list of tags to be added to the adapter.
Implementation
Future<CreateAdapterResponse> createAdapter({
required String adapterName,
required List<FeatureType> featureTypes,
AutoUpdate? autoUpdate,
String? clientRequestToken,
String? description,
Map<String, String>? tags,
}) async {
final headers = <String, String>{
'Content-Type': 'application/x-amz-json-1.1',
'X-Amz-Target': 'Textract.CreateAdapter'
};
final jsonResponse = await _protocol.send(
method: 'POST',
requestUri: '/',
exceptionFnMap: _exceptionFns,
// TODO queryParams
headers: headers,
payload: {
'AdapterName': adapterName,
'FeatureTypes': featureTypes.map((e) => e.value).toList(),
if (autoUpdate != null) 'AutoUpdate': autoUpdate.value,
'ClientRequestToken':
clientRequestToken ?? _s.generateIdempotencyToken(),
if (description != null) 'Description': description,
if (tags != null) 'Tags': tags,
},
);
return CreateAdapterResponse.fromJson(jsonResponse.body);
}