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

package ecr

import (
	"context"
	"github.com/aws/aws-sdk-go-v2/service/ecr/schemas"
	smithy "github.com/aws/smithy-go"
	"github.com/aws/smithy-go/middleware"
	"time"
)

// Deletes a pull through cache rule.
func (c *Client) DeletePullThroughCacheRule(ctx context.Context, params *DeletePullThroughCacheRuleInput, optFns ...func(*Options)) (*DeletePullThroughCacheRuleOutput, error) {
	if params == nil {
		params = &DeletePullThroughCacheRuleInput{}
	}

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

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

type DeletePullThroughCacheRuleInput struct {

	// The Amazon ECR repository prefix associated with the pull through cache rule to
	// delete.
	//
	// This member is required.
	EcrRepositoryPrefix *string

	// The Amazon Web Services account ID associated with the registry that contains
	// the pull through cache rule. If you do not specify a registry, the default
	// registry is assumed.
	RegistryId *string

	noSmithyDocumentSerde
}

func (v *DeletePullThroughCacheRuleInput) Serialize(s smithy.ShapeSerializer) {
	s.WriteStruct(schemas.DeletePullThroughCacheRuleRequest)
	v.SerializeMembers(s)
	s.CloseStruct()
}

func (v *DeletePullThroughCacheRuleInput) SerializeMembers(s smithy.ShapeSerializer) {
	if v.EcrRepositoryPrefix != nil {
		s.WriteString(schemas.DeletePullThroughCacheRuleRequest_ecrRepositoryPrefix, *v.EcrRepositoryPrefix)
	}
	if v.RegistryId != nil {
		s.WriteString(schemas.DeletePullThroughCacheRuleRequest_registryId, *v.RegistryId)
	}
}

type DeletePullThroughCacheRuleOutput struct {

	// The timestamp associated with the pull through cache rule.
	CreatedAt *time.Time

	// The Amazon Resource Name (ARN) of the Amazon Web Services Secrets Manager
	// secret associated with the pull through cache rule.
	CredentialArn *string

	// The ARN of the IAM role associated with the pull through cache rule.
	CustomRoleArn *string

	// The Amazon ECR repository prefix associated with the request.
	EcrRepositoryPrefix *string

	// The registry ID associated with the request.
	RegistryId *string

	// The upstream registry URL associated with the pull through cache rule.
	UpstreamRegistryUrl *string

	// The upstream repository prefix associated with the pull through cache rule.
	UpstreamRepositoryPrefix *string

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

	noSmithyDocumentSerde
}

func (v *DeletePullThroughCacheRuleOutput) Serialize(s smithy.ShapeSerializer) {
	s.WriteStruct(schemas.DeletePullThroughCacheRuleResponse)
	v.SerializeMembers(s)
	s.CloseStruct()
}

func (v *DeletePullThroughCacheRuleOutput) SerializeMembers(s smithy.ShapeSerializer) {
	if v.CreatedAt != nil {
		s.WriteTime(schemas.DeletePullThroughCacheRuleResponse_createdAt, *v.CreatedAt)
	}
	if v.CredentialArn != nil {
		s.WriteString(schemas.DeletePullThroughCacheRuleResponse_credentialArn, *v.CredentialArn)
	}
	if v.CustomRoleArn != nil {
		s.WriteString(schemas.DeletePullThroughCacheRuleResponse_customRoleArn, *v.CustomRoleArn)
	}
	if v.EcrRepositoryPrefix != nil {
		s.WriteString(schemas.DeletePullThroughCacheRuleResponse_ecrRepositoryPrefix, *v.EcrRepositoryPrefix)
	}
	if v.RegistryId != nil {
		s.WriteString(schemas.DeletePullThroughCacheRuleResponse_registryId, *v.RegistryId)
	}
	if v.UpstreamRegistryUrl != nil {
		s.WriteString(schemas.DeletePullThroughCacheRuleResponse_upstreamRegistryUrl, *v.UpstreamRegistryUrl)
	}
	if v.UpstreamRepositoryPrefix != nil {
		s.WriteString(schemas.DeletePullThroughCacheRuleResponse_upstreamRepositoryPrefix, *v.UpstreamRepositoryPrefix)
	}
}
func (v *DeletePullThroughCacheRuleOutput) Deserialize(d smithy.ShapeDeserializer) error {
	return smithy.ReadStruct(d, schemas.DeletePullThroughCacheRuleResponse, func(s *smithy.Schema) error {
		switch s {
		case schemas.DeletePullThroughCacheRuleResponse_createdAt:
			v.CreatedAt = new(time.Time)
			return d.ReadTime(schemas.DeletePullThroughCacheRuleResponse_createdAt, v.CreatedAt)
		case schemas.DeletePullThroughCacheRuleResponse_credentialArn:
			v.CredentialArn = new(string)
			return d.ReadString(schemas.DeletePullThroughCacheRuleResponse_credentialArn, v.CredentialArn)
		case schemas.DeletePullThroughCacheRuleResponse_customRoleArn:
			v.CustomRoleArn = new(string)
			return d.ReadString(schemas.DeletePullThroughCacheRuleResponse_customRoleArn, v.CustomRoleArn)
		case schemas.DeletePullThroughCacheRuleResponse_ecrRepositoryPrefix:
			v.EcrRepositoryPrefix = new(string)
			return d.ReadString(schemas.DeletePullThroughCacheRuleResponse_ecrRepositoryPrefix, v.EcrRepositoryPrefix)
		case schemas.DeletePullThroughCacheRuleResponse_registryId:
			v.RegistryId = new(string)
			return d.ReadString(schemas.DeletePullThroughCacheRuleResponse_registryId, v.RegistryId)
		case schemas.DeletePullThroughCacheRuleResponse_upstreamRegistryUrl:
			v.UpstreamRegistryUrl = new(string)
			return d.ReadString(schemas.DeletePullThroughCacheRuleResponse_upstreamRegistryUrl, v.UpstreamRegistryUrl)
		case schemas.DeletePullThroughCacheRuleResponse_upstreamRepositoryPrefix:
			v.UpstreamRepositoryPrefix = new(string)
			return d.ReadString(schemas.DeletePullThroughCacheRuleResponse_upstreamRepositoryPrefix, v.UpstreamRepositoryPrefix)
		}
		return nil
	})
}
func (c *Client) addOperationDeletePullThroughCacheRuleMiddlewares(stack *middleware.Stack, options Options) (err error) {
	if err := stack.Serialize.Add(&serializeRequestMiddleware{options: &options, operationSchema: smithy.NewOperationSchema(schemas.DeletePullThroughCacheRule, schemas.DeletePullThroughCacheRuleRequest, schemas.DeletePullThroughCacheRuleResponse)}, middleware.After); err != nil {
		return err
	}
	if err := stack.Deserialize.Add(&deserializeResponseMiddleware{options: &options, operationSchema: smithy.NewOperationSchema(schemas.DeletePullThroughCacheRule, schemas.DeletePullThroughCacheRuleRequest, schemas.DeletePullThroughCacheRuleResponse), output: &DeletePullThroughCacheRuleOutput{}}, middleware.After); 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 = addCredentialSource(stack, options); err != nil {
		return err
	}
	if err = addOpDeletePullThroughCacheRuleValidationMiddleware(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 = addInterceptors(stack, options); err != nil {
		return err
	}
	return nil
}
