def do_query(tags = nil, hrefs = nil, options = {})
      raw = options[:raw]
      timeout = options[:timeout]

      request_options = {}
      request_options[:timeout] = timeout if timeout

      agent_check
      payload = {:agent_identity => @agent.identity}
      payload[:tags] = ensure_flat_array_value(tags) unless tags.nil? || tags.empty?
      # TODO remove use of agent identity when fully drop AMQP
      if @agent.mode == :http
        payload[:hrefs] = ensure_flat_array_value(hrefs) unless hrefs.nil? || hrefs.empty?
      else
        payload[:agent_ids] = ensure_flat_array_value(hrefs) unless hrefs.nil? || hrefs.empty?
      end
      request = RightScale::RetryableRequest.new("/router/query_tags", payload, request_options)
      request.callback { |result| yield raw ? request.raw_response : result }
      request.errback do |message|
        ErrorTracker.log(self, "Failed to query tags (#{message})")
        yield((raw ? request.raw_response : nil) || message)
      end
      request.run
      true
    end
def do_query(tags = nil, hrefs = nil, options = {})
      raw = options[:raw]
      timeout = options[:timeout]

      request_options = {}
      request_options[:timeout] = timeout if timeout

      agent_check
      payload = {:agent_identity => @agent.identity}
      payload[:tags] = ensure_flat_array_value(tags) unless tags.nil? || tags.empty?
      # TODO remove use of agent identity when fully drop AMQP
      if @agent.mode == :http
        payload[:hrefs] = ensure_flat_array_value(hrefs) unless hrefs.nil? || hrefs.empty?
      else
        payload[:agent_ids] = ensure_flat_array_value(hrefs) unless hrefs.nil? || hrefs.empty?
      end
      request = RightScale::RetryableRequest.new("/router/query_tags", payload, request_options)
      request.callback { |result| yield raw ? request.raw_response : result }
      request.errback do |message|
        ErrorTracker.log(self, "Failed to query tags (#{message})")
        yield((raw ? request.raw_response : nil) || message)
      end
      request.run
      true
    end
Runs a tag query with an optional list of tags.

 === Parameters
 tags(Array):: Tags to query or empty or nil
 hrefs(Array):: hrefs of resources to query with empty or nil meaning all instances in deployment
 options(Hash):: Request options
   :raw(Boolean):: true to yield raw tag response instead of unserialized tags
   :timeout(Integer):: timeout in seconds before giving up and yielding an error message

 === Block
 Given block should take one argument which will be set with an array
 initialized with the tags of this instance

 === Return
 true:: Always return true