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

package datazone

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

// Deletes and subscription grant in Amazon DataZone.
func (c *Client) DeleteSubscriptionGrant(ctx context.Context, params *DeleteSubscriptionGrantInput, optFns ...func(*Options)) (*DeleteSubscriptionGrantOutput, error) {
	if params == nil {
		params = &DeleteSubscriptionGrantInput{}
	}

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

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

type DeleteSubscriptionGrantInput struct {

	// The ID of the Amazon DataZone domain where the subscription grant is deleted.
	//
	// This member is required.
	DomainIdentifier *string

	// The ID of the subscription grant that is deleted.
	//
	// This member is required.
	Identifier *string

	noSmithyDocumentSerde
}

type DeleteSubscriptionGrantOutput struct {

	// The timestamp of when the subscription grant that is deleted was created.
	//
	// This member is required.
	CreatedAt *time.Time

	// The Amazon DataZone user who created the subscription grant that is deleted.
	//
	// This member is required.
	CreatedBy *string

	// The ID of the Amazon DataZone domain in which the subscription grant is deleted.
	//
	// This member is required.
	DomainId *string

	// The entity to which the subscription is deleted.
	//
	// This member is required.
	GrantedEntity types.GrantedEntity

	// The ID of the subscription grant that is deleted.
	//
	// This member is required.
	Id *string

	// The status of the subscription grant that is deleted.
	//
	// This member is required.
	Status types.SubscriptionGrantOverallStatus

	// The ID of the subscription target associated with the subscription grant that
	// is deleted.
	//
	// This member is required.
	SubscriptionTargetId *string

	// The timestamp of when the subscription grant that is deleted was updated.
	//
	// This member is required.
	UpdatedAt *time.Time

	// The assets for which the subsctiption grant that is deleted gave access.
	Assets []types.SubscribedAsset

	// The ID of the environment in which the subscription grant is deleted.
	EnvironmentId *string

	// The identifier of the subsctiption whose subscription grant is to be deleted.
	//
	// Deprecated: Multiple subscriptions can exist for a single grant
	SubscriptionId *string

	// The Amazon DataZone user who updated the subscription grant that is deleted.
	UpdatedBy *string

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

	noSmithyDocumentSerde
}

func (c *Client) addOperationDeleteSubscriptionGrantMiddlewares(stack *middleware.Stack, options Options) (err error) {
	if err := stack.Serialize.Add(&setOperationInputMiddleware{}, middleware.After); err != nil {
		return err
	}
	err = stack.Serialize.Add(&awsRestjson1_serializeOpDeleteSubscriptionGrant{}, middleware.After)
	if err != nil {
		return err
	}
	err = stack.Deserialize.Add(&awsRestjson1_deserializeOpDeleteSubscriptionGrant{}, middleware.After)
	if err != nil {
		return err
	}
	if err := addProtocolFinalizerMiddlewares(stack, options, "DeleteSubscriptionGrant"); err != nil {
		return fmt.Errorf("add protocol finalizers: %v", err)
	}

	if err = addlegacyEndpointContextSetter(stack, options); err != nil {
		return err
	}
	if err = addSetLoggerMiddleware(stack, options); err != nil {
		return err
	}
	if err = addClientRequestID(stack); 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 = addRetry(stack, options); err != nil {
		return err
	}
	if err = addRawResponseToMetadata(stack); err != nil {
		return err
	}
	if err = addRecordResponseTiming(stack); err != nil {
		return err
	}
	if err = addSpanRetryLoop(stack, options); err != nil {
		return err
	}
	if err = addClientUserAgent(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 = addSetLegacyContextSigningOptionsMiddleware(stack); err != nil {
		return err
	}
	if err = addTimeOffsetBuild(stack, c); err != nil {
		return err
	}
	if err = addUserAgentRetryMode(stack, options); err != nil {
		return err
	}
	if err = addCredentialSource(stack, options); err != nil {
		return err
	}
	if err = addOpDeleteSubscriptionGrantValidationMiddleware(stack); err != nil {
		return err
	}
	if err = stack.Initialize.Add(newServiceMetadataMiddleware_opDeleteSubscriptionGrant(options.Region), middleware.Before); err != nil {
		return err
	}
	if err = addRecursionDetection(stack); 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 = addInterceptBeforeRetryLoop(stack, options); err != nil {
		return err
	}
	if err = addInterceptAttempt(stack, options); err != nil {
		return err
	}
	if err = addInterceptors(stack, options); err != nil {
		return err
	}
	return nil
}

func newServiceMetadataMiddleware_opDeleteSubscriptionGrant(region string) *awsmiddleware.RegisterServiceMetadata {
	return &awsmiddleware.RegisterServiceMetadata{
		Region:        region,
		ServiceID:     ServiceID,
		OperationName: "DeleteSubscriptionGrant",
	}
}
