def get(context, request, resource=None, uid=None): """Get Plone contents, e.g. <Plonesite>/@@API/plone/api/1.0/folder -> returns all folders <Plonesite>/@@API/plone/api/1.0/folder/4711 -> returns the folder with UID 4711 """ # We have a UID, return the record if uid and not resource: return api.get_record(uid) # we have a UID as resource, return the record if api.is_uid(resource): return api.get_record(resource) # BBB if resource == "get": logger.warn( "The /get route is obsolete and will be removed in 1.0.0. Please use /<UID> instead" ) return api.get_record(uid) portal_type = api.resource_to_portal_type(resource) if portal_type is None: raise APIError(404, "Not Found") return api.get_batched(portal_type=portal_type, uid=uid, endpoint="plone.jsonapi.routes.get")
def search(context, request): """Generic search route <Plonesite>/@@API/plone/api/1.0/search -> returns all contents of the portal <Plonesite>/@@API/plone/api/1.0/search?portal_type=Folder -> returns only folders ... """ return api.get_batched()
def get(context, request, resource=None, uid=None): """Get Plone contents, e.g. <Plonesite>/@@API/plone/api/1.0/folder -> returns all folders <Plonesite>/@@API/plone/api/1.0/folder/4711 -> returns the folder with UID 4711 """ # We have a UID, return the record if uid and not resource: return api.get_record(uid) # we have a UID as resource, return the record if api.is_uid(resource): return api.get_record(resource) # BBB if resource == "get": logger.warn("The /get route is obsolete and will be removed in 1.0.0. Please use /<UID> instead") return api.get_record(uid) portal_type = api.resource_to_portal_type(resource) if portal_type is None: raise APIError(404, "Not Found") return api.get_batched(portal_type=portal_type, uid=uid, endpoint="plone.jsonapi.routes.get")
def get(context, request, uid=None): """ get folders """ return get_batched("Folder", uid=uid, endpoint="folders")
def get(context, request, uid=None): """ get topics """ return get_batched("Topic", uid=uid, endpoint="topics")
def get(context, request, uid=None): """ get newsitems """ return get_batched("News Item", uid=uid, endpoint="newsitems")
def get(context, request, uid=None): """ get documents """ return get_batched("Document", uid=uid, endpoint="documents")
def get(context, request, uid=None): """ get events """ return get_batched("Event", uid=uid, endpoint="events")
def get(context, request, uid=None): """ get images """ return get_batched("Image", uid=uid, endpoint="images")
def get(context, request, uid=None): """ Plone sites """ return get_batched("Plone Site", uid=uid, endpoint="plonesites")
def test_get_batched(self): results = api.get_batched("Document") self.assertEqual(results["count"], 50) self.assertEqual(results["pages"], 2)
def get(context, request, uid=None): """ get files """ return get_batched("File", request, uid=uid, endpoint="files")
def get(context, request, uid=None): """ get links """ return get_batched("Link", uid=uid, endpoint="links")
def get(context, request, uid=None): """ get collections """ return get_batched("Collection", uid=uid, endpoint="collections")
def get(context, request): """ search all contents """ return get_batched([])