func (rm *resourceManager) newListRequestPayload(
	r *resource,
) (*svcsdk.DescribeReplicationGroupsInput, error) {
	res := &svcsdk.DescribeReplicationGroupsInput{}
	if r.ko.Spec.ReplicationGroupID != nil {
		res.SetReplicationGroupId(*r.ko.Spec.ReplicationGroupID)
	}
	return res, nil
}
newListRequestPayload returns SDK-specific struct for the HTTP request
payload of the List API call for the resource
package replication_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.ReplicationGroup{}
	_ = 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.DescribeReplicationGroupsOutput
	resp, err = rm.sdkapi.DescribeReplicationGroupsWithContext(ctx, input)
	rm.metrics.RecordAPICall("READ_MANY", "DescribeReplicationGroups", err)
	if err != nil {
		if awsErr, ok := ackerr.AWSError(err); ok && awsErr.Code() == "ReplicationGroupNotFoundFault" {
			return nil, ackerr.NotFound
		}
		return nil, err
	}
	ko := r.ko.DeepCopy()
	found := false
	for _, elem := range resp.ReplicationGroups {
		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.AtRestEncryptionEnabled != nil {
			ko.Spec.AtRestEncryptionEnabled = elem.AtRestEncryptionEnabled
		} else {
			ko.Spec.AtRestEncryptionEnabled = nil
		}
		if elem.AuthTokenEnabled != nil {
			ko.Status.AuthTokenEnabled = elem.AuthTokenEnabled
		} else {
			ko.Status.AuthTokenEnabled = nil
		}
		if elem.AuthTokenLastModifiedDate != nil {
			ko.Status.AuthTokenLastModifiedDate = &metav1.Time{*elem.AuthTokenLastModifiedDate}
		} else {
			ko.Status.AuthTokenLastModifiedDate = nil
		}
		if elem.AutomaticFailover != nil {
			ko.Status.AutomaticFailover = elem.AutomaticFailover
		} else {
			ko.Status.AutomaticFailover = nil
		}
		if elem.CacheNodeType != nil {
			ko.Spec.CacheNodeType = elem.CacheNodeType
		} else {
			ko.Spec.CacheNodeType = nil
		}
		if elem.ClusterEnabled != nil {
			ko.Status.ClusterEnabled = elem.ClusterEnabled
		} else {
			ko.Status.ClusterEnabled = nil
		}
		if elem.ConfigurationEndpoint != nil {
			f7 := &svcapitypes.Endpoint{}
			if elem.ConfigurationEndpoint.Address != nil {
				f7.Address = elem.ConfigurationEndpoint.Address
			}
			if elem.ConfigurationEndpoint.Port != nil {
				f7.Port = elem.ConfigurationEndpoint.Port
			}
			ko.Status.ConfigurationEndpoint = f7
		} else {
			ko.Status.ConfigurationEndpoint = nil
		}
		if elem.Description != nil {
			ko.Status.Description = elem.Description
		} else {
			ko.Status.Description = nil
		}
		if elem.GlobalReplicationGroupInfo != nil {
			f9 := &svcapitypes.GlobalReplicationGroupInfo{}
			if elem.GlobalReplicationGroupInfo.GlobalReplicationGroupId != nil {
				f9.GlobalReplicationGroupID = elem.GlobalReplicationGroupInfo.GlobalReplicationGroupId
			}
			if elem.GlobalReplicationGroupInfo.GlobalReplicationGroupMemberRole != nil {
				f9.GlobalReplicationGroupMemberRole = elem.GlobalReplicationGroupInfo.GlobalReplicationGroupMemberRole
			}
			ko.Status.GlobalReplicationGroupInfo = f9
		} else {
			ko.Status.GlobalReplicationGroupInfo = nil
		}
		if elem.KmsKeyId != nil {
			ko.Spec.KMSKeyID = elem.KmsKeyId
		} else {
			ko.Spec.KMSKeyID = nil
		}
		if elem.LogDeliveryConfigurations != nil {
			f11 := []*svcapitypes.LogDeliveryConfigurationRequest{}
			for _, f11iter := range elem.LogDeliveryConfigurations {
				f11elem := &svcapitypes.LogDeliveryConfigurationRequest{}
				if f11iter.DestinationDetails != nil {
					f11elemf0 := &svcapitypes.DestinationDetails{}
					if f11iter.DestinationDetails.CloudWatchLogsDetails != nil {
						f11elemf0f0 := &svcapitypes.CloudWatchLogsDestinationDetails{}
						if f11iter.DestinationDetails.CloudWatchLogsDetails.LogGroup != nil {
							f11elemf0f0.LogGroup = f11iter.DestinationDetails.CloudWatchLogsDetails.LogGroup
						}
						f11elemf0.CloudWatchLogsDetails = f11elemf0f0
					}
					if f11iter.DestinationDetails.KinesisFirehoseDetails != nil {
						f11elemf0f1 := &svcapitypes.KinesisFirehoseDestinationDetails{}
						if f11iter.DestinationDetails.KinesisFirehoseDetails.DeliveryStream != nil {
							f11elemf0f1.DeliveryStream = f11iter.DestinationDetails.KinesisFirehoseDetails.DeliveryStream
						}
						f11elemf0.KinesisFirehoseDetails = f11elemf0f1
					}
					f11elem.DestinationDetails = f11elemf0
				}
				if f11iter.DestinationType != nil {
					f11elem.DestinationType = f11iter.DestinationType
				}
				if f11iter.LogFormat != nil {
					f11elem.LogFormat = f11iter.LogFormat
				}
				if f11iter.LogType != nil {
					f11elem.LogType = f11iter.LogType
				}
				f11 = append(f11, f11elem)
			}
			ko.Spec.LogDeliveryConfigurations = f11
		} else {
			ko.Spec.LogDeliveryConfigurations = nil
		}
		if elem.MemberClusters != nil {
			f12 := []*string{}
			for _, f12iter := range elem.MemberClusters {
				var f12elem string
				f12elem = *f12iter
				f12 = append(f12, &f12elem)
			}
			ko.Status.MemberClusters = f12
		} else {
			ko.Status.MemberClusters = nil
		}
		if elem.MemberClustersOutpostArns != nil {
			f13 := []*string{}
			for _, f13iter := range elem.MemberClustersOutpostArns {
				var f13elem string
				f13elem = *f13iter
				f13 = append(f13, &f13elem)
			}
			ko.Status.MemberClustersOutpostARNs = f13
		} else {
			ko.Status.MemberClustersOutpostARNs = nil
		}
		if elem.MultiAZ != nil {
			ko.Status.MultiAZ = elem.MultiAZ
		} else {
			ko.Status.MultiAZ = nil
		}
		if elem.NodeGroups != nil {
			f15 := []*svcapitypes.NodeGroup{}
			for _, f15iter := range elem.NodeGroups {
				f15elem := &svcapitypes.NodeGroup{}
				if f15iter.NodeGroupId != nil {
					f15elem.NodeGroupID = f15iter.NodeGroupId
				}
				if f15iter.NodeGroupMembers != nil {
					f15elemf1 := []*svcapitypes.NodeGroupMember{}
					for _, f15elemf1iter := range f15iter.NodeGroupMembers {
						f15elemf1elem := &svcapitypes.NodeGroupMember{}
						if f15elemf1iter.CacheClusterId != nil {
							f15elemf1elem.CacheClusterID = f15elemf1iter.CacheClusterId
						}
						if f15elemf1iter.CacheNodeId != nil {
							f15elemf1elem.CacheNodeID = f15elemf1iter.CacheNodeId
						}
						if f15elemf1iter.CurrentRole != nil {
							f15elemf1elem.CurrentRole = f15elemf1iter.CurrentRole
						}
						if f15elemf1iter.PreferredAvailabilityZone != nil {
							f15elemf1elem.PreferredAvailabilityZone = f15elemf1iter.PreferredAvailabilityZone
						}
						if f15elemf1iter.PreferredOutpostArn != nil {
							f15elemf1elem.PreferredOutpostARN = f15elemf1iter.PreferredOutpostArn
						}
						if f15elemf1iter.ReadEndpoint != nil {
							f15elemf1elemf5 := &svcapitypes.Endpoint{}
							if f15elemf1iter.ReadEndpoint.Address != nil {
								f15elemf1elemf5.Address = f15elemf1iter.ReadEndpoint.Address
							}
							if f15elemf1iter.ReadEndpoint.Port != nil {
								f15elemf1elemf5.Port = f15elemf1iter.ReadEndpoint.Port
							}
							f15elemf1elem.ReadEndpoint = f15elemf1elemf5
						}
						f15elemf1 = append(f15elemf1, f15elemf1elem)
					}
					f15elem.NodeGroupMembers = f15elemf1
				}
				if f15iter.PrimaryEndpoint != nil {
					f15elemf2 := &svcapitypes.Endpoint{}
					if f15iter.PrimaryEndpoint.Address != nil {
						f15elemf2.Address = f15iter.PrimaryEndpoint.Address
					}
					if f15iter.PrimaryEndpoint.Port != nil {
						f15elemf2.Port = f15iter.PrimaryEndpoint.Port
					}
					f15elem.PrimaryEndpoint = f15elemf2
				}
				if f15iter.ReaderEndpoint != nil {
					f15elemf3 := &svcapitypes.Endpoint{}
					if f15iter.ReaderEndpoint.Address != nil {
						f15elemf3.Address = f15iter.ReaderEndpoint.Address
					}
					if f15iter.ReaderEndpoint.Port != nil {
						f15elemf3.Port = f15iter.ReaderEndpoint.Port
					}
					f15elem.ReaderEndpoint = f15elemf3
				}
				if f15iter.Slots != nil {
					f15elem.Slots = f15iter.Slots
				}
				if f15iter.Status != nil {
					f15elem.Status = f15iter.Status
				}
				f15 = append(f15, f15elem)
			}
			ko.Status.NodeGroups = f15
		} else {
			ko.Status.NodeGroups = nil
		}
		if elem.PendingModifiedValues != nil {
			f16 := &svcapitypes.ReplicationGroupPendingModifiedValues{}
			if elem.PendingModifiedValues.AuthTokenStatus != nil {
				f16.AuthTokenStatus = elem.PendingModifiedValues.AuthTokenStatus
			}
			if elem.PendingModifiedValues.AutomaticFailoverStatus != nil {
				f16.AutomaticFailoverStatus = elem.PendingModifiedValues.AutomaticFailoverStatus
			}
			if elem.PendingModifiedValues.LogDeliveryConfigurations != nil {
				f16f2 := []*svcapitypes.PendingLogDeliveryConfiguration{}
				for _, f16f2iter := range elem.PendingModifiedValues.LogDeliveryConfigurations {
					f16f2elem := &svcapitypes.PendingLogDeliveryConfiguration{}
					if f16f2iter.DestinationDetails != nil {
						f16f2elemf0 := &svcapitypes.DestinationDetails{}
						if f16f2iter.DestinationDetails.CloudWatchLogsDetails != nil {
							f16f2elemf0f0 := &svcapitypes.CloudWatchLogsDestinationDetails{}
							if f16f2iter.DestinationDetails.CloudWatchLogsDetails.LogGroup != nil {
								f16f2elemf0f0.LogGroup = f16f2iter.DestinationDetails.CloudWatchLogsDetails.LogGroup
							}
							f16f2elemf0.CloudWatchLogsDetails = f16f2elemf0f0
						}
						if f16f2iter.DestinationDetails.KinesisFirehoseDetails != nil {
							f16f2elemf0f1 := &svcapitypes.KinesisFirehoseDestinationDetails{}
							if f16f2iter.DestinationDetails.KinesisFirehoseDetails.DeliveryStream != nil {
								f16f2elemf0f1.DeliveryStream = f16f2iter.DestinationDetails.KinesisFirehoseDetails.DeliveryStream
							}
							f16f2elemf0.KinesisFirehoseDetails = f16f2elemf0f1
						}
						f16f2elem.DestinationDetails = f16f2elemf0
					}
					if f16f2iter.DestinationType != nil {
						f16f2elem.DestinationType = f16f2iter.DestinationType
					}
					if f16f2iter.LogFormat != nil {
						f16f2elem.LogFormat = f16f2iter.LogFormat
					}
					if f16f2iter.LogType != nil {
						f16f2elem.LogType = f16f2iter.LogType
					}
					f16f2 = append(f16f2, f16f2elem)
				}
				f16.LogDeliveryConfigurations = f16f2
			}
			if elem.PendingModifiedValues.PrimaryClusterId != nil {
				f16.PrimaryClusterID = elem.PendingModifiedValues.PrimaryClusterId
			}
			if elem.PendingModifiedValues.Resharding != nil {
				f16f4 := &svcapitypes.ReshardingStatus{}
				if elem.PendingModifiedValues.Resharding.SlotMigration != nil {
					f16f4f0 := &svcapitypes.SlotMigration{}
					if elem.PendingModifiedValues.Resharding.SlotMigration.ProgressPercentage != nil {
						f16f4f0.ProgressPercentage = elem.PendingModifiedValues.Resharding.SlotMigration.ProgressPercentage
					}
					f16f4.SlotMigration = f16f4f0
				}
				f16.Resharding = f16f4
			}
			if elem.PendingModifiedValues.UserGroups != nil {
				f16f5 := &svcapitypes.UserGroupsUpdateStatus{}
				if elem.PendingModifiedValues.UserGroups.UserGroupIdsToAdd != nil {
					f16f5f0 := []*string{}
					for _, f16f5f0iter := range elem.PendingModifiedValues.UserGroups.UserGroupIdsToAdd {
						var f16f5f0elem string
						f16f5f0elem = *f16f5f0iter
						f16f5f0 = append(f16f5f0, &f16f5f0elem)
					}
					f16f5.UserGroupIDsToAdd = f16f5f0
				}
				if elem.PendingModifiedValues.UserGroups.UserGroupIdsToRemove != nil {
					f16f5f1 := []*string{}
					for _, f16f5f1iter := range elem.PendingModifiedValues.UserGroups.UserGroupIdsToRemove {
						var f16f5f1elem string
						f16f5f1elem = *f16f5f1iter
						f16f5f1 = append(f16f5f1, &f16f5f1elem)
					}
					f16f5.UserGroupIDsToRemove = f16f5f1
				}
				f16.UserGroups = f16f5
			}
			ko.Status.PendingModifiedValues = f16
		} else {
			ko.Status.PendingModifiedValues = nil
		}
		if elem.ReplicationGroupId != nil {
			ko.Spec.ReplicationGroupID = elem.ReplicationGroupId
		} else {
			ko.Spec.ReplicationGroupID = nil
		}
		if elem.SnapshotRetentionLimit != nil {
			ko.Spec.SnapshotRetentionLimit = elem.SnapshotRetentionLimit
		} else {
			ko.Spec.SnapshotRetentionLimit = nil
		}
		if elem.SnapshotWindow != nil {
			ko.Spec.SnapshotWindow = elem.SnapshotWindow
		} else {
			ko.Spec.SnapshotWindow = nil
		}
		if elem.SnapshottingClusterId != nil {
			ko.Status.SnapshottingClusterID = elem.SnapshottingClusterId
		} else {
			ko.Status.SnapshottingClusterID = nil
		}
		if elem.Status != nil {
			ko.Status.Status = elem.Status
		} else {
			ko.Status.Status = nil
		}
		if elem.TransitEncryptionEnabled != nil {
			ko.Spec.TransitEncryptionEnabled = elem.TransitEncryptionEnabled
		} else {
			ko.Spec.TransitEncryptionEnabled = nil
		}
		if elem.UserGroupIds != nil {
			f23 := []*string{}
			for _, f23iter := range elem.UserGroupIds {
				var f23elem string
				f23elem = *f23iter
				f23 = append(f23, &f23elem)
			}
			ko.Spec.UserGroupIDs = f23
		} else {
			ko.Spec.UserGroupIDs = nil
		}
		found = true
		break
	}
	if !found {
		return nil, ackerr.NotFound
	}
	rm.setStatusDefaults(ko)
	ko, err = rm.CustomDescribeReplicationGroupsSetOutput(ctx, r, resp, ko)
	if err != nil {
		return nil, err
	}
	rm.updateSpecFields(ctx, resp.ReplicationGroups[0], &resource{ko})
	if isDeleting(r) {
		ackcondition.SetSynced(
			&resource{ko},
			corev1.ConditionFalse,
			&condMsgCurrentlyDeleting,
			nil,
		)
		return &resource{ko}, nil
	}
	if isModifying(r) {
		ackcondition.SetSynced(
			&resource{ko},
			corev1.ConditionFalse,
			&condMsgNoDeleteWhileModifying,
			nil,
		)
		return &resource{ko}, nil
	}
	if isCreateFailed(r) {
		ackcondition.SetTerminal(
			&resource{ko},
			corev1.ConditionTrue,
			&condMsgTerminalCreateFailed,
			nil,
		)
		return &resource{ko}, nil
	}
	return &resource{ko}, nil
}
func (rm *resourceManager) requiredFieldsMissingFromReadManyInput(
	r *resource,
) bool {
	return r.ko.Spec.ReplicationGroupID == nil
}