a method for adding or updating tags on an AWS instance

        :param instance_id: string of instance id on AWS
        :param tag_list: list of single key-value pairs
        :return: dictionary with aws response info
179861
def tag_instance(self, instance_id, tag_list):

        '''
            
        '''

        title = '%s.tag_instance' % self.__class__.__name__

    # validate inputs
        input_fields = {
            'instance_id': instance_id,
            'tag_list': tag_list
        }
        for key, value in input_fields.items():
            object_title = '%s(%s=%s)' % (title, key, str(value))
            self.fields.validate(value, '.%s' % key, object_title)
    
    # retrieve tag list of instance
        self.iam.printer_on = False
        instance_details = self.read_instance(instance_id)
        self.iam.printer_on = True
        old_tags = instance_details['tags']
    
    # determine tags to remove
        delete_list = []
        tag_map = {}
        for tag in tag_list:
            tag_map[tag['key']] = tag['value']
        for tag in old_tags:
            if tag['key'] not in tag_map.keys():
                delete_list.append(tag)
            elif tag['value'] != tag_map[tag['key']]:
                delete_list.append(tag)

    # convert tag list to camelcase
        delete_list = self.iam.prepare(delete_list)
        tag_list = self.iam.prepare(tag_list)
    
    # remove tags from instance
        if delete_list:
            try:
                delete_kwargs = {
                    'Resources': [ instance_id ],
                    'Tags': delete_list
                }
                self.connection.delete_tags(**delete_kwargs)
            except:
                AWSConnectionError(title)
            
    # tag instance with updated tags
        try:
            create_kwargs = {
                'Resources': [ instance_id ],
                'Tags': tag_list
            }
            response = self.connection.create_tags(**create_kwargs)
        except:
            raise AWSConnectionError(title)
        
        return response
527351
def tag_list(self, other_model=None, queryset=None):
        
        from taggit.models import Tag
        return Tag.objects.filter(id__in=self._taglist(other_model, queryset))
388575
def update_tags(self, image_id, new_tags):
        
        # Do not add :param list in the docstring above until this is solved:
        # https://github.com/sphinx-doc/sphinx/issues/2549
        old_image = self.get(image_id)

        old_tags = frozenset(old_image.tags)
        new_tags = frozenset(new_tags)

        to_add = list(new_tags - old_tags)
        to_remove = list(old_tags - new_tags)

        add_response, remove_response = None, None

        if to_add:
            add_response = self._post('/images/%s/tag' % image_id,
                                      {'tags': to_add}, 'image')

        if to_remove:
            remove_response = self._post('/images/%s/untag' % image_id,
                                         {'tags': to_remove}, 'image')

        return remove_response or add_response or self.get(image_id)
206594
def update_tag(self, tag_id, tag_name):
        
        return self.post(
            url="https://api.weixin.qq.com/cgi-bin/tags/update",
            data={"tag": {
                "id": tag_id,
                "name": tag_name
            }}
        )
529801
def list_addresses(self, tag_values=None):
        
        '''
            
        '''
        
        title = '%s.list_addresses' % self.__class__.__name__

    # validate inputs
        input_fields = {
            'tag_values': tag_values
        }
        for key, value in input_fields.items():
            if value:
                object_title = '%s(%s=%s)' % (title, key, str(value))
                self.fields.validate(value, '.%s' % key, object_title)
            
    # add tags to method arguments
        kw_args = {}
        tag_text = ''
        if tag_values:
            kw_args = {
                'Filters': [ { 'Name': 'tag-value', 'Values': tag_values } ]
            }
            from labpack.parsing.grammar import join_words
            plural_value = ''
            if len(tag_values) > 1:
                plural_value = 's'
            tag_text = ' with tag value%s %s' % (plural_value, join_words(tag_values))
    
    # report query
        self.iam.printer('Querying AWS region %s for elastic ip addresses%s.' % (self.iam.region_name, tag_text))
        address_list = []
        
    # discover details associated with instance id
        try:
            response = self.connection.describe_addresses(**kw_args)
        except:
            raise AWSConnectionError(title)

    # populate address list with response
        response_list = response['Addresses']
        for address in response_list:
            address_list.append(address['PublicIp'])

        return address_list
757352
public List<Tag> getInstanceTags() {
    final DescribeInstancesResult response = ec2
        .describeInstances(new DescribeInstancesRequest()
            .withInstanceIds(Collections.singletonList(instanceIdentity.instanceId)));

    return response.getReservations().stream()
        .flatMap(reservation -> reservation.getInstances().stream())
        .flatMap(instance -> instance.getTags().stream())
        .collect(Collectors.toList());

  }
160041
def tag_add(self, *tags):
        
        return View({**self.spec, 'tag': list(set(self.tags) | set(tags))})
447748
def file_add_tags(object_id, input_params={}, always_retry=True, **kwargs):
    
    return DXHTTPRequest('/%s/addTags' % object_id, input_params, always_retry=always_retry, **kwargs)
536695
def job_add_tags(object_id, input_params={}, always_retry=True, **kwargs):
    
    return DXHTTPRequest('/%s/addTags' % object_id, input_params, always_retry=always_retry, **kwargs)
454253
def list_instance_groups(jobflow_id)
      params = {
        :operation => 'ListInstanceGroups',
        :cluster_id => jobflow_id,
      }
      aws_result = @aws_request.submit(params)
      yield aws_result if block_given?
      JSON.parse(aws_result)
    end
1240843
def _add_tag(self, tag):
        # type: (str) -> bool
        
        tags = self.data.get('tags', None)
        if tags:
            if tag in [x['name'] for x in tags]:
                return False
        else:
            tags = list()
        tags.append({'name': tag})
        self.data['tags'] = tags
        return True
927397
def add_tag(self, tag):
        
        if tag not in self._tags:
            self._tags[tag] = dict()
280400
def add_tags(self, archive_name, tags):
        '''
        

        '''
        updated_tag_list = list(self._get_tags(archive_name))
        for tag in tags:
            if tag not in updated_tag_list:
                updated_tag_list.append(tag)

        self._set_tags(archive_name, updated_tag_list)
114550
def __IpsToServerIds(self):
    
    master_instance = self.__GetMasterInstance()
    assert(master_instance)
    retval, response = self.__RunMaprCli('node list -columns id')
    ip_to_id = {}
    for line_num, line in enumerate(response.split('\n')):
      tokens = line.split()
      if len(tokens) == 3 and tokens[0] != 'id':        
        instance_id = tokens[0]
        ip = tokens[2]
        ip_to_id[ip] = instance_id
    return ip_to_id
1110268
def _tag_ec2(self, conn, role):
        
        tags = {'Role': role}
        conn.create_tags([self.instance_id], tags)
747141
def analysis_add_tags(object_id, input_params={}, always_retry=True, **kwargs):
    
    return DXHTTPRequest('/%s/addTags' % object_id, input_params, always_retry=always_retry, **kwargs)
1102359
def DeleteInstanceTags(r, instance, tags, dry_run=False):
    

    query = {
        "tag": tags,
        "dry-run": dry_run,
    }

    return r.request("delete", "/2/instances/%s/tags" % instance, query=query)