Skip to content

create_connection

create_connection(
    connection_name: ConnectionName,
    *,
    config_overrides: Optional[CodeConnectionsClientConfig] = None,
    provider_type: Optional[ProviderType] = None,
    tags: Optional[TagList] = None,
    host_arn: Optional[HostArn] = None,
    provider_endpoint: Optional[Url] = None,
) -> CreateConnectionOutput

Creates a connection that can then be given to other Amazon Web Services services like CodePipeline so that it can access third-party code repositories. The connection is in pending status until the third-party connection handshake is completed from the console.

Parameters:

  • provider_type (Optional[ProviderType], default: None ) –

    The name of the external provider where your third-party code repository is configured.

  • connection_name (ConnectionName) –

    The name of the connection to be created.

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

    The key-value pair to use when tagging the resource.

  • host_arn (Optional[HostArn], default: None ) –

    The Amazon Resource Name (ARN) of the host associated with the connection to be created.

  • provider_endpoint (Optional[Url], default: None ) –

    The endpoint of the ghe.com tenant where your organization resides. Provide this parameter only when ProviderType is GitHubEnterpriseCloudDataResidency. Leave this parameter empty for all other provider types.

Raises:

Source code in docs_src/capo_codeconnections/_services/code_connections.py
def create_connection(
    self,
    connection_name: "capo_codeconnections.types.connection_name.ConnectionName",
    *,
    config_overrides: Optional[CodeConnectionsClientConfig] = None,
    provider_type: Optional[
        "capo_codeconnections.types.provider_type.ProviderType"
    ] = None,
    tags: Optional["capo_codeconnections.types.tag_list.TagList"] = None,
    host_arn: Optional["capo_codeconnections.types.host_arn.HostArn"] = None,
    provider_endpoint: Optional["capo_codeconnections.types.url.Url"] = None,
) -> "capo_codeconnections.types.create_connection_output.CreateConnectionOutput":
    """<p>Creates a connection that can then be given to other Amazon Web Services services like CodePipeline so that it can access third-party code repositories. The connection is in pending status until the third-party connection handshake is completed from the console.</p>

    Args:
        provider_type: <p>The name of the external provider where your third-party code repository is configured.</p>
        connection_name: <p>The name of the connection to be created.</p>
        tags: <p>The key-value pair to use when tagging the resource.</p>
        host_arn: <p>The Amazon Resource Name (ARN) of the host associated with the connection to be created.</p>
        provider_endpoint: <p>The endpoint of the ghe.com tenant where your organization resides. Provide this parameter only when <code>ProviderType</code> is <code>GitHubEnterpriseCloudDataResidency</code>. Leave this parameter empty for all other provider types.</p>

    Raises:
        capo_codeconnections.errors.invalid_input_exception.InvalidInputException: <p>The input is not valid. Verify that the action is typed correctly.</p>
        capo_codeconnections.errors.limit_exceeded_exception.LimitExceededException: <p>Exceeded the maximum limit for connections.</p>
        capo_codeconnections.errors.resource_not_found_exception.ResourceNotFoundException: <p>Resource not found. Verify the connection resource ARN and try again.</p>
        capo_codeconnections.errors.resource_unavailable_exception.ResourceUnavailableException: <p>Resource not found. Verify the ARN for the host resource and try again.</p>
        capo_codeconnections.errors.unsupported_provider_type_exception.UnsupportedProviderTypeException: <p>The specified provider type is not supported for connections.</p>
        capo_codeconnections.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_codeconnections.types.create_connection_input.CreateConnectionInput]",
    ) -> OperationResponse[
        "capo_codeconnections.types.create_connection_output.CreateConnectionOutput"
    ]:
        if req.options.protocol == "awsJson1_0":
            import capo_codeconnections._operations.code_connections_20231201.aws_json1_0.create_connection

            output, http_response = (
                capo_codeconnections._operations.code_connections_20231201.aws_json1_0.create_connection.create_connection(
                    req.options, req.input
                )
            )
        elif req.options.protocol == "rpcv2Cbor":
            import capo_codeconnections._operations.code_connections_20231201.rpcv2_cbor.create_connection

            output, http_response = (
                capo_codeconnections._operations.code_connections_20231201.rpcv2_cbor.create_connection.create_connection(
                    req.options, req.input
                )
            )
        else:
            raise ValueError(f"unknown protocol {req.options.protocol!r}")
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("CreateConnection")
    )
    input_: capo_codeconnections.types.create_connection_input.CreateConnectionInput = {
        "connection_name": connection_name
    }
    if provider_type is not None:
        input_["provider_type"] = provider_type
    if tags is not None:
        input_["tags"] = tags
    if host_arn is not None:
        input_["host_arn"] = host_arn
    if provider_endpoint is not None:
        input_["provider_endpoint"] = provider_endpoint

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