Skip to content

create_rule async

create_rule(
    instance_id: InstanceId,
    name: RuleName,
    trigger_event_source: RuleTriggerEventSource,
    function: RuleFunction,
    actions: RuleActions,
    publish_status: RulePublishStatus,
    *,
    config_overrides: Optional[AsyncConnectClientConfig] = None,
    pre_evaluation_filters: Optional[PreEvaluationFilters] = None,
    client_token: Optional[ClientToken] = None,
    tags: Optional[TagMap] = None,
) -> CreateRuleResponse

Creates a rule for the specified Connect Customer instance.

Use the Rules Function language to code conditions for the rule.

Parameters:

  • instance_id (InstanceId) –

    The identifier of the Connect Customer instance. You can find the instance ID in the Amazon Resource Name (ARN) of the instance.

  • name (RuleName) –

    A unique name for the rule.

  • trigger_event_source (RuleTriggerEventSource) –

    The event source to trigger the rule.

  • function (RuleFunction) –

    The conditions of the rule.

  • actions (RuleActions) –

    A list of actions to be run when the rule is triggered.

  • publish_status (RulePublishStatus) –

    The publish status of the rule.

  • pre_evaluation_filters (Optional[PreEvaluationFilters], default: None ) –

    The pre-evaluation filters for the rule, that restrict the rule to be applied to only certain resources based on the resource's attributes, such as tags assigned to a contact. The pre-evaluation filters are applied even before rule conditions are evaluated and are used to enforce tag-based-access-control while applying rules.

  • client_token (Optional[ClientToken], default: None ) –

    A unique, case-sensitive identifier that you provide to ensure the idempotency of the request. If not provided, the Amazon Web Services SDK populates this field. For more information about idempotency, see Making retries safe with idempotent APIs.

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

    The tags used to organize, track, or control access for this resource. For example, { "Tags": {"key1":"value1", "key2":"value2"} }.

Raises:

Source code in docs_src/capo_connect/_services/async_connect.py
async def create_rule(
    self,
    instance_id: "capo_connect.types.instance_id.InstanceId",
    name: "capo_connect.types.rule_name.RuleName",
    trigger_event_source: "capo_connect.types.rule_trigger_event_source.RuleTriggerEventSource",
    function: "capo_connect.types.rule_function.RuleFunction",
    actions: "capo_connect.types.rule_actions.RuleActions",
    publish_status: "capo_connect.types.rule_publish_status.RulePublishStatus",
    *,
    config_overrides: Optional[AsyncConnectClientConfig] = None,
    pre_evaluation_filters: Optional[
        "capo_connect.types.pre_evaluation_filters.PreEvaluationFilters"
    ] = None,
    client_token: Optional["capo_connect.types.client_token.ClientToken"] = None,
    tags: Optional["capo_connect.types.tag_map.TagMap"] = None,
) -> "capo_connect.types.create_rule_response.CreateRuleResponse":
    """<p>Creates a rule for the specified Connect Customer instance.</p> <p>Use the <a href="https://docs.aws.amazon.com/connect/latest/APIReference/connect-rules-language.html">Rules Function language</a> to code conditions for the rule. </p>

    Args:
        instance_id: <p>The identifier of the Connect Customer instance. You can <a href="https://docs.aws.amazon.com/connect/latest/adminguide/find-instance-arn.html">find the instance ID</a> in the Amazon Resource Name (ARN) of the instance.</p>
        name: <p>A unique name for the rule.</p>
        trigger_event_source: <p>The event source to trigger the rule.</p>
        function: <p>The conditions of the rule.</p>
        actions: <p>A list of actions to be run when the rule is triggered.</p>
        publish_status: <p>The publish status of the rule.</p>
        pre_evaluation_filters: <p>The pre-evaluation filters for the rule, that restrict the rule to be applied to only certain resources based on the resource's attributes, such as tags assigned to a contact. The pre-evaluation filters are applied even before rule conditions are evaluated and are used to enforce tag-based-access-control while applying rules.</p>
        client_token: <p>A unique, case-sensitive identifier that you provide to ensure the idempotency of the request. If not provided, the Amazon Web Services SDK populates this field. For more information about idempotency, see <a href="https://aws.amazon.com/builders-library/making-retries-safe-with-idempotent-APIs/">Making retries safe with idempotent APIs</a>.</p>
        tags: <p>The tags used to organize, track, or control access for this resource. For example, { "Tags": {"key1":"value1", "key2":"value2"} }.</p>

    Raises:
        capo_connect.errors.access_denied_exception.AccessDeniedException: <p>You do not have sufficient permissions to perform this action.</p>
        capo_connect.errors.internal_service_exception.InternalServiceException: <p>Request processing failed because of an error or failure with the service.</p>
        capo_connect.errors.invalid_request_exception.InvalidRequestException: <p>The request is not valid.</p>
        capo_connect.errors.resource_conflict_exception.ResourceConflictException: <p>A resource already has that name.</p>
        capo_connect.errors.resource_not_found_exception.ResourceNotFoundException: <p>The specified resource was not found.</p>
        capo_connect.errors.service_quota_exceeded_exception.ServiceQuotaExceededException: <p>The service quota has been exceeded.</p>
        capo_connect.errors.throttling_exception.ThrottlingException: <p>The throttling limit has been exceeded.</p>
        capo_connect.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_connect.types.create_rule_request.CreateRuleRequest]",
    ) -> AsyncOperationResponse[
        "capo_connect.types.create_rule_response.CreateRuleResponse"
    ]:
        import capo_connect._operations.amazon_connect_service.create_rule

        (
            output,
            http_response,
        ) = await capo_connect._operations.amazon_connect_service.create_rule.async_create_rule(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("CreateRule")
    )
    input_: capo_connect.types.create_rule_request.CreateRuleRequest = {
        "instance_id": instance_id,
        "name": name,
        "trigger_event_source": trigger_event_source,
        "function": function,
        "actions": actions,
        "publish_status": publish_status,
    }
    if pre_evaluation_filters is not None:
        input_["pre_evaluation_filters"] = pre_evaluation_filters
    if client_token is None:
        client_token = str(uuid.uuid4())
    input_["client_token"] = client_token
    if tags is not None:
        input_["tags"] = tags

    response = await aexecute_pipeline(
        AsyncOperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    await response.response.aclose()
    return response.output