Takes the list of configured tag names and compares it with tagsUtils on the ec2 instance.
FilterUtils (tag:key=value) will be created for all matches.

@return a list of filters for instances that share common tags with
this instance.
172939
@SuppressWarnings("OptionalUsedAsFieldOrParameterType")
  public List<Filter> instanceTagNamesToFilters() {
    return tagsUtils.getAwsTagNames().map(Stream::of).orElseGet(Stream::empty)
        .map(tagNames -> new Tuple<>(tagNames, tagsUtils.getInstanceTags()))
        .flatMap(namesAndTags -> namesAndTags.getVal2()
            .stream()
            .filter(tag -> namesAndTags.getVal1().contains(tag.getKey())))
        .map(tag -> new Filter("tag:" + tag.getKey(), Collections.singletonList(tag.getValue())))
        .collect(Collectors.toList());
  }
1363798
public java.util.List<Tag> getTagsToAdd() {
        if (tagsToAdd == null) {
            tagsToAdd = new com.amazonaws.internal.SdkInternalList<Tag>();
        }
        return tagsToAdd;
    }
750916
def __GetInstances(self, group_name = None, state_filter=None):
    
    all_instances = self.ec2.get_all_instances()
    instances = []
    for res in all_instances:
      for group in res.groups:
        if group_name and group.name != group_name:
          continue
        for instance in res.instances:
          if state_filter == None or instance.state == state_filter:
            instances.append(instance)
    return instances
540389
public TagsUtils validateTags() {
    final List<String> instanceTags = getInstanceTags().stream()
        .map(Tag::getKey)
        .collect(Collectors.toList());

    final List<String> missingTags = getAwsTagNames().map(List::stream).orElse(Stream.empty())
        .filter(configuredTag -> !instanceTags.contains(configuredTag))
        .collect(Collectors.toList());

    if(!missingTags.isEmpty()) {
      throw new IllegalStateException("expected instance tag(s) missing: " + missingTags.stream().collect(Collectors.joining(", ")));
    }

    return this;
  }
216600
def tag_match(self, tags=None):
        
        if 'tags' not in self.database.collection_names():
            print 'Warning: Searching on non-existance tags collection'
            return None
        if not tags:
            cursor = self.database['tags'].find({}, {'_id':0, 'md5':1})
        else:
            cursor = self.database['tags'].find({'tags': {'$in': tags}}, {'_id':0, 'md5':1})

        # We have the tags, now make sure we only return those md5 which 
        # also exist in the samples collection
        tag_md5s = set([item['md5'] for item in cursor])
        sample_md5s = set(item['md5'] for item in self.database['samples'].find({}, {'_id':0, 'md5':1}))
        return list(tag_md5s.intersection(sample_md5s))
812107
def filter_service_by_host_tag_name(tpl):
    

    def inner_filter(items):
        """Inner filter for service. Accept if tpl in service.host.tags"""
        service = items["service"]
        host = items["hosts"][service.host]
        if service is None or host is None:
            return False
        return tpl in [t.strip() for t in host.tags]

    return inner_filter
104403
public java.util.List<String> getTagKeys() {
        if (tagKeys == null) {
            tagKeys = new com.amazonaws.internal.SdkInternalList<String>();
        }
        return tagKeys;
    }
328698
def get_instances_by_tag(self, tags):
        

        try:
            c = ec2.connect_to_region(self._region,
                                      aws_access_key_id=self._aws_access_key_id,
                                      aws_secret_access_key=self._aws_secret_access_key)

            # select instance by list of tags (OR used)
            reservations = c.get_all_reservations(filters=SergentSsh.tags_to_dict(tags))
            instances = list()

            for r in reservations:
                # for each instance launched by this reservation
                for instance in r.instances:
                    # we need only running instances
                    if instance.state.lower() == 'running':
                        instances.append(instance)

            return instances
        except NoAuthHandlerFound:
            raise SergentSshException('Boto said that you should check your credentials')
21453
public java.util.List<TaggedResource> getTaggedResources() {
        if (taggedResources == null) {
            taggedResources = new com.amazonaws.internal.SdkInternalList<TaggedResource>();
        }
        return taggedResources;
    }
1004515
public java.util.List<Tag> getTagSet() {
        if (tagSet == null) {
            tagSet = new com.amazonaws.internal.SdkInternalList<Tag>();
        }
        return tagSet;
    }
820044
def tags(self):
        
        if self._tags is None:
            LOG.debug('need to build tags')
            self._tags = {}

            if hasattr(self.Meta, 'tags_spec') and (self.Meta.tags_spec is not None):
                LOG.debug('have a tags_spec')
                method, path, param_name, param_value = self.Meta.tags_spec[:4]
                kwargs = {}
                filter_type = getattr(self.Meta, 'filter_type', None)
                if filter_type == 'arn':
                    kwargs = {param_name: [getattr(self, param_value)]}
                elif filter_type == 'list':
                    kwargs = {param_name: [getattr(self, param_value)]}
                else:
                    kwargs = {param_name: getattr(self, param_value)}
                if len(self.Meta.tags_spec) > 4:
                    kwargs.update(self.Meta.tags_spec[4])
                LOG.debug('fetching tags')
                self.data['Tags'] = self._client.call(
                    method, query=path, **kwargs)
                LOG.debug(self.data['Tags'])

            if 'Tags' in self.data:
                _tags = self.data['Tags']
                if isinstance(_tags, list):
                    for kvpair in _tags:
                        if kvpair['Key'] in self._tags:
                            if not isinstance(self._tags[kvpair['Key']], list):
                                self._tags[kvpair['Key']] = [self._tags[kvpair['Key']]]
                            self._tags[kvpair['Key']].append(kvpair['Value'])
                        else:
                            self._tags[kvpair['Key']] = kvpair['Value']
                elif isinstance(_tags, dict):
                    self._tags = _tags
        return self._tags
251448
public static BasicTagList copyOf(Map<String, String> tags) {
    SmallTagMap.Builder builder = SmallTagMap.builder();
    for (Map.Entry<String, String> tag : tags.entrySet()) {
      builder.add(Tags.newTag(tag.getKey(), tag.getValue()));
    }
    return new BasicTagList(builder.result());
  }
716318
public java.util.List<Tag> getTagsList() {
        if (tagsList == null) {
            tagsList = new com.amazonaws.internal.SdkInternalList<Tag>();
        }
        return tagsList;
    }
1164550
def matches? query
      query.reduce(true) do |matches, (key, value)|
        matches = if key == 'tag'
          return false unless tags.present?
          tags.include? value
        else
          attributes[key] == value
        end
      end
    end
762613
def filter(self, names):
        
        names = list_strings(names)

        fnames = []
        for f in names:
            for pat in self.pats:
                if fnmatch.fnmatch(f, pat):
                    fnames.append(f)

        return fnames
858296
public static <R> Set<R> filterAndListKeys(Iterator<R> keys, KeyFilter<R> filter) {
        Set<R> ret = new HashSet<R>();
        while (keys.hasNext()) {
            R key = keys.next();
            R filtered = filter.filter(key);
            if (filtered != null) {
                ret.add(filtered);
            }
        }
        return ret;
    }
257069
public java.util.List<TagSpecification> getTagSpecifications() {
        if (tagSpecifications == null) {
            tagSpecifications = new com.amazonaws.internal.SdkInternalList<TagSpecification>();
        }
        return tagSpecifications;
    }