Format data as a Resource object or list of Resource objects.

        See: http://jsonapi.org/format/#document-resource-objects
196298
def format_items(self, data, many):
        
        if many:
            return [self.format_item(item) for item in data]
        else:
            return self.format_item(data)
780024
def update(self, data):
        
        data = values.of({'Data': serialize.object(data), })

        payload = self._version.update(
            'POST',
            self._uri,
            data=data,
        )

        return DocumentInstance(
            self._version,
            payload,
            service_sid=self._solution['service_sid'],
            sid=self._solution['sid'],
        )
1317772
protected void _format(XtextResource resource, IFormattableDocument document) {
		List<EObject> contents = resource.getContents();
		if (!contents.isEmpty()) {
			EObject model = contents.get(0);
			document.format(model);
		}
	}
81118
def resource_collection_create(self, data, **kwargs):
        ""
        api_path = "/api/v2/resource_collections.json"
        return self.call(api_path, method="POST", data=data, **kwargs)
788268
def resource_list(cls):
        
        items = cls.list({'items_per_page': 500})
        ret = [str(ip['id']) for ip in items]
        ret.extend([ip['ip'] for ip in items])
        return ret
331023
def format(self, formatter, *args, **kwargs):
        
        # TODO: data export?
        return self.get_formatter(formatter)(*args, **kwargs)
273078
def make_resource_document(self, title, content, tags=[],):
        """"""

        assert "<html>" not in content
        assert "<body>" not in content

        return """
        <html>
        <head><title>%(title)s</title></head>
        <body>
        %(content)s
        </body>
        """ % dict(
            title=title,
            content=content,
        )
726291
def handle_resourcelist(ltext, **kwargs):
    '''
    
    '''
    base=kwargs.get('base', VERSA_BASEIRI)
    model=kwargs.get('model')
    iris = ltext.strip().split()
    newlist = model.generate_resource()
    for i in iris:
        model.add(newlist, VERSA_BASEIRI + 'item', I(iri.absolutize(i, base)))
    return newlist
793606
def _format_data(self, name=None):
        

        # do we want to justify (only do so for non-objects)
        is_justify = not (self.inferred_type in ('string', 'unicode') or
                          (self.inferred_type == 'categorical' and
                           is_object_dtype(self.categories)))

        return format_object_summary(self, self._formatter_func,
                                     is_justify=is_justify, name=name)
1149461
def format_content_type_object(repo, content_type, uuid):
    
    try:
        storage_manager = StorageManager(repo)
        model_class = load_model_class(repo, content_type)
        return dict(storage_manager.get(model_class, uuid))
    except GitCommandError:
        raise NotFound('Object does not exist.')
1352951
def format_dict(self, delim=':', qu="'"):
        
        res = 'name' + delim + qu + self.name + qu + ','
        for num, d in enumerate(self.data):
            res += 'col' + str(num) + delim + qu + str(d) + qu + ','
        return res
26826
private void writeResources(List<Resource> resources)
            throws JsonGenerationException, IOException {

        PolicyUtils.validateResourceList(resources);
        List<String> resourceStrings = new ArrayList<String>();

        for (Resource resource : resources) {
            resourceStrings.add(resource.getId());
        }

        // all resources are validated to be of the same type, so it is safe to take the type of the first one
        if (resources.get(0).isNotType()) {
            writeJsonArray(JsonDocumentFields.NOT_RESOURCE, resourceStrings);
        } else {
            writeJsonArray(JsonDocumentFields.RESOURCE, resourceStrings);
        }
    }
421033
def document
      json = Net::HTTP.get_response URI.parse(query_string(@query))
      json.body
    end
427632
def from_json(self, json):
        
        res_type = json['sys']['type']

        if ResourceType.Array.value == res_type:
            return self.create_array(json)
        elif ResourceType.Entry.value == res_type:
            return self.create_entry(json)
        elif ResourceType.Asset.value == res_type:
            return ResourceFactory.create_asset(json)
        elif ResourceType.ContentType.value == res_type:
            return ResourceFactory.create_content_type(json)
        elif ResourceType.Space.value == res_type:
            return ResourceFactory.create_space(json)
430404
def serialize(self, resources):
        """"""
        serialized = {
            'meta': {
                'sqlalchemy_jsonapi_version': '4.0.9'
            },
            'jsonapi': {
                'version': '1.0'
            }
        }
        # Determine multiple resources by checking for SQLAlchemy query count.
        if hasattr(resources, 'count'):
            serialized['data'] = []
            for resource in resources:
                serialized['data'].append(
                    self._render_resource(resource))
        else:
            serialized['data'] = self._render_resource(resources)

        return serialized
45518
def map_to_resource(self, data_element, resource=None):
        
        if not IDataElement.providedBy(data_element): # pylint:disable=E1101
            raise ValueError('Expected data element, got %s.' % data_element)
        if resource is None:
            coll = \
                create_staging_collection(data_element.mapping.mapped_class)
            agg = coll.get_aggregate()
            agg.add(data_element)
            if IMemberDataElement.providedBy(data_element): # pylint: disable=E1101
                ent = next(iter(agg))
                resource = \
                    data_element.mapping.mapped_class.create_from_entity(ent)
            else:
                resource = coll
        else:
            resource.update(data_element)
        return resource
915165
def resource_definition(resource):
    
    meta = getmeta(resource)

    definition = {
        'type': "object",
        'properties': {}
    }

    for field in meta.all_fields:
        field_definition = {}

        type_def = map_field_to_type(field)
        if type_def:
            field_definition['type'] = str(type_def)
            if type_def.format:
                field_definition['format'] = type_def.format

        if field.doc_text:
            field_definition['description'] = field.doc_text

        if isinstance(field, VirtualField) or field in meta.readonly_fields:
            field_definition['readOnly'] = True

        # Use getattr to support calculated fields
        if getattr(field, 'choices', None):
            field_definition['enum'] = [c[0] for c in field.choices]

        definition['properties'][field.name] = field_definition

    return definition