Exemplo n.º 1
0
 def get_source_by_content_object(self, document_family: DocumentFamily, content_object: ContentObject) -> \
         Any:
     from kodexa import KodexaPlatform
     get_response = KodexaPlatform.get_client().get(
         f"api/stores/{self.ref.replace(':', '/')}/families/{document_family.id}/objects/{content_object.id}/content"
     )
     return get_response.content if get_response is not None else None
Exemplo n.º 2
0
    def count(self) -> int:
        from kodexa import KodexaPlatform
        get_response = KodexaPlatform.get_client().get(
            f"api/stores/{self.ref.replace(':', '/')}/families")
        if get_response is not None:
            return get_response.json()['totalElements']

        return 0
Exemplo n.º 3
0
 def get_document_by_content_object(self, document_family: DocumentFamily, content_object: ContentObject) -> \
         Optional[Document]:
     from kodexa import KodexaPlatform
     get_response = KodexaPlatform.get_client().get(
         f"api/stores/{self.ref.replace(':', '/')}/families/{document_family.id}/objects/{content_object.id}/content"
     )
     return Document.from_kddb(
         get_response.content) if get_response is not None else None
Exemplo n.º 4
0
 def get_family_by_path(self, path: str) -> Optional[DocumentFamily]:
     from kodexa import KodexaPlatform
     get_response = KodexaPlatform.get_client().get(
         f"api/stores/{self.ref.replace(':', '/')}/fs",
         params={
             "path": path,
             "meta": True
         })
     return DocumentFamily.parse_obj(
         get_response.json()) if get_response is not None else None
Exemplo n.º 5
0
    def list_contents(self) -> List[str]:

        # TODO this needs to be cleaned up a bit
        params = {'page': 1, 'pageSize': 1000, 'query': '*'}
        from kodexa import KodexaPlatform
        get_response = KodexaPlatform.get_client().get(
            f"api/stores/{self.ref.replace(':', '/')}/families", params=params)
        if get_response is not None:
            paths = []
            for fam_dict in get_response.json()['content']:
                paths.append(fam_dict['path'])
            return paths

        return []
Exemplo n.º 6
0
    def query_families(self,
                       query: str = "*",
                       page: int = 1,
                       page_size: int = 100,
                       sort=None) -> List[DocumentFamily]:
        params = {'page': page, 'pageSize': page_size, 'query': query}

        if sort is not None:
            params.sort = sort

        from kodexa import KodexaPlatform
        get_response = KodexaPlatform.get_client().get(
            f"api/stores/{self.ref.replace(':', '/')}/families", params=params)
        if get_response is not None:
            families = []
            for fam_dict in get_response.json()['content']:
                families.append(DocumentFamily.parse_obj(fam_dict))
            return families

        return []