Return the resource in *collection* identified by key *key*.

    :param string collection: a :class:`sandman.model.Model` endpoint
    :param string key: primary key of resource
    :rtype: class:`sandman.model.Model`
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
486656
def collections(record, key, value):
    """"""
    return {
        'primary': value.get('a'),
        'secondary': value.get('b'),
        'deleted': value.get('c'),
    }
272109
def fetch(key, default=nil)
      found_in = self_and_sub_collections.detect{ |c| c[key] }
      raise KeyError unless found_in
      found_in[key]
    end
744685
def get(self, key):
        

        match = self._get_match(key=key)

        if not match:
            return None

        return self._get_value_from_match(key=key, match=match)
1077177
def get_resource_by_key(self, resource_key):
        

        # search for quick_key by default
        lookup_order = ["quick_key", "folder_key"]

        if len(resource_key) == FOLDER_KEY_LENGTH:
            lookup_order = ["folder_key", "quick_key"]

        resource = None

        for lookup_key in lookup_order:
            try:
                if lookup_key == "folder_key":
                    info = self.api.folder_get_info(folder_key=resource_key)
                    resource = Folder(info['folder_info'])
                elif lookup_key == "quick_key":
                    info = self.api.file_get_info(quick_key=resource_key)
                    resource = File(info['file_info'])
            except MediaFireApiError:
                # TODO: Check response code
                pass

            if resource:
                break

        if not resource:
            raise ResourceNotFoundError(resource_key)

        return resource
1163549
def get_resource(id):
    ''''''
    dataset = Dataset.objects(resources__id=id).first()
    if dataset:
        return get_by(dataset.resources, 'id', id)
    else:
        return CommunityResource.objects(id=id).first()
156235
def get_collection(self, key=None, name=None):
        
        if name is not None:
            logger.warn("TowerTensorHandle.get_collection(name=..) was renamed to (key=..) !")
            key = name
        return self._ctx.get_collection_in_tower(key)
263972
def from_key(key):
    
    model = get_model_from_key(key)
    if model is None:
        raise BadKeyError
    try:
        _, id = key.split(':', 2)
        id = int(id)
    except ValueError, TypeError:
        raise BadKeyError
    return model.objects.get_by_id(id)
272499
def group_by(resources, key):
    
    resource_map = {}
    parts = key.split('.')
    for r in resources:
        v = r
        for k in parts:
            v = v.get(k)
            if not isinstance(v, dict):
                break
        resource_map.setdefault(v, []).append(r)
    return resource_map
6534
def find_by_id(key: str, user: str=None) -> Optional['ApiKey']:
        
        return ApiKey.from_db(db.get_key(key, user))
136639
def get_value_from_set(self, key):
        
        #TODO: This should be done locally. 
        # We do not really need to call centralised server if the set is already
        # reserved as the data there is immutable during execution
        key = key.lower()
        if self._remotelib:
            while True:
                value = self._remotelib.run_keyword('get_value_from_set',
                                                    [key, self._my_id], {})
                if value:
                    return value
                time.sleep(0.1)
                logger.debug('waiting for a value')
        else:
            return _PabotLib.get_value_from_set(self, key, self._my_id)
924399
def Get(self,key):
		

		for network in self.networks:
			try:
				if network.id == key:  return(network)
				if network.name == key:  return(network)
				if network.cidr == key:  return(network)
			except:
				# We ignore malformed records with missing attributes
				pass
998506
def resource_collection_show(self, id, **kwargs):
        ""
        api_path = "/api/v2/resource_collections/{id}.json"
        api_path = api_path.format(id=id)
        return self.call(api_path, **kwargs)
749923
def get_one(self, key):
        
        query = {'_id': ObjectId(key)}
        collection = self.ds.connection(COLLECTION_UNIT_OF_WORK)

        document = collection.find_one(query)
        if document is None:
            msg = 'UOW with ID={0} was not found'.format(key)
            self.logger.warning(msg)
            raise LookupError(msg)
        return UnitOfWork.from_json(document)
110409
function collection(id) {
    if(!this.resource) {
      throw new Error('This Entity does not have a Resource.');
    }

    var path = this.resource.path + '/collections';

    return Resource.constructorFactory(path, EVT.Entity.Collection)
      .call(this.resource.scope, id);
  }
871913
def get_metadata(self, key) -> str:
        
        return self.metadata[key] if key in self.metadata else None
894273
def get_resource_key(self):
        """"""
        model = self.get_model()
        if model:
            return get_model_table(model)
        else:
            return self.get_name()