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

package appflow

import (
	"context"
	"github.com/aws/smithy-go/middleware"
	smithyhttp "github.com/aws/smithy-go/transport/http"
)

// Unregisters the custom connector registered in your account that matches the
// connector label provided in the request.
func (c *Client) UnregisterConnector(ctx context.Context, params *UnregisterConnectorInput, optFns ...func(*Options)) (*UnregisterConnectorOutput, error) {
	if params == nil {
		params = &UnregisterConnectorInput{}
	}

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

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

type UnregisterConnectorInput struct {

	// The label of the connector. The label is unique for each ConnectorRegistration
	// in your Amazon Web Services account.
	//
	// This member is required.
	ConnectorLabel *string

	// Indicates whether Amazon AppFlow should unregister the connector, even if it is
	// currently in use in one or more connector profiles. The default value is false.
	ForceDelete bool

	noSmithyDocumentSerde
}

type UnregisterConnectorOutput struct {
	// Metadata pertaining to the operation's result.
	ResultMetadata middleware.Metadata

	noSmithyDocumentSerde
}

func (c *Client) addOperationUnregisterConnectorMiddlewares(stack *middleware.Stack, options Options) (err error) {
	err = stack.Serialize.Add(&awsRestjson1_serializeOpUnregisterConnector{}, middleware.After)
	if err != nil {
		return err
	}
	err = stack.Deserialize.Add(&awsRestjson1_deserializeOpUnregisterConnector{}, 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, options); 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 = addOpUnregisterConnectorValidationMiddleware(stack); err != nil {
		return err
	}
	if err = stack.Initialize.Add(newServiceMetadataMiddleware(options.Region, "UnregisterConnector"), 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
}
