Returns a callable which conjures the URL for the resource and GETs a response
166887
def _generate_read_callable(name, display_name, arguments, regex, doc, supported):
    
    def f(self, *args, **kwargs):
        url = self._generate_url(regex, args)
        if 'params' in kwargs:
            url += "?" + urllib.urlencode(kwargs['params'])
        return self._get_data(url, accept=(kwargs.get('accept')))
    f.__name__ = str('read_%s' % name)
    f.__doc__ = doc
    f._resource_uri = regex
    f._get_args = arguments
    f._put_or_post_args = None 
    f.resource_name = display_name
    f.is_api_call = True
    f.is_supported_api = supported
    return f
519293
def receiver(url, **kwargs):
    
    res = url_to_resources(url)
    fnc = res["receiver"]
    return fnc(res.get("url"), **kwargs)
880460
def _build_url(self, resource, **kwargs):
        # type: (str, **str) -> str
        """"""
        return urljoin(self.api_root, API_PATH[resource].format(**kwargs))
869016
def _http_resource(self, method, resource, params=None, data=None):
        """"""

        if not is_collection(resource):
            resource = [resource]

        url = self._url_for(*resource)
        r = self._session.request(method, url, params=params, data=data)

        if r.status_code == 422:
            http_error = HTTPError('%s Client Error: %s' %
                                   (r.status_code, r.content.decode("utf-8")))
            http_error.response = r
            raise http_error

        r.raise_for_status()

        return r
361166
def get_page(self, url, *args, **kwds):
        
        contextFactory = None
        scheme, host, port, path = parse(url)
        data = kwds.get('postdata', None)
        self._method = method = kwds.get('method', 'GET')
        self.request_headers = self._headers(kwds.get('headers', {}))
        if (self.body_producer is None) and (data is not None):
            self.body_producer = FileBodyProducer(StringIO(data))
        if self.endpoint.ssl_hostname_verification:
            contextFactory = None
        else:
            contextFactory = WebClientContextFactory()
        agent = _get_agent(scheme, host, self.reactor, contextFactory)
        if scheme == "https":
            self.client.url = url
        d = agent.request(method, url, self.request_headers, self.body_producer)
        d.addCallback(self._handle_response)
        return d
615424
def _request(self, method, resource, **kwargs):
        
        url = self._resolve_resource_name(resource)

        if hasattr(self, 'access_token'):
            kwargs.update(dict(oauth_token=self.access_token))
        if hasattr(self, 'client_id'):
            kwargs.update(dict(client_id=self.client_id))

        kwargs.update({
            'verify_ssl': self.options.get('verify_ssl', True),
            'proxies': self.options.get('proxies', None)
        })
        return wrapped_resource(make_request(method, url, kwargs))
453980
def _get(self, url):
        
        try:
            response = requests.get(url, verify=self.verify,
                                    cookies=self.cookies, timeout=self.timeout,
                                    auth=self._client.auth())
            response.raise_for_status()
            return response
        except HTTPError as exc:
            if exc.response.status_code in (404, 407):
                raise EntityNotFound(url)
            else:
                message = ('Error during request: {url} '
                           'status code:({code}) '
                           'message: {message}').format(
                               url=url,
                               code=exc.response.status_code,
                               message=exc.response.text)
                logging.error(message)
                raise ServerError(exc.response.status_code,
                                  exc.response.text,
                                  message)
        except Timeout:
            message = 'Request timed out: {url} timeout: {timeout}'
            message = message.format(url=url, timeout=self.timeout)
            logging.error(message)
            raise ServerError(message)
        except RequestException as exc:
            message = ('Error during request: {url} '
                       'message: {message}').format(
                           url=url,
                           message=exc)
            logging.error(message)
            raise ServerError(exc.args[0][1].errno,
                              exc.args[0][1].strerror,
                              message)
972382
def _get(self, uri):
        
        resp, resp_body = self.api.method_get(uri)
        return self.resource_class(self, resp_body, self.response_key,
                loaded=True)
433120
def retrieve(self, request, *args, **kwargs):
        

        try:
            instance = self.get_object()
            serializer = self.get_serializer(instance)
            return Response(serializer.data)
        except Http404:
            pass

        lookup_url_kwarg = self.lookup_url_kwarg or self.lookup_field
        slug = self.kwargs[lookup_url_kwarg]

        # fall back to accession_temp_fallback
        try:
            tmp = get_object_or_404(
                self.queryset, accession_temp_fallback=slug)
            return HttpResponseRedirect(
                reverse(self.redirect_view_name, (tmp.slug, ))
            )
        except (Http404, FieldError):
            pass

        # fall back to embark ID
        try:
            embark = get_object_or_404(self.queryset, id=int(slug))
            return HttpResponseRedirect(
                reverse(self.redirect_view_name, (embark.slug, ))
            )
        except (Http404, ValueError):
            pass

        # fall back to alt slug
        try:
            from glamkit_collections.utils import alt_slugify
            alt_slug = alt_slugify(slug)
            alt = get_object_or_404(self.queryset, alt_slug=alt_slug)
            return HttpResponseRedirect(
                reverse(self.redirect_view_name, (alt.slug, ))
            )
        except Http404:
            pass

        # well, we tried
        raise Http404
757915
def get_resources(url, resource_class, params={})
      get(url, params).map do |result|
        resource_class.from_hash(result, client: self)
      end
    end
1270156
def _call_api_single_related_resource(self, resource, full_resource_url,
                                          method_name, **kwargs):
        
        url = full_resource_url
        params = {
            'headers': self.get_http_headers(
                resource.Meta.name, method_name, **kwargs),
            'url': url
        }
        prepared_request = self.prepare_http_request(
            'GET', params, **kwargs)
        response = self.session.send(prepared_request)
        return self._handle_response(
            response, resource.Meta.valid_status_codes, resource)
76270
public ClientResponse getResponse(String url, Method method)
      throws Exception {
    Builder resource = getResource(url);
    ClientResponse response = null;
    switch (method) {
    case Get:
      response = resource.get(ClientResponse.class);
      break;
    case Post:
      response = resource.post(ClientResponse.class);
      break;
    case Head:
      response = resource.head();
      break;
    case Put:
      response = resource.put(ClientResponse.class);
      break;
    }
    return response;
  }
767253
def _get(self, url, query=None):
        

        if query is None:
            query = {}

        response = retry_request(self)(self._http_get)(url, query=query)

        if self.raw_mode:
            return response

        if response.status_code != 200:
            error = get_error(response)
            if self.raise_errors:
                raise error
            return error

        localized = query.get('locale', '') == '*'
        return ResourceBuilder(
            self.default_locale,
            localized,
            response.json(),
            max_depth=self.max_include_resolution_depth,
            reuse_entries=self.reuse_entries
        ).build()
230540
def get(self, url, **kwargs):
        
        """

        kwargs.setdefault('allow_redirects', True)
        return self.request('GET', url, **kwargs)
315665
def _call(self, method, url, params):
        """"""
        request_params = {}
        if method == 'GET':
            request_params['params'] = params
        elif method == 'POST':
            request_params['data'] = params
        response = requests.request(method, url, **request_params)
        return response
226006
def get_resource(url):
    
    response = DAO.getURL(url, {'Accept': 'application/json',
                                'Connection': 'keep-alive'})
    if response.status != 200:
        raise DataFailureException(url, response.status, response.data)
    return json.loads(response.data)
974819
def _request(self, func, url, version=1, *args, **kwargs):
        
        return_json = kwargs.pop('return_json', False)
        url = self.api_url[version] + url
        response = func(url, *args, **kwargs)

        if 'proxies' not in kwargs:
            kwargs['proxies'] = self.proxydict

        # Check for error, raising an exception if appropriate.
        response.raise_for_status()

        try:
            json_response = response.json()
        except ValueError:
            json_response = None
        if isinstance(json_response, dict):
            error = json_response.get('error')
            if error:
                raise BitstampError(error)
            elif json_response.get('status') == "error":
                raise BitstampError(json_response.get('reason'))

        if return_json:
            if json_response is None:
                raise BitstampError(
                    "Could not decode json for: " + response.text)
            return json_response

        return response