func (rm *resourceManager) newDeleteRequestPayload(
	r *resource,
) (*svcsdk.DeleteCacheSubnetGroupInput, error) {
	res := &svcsdk.DeleteCacheSubnetGroupInput{}
	if r.ko.Spec.CacheSubnetGroupName != nil {
		res.SetCacheSubnetGroupName(*r.ko.Spec.CacheSubnetGroupName)
	}
	return res, nil
}
newDeleteRequestPayload returns an SDK-specific struct for the HTTP request
payload of the Delete API call for the resource
package cache_subnet_group
import (
	"context"
	"strings"
	ackv1alpha1 "github.com/aws-controllers-k8s/runtime/apis/core/v1alpha1"
	ackcompare "github.com/aws-controllers-k8s/runtime/pkg/compare"
	ackcondition "github.com/aws-controllers-k8s/runtime/pkg/condition"
	ackerr "github.com/aws-controllers-k8s/runtime/pkg/errors"
	ackrtlog "github.com/aws-controllers-k8s/runtime/pkg/runtime/log"
	"github.com/aws/aws-sdk-go/aws"
	svcsdk "github.com/aws/aws-sdk-go/service/elasticache"
	corev1 "k8s.io/api/core/v1"
	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
	svcapitypes "github.com/aws-controllers-k8s/elasticache-controller/apis/v1alpha1"
)
var (
	_ = &metav1.Time{}
	_ = strings.ToLower("")
	_ = &aws.JSONValue{}
	_ = &svcsdk.ElastiCache{}
	_ = &svcapitypes.CacheSubnetGroup{}
	_ = ackv1alpha1.AWSAccountID("")
	_ = &ackerr.NotFound
	_ = &ackcondition.NotManagedMessage
)
func (rm *resourceManager) sdkFind(
	ctx context.Context,
	r *resource,
) (latest *resource, err error) {
	rlog := ackrtlog.FromContext(ctx)
	exit := rlog.Trace("rm.sdkFind")
	defer exit(err)
	if rm.requiredFieldsMissingFromReadManyInput(r) {
		return nil, ackerr.NotFound
	}
	input, err := rm.newListRequestPayload(r)
	if err != nil {
		return nil, err
	}
	var resp *svcsdk.DescribeCacheSubnetGroupsOutput
	resp, err = rm.sdkapi.DescribeCacheSubnetGroupsWithContext(ctx, input)
	rm.metrics.RecordAPICall("READ_MANY", "DescribeCacheSubnetGroups", err)
	if err != nil {
		if awsErr, ok := ackerr.AWSError(err); ok && awsErr.Code() == "CacheSubnetGroupNotFoundFault" {
			return nil, ackerr.NotFound
		}
		return nil, err
	}
	ko := r.ko.DeepCopy()
	found := false
	for _, elem := range resp.CacheSubnetGroups {
		if elem.ARN != nil {
			if ko.Status.ACKResourceMetadata == nil {
				ko.Status.ACKResourceMetadata = &ackv1alpha1.ResourceMetadata{}
			}
			tmpARN := ackv1alpha1.AWSResourceName(*elem.ARN)
			ko.Status.ACKResourceMetadata.ARN = &tmpARN
		}
		if elem.CacheSubnetGroupDescription != nil {
			ko.Spec.CacheSubnetGroupDescription = elem.CacheSubnetGroupDescription
		} else {
			ko.Spec.CacheSubnetGroupDescription = nil
		}
		if elem.CacheSubnetGroupName != nil {
			ko.Spec.CacheSubnetGroupName = elem.CacheSubnetGroupName
		} else {
			ko.Spec.CacheSubnetGroupName = nil
		}
		if elem.Subnets != nil {
			f3 := []*svcapitypes.Subnet{}
			for _, f3iter := range elem.Subnets {
				f3elem := &svcapitypes.Subnet{}
				if f3iter.SubnetAvailabilityZone != nil {
					f3elemf0 := &svcapitypes.AvailabilityZone{}
					if f3iter.SubnetAvailabilityZone.Name != nil {
						f3elemf0.Name = f3iter.SubnetAvailabilityZone.Name
					}
					f3elem.SubnetAvailabilityZone = f3elemf0
				}
				if f3iter.SubnetIdentifier != nil {
					f3elem.SubnetIdentifier = f3iter.SubnetIdentifier
				}
				if f3iter.SubnetOutpost != nil {
					f3elemf2 := &svcapitypes.SubnetOutpost{}
					if f3iter.SubnetOutpost.SubnetOutpostArn != nil {
						f3elemf2.SubnetOutpostARN = f3iter.SubnetOutpost.SubnetOutpostArn
					}
					f3elem.SubnetOutpost = f3elemf2
				}
				f3 = append(f3, f3elem)
			}
			ko.Status.Subnets = f3
		} else {
			ko.Status.Subnets = nil
		}
		if elem.VpcId != nil {
			ko.Status.VPCID = elem.VpcId
		} else {
			ko.Status.VPCID = nil
		}
		found = true
		break
	}
	if !found {
		return nil, ackerr.NotFound
	}
	rm.setStatusDefaults(ko)
	ko, err = rm.CustomDescribeCacheSubnetGroupsSetOutput(ctx, r, resp, ko)
	if err != nil {
		return nil, err
	}
	return &resource{ko}, nil
}
func (rm *resourceManager) requiredFieldsMissingFromReadManyInput(
	r *resource,
) bool {
	return r.ko.Spec.CacheSubnetGroupName == nil
}
func (rm *resourceManager) newListRequestPayload(
	r *resource,
) (*svcsdk.DescribeCacheSubnetGroupsInput, error) {
	res := &svcsdk.DescribeCacheSubnetGroupsInput{}
	if r.ko.Spec.CacheSubnetGroupName != nil {
		res.SetCacheSubnetGroupName(*r.ko.Spec.CacheSubnetGroupName)
	}
	return res, nil
}
func (rm *resourceManager) sdkCreate(
	ctx context.Context,
	desired *resource,
) (created *resource, err error) {
	rlog := ackrtlog.FromContext(ctx)
	exit := rlog.Trace("rm.sdkCreate")
	defer exit(err)
	input, err := rm.newCreateRequestPayload(ctx, desired)
	if err != nil {
		return nil, err
	}
	var resp *svcsdk.CreateCacheSubnetGroupOutput
	_ = resp
	resp, err = rm.sdkapi.CreateCacheSubnetGroupWithContext(ctx, input)
	rm.metrics.RecordAPICall("CREATE", "CreateCacheSubnetGroup", err)
	if err != nil {
		return nil, err
	}
	ko := desired.ko.DeepCopy()
	if ko.Status.ACKResourceMetadata == nil {
		ko.Status.ACKResourceMetadata = &ackv1alpha1.ResourceMetadata{}
	}
	if resp.CacheSubnetGroup.ARN != nil {
		arn := ackv1alpha1.AWSResourceName(*resp.CacheSubnetGroup.ARN)
		ko.Status.ACKResourceMetadata.ARN = &arn
	}
	if resp.CacheSubnetGroup.CacheSubnetGroupDescription != nil {
		ko.Spec.CacheSubnetGroupDescription = resp.CacheSubnetGroup.CacheSubnetGroupDescription
	} else {
		ko.Spec.CacheSubnetGroupDescription = nil
	}
	if resp.CacheSubnetGroup.CacheSubnetGroupName != nil {
		ko.Spec.CacheSubnetGroupName = resp.CacheSubnetGroup.CacheSubnetGroupName
	} else {
		ko.Spec.CacheSubnetGroupName = nil
	}
	if resp.CacheSubnetGroup.Subnets != nil {
		f3 := []*svcapitypes.Subnet{}
		for _, f3iter := range resp.CacheSubnetGroup.Subnets {
			f3elem := &svcapitypes.Subnet{}
			if f3iter.SubnetAvailabilityZone != nil {
				f3elemf0 := &svcapitypes.AvailabilityZone{}
				if f3iter.SubnetAvailabilityZone.Name != nil {
					f3elemf0.Name = f3iter.SubnetAvailabilityZone.Name
				}
				f3elem.SubnetAvailabilityZone = f3elemf0
			}
			if f3iter.SubnetIdentifier != nil {
				f3elem.SubnetIdentifier = f3iter.SubnetIdentifier
			}
			if f3iter.SubnetOutpost != nil {
				f3elemf2 := &svcapitypes.SubnetOutpost{}
				if f3iter.SubnetOutpost.SubnetOutpostArn != nil {
					f3elemf2.SubnetOutpostARN = f3iter.SubnetOutpost.SubnetOutpostArn
				}
				f3elem.SubnetOutpost = f3elemf2
			}
			f3 = append(f3, f3elem)
		}
		ko.Status.Subnets = f3
	} else {
		ko.Status.Subnets = nil
	}
	if resp.CacheSubnetGroup.VpcId != nil {
		ko.Status.VPCID = resp.CacheSubnetGroup.VpcId
	} else {
		ko.Status.VPCID = nil
	}
	rm.setStatusDefaults(ko)
	return &resource{ko}, nil
}
func (rm *resourceManager) newCreateRequestPayload(
	ctx context.Context,
	r *resource,
) (*svcsdk.CreateCacheSubnetGroupInput, error) {
	res := &svcsdk.CreateCacheSubnetGroupInput{}
	if r.ko.Spec.CacheSubnetGroupDescription != nil {
		res.SetCacheSubnetGroupDescription(*r.ko.Spec.CacheSubnetGroupDescription)
	}
	if r.ko.Spec.CacheSubnetGroupName != nil {
		res.SetCacheSubnetGroupName(*r.ko.Spec.CacheSubnetGroupName)
	}
	if r.ko.Spec.SubnetIDs != nil {
		f2 := []*string{}
		for _, f2iter := range r.ko.Spec.SubnetIDs {
			var f2elem string
			f2elem = *f2iter
			f2 = append(f2, &f2elem)
		}
		res.SetSubnetIds(f2)
	}
	if r.ko.Spec.Tags != nil {
		f3 := []*svcsdk.Tag{}
		for _, f3iter := range r.ko.Spec.Tags {
			f3elem := &svcsdk.Tag{}
			if f3iter.Key != nil {
				f3elem.SetKey(*f3iter.Key)
			}
			if f3iter.Value != nil {
				f3elem.SetValue(*f3iter.Value)
			}
			f3 = append(f3, f3elem)
		}
		res.SetTags(f3)
	}
	return res, nil
}
func (rm *resourceManager) sdkUpdate(
	ctx context.Context,
	desired *resource,
	latest *resource,
	delta *ackcompare.Delta,
) (updated *resource, err error) {
	rlog := ackrtlog.FromContext(ctx)
	exit := rlog.Trace("rm.sdkUpdate")
	defer exit(err)
	input, err := rm.newUpdateRequestPayload(ctx, desired)
	if err != nil {
		return nil, err
	}
	var resp *svcsdk.ModifyCacheSubnetGroupOutput
	_ = resp
	resp, err = rm.sdkapi.ModifyCacheSubnetGroupWithContext(ctx, input)
	rm.metrics.RecordAPICall("UPDATE", "ModifyCacheSubnetGroup", err)
	if err != nil {
		return nil, err
	}
	ko := desired.ko.DeepCopy()
	if ko.Status.ACKResourceMetadata == nil {
		ko.Status.ACKResourceMetadata = &ackv1alpha1.ResourceMetadata{}
	}
	if resp.CacheSubnetGroup.ARN != nil {
		arn := ackv1alpha1.AWSResourceName(*resp.CacheSubnetGroup.ARN)
		ko.Status.ACKResourceMetadata.ARN = &arn
	}
	if resp.CacheSubnetGroup.CacheSubnetGroupDescription != nil {
		ko.Spec.CacheSubnetGroupDescription = resp.CacheSubnetGroup.CacheSubnetGroupDescription
	} else {
		ko.Spec.CacheSubnetGroupDescription = nil
	}
	if resp.CacheSubnetGroup.CacheSubnetGroupName != nil {
		ko.Spec.CacheSubnetGroupName = resp.CacheSubnetGroup.CacheSubnetGroupName
	} else {
		ko.Spec.CacheSubnetGroupName = nil
	}
	if resp.CacheSubnetGroup.Subnets != nil {
		f3 := []*svcapitypes.Subnet{}
		for _, f3iter := range resp.CacheSubnetGroup.Subnets {
			f3elem := &svcapitypes.Subnet{}
			if f3iter.SubnetAvailabilityZone != nil {
				f3elemf0 := &svcapitypes.AvailabilityZone{}
				if f3iter.SubnetAvailabilityZone.Name != nil {
					f3elemf0.Name = f3iter.SubnetAvailabilityZone.Name
				}
				f3elem.SubnetAvailabilityZone = f3elemf0
			}
			if f3iter.SubnetIdentifier != nil {
				f3elem.SubnetIdentifier = f3iter.SubnetIdentifier
			}
			if f3iter.SubnetOutpost != nil {
				f3elemf2 := &svcapitypes.SubnetOutpost{}
				if f3iter.SubnetOutpost.SubnetOutpostArn != nil {
					f3elemf2.SubnetOutpostARN = f3iter.SubnetOutpost.SubnetOutpostArn
				}
				f3elem.SubnetOutpost = f3elemf2
			}
			f3 = append(f3, f3elem)
		}
		ko.Status.Subnets = f3
	} else {
		ko.Status.Subnets = nil
	}
	if resp.CacheSubnetGroup.VpcId != nil {
		ko.Status.VPCID = resp.CacheSubnetGroup.VpcId
	} else {
		ko.Status.VPCID = nil
	}
	rm.setStatusDefaults(ko)
	return &resource{ko}, nil
}
func (rm *resourceManager) newUpdateRequestPayload(
	ctx context.Context,
	r *resource,
) (*svcsdk.ModifyCacheSubnetGroupInput, error) {
	res := &svcsdk.ModifyCacheSubnetGroupInput{}
	if r.ko.Spec.CacheSubnetGroupDescription != nil {
		res.SetCacheSubnetGroupDescription(*r.ko.Spec.CacheSubnetGroupDescription)
	}
	if r.ko.Spec.CacheSubnetGroupName != nil {
		res.SetCacheSubnetGroupName(*r.ko.Spec.CacheSubnetGroupName)
	}
	if r.ko.Spec.SubnetIDs != nil {
		f2 := []*string{}
		for _, f2iter := range r.ko.Spec.SubnetIDs {
			var f2elem string
			f2elem = *f2iter
			f2 = append(f2, &f2elem)
		}
		res.SetSubnetIds(f2)
	}
	return res, nil
}
func (rm *resourceManager) sdkDelete(
	ctx context.Context,
	r *resource,
) (latest *resource, err error) {
	rlog := ackrtlog.FromContext(ctx)
	exit := rlog.Trace("rm.sdkDelete")
	defer exit(err)
	input, err := rm.newDeleteRequestPayload(r)
	if err != nil {
		return nil, err
	}
	var resp *svcsdk.DeleteCacheSubnetGroupOutput
	_ = resp
	resp, err = rm.sdkapi.DeleteCacheSubnetGroupWithContext(ctx, input)
	rm.metrics.RecordAPICall("DELETE", "DeleteCacheSubnetGroup", err)
	return nil, err
}