// 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"
	"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) {
	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 = 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 = addOpDeleteSubscriptionGrantValidationMiddleware(stack); err != nil {
		return err
	}
	if err = stack.Initialize.Add(newServiceMetadataMiddleware(options.Region, "DeleteSubscriptionGrant"), 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
}
