startPiiEntitiesDetectionJob method

Future<StartPiiEntitiesDetectionJobResponse> startPiiEntitiesDetectionJob({
  1. required String dataAccessRoleArn,
  2. required InputDataConfig inputDataConfig,
  3. required LanguageCode languageCode,
  4. required PiiEntitiesDetectionMode mode,
  5. required OutputDataConfig outputDataConfig,
  6. String? clientRequestToken,
  7. String? jobName,
  8. RedactionConfig? redactionConfig,
})

Starts an asynchronous PII entity detection job for a collection of documents.

May throw InvalidRequestException. May throw TooManyRequestsException. May throw KmsKeyValidationException. May throw InternalServerException.

Parameter dataAccessRoleArn : The Amazon Resource Name (ARN) of the AWS Identity and Access Management (IAM) role that grants Amazon Comprehend read access to your input data.

Parameter inputDataConfig : The input properties for a PII entities detection job.

Parameter languageCode : The language of the input documents.

Parameter mode : Specifies whether the output provides the locations (offsets) of PII entities or a file in which PII entities are redacted.

Parameter outputDataConfig : Provides configuration parameters for the output of PII entity detection jobs.

Parameter clientRequestToken : A unique identifier for the request. If you don't set the client request token, Amazon Comprehend generates one.

Parameter jobName : The identifier of the job.

Parameter redactionConfig : Provides configuration parameters for PII entity redaction.

This parameter is required if you set the Mode parameter to ONLY_REDACTION. In that case, you must provide a RedactionConfig definition that includes the PiiEntityTypes parameter.

Implementation

Future<StartPiiEntitiesDetectionJobResponse> startPiiEntitiesDetectionJob({
  required String dataAccessRoleArn,
  required InputDataConfig inputDataConfig,
  required LanguageCode languageCode,
  required PiiEntitiesDetectionMode mode,
  required OutputDataConfig outputDataConfig,
  String? clientRequestToken,
  String? jobName,
  RedactionConfig? redactionConfig,
}) async {
  ArgumentError.checkNotNull(dataAccessRoleArn, 'dataAccessRoleArn');
  _s.validateStringLength(
    'dataAccessRoleArn',
    dataAccessRoleArn,
    20,
    2048,
    isRequired: true,
  );
  ArgumentError.checkNotNull(inputDataConfig, 'inputDataConfig');
  ArgumentError.checkNotNull(languageCode, 'languageCode');
  ArgumentError.checkNotNull(mode, 'mode');
  ArgumentError.checkNotNull(outputDataConfig, 'outputDataConfig');
  _s.validateStringLength(
    'clientRequestToken',
    clientRequestToken,
    1,
    64,
  );
  _s.validateStringLength(
    'jobName',
    jobName,
    1,
    256,
  );
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'Comprehend_20171127.StartPiiEntitiesDetectionJob'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'DataAccessRoleArn': dataAccessRoleArn,
      'InputDataConfig': inputDataConfig,
      'LanguageCode': languageCode.toValue(),
      'Mode': mode.toValue(),
      'OutputDataConfig': outputDataConfig,
      'ClientRequestToken':
          clientRequestToken ?? _s.generateIdempotencyToken(),
      if (jobName != null) 'JobName': jobName,
      if (redactionConfig != null) 'RedactionConfig': redactionConfig,
    },
  );

  return StartPiiEntitiesDetectionJobResponse.fromJson(jsonResponse.body);
}