Extracts a result from a Roads API HTTP response.
493540
def extract_roads_body(response)
        begin
          body = MultiJson.load(response.body, :symbolize_keys => true)
        rescue
          unless response.status_code == 200
            check_response_status_code(response)
          end
          raise GoogleMapsService::Error::ApiError.new(response), 'Received a malformed response.'
        end

        check_roads_body_error(response, body)

        unless response.status_code == 200
          raise GoogleMapsService::Error::ApiError.new(response)
        end
        return body
      end
544475
def _get_response(self, endpoint, query, is_post=False):
        """"""
        timeout_secs = self._settings.get('timeout', 10)
        headers = self._settings.get('request_headers', {})
        try:
            if is_post:
                response = requests.post(
                    endpoint, data=query, headers=headers, timeout=timeout_secs)
            else:
                response = requests.get(
                    endpoint, params=query, headers=headers, timeout=timeout_secs)
        except requests.exceptions.Timeout as e:
            raise Exception(
                'API request timed out after %s seconds.' % timeout_secs)
        except Exception as e:
            raise e

        if response.status_code != 200:
            raise Exception('Received status code %s from %s. Content is:\n%s'
                            % (response.status_code,
                               self.get_service_name(),
                               response.text))
        return response
1220670
def route(self, data):
        
        if isinstance(data, (dict, list)):
            requests = data
        else:
            requests = json.loads(data)
        if not isinstance(requests, list):
            requests = [requests]
        responses = []
        for request in requests:
            responses.append(self.call(request))
        if len(responses) == 1:
            return json.dumps(responses[0])
        return json.dumps(responses)
460552
def get_key_from_request(self):
        '''
        '''

        path = "result:%s" % self.context.request.url

        if self.is_auto_webp():
            path += '/webp'

        return path
382811
def get_status(self, response, finished=False):
        """"""
        for line in response.split("\n"):
            if line.strip() in self.status_mapping:
                return self.status_mapping[line.strip()]
        return None
33549
async def fetchResults(self, url, post_data=None):
    
    if post_data is not None:
      self.logger.debug("Querying URL '%s' %s..." % (url, dict(post_data)))
    else:
      self.logger.debug("Querying URL '%s'..." % (url))
    headers = {}
    self.updateHttpHeaders(headers)
    return await self.http.query(url,
                                 post_data=post_data,
                                 headers=headers,
                                 cache=__class__.api_cache)
230334
def _get_results_from_api(identifiers, endpoints, api_key, api_secret):
    """"""

    if api_key is not None and api_secret is not None:
        client = housecanary.ApiClient(api_key, api_secret)
    else:
        client = housecanary.ApiClient()

    wrapper = getattr(client, endpoints[0].split('/')[0])

    if len(endpoints) > 1:
        # use component_mget to request multiple endpoints in one call
        return wrapper.component_mget(identifiers, endpoints)
    else:
        return wrapper.fetch_identifier_component(endpoints[0], identifiers)
595528
def _get_response(self, **kwargs):
        
        # pylint: disable=E1101
        url = self.read_url + "?output=JSON&token=%s" % self.read_token
        for key in kwargs:
            if key and kwargs[key]:
                val = kwargs[key]
                if isinstance(val, (list, tuple)):
                    val = ",".join(val)
                url += "&%s=%s" % (key, val)
        self._api_url = url
        req = urllib2.urlopen(url)
        data = simplejson.loads(req.read())
        self._api_raw_data = data
        if data and data.get('error', None):
            exceptions.BrightcoveError.raise_exception(
                data['error'])
        if data == None:
            raise exceptions.NoDataFoundError(
                "No data found for %s" % repr(kwargs))
        return data
69011
def get(self, uri, disable_proxy=False, stream=False):
        """"""
        response = requests.get(
            uri,
            headers=self.headers,
            allow_redirects=True,
            cookies={},
            stream=stream,
            proxies=self.proxy if not disable_proxy else False
        )

        if response.status_code in _PERMITTED_STATUS_CODES:
            self.response_headers = response.headers
            return response.content if not stream else response.iter_content()
        else:
            raise requests.exceptions.HTTPError(
                "HTTP response did not have a permitted status code."
            )
256443
def get(url, parameters = {}, skip_status_check = false)
      response = connection.get("#{api_endpoint}#{url}", parameters)
      on_complete(response) unless skip_status_check
      response
    end
974756
def get(self, url, data=None):
        
        response = self.http.get(url,
                                 headers=self.headers,
                                 params=data,
                                 **self.requests_params)
        return self.process(response)
415469
def from_response_data(cls, response_data):
        

        response_json = response_data.json()

        return cls(
            response_data.url,
            response_json["number_of_page_results"],
            response_json["number_of_total_results"],
            response_json["results"],
        )
91046
def map_response(response, path)
      case path
      when "/audit_entries"
        # Convert returned audit entry href to audit ID
        response.sub!(/^.*\/api\/audit_entries\//, "") if response.is_a?(String)
      when "/tags/by_resource", "/tags/by_tag"
        # Extract tags for each instance resource from response array with members of form
        # {"actions" => [], "links" => [{"rel" => "resource", "href" => <href>}, ...]}, "tags" => [{"name" => <tag>}, ...]
        tags = {}
        if response
          response.each do |hash|
            r = {}
            hash["links"].each { |l| r[l["href"]] = {"tags" => []} if l["href"] =~ /instances/ }
            hash["tags"].each { |t| r.each_key { |k| r[k]["tags"] << t["name"] } } if r.any?
            tags.merge!(r)
          end
        end
        response = tags
      end
      response
    end
411348
def parse_response(self, response):
        """"""
        try:
            for header in response.msg.get_all("Set-Cookie"):
                cookie = header.split(";", 1)[0]
                cookieKey, cookieValue = cookie.split("=", 1)
                self._cookies[cookieKey] = cookieValue
        finally:
            return Transport.parse_response(self, response)
177675
def response_builder(self, response):
        '''
        '''
        try:
            r = response.json()
            result = r['query']['results']
            response = {
                'num_result': r['query']['count'] ,
                'result': result
            }
        except (Exception,) as e:
            print(e)
            return response.content

        return response
715901
def _parse_response(self, results):
        

        dict_response = results.get("response")
        result_obj = SolrResults()
        result_obj.query_time = results.get("responseHeader").get("QTime", None)
        result_obj.results_count = dict_response.get("numFound", 0)
        result_obj.start_index = dict_response.get("start", 0)

        for doc in dict_response.get("docs", []):
            result_obj.documents.append(doc)

        # Process facets
        if "facet_counts" in results:
            facet_types = ["facet_fields", "facet_dates", "facet_ranges", "facet_queries"]
            for type in facet_types:
                assert type in results.get("facet_counts")
                items = results.get("facet_counts").get(type)
                for field, values in items.items():
                    result_obj.facets[field] = []

                    # Range facets have results in "counts" subkey and "between/after" on top level. Flatten this.
                    if type == "facet_ranges":
                        if not "counts" in values:
                            continue

                        for facet, value in values["counts"].items():
                            result_obj.facets[field].append((facet, value))

                        if "before" in values:
                            result_obj.facets[field].append(("before", values["before"]))

                        if "after" in values:
                            result_obj.facets[field].append(("after", values["after"]))
                    else:
                        for facet, value in values.items():
                            # Date facets have metadata fields between the results, skip the params, keep "before" and "after" fields for other
                            if type == "facet_dates" and \
                            (facet == "gap" or facet == "between" or facet == "start" or facet == "end"):
                                continue
                            result_obj.facets[field].append((facet, value))

        # Process highlights
        if "highlighting" in results:
            for key, value in results.get("highlighting").items():
                result_obj.highlights[key] = value

        return result_obj
707182
def get(url):
    """"""
    writeln("Getting data from url", url)
    response = requests.get(url)
    if response.status_code == 200:
        writeln(response.text)
    else:
        writeln(str(response.status_code), response.reason)