func (rm *resourceManager) setStatusDefaults(
	ko *svcapitypes.User,
) {
	if ko.Status.ACKResourceMetadata == nil {
		ko.Status.ACKResourceMetadata = &ackv1alpha1.ResourceMetadata{}
	}
	if ko.Status.ACKResourceMetadata.OwnerAccountID == nil {
		ko.Status.ACKResourceMetadata.OwnerAccountID = &rm.awsAccountID
	}
	if ko.Status.Conditions == nil {
		ko.Status.Conditions = []*ackv1alpha1.Condition{}
	}
}
setStatusDefaults sets default properties into supplied custom resource
package user
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.User{}
	_ = 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.DescribeUsersOutput
	resp, err = rm.sdkapi.DescribeUsersWithContext(ctx, input)
	rm.metrics.RecordAPICall("READ_MANY", "DescribeUsers", err)
	if err != nil {
		if awsErr, ok := ackerr.AWSError(err); ok && awsErr.Code() == "UserNotFound" {
			return nil, ackerr.NotFound
		}
		return nil, err
	}
	ko := r.ko.DeepCopy()
	found := false
	for _, elem := range resp.Users {
		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.AccessString != nil {
			ko.Spec.AccessString = elem.AccessString
		} else {
			ko.Spec.AccessString = nil
		}
		if elem.Authentication != nil {
			f2 := &svcapitypes.Authentication{}
			if elem.Authentication.PasswordCount != nil {
				f2.PasswordCount = elem.Authentication.PasswordCount
			}
			if elem.Authentication.Type != nil {
				f2.Type = elem.Authentication.Type
			}
			ko.Status.Authentication = f2
		} else {
			ko.Status.Authentication = nil
		}
		if elem.Engine != nil {
			ko.Spec.Engine = elem.Engine
		} else {
			ko.Spec.Engine = nil
		}
		if elem.Status != nil {
			ko.Status.Status = elem.Status
		} else {
			ko.Status.Status = nil
		}
		if elem.UserGroupIds != nil {
			f5 := []*string{}
			for _, f5iter := range elem.UserGroupIds {
				var f5elem string
				f5elem = *f5iter
				f5 = append(f5, &f5elem)
			}
			ko.Status.UserGroupIDs = f5
		} else {
			ko.Status.UserGroupIDs = nil
		}
		if elem.UserId != nil {
			ko.Spec.UserID = elem.UserId
		} else {
			ko.Spec.UserID = nil
		}
		if elem.UserName != nil {
			ko.Spec.UserName = elem.UserName
		} else {
			ko.Spec.UserName = nil
		}
		found = true
		break
	}
	if !found {
		return nil, ackerr.NotFound
	}
	rm.setStatusDefaults(ko)
	rm.setSyncedCondition(resp.Users[0].Status, &resource{ko})
	return &resource{ko}, nil
}
func (rm *resourceManager) requiredFieldsMissingFromReadManyInput(
	r *resource,
) bool {
	return r.ko.Spec.UserID == nil
}
func (rm *resourceManager) newListRequestPayload(
	r *resource,
) (*svcsdk.DescribeUsersInput, error) {
	res := &svcsdk.DescribeUsersInput{}
	if r.ko.Spec.UserID != nil {
		res.SetUserId(*r.ko.Spec.UserID)
	}
	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.CreateUserOutput
	_ = resp
	resp, err = rm.sdkapi.CreateUserWithContext(ctx, input)
	rm.metrics.RecordAPICall("CREATE", "CreateUser", err)
	if err != nil {
		return nil, err
	}
	ko := desired.ko.DeepCopy()
	if ko.Status.ACKResourceMetadata == nil {
		ko.Status.ACKResourceMetadata = &ackv1alpha1.ResourceMetadata{}
	}
	if resp.ARN != nil {
		arn := ackv1alpha1.AWSResourceName(*resp.ARN)
		ko.Status.ACKResourceMetadata.ARN = &arn
	}
	if resp.AccessString != nil {
		ko.Spec.AccessString = resp.AccessString
	} else {
		ko.Spec.AccessString = nil
	}
	if resp.Authentication != nil {
		f2 := &svcapitypes.Authentication{}
		if resp.Authentication.PasswordCount != nil {
			f2.PasswordCount = resp.Authentication.PasswordCount
		}
		if resp.Authentication.Type != nil {
			f2.Type = resp.Authentication.Type
		}
		ko.Status.Authentication = f2
	} else {
		ko.Status.Authentication = nil
	}
	if resp.Engine != nil {
		ko.Spec.Engine = resp.Engine
	} else {
		ko.Spec.Engine = nil
	}
	if resp.Status != nil {
		ko.Status.Status = resp.Status
	} else {
		ko.Status.Status = nil
	}
	if resp.UserGroupIds != nil {
		f5 := []*string{}
		for _, f5iter := range resp.UserGroupIds {
			var f5elem string
			f5elem = *f5iter
			f5 = append(f5, &f5elem)
		}
		ko.Status.UserGroupIDs = f5
	} else {
		ko.Status.UserGroupIDs = nil
	}
	if resp.UserId != nil {
		ko.Spec.UserID = resp.UserId
	} else {
		ko.Spec.UserID = nil
	}
	if resp.UserName != nil {
		ko.Spec.UserName = resp.UserName
	} else {
		ko.Spec.UserName = nil
	}
	rm.setStatusDefaults(ko)
	ko, err = rm.CustomCreateUserSetOutput(ctx, desired, resp, ko)
	if err != nil {
		return nil, err
	}
	rm.setSyncedCondition(resp.Status, &resource{ko})
	return &resource{ko}, nil
}
func (rm *resourceManager) newCreateRequestPayload(
	ctx context.Context,
	r *resource,
) (*svcsdk.CreateUserInput, error) {
	res := &svcsdk.CreateUserInput{}
	if r.ko.Spec.AccessString != nil {
		res.SetAccessString(*r.ko.Spec.AccessString)
	}
	if r.ko.Spec.Engine != nil {
		res.SetEngine(*r.ko.Spec.Engine)
	}
	if r.ko.Spec.NoPasswordRequired != nil {
		res.SetNoPasswordRequired(*r.ko.Spec.NoPasswordRequired)
	}
	if r.ko.Spec.Passwords != nil {
		f3 := []*string{}
		for _, f3iter := range r.ko.Spec.Passwords {
			var f3elem string
			if f3iter != nil {
				tmpSecret, err := rm.rr.SecretValueFromReference(ctx, f3iter)
				if err != nil {
					return nil, err
				}
				if tmpSecret != "" {
					f3elem = tmpSecret
				}
			}
			f3 = append(f3, &f3elem)
		}
		res.SetPasswords(f3)
	}
	if r.ko.Spec.Tags != nil {
		f4 := []*svcsdk.Tag{}
		for _, f4iter := range r.ko.Spec.Tags {
			f4elem := &svcsdk.Tag{}
			if f4iter.Key != nil {
				f4elem.SetKey(*f4iter.Key)
			}
			if f4iter.Value != nil {
				f4elem.SetValue(*f4iter.Value)
			}
			f4 = append(f4, f4elem)
		}
		res.SetTags(f4)
	}
	if r.ko.Spec.UserID != nil {
		res.SetUserId(*r.ko.Spec.UserID)
	}
	if r.ko.Spec.UserName != nil {
		res.SetUserName(*r.ko.Spec.UserName)
	}
	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)
	updated, err = rm.CustomModifyUser(ctx, desired, latest, delta)
	if updated != nil || err != nil {
		return updated, err
	}
	input, err := rm.newUpdateRequestPayload(ctx, desired)
	if err != nil {
		return nil, err
	}
	rm.populateUpdatePayload(input, desired, delta)
	var resp *svcsdk.ModifyUserOutput
	_ = resp
	resp, err = rm.sdkapi.ModifyUserWithContext(ctx, input)
	rm.metrics.RecordAPICall("UPDATE", "ModifyUser", err)
	if err != nil {
		return nil, err
	}
	ko := desired.ko.DeepCopy()
	if ko.Status.ACKResourceMetadata == nil {
		ko.Status.ACKResourceMetadata = &ackv1alpha1.ResourceMetadata{}
	}
	if resp.ARN != nil {
		arn := ackv1alpha1.AWSResourceName(*resp.ARN)
		ko.Status.ACKResourceMetadata.ARN = &arn
	}
	if resp.AccessString != nil {
		ko.Spec.AccessString = resp.AccessString
	} else {
		ko.Spec.AccessString = nil
	}
	if resp.Authentication != nil {
		f2 := &svcapitypes.Authentication{}
		if resp.Authentication.PasswordCount != nil {
			f2.PasswordCount = resp.Authentication.PasswordCount
		}
		if resp.Authentication.Type != nil {
			f2.Type = resp.Authentication.Type
		}
		ko.Status.Authentication = f2
	} else {
		ko.Status.Authentication = nil
	}
	if resp.Engine != nil {
		ko.Spec.Engine = resp.Engine
	} else {
		ko.Spec.Engine = nil
	}
	if resp.Status != nil {
		ko.Status.Status = resp.Status
	} else {
		ko.Status.Status = nil
	}
	if resp.UserGroupIds != nil {
		f5 := []*string{}
		for _, f5iter := range resp.UserGroupIds {
			var f5elem string
			f5elem = *f5iter
			f5 = append(f5, &f5elem)
		}
		ko.Status.UserGroupIDs = f5
	} else {
		ko.Status.UserGroupIDs = nil
	}
	if resp.UserId != nil {
		ko.Spec.UserID = resp.UserId
	} else {
		ko.Spec.UserID = nil
	}
	if resp.UserName != nil {
		ko.Spec.UserName = resp.UserName
	} else {
		ko.Spec.UserName = nil
	}
	rm.setStatusDefaults(ko)
	ko, err = rm.CustomModifyUserSetOutput(ctx, desired, resp, ko)
	if err != nil {
		return nil, err
	}
	rm.setSyncedCondition(resp.Status, &resource{ko})
	return &resource{ko}, nil
}
func (rm *resourceManager) newUpdateRequestPayload(
	ctx context.Context,
	r *resource,
) (*svcsdk.ModifyUserInput, error) {
	res := &svcsdk.ModifyUserInput{}
	if r.ko.Spec.UserID != nil {
		res.SetUserId(*r.ko.Spec.UserID)
	}
	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.DeleteUserOutput
	_ = resp
	resp, err = rm.sdkapi.DeleteUserWithContext(ctx, input)
	rm.metrics.RecordAPICall("DELETE", "DeleteUser", err)
	return nil, err
}
func (rm *resourceManager) newDeleteRequestPayload(
	r *resource,
) (*svcsdk.DeleteUserInput, error) {
	res := &svcsdk.DeleteUserInput{}
	if r.ko.Spec.UserID != nil {
		res.SetUserId(*r.ko.Spec.UserID)
	}
	return res, nil
}