Skip to content

create_gateway async

create_gateway(
    name: GatewayName,
    role_arn: RoleArn,
    authorizer_type: AuthorizerType,
    *,
    config_overrides: Optional[AsyncBedrockAgentCoreControlClientConfig] = None,
    description: Optional[GatewayDescription] = None,
    client_token: Optional[ClientToken] = None,
    protocol_type: Optional[GatewayProtocolType] = None,
    protocol_configuration: Optional[GatewayProtocolConfiguration] = None,
    authorizer_configuration: Optional[AuthorizerConfiguration] = None,
    kms_key_arn: Optional[KmsKeyArn] = None,
    interceptor_configurations: Optional[GatewayInterceptorConfigurations] = None,
    policy_engine_configuration: Optional[GatewayPolicyEngineConfiguration] = None,
    exception_level: Optional[ExceptionLevel] = None,
    tags: Optional[TagsMap] = None,
) -> CreateGatewayResponse

Creates a gateway for Amazon Bedrock Agent. A gateway serves as an integration point between your agent and external services.

If you specify CUSTOM_JWT as the authorizerType, you must provide an authorizerConfiguration.

Parameters:

  • name (GatewayName) –

    The name of the gateway. The name must be unique within your account.

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

    The description of the gateway.

  • 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.

  • role_arn (RoleArn) –

    The Amazon Resource Name (ARN) of the IAM role that provides permissions for the gateway to access Amazon Web Services services.

  • protocol_type (Optional[GatewayProtocolType], default: None ) –

    The protocol type for the gateway.

  • protocol_configuration (Optional[GatewayProtocolConfiguration], default: None ) –

    The configuration settings for the protocol specified in the protocolType parameter.

  • authorizer_type (AuthorizerType) –

    The type of authorizer to use for the gateway.

    • CUSTOM_JWT - Authorize with a bearer token.

    • AWS_IAM - Authorize with your Amazon Web Services IAM credentials.

    • NONE - No authorization

  • authorizer_configuration (Optional[AuthorizerConfiguration], default: None ) –

    The authorizer configuration for the gateway. Required if authorizerType is CUSTOM_JWT.

  • kms_key_arn (Optional[KmsKeyArn], default: None ) –

    The Amazon Resource Name (ARN) of the KMS key used to encrypt data associated with the gateway.

  • interceptor_configurations (Optional[GatewayInterceptorConfigurations], default: None ) –

    A list of configuration settings for a gateway interceptor. Gateway interceptors allow custom code to be invoked during gateway invocations.

  • policy_engine_configuration (Optional[GatewayPolicyEngineConfiguration], default: None ) –

    The policy engine configuration for the gateway. A policy engine is a collection of policies that evaluates and authorizes agent tool calls. When associated with a gateway, the policy engine intercepts all agent requests and determines whether to allow or deny each action based on the defined policies.

  • exception_level (Optional[ExceptionLevel], default: None ) –

    The level of detail in error messages returned when invoking the gateway.

    • If the value is DEBUG, granular exception messages are returned to help a user debug the gateway.

    • If the value is omitted, a generic error message is returned to the end user.

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

    A map of key-value pairs to associate with the gateway as metadata tags.

Raises:

Source code in docs_src/capo_bedrock_agentcore_control/_services/async_bedrock_agent_core_control.py
async def create_gateway(
    self,
    name: "capo_bedrock_agentcore_control.types.gateway_name.GatewayName",
    role_arn: "capo_bedrock_agentcore_control.types.role_arn.RoleArn",
    authorizer_type: "capo_bedrock_agentcore_control.types.authorizer_type.AuthorizerType",
    *,
    config_overrides: Optional[AsyncBedrockAgentCoreControlClientConfig] = None,
    description: Optional[
        "capo_bedrock_agentcore_control.types.gateway_description.GatewayDescription"
    ] = None,
    client_token: Optional[
        "capo_bedrock_agentcore_control.types.client_token.ClientToken"
    ] = None,
    protocol_type: Optional[
        "capo_bedrock_agentcore_control.types.gateway_protocol_type.GatewayProtocolType"
    ] = None,
    protocol_configuration: Optional[
        "capo_bedrock_agentcore_control.types.gateway_protocol_configuration.GatewayProtocolConfiguration"
    ] = None,
    authorizer_configuration: Optional[
        "capo_bedrock_agentcore_control.types.authorizer_configuration.AuthorizerConfiguration"
    ] = None,
    kms_key_arn: Optional[
        "capo_bedrock_agentcore_control.types.kms_key_arn.KmsKeyArn"
    ] = None,
    interceptor_configurations: Optional[
        "capo_bedrock_agentcore_control.types.gateway_interceptor_configurations.GatewayInterceptorConfigurations"
    ] = None,
    policy_engine_configuration: Optional[
        "capo_bedrock_agentcore_control.types.gateway_policy_engine_configuration.GatewayPolicyEngineConfiguration"
    ] = None,
    exception_level: Optional[
        "capo_bedrock_agentcore_control.types.exception_level.ExceptionLevel"
    ] = None,
    tags: Optional["capo_bedrock_agentcore_control.types.tags_map.TagsMap"] = None,
) -> "capo_bedrock_agentcore_control.types.create_gateway_response.CreateGatewayResponse":
    """<p>Creates a gateway for Amazon Bedrock Agent. A gateway serves as an integration point between your agent and external services.</p> <p>If you specify <code>CUSTOM_JWT</code> as the <code>authorizerType</code>, you must provide an <code>authorizerConfiguration</code>.</p>

    Args:
        name: <p>The name of the gateway. The name must be unique within your account.</p>
        description: <p>The description of the gateway.</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>
        role_arn: <p>The Amazon Resource Name (ARN) of the IAM role that provides permissions for the gateway to access Amazon Web Services services.</p>
        protocol_type: <p>The protocol type for the gateway.</p>
        protocol_configuration: <p>The configuration settings for the protocol specified in the <code>protocolType</code> parameter.</p>
        authorizer_type: <p>The type of authorizer to use for the gateway.</p> <ul> <li> <p> <code>CUSTOM_JWT</code> - Authorize with a bearer token.</p> </li> <li> <p> <code>AWS_IAM</code> - Authorize with your Amazon Web Services IAM credentials.</p> </li> <li> <p> <code>NONE</code> - No authorization</p> </li> </ul>
        authorizer_configuration: <p>The authorizer configuration for the gateway. Required if <code>authorizerType</code> is <code>CUSTOM_JWT</code>.</p>
        kms_key_arn: <p>The Amazon Resource Name (ARN) of the KMS key used to encrypt data associated with the gateway.</p>
        interceptor_configurations: <p>A list of configuration settings for a gateway interceptor. Gateway interceptors allow custom code to be invoked during gateway invocations.</p>
        policy_engine_configuration: <p>The policy engine configuration for the gateway. A policy engine is a collection of policies that evaluates and authorizes agent tool calls. When associated with a gateway, the policy engine intercepts all agent requests and determines whether to allow or deny each action based on the defined policies.</p>
        exception_level: <p>The level of detail in error messages returned when invoking the gateway.</p> <ul> <li> <p>If the value is <code>DEBUG</code>, granular exception messages are returned to help a user debug the gateway.</p> </li> <li> <p>If the value is omitted, a generic error message is returned to the end user.</p> </li> </ul>
        tags: <p>A map of key-value pairs to associate with the gateway as metadata tags.</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.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_request.CreateGatewayRequest]",
    ) -> AsyncOperationResponse[
        "capo_bedrock_agentcore_control.types.create_gateway_response.CreateGatewayResponse"
    ]:
        import capo_bedrock_agentcore_control._operations.amazon_bedrock_agent_core_control.create_gateway

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

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

        return capo_bedrock_agentcore_control.types.create_gateway_request.redact_sensitive(
            input_
        )

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

        return capo_bedrock_agentcore_control.types.create_gateway_response.redact_sensitive(
            output
        )

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging(
            "CreateGateway",
            redact_input=_redact_input,
            redact_output=_redact_output,
        ),
    )
    input_: capo_bedrock_agentcore_control.types.create_gateway_request.CreateGatewayRequest = {
        "name": name,
        "role_arn": role_arn,
        "authorizer_type": authorizer_type,
    }
    if description is not None:
        input_["description"] = description
    if client_token is None:
        client_token = str(uuid.uuid4())
    input_["client_token"] = client_token
    if protocol_type is not None:
        input_["protocol_type"] = protocol_type
    if protocol_configuration is not None:
        input_["protocol_configuration"] = protocol_configuration
    if authorizer_configuration is not None:
        input_["authorizer_configuration"] = authorizer_configuration
    if kms_key_arn is not None:
        input_["kms_key_arn"] = kms_key_arn
    if interceptor_configurations is not None:
        input_["interceptor_configurations"] = interceptor_configurations
    if policy_engine_configuration is not None:
        input_["policy_engine_configuration"] = policy_engine_configuration
    if exception_level is not None:
        input_["exception_level"] = exception_level
    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