startTextTranslationJob method

Future<StartTextTranslationJobResponse> startTextTranslationJob({
  1. required String dataAccessRoleArn,
  2. required InputDataConfig inputDataConfig,
  3. required OutputDataConfig outputDataConfig,
  4. required String sourceLanguageCode,
  5. required List<String> targetLanguageCodes,
  6. String? clientToken,
  7. String? jobName,
  8. List<String>? parallelDataNames,
  9. List<String>? terminologyNames,
})

Starts an asynchronous batch translation job. Batch translation jobs can be used to translate large volumes of text across multiple documents at once. For more information, see async.

Batch translation jobs can be described with the DescribeTextTranslationJob operation, listed with the ListTextTranslationJobs operation, and stopped with the StopTextTranslationJob operation.

May throw TooManyRequestsException. May throw UnsupportedLanguagePairException. May throw InvalidRequestException. May throw ResourceNotFoundException. May throw InternalServerException.

Parameter dataAccessRoleArn : The Amazon Resource Name (ARN) of an AWS Identity Access and Management (IAM) role that grants Amazon Translate read access to your input data. For more nformation, see identity-and-access-management.

Parameter inputDataConfig : Specifies the format and S3 location of the input documents for the translation job.

Parameter outputDataConfig : Specifies the S3 folder to which your job output will be saved.

Parameter sourceLanguageCode : The language code of the input language. For a list of language codes, see what-is-languages.

Amazon Translate does not automatically detect a source language during batch translation jobs.

Parameter targetLanguageCodes : The language code of the output language.

Parameter clientToken : A unique identifier for the request. This token is auto-generated when using the Amazon Translate SDK.

Parameter jobName : The name of the batch translation job to be performed.

Parameter parallelDataNames : The names of the parallel data resources to use in the batch translation job. For a list of available parallel data resources, use the ListParallelData operation.

Parameter terminologyNames : The name of the terminology to use in the batch translation job. For a list of available terminologies, use the ListTerminologies operation.

Implementation

Future<StartTextTranslationJobResponse> startTextTranslationJob({
  required String dataAccessRoleArn,
  required InputDataConfig inputDataConfig,
  required OutputDataConfig outputDataConfig,
  required String sourceLanguageCode,
  required List<String> targetLanguageCodes,
  String? clientToken,
  String? jobName,
  List<String>? parallelDataNames,
  List<String>? terminologyNames,
}) async {
  ArgumentError.checkNotNull(dataAccessRoleArn, 'dataAccessRoleArn');
  _s.validateStringLength(
    'dataAccessRoleArn',
    dataAccessRoleArn,
    20,
    2048,
    isRequired: true,
  );
  ArgumentError.checkNotNull(inputDataConfig, 'inputDataConfig');
  ArgumentError.checkNotNull(outputDataConfig, 'outputDataConfig');
  ArgumentError.checkNotNull(sourceLanguageCode, 'sourceLanguageCode');
  _s.validateStringLength(
    'sourceLanguageCode',
    sourceLanguageCode,
    2,
    5,
    isRequired: true,
  );
  ArgumentError.checkNotNull(targetLanguageCodes, 'targetLanguageCodes');
  _s.validateStringLength(
    'clientToken',
    clientToken,
    1,
    64,
  );
  _s.validateStringLength(
    'jobName',
    jobName,
    1,
    256,
  );
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'AWSShineFrontendService_20170701.StartTextTranslationJob'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'DataAccessRoleArn': dataAccessRoleArn,
      'InputDataConfig': inputDataConfig,
      'OutputDataConfig': outputDataConfig,
      'SourceLanguageCode': sourceLanguageCode,
      'TargetLanguageCodes': targetLanguageCodes,
      'ClientToken': clientToken ?? _s.generateIdempotencyToken(),
      if (jobName != null) 'JobName': jobName,
      if (parallelDataNames != null) 'ParallelDataNames': parallelDataNames,
      if (terminologyNames != null) 'TerminologyNames': terminologyNames,
    },
  );

  return StartTextTranslationJobResponse.fromJson(jsonResponse.body);
}