Corresponds to GET request with a resource unique identifier, fetching a single document from the database
340003
async def detail(self, **kwargs):
        '''
        
        '''
        try:
            pk = self.pk_type(kwargs.get('pk'))
            obj = await self._meta.object_class.find_one(self.db, {self.pk: pk})
            if obj:
                return await obj.serialize()
            raise NotFound('Object matching the given {} with value {} was not found'.format(self.pk, str(pk)))
        except InvalidId:
            raise NotFound('Invalid ID')
1347064
def get_id(request):
        
        if isinstance(request, etree._Element):
            elem = request
        else:
            if isinstance(request, Document):
                request = request.toxml()
            elem = fromstring(request, forbid_dtd=True)
        return elem.get('ID', None)
620781
def get_one(self, schema, query=None, **kwargs):
        
        ret = self._get_query(self._get_one, schema, query, **kwargs)
        if not ret: ret = {}
        return ret
1158352
def get(self, index, doc_type, id, fields=None, model=None, **query_params):
        
        path = make_path(index, doc_type, id)
        if fields is not None:
            query_params["fields"] = ",".join(fields)
        model = model or self.model
        return model(self, self._send_request('GET', path, params=query_params))
919025
def get(cls, id=None, condition=None, fields=None, cache=False, engine_name=None, **kwargs):
        
        
        if id is None and condition is None:
            return None
        
        can_cacheable = (cache or getattr(cls, '__cacheable__', None)) and \
            isinstance(id, (int, long, str, unicode))
        if can_cacheable:
            #send 'get_object' topic to get cached object
            obj = dispatch.get(cls, 'get_object', id)
            if obj:
                return obj

        if condition is not None:
            _cond = condition
        else:
            if is_condition(id):
                _cond = id
            else:
                _cond = cls.c[cls._primary_field] == id
            #todo
            # if isinstance(id, (int, long)):
            #     _cond = cls.c.id==id
            # elif isinstance(id, (str, unicode)) and id.isdigit():
            #     _cond = cls.c.id==int(id)
            # else:
            #     _cond = id

        #if there is no cached object, then just fetch from database
        obj = cls.filter(_cond, **kwargs).fields(*(fields or [])).one()
        
        if obj and cache or getattr(cls, '__cacheable__', None):
            dispatch.call(cls, 'set_object', instance=obj)

        return obj
695880
def get(self, id):
        
        try:
            session_json = self.db[id]
        except KeyError:
            session_json = "{}"
        return json_loads(session_json)
860083
def wikidata_get(identifier):
    
    url = 'https://www.wikidata.org/wiki/Special:EntityData/{}.json'.format(identifier)
    #logging.info(url)
    return json.loads(requests.get(url).content)
933652
def get_any_entity(self, id=None, uri=None, match=None):
        

        if not id and not uri and not match:
            return None

        if type(id) == type("string"):
            uri = id
            id = None
            if not is_http(uri):
                match = uri
                uri = None
        if match:
            if type(match) != type("string"):
                return []
            res = []
            if ":" in match:  # qname
                for x in self.all_classes:
                    if match.lower() in x.qname.lower():
                        res += [x]
                for x in self.all_properties:
                    if match.lower() in x.qname.lower():
                        res += [x]
            else:
                for x in self.all_classes:
                    if match.lower() in x.uri.lower():
                        res += [x]
                for x in self.all_properties:
                    if match.lower() in x.uri.lower():
                        res += [x]
            return res
        else:
            for x in self.all_classes:
                if id and x.id == id:
                    return x
                if uri and x.uri.lower() == uri.lower():
                    return x
            for x in self.all_properties:
                if id and x.id == id:
                    return x
                if uri and x.uri.lower() == uri.lower():
                    return x
            return None
1255973
def read_single(db, collection, match_params=None):
        
        return db[collection].find_one(match_params if match_params else {}, {'_id': False})
292921
def request_single(self, name, content={}):
        
        resp = self.request(name, content)

        # We stop on the first non-attribute (attributes are unicode/str)
        # If it's a list, we only return the first one.

        for i in resp.values():
            if type(i) == list:
                return i[0]
            elif type(i) == dict:
                return i

        return None
505692
function(key) {
      var that = this;

      if (!this._key || !key) {
        return Promise.reject(new Error('No unique key specified'));
      }

      var props = {};
      props[this._key] = key;

      return this._dbApi.find(props).then(function(docs) {
        return that._readDoc(docs[0]);
      });
    }
515711
def get_one(self, request, **kwargs):
        """"""
        resource = request.match_info.get(self.name)
        if not resource:
            return None

        try:
            return self.collection.where(self.meta.model_pk == resource).get()
        except Exception:
            raise RESTNotFound(reason='Resource not found.')
964016
def retrieve_resource(collection, key):
    
    session = _get_session()
    cls = endpoint_class(collection)
    resource = session.query(cls).get(key)
    if resource is None:
        raise InvalidAPIUsage(404)
    return resource
1142349
def get(identifier, namespace='cid', domain='compound', operation=None, output='JSON', searchtype=None, **kwargs):
    """"""
    if (searchtype and searchtype != 'xref') or namespace in ['formula']:
        response = request(identifier, namespace, domain, None, 'JSON', searchtype, **kwargs).read()
        status = json.loads(response.decode())
        if 'Waiting' in status and 'ListKey' in status['Waiting']:
            identifier = status['Waiting']['ListKey']
            namespace = 'listkey'
            while 'Waiting' in status and 'ListKey' in status['Waiting']:
                time.sleep(2)
                response = request(identifier, namespace, domain, operation, 'JSON', **kwargs).read()
                status = json.loads(response.decode())
            if not output == 'JSON':
                response = request(identifier, namespace, domain, operation, output, searchtype, **kwargs).read()
    else:
        response = request(identifier, namespace, domain, operation, output, searchtype, **kwargs).read()
    return response
300664
def do_get(path, params={})
      login if need_login?

      # Resource id is a special param as it needs to be added to the path
      path = add_id_and_params_to_path(path, params)

      req, res, resource_type, body = nil

      begin
        retry_request(true) do
          # Return content type so the resulting resource object knows what kind of resource it is.
          resource_type, body = @rest_client[path].get(headers) do |response, request, result, &block|
            req, res = request, response
            update_cookies(response)
            update_last_request(request, response)

            case response.code
            when 200
              # Get the resource_type from the content_type, the resource_type
              # will be used later to add relevant methods to relevant resources
              type = if result.content_type.index('rightscale')
                get_resource_type(result.content_type)
              elsif result.content_type.index('text/plain')
                'text'
              else
                ''
              end

              # work around getting ASCII-8BIT from some resources like audit entry detail
              charset = get_charset(response.headers)
              if charset && response.body.encoding != charset
                response.body.force_encoding(charset)
              end

              # raise an error if the API is misbehaving and returning an empty response when it shouldn't
              if type != 'text' && response.body.empty?
                raise EmptyBodyError.new(request, response)
              end

              [type, response.body]
            when 301, 302
              update_api_url(response)
              response.follow_redirection(request, result, &block)
            when 404
              raise UnknownRouteError.new(request, response)
            else
              raise ApiError.new(request, response)
            end
          end
        end
      rescue => e
        raise wrap(e, :get, path, params, req, res)
      end

      data = if resource_type == 'text'
        { 'text' => body }
      else
        JSON.parse(body, :allow_nan => true)
      end

      [resource_type, path, data]
    end
586491
def get(path, params = {})
      uri = path
      if params.count > 0
        uri += "?#{URI.encode_www_form(params)}"
      end

      headers = {}

      request('GET', uri, nil, headers) do |resp|
        if params[:fetch_all] == true &&
            resp.body.has_key?('pagination') &&
            resp.body['pagination']['next_uri'] != nil
          params[:starting_after] = resp.body['data'].last['id']
          get(path, params) do |page|
            body = resp.body
            body['data'] += page.data
            resp.body = body
            yield(resp) if block_given?
          end
        else
          yield(resp) if block_given?
        end
      end
    end
135688
Document getResourceAsDoc(String resource) throws Exception {
        ClassLoader cl = Thread.currentThread().getContextClassLoader();
        InputStream is = cl.getResourceAsStream(resource);
        if (is != null) {
            DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
            dbf.setNamespaceAware(true);
            // Fortify Mod: prevent external entity injection
            dbf.setExpandEntityReferences(false);
            DocumentBuilder db = dbf.newDocumentBuilder();
            // Fortify Mod: prevent external entity injection 
            TransformerFactory tf = TransformerFactory.newInstance();
            tf.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
            Transformer t = tf.newTransformer();
            //Transformer t = TransformerFactory.newInstance().newTransformer();
	       // End Fortify Mod
            Document doc = db.newDocument();
            t.transform(new StreamSource(is), new DOMResult(doc));
            // Fortify Mod: Close the InputStream and release its resources
            is.close();
            return doc;
        } else {
            return null;
        }
    }