createTrigger method

Future<CreateTriggerResponse> createTrigger({
  1. required List<Action> actions,
  2. required String name,
  3. required TriggerType type,
  4. String? description,
  5. EventBatchingCondition? eventBatchingCondition,
  6. Predicate? predicate,
  7. String? schedule,
  8. bool? startOnCreation,
  9. Map<String, String>? tags,
  10. String? workflowName,
})

Creates a new trigger.

Job arguments may be logged. Do not pass plaintext secrets as arguments. Retrieve secrets from a Glue Connection, Amazon Web Services Secrets Manager or other secret management mechanism if you intend to keep them within the Job.

May throw AlreadyExistsException. May throw ConcurrentModificationException. May throw EntityNotFoundException. May throw IdempotentParameterMismatchException. May throw InternalServiceException. May throw InvalidInputException. May throw OperationTimeoutException. May throw ResourceNumberLimitExceededException.

Parameter actions : The actions initiated by this trigger when it fires.

Parameter name : The name of the trigger.

Parameter type : The type of the new trigger.

Parameter description : A description of the new trigger.

Parameter eventBatchingCondition : Batch condition that must be met (specified number of events received or batch time window expired) before EventBridge event trigger fires.

Parameter predicate : A predicate to specify when the new trigger should fire.

This field is required when the trigger type is CONDITIONAL.

Parameter schedule : A cron expression used to specify the schedule (see Time-Based Schedules for Jobs and Crawlers. For example, to run something every day at 12:15 UTC, you would specify: cron(15 12 * * ? *).

This field is required when the trigger type is SCHEDULED.

Parameter startOnCreation : Set to true to start SCHEDULED and CONDITIONAL triggers when created. True is not supported for ON_DEMAND triggers.

Parameter tags : The tags to use with this trigger. You may use tags to limit access to the trigger. For more information about tags in Glue, see Amazon Web Services Tags in Glue in the developer guide.

Parameter workflowName : The name of the workflow associated with the trigger.

Implementation

Future<CreateTriggerResponse> createTrigger({
  required List<Action> actions,
  required String name,
  required TriggerType type,
  String? description,
  EventBatchingCondition? eventBatchingCondition,
  Predicate? predicate,
  String? schedule,
  bool? startOnCreation,
  Map<String, String>? tags,
  String? workflowName,
}) async {
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'AWSGlue.CreateTrigger'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'Actions': actions,
      'Name': name,
      'Type': type.value,
      if (description != null) 'Description': description,
      if (eventBatchingCondition != null)
        'EventBatchingCondition': eventBatchingCondition,
      if (predicate != null) 'Predicate': predicate,
      if (schedule != null) 'Schedule': schedule,
      if (startOnCreation != null) 'StartOnCreation': startOnCreation,
      if (tags != null) 'Tags': tags,
      if (workflowName != null) 'WorkflowName': workflowName,
    },
  );

  return CreateTriggerResponse.fromJson(jsonResponse.body);
}