// merge name of type with resource type name.
505488
func mergeTypeName(name, rtName string, apiDef *APIDefinition) string {
	if apiDef == nil {
		log.Warning("passing nil API definition to mergeTypeName")
		return name
	}

	// check if this resource type is in library
	splt := strings.Split(rtName, ".")
	if len(splt) < 2 {
		// if not in library, we need to do nothing
		return name
	}

	// get the library object from API definition root object
	libName := splt[0]
	lib, ok := apiDef.Libraries[libName]
	if !ok {
		return name
	}

	// type not exist in the library
	if _, ok := lib.Types[name]; !ok {
		return name
	}

	return strings.Join([]string{libName, name}, ".")
}
763334
func (s *DeleteRemediationConfigurationInput) SetResourceType(v string) *DeleteRemediationConfigurationInput {
	s.ResourceType = &v
	return s
}
1278075
func (s *Operation) SetResourceType(v string) *Operation {
	s.ResourceType = &v
	return s
}
143499
func (s *Job) SetResourceType(v string) *Job {
	s.ResourceType = &v
	return s
}
173994
func (ep Endpoint) ResourceName() string {
	name := ep.Addr
	splt := strings.Split(name, "/")
	if len(splt) > 0 {
		name = splt[0]
	}
	return strings.TrimSuffix(strings.TrimPrefix(name, "/"), "/")
}
1068348
func MergeAssociations(associations []IdentityAssociation, merge []IdentityAssociation) []IdentityAssociation {
	for _, merging := range merge {
		found := false
		for i, assoc := range associations {
			// there is a match if the record to be merged has the same ResourceID (there must always be a resource)
			if assoc.ResourceID == merging.ResourceID {
				found = true

				if !assoc.Member {
					assoc.Member = merging.Member
				}

				if assoc.IdentityID == nil && merging.IdentityID != nil {
					assoc.IdentityID = merging.IdentityID
				}

				for _, roleToMerge := range merging.Roles {
					roleFound := false

					for _, assocRole := range assoc.Roles {
						if assocRole == roleToMerge {
							roleFound = true
							break
						}
					}

					if !roleFound {
						assoc.Roles = append(assoc.Roles, roleToMerge)
					}
				}

				associations[i] = assoc
			}
		}

		if !found {
			associations = append(associations, merging)
		}
	}

	return associations
}
986195
func splitResourceTypeName(s string) (resourceTuple, bool, error) {
	if !strings.Contains(s, "/") {
		return resourceTuple{}, false, nil
	}
	seg := strings.Split(s, "/")
	if len(seg) != 2 {
		return resourceTuple{}, false, fmt.Errorf("arguments in resource/name form may not have more than one slash")
	}
	resource, name := seg[0], seg[1]
	if len(resource) == 0 || len(name) == 0 || len(SplitResourceArgument(resource)) != 1 {
		return resourceTuple{}, false, fmt.Errorf("arguments in resource/name form must have a single resource and name")
	}
	return resourceTuple{Resource: resource, Name: name}, true, nil
}
616426
func (s *ListTagsForResourcesInput) SetResourceType(v string) *ListTagsForResourcesInput {
	s.ResourceType = &v
	return s
}
796230
func (v delegatingStrategy) MergeType(diff apply.TypeElement) (apply.Result, error) {
	switch diff.GetFieldMergeType() {
	case apply.MergeStrategy:
		return v.merge.MergeType(diff)
	case apply.ReplaceStrategy:
		return v.replace.MergeType(diff)
	case apply.RetainKeysStrategy:
		return v.retainKeys.MergeType(diff)
	default:
		return v.merge.MergeType(diff)
	}
}
1170876
func (v replaceStrategy) MergeType(e apply.TypeElement) (apply.Result, error) {
	return v.doReplace(e)
}
522657
func (s *Relationship) SetResourceType(v string) *Relationship {
	s.ResourceType = &v
	return s
}
105785
func (t Term) Merge(args ...interface{}) Term {
	return constructMethodTerm(t, "Merge", p.Term_MERGE, funcWrapArgs(args), map[string]interface{}{})
}
720748
func (s *StringValue) Merge(onto *string) {
	if s.v != nil {
		*onto = *(s.v)
	}
}
251110
func (s *StackResource) SetResourceType(v string) *StackResource {
	s.ResourceType = &v
	return s
}
1084888
func (s *ListAggregateDiscoveredResourcesInput) SetResourceType(v string) *ListAggregateDiscoveredResourcesInput {
	s.ResourceType = &v
	return s
}
868956
func (s *LoadBalancerTlsCertificate) SetResourceType(v string) *LoadBalancerTlsCertificate {
	s.ResourceType = &v
	return s
}
651707
func (e TypeElement) Merge(v Strategy) (Result, error) {
	return v.MergeType(e)
}