Get a resource

        :param resource_id: a resource's ID
        :param include_deactivated: Include deactivated resources in response

        :returns: Document instance
        :raises: SocketError, CouchException
181755
def get(cls, resource_id, include_deactivated=False):
        
        resource = yield cls.db_client().get_doc(resource_id)

        if resource.get('type') != cls.resource_type:
            raise exceptions.NotFound()

        if not include_deactivated and resource.get('state') == State.deactivated.name:
            raise exceptions.NotFound()

        raise Return(cls(**resource))
1328515
def get_resources_to_check(client_site_url, apikey):
    
    url = client_site_url + u"deadoralive/get_resources_to_check"
    response = requests.get(url, headers=dict(Authorization=apikey))
    if not response.ok:
        raise CouldNotGetResourceIDsError(
            u"Couldn't get resource IDs to check: {code} {reason}".format(
                code=response.status_code, reason=response.reason))
    return response.json()
585216
def get(self, id_or_uri):
        
        uri = self.build_uri(id_or_uri)
        logger.debug('Get resource (uri = %s, ID = %s)' %
                     (uri, str(id_or_uri)))
        return self._connection.get(uri)
870121
def extract_included(cls, fields, resource, resource_instance, included_resources,
                         included_cache):
        
        # this function may be called with an empty record (example: Browsable Interface)
        if not resource_instance:
            return

        current_serializer = fields.serializer
        context = current_serializer.context
        included_serializers = utils.get_included_serializers(current_serializer)
        included_resources = copy.copy(included_resources)
        included_resources = [inflection.underscore(value) for value in included_resources]

        for field_name, field in six.iteritems(fields):
            # Skip URL field
            if field_name == api_settings.URL_FIELD_NAME:
                continue

            # Skip fields without relations or serialized data
            if not isinstance(
                    field, (relations.RelatedField, relations.ManyRelatedField, BaseSerializer)
            ):
                continue

            try:
                included_resources.remove(field_name)
            except ValueError:
                # Skip fields not in requested included resources
                # If no child field, directly continue with the next field
                if field_name not in [node.split('.')[0] for node in included_resources]:
                    continue

            relation_instance = cls.extract_relation_instance(
                field_name, field, resource_instance, current_serializer
            )
            if isinstance(relation_instance, Manager):
                relation_instance = relation_instance.all()

            serializer_data = resource.get(field_name)

            if isinstance(field, relations.ManyRelatedField):
                serializer_class = included_serializers[field_name]
                field = serializer_class(relation_instance, many=True, context=context)
                serializer_data = field.data

            if isinstance(field, relations.RelatedField):
                if relation_instance is None or not serializer_data:
                    continue

                many = field._kwargs.get('child_relation', None) is not None

                if isinstance(field, ResourceRelatedField) and not many:
                    already_included = serializer_data['type'] in included_cache and \
                        serializer_data['id'] in included_cache[serializer_data['type']]

                    if already_included:
                        continue

                serializer_class = included_serializers[field_name]
                field = serializer_class(relation_instance, many=many, context=context)
                serializer_data = field.data

            new_included_resources = [key.replace('%s.' % field_name, '', 1)
                                      for key in included_resources
                                      if field_name == key.split('.')[0]]

            if isinstance(field, ListSerializer):
                serializer = field.child
                relation_type = utils.get_resource_type_from_serializer(serializer)
                relation_queryset = list(relation_instance)

                if serializer_data:
                    for position in range(len(serializer_data)):
                        serializer_resource = serializer_data[position]
                        nested_resource_instance = relation_queryset[position]
                        resource_type = (
                            relation_type or
                            utils.get_resource_type_from_instance(nested_resource_instance)
                        )
                        serializer_fields = utils.get_serializer_fields(
                            serializer.__class__(
                                nested_resource_instance, context=serializer.context
                            )
                        )
                        new_item = cls.build_json_resource_obj(
                            serializer_fields,
                            serializer_resource,
                            nested_resource_instance,
                            resource_type,
                            getattr(serializer, '_poly_force_type_resolution', False)
                        )
                        included_cache[new_item['type']][new_item['id']] = \
                            utils._format_object(new_item)
                        cls.extract_included(
                            serializer_fields,
                            serializer_resource,
                            nested_resource_instance,
                            new_included_resources,
                            included_cache,
                        )

            if isinstance(field, Serializer):
                relation_type = utils.get_resource_type_from_serializer(field)

                # Get the serializer fields
                serializer_fields = utils.get_serializer_fields(field)
                if serializer_data:
                    new_item = cls.build_json_resource_obj(
                        serializer_fields,
                        serializer_data,
                        relation_instance,
                        relation_type,
                        getattr(field, '_poly_force_type_resolution', False)
                    )
                    included_cache[new_item['type']][new_item['id']] = utils._format_object(
                        new_item
                    )
                    cls.extract_included(
                        serializer_fields,
                        serializer_data,
                        relation_instance,
                        new_included_resources,
                        included_cache,
                    )
1207706
def resource(resource_id):
    """"""
    resource_obj = app.db.resource(resource_id)

    if 'raw' in request.args:
        return send_from_directory(os.path.dirname(resource_obj.path),
                                   os.path.basename(resource_obj.path))

    return render_template('resource.html', resource=resource_obj)
1018041
def get(ctx, resource, id):
    
    session, api_url, project_id = build_client_from_context(ctx)
    url = '/'.join([api_url, resource, id])
    r = session.get(url)
    if r.status_code != 200:
        raise failed_request_exception('Failed to get resource', r)

    response = json.loads(r.text)
    if resource == 'deviceModels':
        pretty_print_model(response)
    elif resource == 'devices':
        pretty_print_device(response)
    logging.debug(r.text)
272019
def delete(self, resource_id, **kwargs):
        

        return self.client._delete(self._url(resource_id), **kwargs)
355550
def get_resource_id(self):
        
        # Implemented from template for osid.resource.Resource.get_avatar_id_template
        if not bool(self._my_map['resourceId']):
            raise errors.IllegalState('this Authorization has no resource')
        else:
            return Id(self._my_map['resourceId'])
1155025
def get_document(self, doc_id):
        ''''''
        conn = self.agency._database.get_connection()
        return conn.get_document(doc_id)
1030371
def _get_element_by_id(self, resource_name, eclass, id):
        """"""
        elements = self._get_elements(resource_name, eclass, id=id)
        if not elements:
            raise ValueError("No resource matching: {0}".format(id))
        if len(elements) == 1:
            return elements[0]
        raise ValueError("Multiple resources matching: {0}".format(id))
246780
def get!(id, params = {})
      slug = escape_docid(id)
      url = CouchRest.paramify_url("#{path}/#{slug}", params)
      result = connection.get(url)
      return result unless result.is_a?(Hash)
      doc = if /^_design/ =~ result["_id"]
        Design.new(result)
      else
        Document.new(result)
      end
      doc.database = self
      doc
    end
426493
def get(self, resource_id):
        
        response = self.requester.get(
            '/{endpoint}/{entity}/{id}',
            endpoint=self.endpoint, entity=self.entity, id=resource_id,
            paginate=False
        )
        return response.json()
1220168
def get_url_for_id(client_site_url, apikey, resource_id):
    
    # TODO: Handle invalid responses from the client site.
    url = client_site_url + u"deadoralive/get_url_for_resource_id"
    params = {"resource_id": resource_id}
    response = requests.get(url, headers=dict(Authorization=apikey),
                            params=params)
    if not response.ok:
        raise CouldNotGetURLError(
            u"Couldn't get URL for resource {id}: {code} {reason}".format(
                id=resource_id, code=response.status_code,
                reason=response.reason))

    return response.json()
345696
def resource(self, name):
        
        for resource in self.resources():
            if resource.name.lower() == name.lower():
                return resource
        raise NotFound('Unable to find resource %s' % name)
1140860
def get(self, id):
        
        url = self._url('%s' % (id))
        return self.client.get(url)
700078
def get_resource_id(resource, name=None, resource_id=None, region=None,
                    key=None, keyid=None, profile=None):
    '''
    

    '''

    try:
        return {'id': _get_resource_id(resource, name, region=region, key=key,
                                       keyid=keyid, profile=profile)}
    except BotoServerError as e:
        return {'error': __utils__['boto.get_error'](e)}
677365
def _get_next_resource(self, resource, next_resource_name, selectors):
        
        # don't fetch twice
        if 'id_perms' not in resource:
            resource.fetch()

        res = None
        for res_list in (getattr(resource.refs, next_resource_name),
                         getattr(resource.back_refs, next_resource_name),
                         getattr(resource.children, next_resource_name)):
            res = self._select_next_resource(res_list, selectors)
            if res is not None:
                break

        if res is None:
            raise CommandError("Resource '%s' is not linked to resource type '%s'" %
                               (self.current_path(resource), next_resource_name))

        return (res.type, res)