Skip to content

create_gateway_rule async

create_gateway_rule(
    gateway_identifier: GatewayIdentifier,
    priority: GatewayRulePriority,
    actions: Actions,
    *,
    config_overrides: Optional[AsyncBedrockAgentCoreControlClientConfig] = None,
    client_token: Optional[ClientToken] = None,
    conditions: Optional[Conditions] = None,
    description: Optional[GatewayRuleDescription] = None,
) -> CreateGatewayRuleResponse

Creates a rule for a gateway. Rules define conditions and actions that control how requests are routed and processed through the gateway, including principal-based access control and path-based routing.

Parameters:

  • gateway_identifier (GatewayIdentifier) –

    The identifier of the gateway to create a rule for.

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

    A unique, case-sensitive identifier to ensure that the API request completes no more than one time. If you don't specify this field, a value is randomly generated for you. If this token matches a previous request, the service ignores the request, but doesn't return an error. For more information, see Ensuring idempotency.

  • priority (GatewayRulePriority) –

    The priority of the rule. Rules are evaluated in order of priority, with lower numbers evaluated first. Must be between 1 and 1,000,000.

  • conditions (Optional[Conditions], default: None ) –

    The conditions that must be met for the rule to apply. Conditions can match on principals (IAM ARNs) or request paths.

  • actions (Actions) –

    The actions to take when the rule conditions are met. Actions can route to a specific target or apply a configuration bundle override.

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

    The description of the gateway rule.

Raises:

Source code in docs_src/capo_bedrock_agentcore_control/_services/async_bedrock_agent_core_control.py
async def create_gateway_rule(
    self,
    gateway_identifier: "capo_bedrock_agentcore_control.types.gateway_identifier.GatewayIdentifier",
    priority: "capo_bedrock_agentcore_control.types.gateway_rule_priority.GatewayRulePriority",
    actions: "capo_bedrock_agentcore_control.types.actions.Actions",
    *,
    config_overrides: Optional[AsyncBedrockAgentCoreControlClientConfig] = None,
    client_token: Optional[
        "capo_bedrock_agentcore_control.types.client_token.ClientToken"
    ] = None,
    conditions: Optional[
        "capo_bedrock_agentcore_control.types.conditions.Conditions"
    ] = None,
    description: Optional[
        "capo_bedrock_agentcore_control.types.gateway_rule_description.GatewayRuleDescription"
    ] = None,
) -> "capo_bedrock_agentcore_control.types.create_gateway_rule_response.CreateGatewayRuleResponse":
    """<p>Creates a rule for a gateway. Rules define conditions and actions that control how requests are routed and processed through the gateway, including principal-based access control and path-based routing.</p>

    Args:
        gateway_identifier: <p>The identifier of the gateway to create a rule for.</p>
        client_token: <p>A unique, case-sensitive identifier to ensure that the API request completes no more than one time. If you don't specify this field, a value is randomly generated for you. If this token matches a previous request, the service ignores the request, but doesn't return an error. For more information, see <a href="https://docs.aws.amazon.com/AWSEC2/latest/APIReference/Run_Instance_Idempotency.html">Ensuring idempotency</a>.</p>
        priority: <p>The priority of the rule. Rules are evaluated in order of priority, with lower numbers evaluated first. Must be between 1 and 1,000,000.</p>
        conditions: <p>The conditions that must be met for the rule to apply. Conditions can match on principals (IAM ARNs) or request paths.</p>
        actions: <p>The actions to take when the rule conditions are met. Actions can route to a specific target or apply a configuration bundle override.</p>
        description: <p>The description of the gateway rule.</p>

    Raises:
        capo_bedrock_agentcore_control.errors.access_denied_exception.AccessDeniedException: <p>This exception is thrown when a request is denied per access permissions</p>
        capo_bedrock_agentcore_control.errors.conflict_exception.ConflictException: <p>This exception is thrown when there is a conflict performing an operation</p>
        capo_bedrock_agentcore_control.errors.internal_server_exception.InternalServerException: <p>This exception is thrown if there was an unexpected error during processing of request</p>
        capo_bedrock_agentcore_control.errors.resource_not_found_exception.ResourceNotFoundException: <p>This exception is thrown when a resource referenced by the operation does not exist</p>
        capo_bedrock_agentcore_control.errors.service_quota_exceeded_exception.ServiceQuotaExceededException: <p>This exception is thrown when a request is made beyond the service quota</p>
        capo_bedrock_agentcore_control.errors.throttling_exception.ThrottlingException: <p>This exception is thrown when the number of requests exceeds the limit</p>
        capo_bedrock_agentcore_control.errors.validation_exception.ValidationException: <p>The input fails to satisfy the constraints specified by the service.</p>
        capo_bedrock_agentcore_control.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_bedrock_agentcore_control.types.create_gateway_rule_request.CreateGatewayRuleRequest]",
    ) -> AsyncOperationResponse[
        "capo_bedrock_agentcore_control.types.create_gateway_rule_response.CreateGatewayRuleResponse"
    ]:
        import capo_bedrock_agentcore_control._operations.amazon_bedrock_agent_core_control.create_gateway_rule

        (
            output,
            http_response,
        ) = await capo_bedrock_agentcore_control._operations.amazon_bedrock_agent_core_control.create_gateway_rule.async_create_gateway_rule(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    def _redact_input(
        input_: "capo_bedrock_agentcore_control.types.create_gateway_rule_request.CreateGatewayRuleRequest",
    ) -> dict[str, Any]:
        import capo_bedrock_agentcore_control.types.create_gateway_rule_request

        return capo_bedrock_agentcore_control.types.create_gateway_rule_request.redact_sensitive(
            input_
        )

    def _redact_output(
        output: "capo_bedrock_agentcore_control.types.create_gateway_rule_response.CreateGatewayRuleResponse",
    ) -> dict[str, Any]:
        import capo_bedrock_agentcore_control.types.create_gateway_rule_response

        return capo_bedrock_agentcore_control.types.create_gateway_rule_response.redact_sensitive(
            output
        )

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging(
            "CreateGatewayRule",
            redact_input=_redact_input,
            redact_output=_redact_output,
        ),
    )
    input_: capo_bedrock_agentcore_control.types.create_gateway_rule_request.CreateGatewayRuleRequest = {
        "gateway_identifier": gateway_identifier,
        "priority": priority,
        "actions": actions,
    }
    if client_token is None:
        client_token = str(uuid.uuid4())
    input_["client_token"] = client_token
    if conditions is not None:
        input_["conditions"] = conditions
    if description is not None:
        input_["description"] = description

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