Skip to content

create_connection

create_connection(
    name: ConnectionName,
    authorization_type: ConnectionAuthorizationType,
    auth_parameters: CreateConnectionAuthRequestParameters,
    *,
    config_overrides: Optional[CloudWatchEventsClientConfig] = None,
    description: Optional[ConnectionDescription] = None,
) -> CreateConnectionResponse

Creates a connection. A connection defines the authorization type and credentials to use for authorization with an API destination HTTP endpoint.

Parameters:

Raises:

Source code in docs_src/capo_cloudwatch_events/_services/cloud_watch_events.py
def create_connection(
    self,
    name: "capo_cloudwatch_events.types.connection_name.ConnectionName",
    authorization_type: "capo_cloudwatch_events.types.connection_authorization_type.ConnectionAuthorizationType",
    auth_parameters: "capo_cloudwatch_events.types.create_connection_auth_request_parameters.CreateConnectionAuthRequestParameters",
    *,
    config_overrides: Optional[CloudWatchEventsClientConfig] = None,
    description: Optional[
        "capo_cloudwatch_events.types.connection_description.ConnectionDescription"
    ] = None,
) -> "capo_cloudwatch_events.types.create_connection_response.CreateConnectionResponse":
    """<p>Creates a connection. A connection defines the authorization type and credentials to use for authorization with an API destination HTTP endpoint.</p>

    Args:
        name: <p>The name for the connection to create.</p>
        description: <p>A description for the connection to create.</p>
        authorization_type: <p>The type of authorization to use for the connection.</p>
        auth_parameters: <p>A <code>CreateConnectionAuthRequestParameters</code> object that contains the authorization parameters to use to authorize with the endpoint. </p>

    Raises:
        capo_cloudwatch_events.errors.internal_exception.InternalException: <p>This exception occurs due to unexpected causes.</p>
        capo_cloudwatch_events.errors.limit_exceeded_exception.LimitExceededException: <p>The request failed because it attempted to create resource beyond the allowed service quota.</p>
        capo_cloudwatch_events.errors.resource_already_exists_exception.ResourceAlreadyExistsException: <p>The resource you are trying to create already exists.</p>
        capo_cloudwatch_events.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_cloudwatch_events.types.create_connection_request.CreateConnectionRequest]",
    ) -> OperationResponse[
        "capo_cloudwatch_events.types.create_connection_response.CreateConnectionResponse"
    ]:
        import capo_cloudwatch_events._operations.aws_events.create_connection

        output, http_response = (
            capo_cloudwatch_events._operations.aws_events.create_connection.create_connection(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    def _redact_input(
        input_: "capo_cloudwatch_events.types.create_connection_request.CreateConnectionRequest",
    ) -> dict[str, Any]:
        import capo_cloudwatch_events.types.create_connection_request

        return (
            capo_cloudwatch_events.types.create_connection_request.redact_sensitive(
                input_
            )
        )

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging("CreateConnection", redact_input=_redact_input),
    )
    input_: capo_cloudwatch_events.types.create_connection_request.CreateConnectionRequest = {
        "name": name,
        "authorization_type": authorization_type,
        "auth_parameters": auth_parameters,
    }
    if description is not None:
        input_["description"] = description

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