// DetachTags detaches a bunch of tags from an instance.
//
// Assumes inputs are already validated. Launches a transaction inside (and thus
// can't be a part of a transaction itself).
//
// 'inst' is used only for its key.
421160
func DetachTags(c context.Context, inst *Instance, tags []*api.Tag) error {
	return Txn(c, "DetachTags", func(c context.Context) error {
		existing, _, err := checkExistingTags(c, inst, tags)
		if err != nil {
			return err
		}

		if err := datastore.Delete(c, existing); err != nil {
			return transient.Tag.Apply(err)
		}

		events := Events{}
		for _, t := range existing {
			events.Emit(&api.Event{
				Kind:     api.EventKind_INSTANCE_TAG_DETACHED,
				Package:  inst.Package.StringID(),
				Instance: inst.InstanceID,
				Tag:      t.Tag,
			})
		}
		return events.Flush(c)
	})
}
568788
func NewTags(tags string) (*Tags, error) {
	if tags == "" {
		empty := make(Tags, 0)
		return &empty, nil
	}
	if err := CheckTags(tags); err != nil {
		return nil, e.Forward(err)
	}
	t := &Tags{}
	if tags != "" {
		splitted := strings.Split(tags, ",")
		for _, tag := range splitted {
			trim := strings.Trim(tag, " ")
			if trim == "" {
				continue
			}
			err := t.Add(tag)
			if err != nil {
				return t, e.Forward(err)
			}
		}
	}
	return t, nil
}
367110
func diffTagsBeanstalk(oldTags, newTags []*elasticbeanstalk.Tag) ([]*elasticbeanstalk.Tag, []*string) {
	// First, we're creating everything we have
	create := make(map[string]interface{})
	for _, t := range newTags {
		create[*t.Key] = *t.Value
	}

	// Build the list of what to remove
	var remove []*string
	for _, t := range oldTags {
		if _, ok := create[*t.Key]; !ok {
			// Delete it!
			remove = append(remove, t.Key)
		}
	}

	return tagsFromMapBeanstalk(create), remove
}
235042
func Tags(obj interface{}, key string) (map[string]string, error) {
	return tags(obj, key, false)
}
1176680
func (s *InputSecurityGroup) SetTags(v map[string]*string) *InputSecurityGroup {
	s.Tags = v
	return s
}
908670
func (s *InstanceInfo) SetTags(v []*Tag) *InstanceInfo {
	s.Tags = v
	return s
}
2482
func (s *CreateRelationalDatabaseFromSnapshotInput) SetTags(v []*Tag) *CreateRelationalDatabaseFromSnapshotInput {
	s.Tags = v
	return s
}
312678
func (s *Branch) SetTags(v map[string]*string) *Branch {
	s.Tags = v
	return s
}
549964
func AllTags(next NextTagFunction) []*Tag {
	tags := make([]*Tag, 0)

	tag, _ := next()
	for *tag != NoneTag {
		tags = append(tags, tag)
		tag, _ = next()
	}

	return tags
}
185674
func (o *FindPetsByTagsParams) bindTags(rawData []string, hasKey bool, formats strfmt.Registry) error {

	// CollectionFormat: multi
	tagsIC := rawData

	if len(tagsIC) == 0 {
		return nil
	}

	var tagsIR []string
	for _, tagsIV := range tagsIC {
		tagsI := tagsIV

		tagsIR = append(tagsIR, tagsI)
	}

	o.Tags = tagsIR

	return nil
}
158252
func (s *Input) SetTags(v map[string]*string) *Input {
	s.Tags = v
	return s
}
946088
func mergeTags(metricTags, outerTags map[string]string) map[string]string {
	tags := make(map[string]string)
	for k, v := range outerTags {
		tags[k] = v
	}
	for k, v := range metricTags {
		tags[k] = v
	}

	return tags
}
556657
func (s *handler) AttachedTags(ref vim.ManagedObjectReference) ([]vim.VslmTagEntry, vim.BaseMethodFault) {
	oid := internal.AssociatedObject(ref)
	var tags []vim.VslmTagEntry
	for id, objs := range s.Association {
		if objs[oid] {
			tag := s.Tag[id]
			cat := s.Category[tag.CategoryID]
			tags = append(tags, vim.VslmTagEntry{
				TagName:            tag.Name,
				ParentCategoryName: cat.Name,
			})
		}
	}
	return tags, nil
}
96551
func (c *retryRepository) Tags(ctx context.Context) distribution.TagService {
	return &retryTags{TagService: c.Repository.Tags(ctx), repo: c}
}
1203655
func Tags(tags map[string]string) TracerOption {
	return func(o *tracerOptions) {
		for k, v := range tags {
			o.tags[k] = v
		}
	}
}
884879
func tags(x interface{}) map[string]int {
	t := reflect.TypeOf(x)
	if t.Kind() == reflect.Ptr {
		t = t.Elem()
	}
	if t.Kind() != reflect.Struct {
		panic(errors.Errorf("expected struct, not %s", t))
	}

	if tagm := tagsForType[t]; tagm != nil {
		return tagm
	}
	panic(errors.Errorf("%s not found in type table", t))
}
840701
func (s *CreateDeploymentJobOutput) SetTags(v map[string]*string) *CreateDeploymentJobOutput {
	s.Tags = v
	return s
}