// Code generated by smithy-go-codegen DO NOT EDIT.

package datazone

import (
	"context"
	"github.com/aws/aws-sdk-go-v2/service/datazone/types"
	"github.com/aws/smithy-go/middleware"
	smithyhttp "github.com/aws/smithy-go/transport/http"
)

// Gets a connection. In Amazon DataZone, a connection enables you to connect your
// resources (domains, projects, and environments) to external resources and
// services.
func (c *Client) GetConnection(ctx context.Context, params *GetConnectionInput, optFns ...func(*Options)) (*GetConnectionOutput, error) {
	if params == nil {
		params = &GetConnectionInput{}
	}

	result, metadata, err := c.invokeOperation(ctx, "GetConnection", params, optFns, c.addOperationGetConnectionMiddlewares)
	if err != nil {
		return nil, err
	}

	out := result.(*GetConnectionOutput)
	out.ResultMetadata = metadata
	return out, nil
}

type GetConnectionInput struct {

	// The ID of the domain where we get the connection.
	//
	// This member is required.
	DomainIdentifier *string

	// The connection ID.
	//
	// This member is required.
	Identifier *string

	// Specifies whether a connection has a secret.
	WithSecret *bool

	noSmithyDocumentSerde
}

type GetConnectionOutput struct {

	// The ID of the connection.
	//
	// This member is required.
	ConnectionId *string

	// The domain ID of the connection.
	//
	// This member is required.
	DomainId *string

	// The domain unit ID of the connection.
	//
	// This member is required.
	DomainUnitId *string

	// The name of the connection.
	//
	// This member is required.
	Name *string

	// The physical endpoints of the connection.
	//
	// This member is required.
	PhysicalEndpoints []types.PhysicalEndpoint

	// The type of the connection.
	//
	// This member is required.
	Type types.ConnectionType

	// The configurations of the connection.
	Configurations []types.Configuration

	// Connection credentials.
	ConnectionCredentials *types.ConnectionCredentials

	// Connection description.
	Description *string

	// The ID of the environment.
	EnvironmentId *string

	// The environment user role.
	EnvironmentUserRole *string

	// The ID of the project.
	ProjectId *string

	// Connection props.
	Props types.ConnectionPropertiesOutput

	// The scope of the connection.
	Scope types.ConnectionScope

	// Metadata pertaining to the operation's result.
	ResultMetadata middleware.Metadata

	noSmithyDocumentSerde
}

func (c *Client) addOperationGetConnectionMiddlewares(stack *middleware.Stack, options Options) (err error) {
	err = stack.Serialize.Add(&awsRestjson1_serializeOpGetConnection{}, middleware.After)
	if err != nil {
		return err
	}
	err = stack.Deserialize.Add(&awsRestjson1_deserializeOpGetConnection{}, middleware.After)
	if err != nil {
		return err
	}

	if err = addlegacyEndpointContextSetter(stack, options); err != nil {
		return err
	}
	if err = addComputeContentLength(stack); err != nil {
		return err
	}
	if err = addResolveEndpointMiddleware(stack, options); err != nil {
		return err
	}
	if err = addComputePayloadSHA256(stack); err != nil {
		return err
	}
	if err = addRecordResponseTiming(stack); err != nil {
		return err
	}
	if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
		return err
	}
	if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
		return err
	}
	if err = addCredentialSource(stack, options); err != nil {
		return err
	}
	if err = addOpGetConnectionValidationMiddleware(stack); err != nil {
		return err
	}
	if err = stack.Initialize.Add(newServiceMetadataMiddleware(options.Region, "GetConnection"), middleware.Before); err != nil {
		return err
	}
	if err = addRequestIDRetrieverMiddleware(stack); err != nil {
		return err
	}
	if err = addResponseErrorMiddleware(stack); err != nil {
		return err
	}
	if err = addRequestResponseLogging(stack, options); err != nil {
		return err
	}
	if err = addDisableHTTPSMiddleware(stack, options); err != nil {
		return err
	}
	if err = addInterceptors(stack, options); err != nil {
		return err
	}
	return nil
}
