Skip to content

create_trigger

create_trigger(
    name: NameString,
    type: TriggerType,
    actions: ActionList,
    *,
    config_overrides: Optional[GlueClientConfig] = None,
    workflow_name: Optional[NameString] = None,
    schedule: Optional[GenericString] = None,
    predicate: Optional[Predicate] = None,
    description: Optional[DescriptionString] = None,
    start_on_creation: Optional[BooleanValue] = None,
    tags: Optional[TagsMap] = None,
    event_batching_condition: Optional[EventBatchingCondition] = None,
) -> CreateTriggerResponse

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.

Parameters:

  • name (NameString) –

    The name of the trigger.

  • workflow_name (Optional[NameString], default: None ) –

    The name of the workflow associated with the trigger.

  • type (TriggerType) –

    The type of the new trigger.

  • schedule (Optional[GenericString], default: None ) –

    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.

  • predicate (Optional[Predicate], default: None ) –

    A predicate to specify when the new trigger should fire.

    This field is required when the trigger type is CONDITIONAL.

  • actions (ActionList) –

    The actions initiated by this trigger when it fires.

  • description (Optional[DescriptionString], default: None ) –

    A description of the new trigger.

  • start_on_creation (Optional[BooleanValue], default: None ) –

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

  • tags (Optional[TagsMap], default: None ) –

    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.

  • event_batching_condition (Optional[EventBatchingCondition], default: None ) –

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

Raises:

Source code in docs_src/capo_glue/_services/glue.py
def create_trigger(
    self,
    name: "capo_glue.types.name_string.NameString",
    type: "capo_glue.types.trigger_type.TriggerType",
    actions: "capo_glue.types.action_list.ActionList",
    *,
    config_overrides: Optional[GlueClientConfig] = None,
    workflow_name: Optional["capo_glue.types.name_string.NameString"] = None,
    schedule: Optional["capo_glue.types.generic_string.GenericString"] = None,
    predicate: Optional["capo_glue.types.predicate.Predicate"] = None,
    description: Optional[
        "capo_glue.types.description_string.DescriptionString"
    ] = None,
    start_on_creation: Optional[
        "capo_glue.types.boolean_value.BooleanValue"
    ] = None,
    tags: Optional["capo_glue.types.tags_map.TagsMap"] = None,
    event_batching_condition: Optional[
        "capo_glue.types.event_batching_condition.EventBatchingCondition"
    ] = None,
) -> "capo_glue.types.create_trigger_response.CreateTriggerResponse":
    """<p>Creates a new trigger.</p> <p>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.</p>

    Args:
        name: <p>The name of the trigger.</p>
        workflow_name: <p>The name of the workflow associated with the trigger.</p>
        type: <p>The type of the new trigger.</p>
        schedule: <p>A <code>cron</code> expression used to specify the schedule (see <a href="https://docs.aws.amazon.com/glue/latest/dg/monitor-data-warehouse-schedule.html">Time-Based Schedules for Jobs and Crawlers</a>. For example, to run something every day at 12:15 UTC, you would specify: <code>cron(15 12 * * ? *)</code>.</p> <p>This field is required when the trigger type is SCHEDULED.</p>
        predicate: <p>A predicate to specify when the new trigger should fire.</p> <p>This field is required when the trigger type is <code>CONDITIONAL</code>.</p>
        actions: <p>The actions initiated by this trigger when it fires.</p>
        description: <p>A description of the new trigger.</p>
        start_on_creation: <p>Set to <code>true</code> to start <code>SCHEDULED</code> and <code>CONDITIONAL</code> triggers when created. True is not supported for <code>ON_DEMAND</code> triggers.</p>
        tags: <p>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 <a href="https://docs.aws.amazon.com/glue/latest/dg/monitor-tags.html">Amazon Web Services Tags in Glue</a> in the developer guide. </p>
        event_batching_condition: <p>Batch condition that must be met (specified number of events received or batch time window expired) before EventBridge event trigger fires.</p>

    Raises:
        capo_glue.errors.already_exists_exception.AlreadyExistsException: <p>A resource to be created or added already exists.</p>
        capo_glue.errors.concurrent_modification_exception.ConcurrentModificationException: <p>Two processes are trying to modify a resource simultaneously.</p>
        capo_glue.errors.entity_not_found_exception.EntityNotFoundException: <p>A specified entity does not exist</p>
        capo_glue.errors.idempotent_parameter_mismatch_exception.IdempotentParameterMismatchException: <p>The same unique identifier was associated with two different records.</p>
        capo_glue.errors.internal_service_exception.InternalServiceException: <p>An internal service error occurred.</p>
        capo_glue.errors.invalid_input_exception.InvalidInputException: <p>The input provided was not valid.</p>
        capo_glue.errors.operation_timeout_exception.OperationTimeoutException: <p>The operation timed out.</p>
        capo_glue.errors.resource_number_limit_exceeded_exception.ResourceNumberLimitExceededException: <p>A resource numerical limit was exceeded.</p>
        capo_glue.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_glue.types.create_trigger_request.CreateTriggerRequest]",
    ) -> OperationResponse[
        "capo_glue.types.create_trigger_response.CreateTriggerResponse"
    ]:
        import capo_glue._operations.aws_glue.create_trigger

        output, http_response = (
            capo_glue._operations.aws_glue.create_trigger.create_trigger(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("CreateTrigger")
    )
    input_: capo_glue.types.create_trigger_request.CreateTriggerRequest = {
        "name": name,
        "type": type,
        "actions": actions,
    }
    if workflow_name is not None:
        input_["workflow_name"] = workflow_name
    if schedule is not None:
        input_["schedule"] = schedule
    if predicate is not None:
        input_["predicate"] = predicate
    if description is not None:
        input_["description"] = description
    if start_on_creation is not None:
        input_["start_on_creation"] = start_on_creation
    if tags is not None:
        input_["tags"] = tags
    if event_batching_condition is not None:
        input_["event_batching_condition"] = event_batching_condition

    response = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    response.response.close()
    return response.output