kodexa 7.4.412538129491__py3-none-any.whl → 7.4.412538433490__py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
kodexa/platform/client.py CHANGED
@@ -4783,7 +4783,8 @@ class DocumentFamilyEndpoint(DocumentFamily, ClientEndpoint):
4783
4783
  self.client.put(url, body=document_status.model_dump(by_alias=True))
4784
4784
 
4785
4785
  def add_document(
4786
- self, document: Document, content_object: Optional[ContentObject] = None
4786
+ self, document: Document, content_object: Optional[ContentObject] = None,
4787
+ taxonomies: Optional[List[Taxonomy]] = None, data_store: Optional[Store] = None
4787
4788
  ):
4788
4789
  """
4789
4790
  Add a document to the document family.
@@ -4791,22 +4792,36 @@ class DocumentFamilyEndpoint(DocumentFamily, ClientEndpoint):
4791
4792
  Args:
4792
4793
  document (Document): The document to add.
4793
4794
  content_object (Optional[ContentObject]): The content object. Defaults to None.
4795
+ taxonomies (Optional[List[Taxonomy]]): List of taxonomies to use. Defaults to None.
4796
+ data_store (Optional[Store]): Data store to add document to. Defaults to None.
4794
4797
  """
4795
4798
  url = (
4796
4799
  f'/api/stores/{self.store_ref.replace(":", "/")}/families/{self.id}/objects'
4797
4800
  )
4798
4801
  if content_object is None:
4799
4802
  content_object = self.content_objects[-1]
4803
+
4804
+ params = {
4805
+ "sourceContentObjectId": content_object.id,
4806
+ "transitionType": "DERIVED",
4807
+ "documentVersion": document.version
4808
+ }
4809
+
4810
+ # If we have a store but no taxonomies or the other way around then we need to throw an error
4811
+ if (data_store and not taxonomies) or (taxonomies and not data_store):
4812
+ raise Exception("If you provide a data store you must also provide taxonomies and vice-versa")
4813
+
4814
+ if taxonomies:
4815
+ params["taxonomyRefs"] = ",".join([taxonomy.ref for taxonomy in taxonomies])
4816
+
4817
+ if data_store:
4818
+ params["dataStoreRef"] = data_store.ref
4819
+
4800
4820
  self.client.post(
4801
4821
  url,
4802
- params={
4803
- "sourceContentObjectId": content_object.id,
4804
- "transitionType": "DERIVED",
4805
- "documentVersion": document.version,
4806
- },
4822
+ params=params,
4807
4823
  files={"file": document.to_kddb()},
4808
4824
  )
4809
-
4810
4825
  def export_as_zip(self) -> bytes:
4811
4826
  """
4812
4827
  Export the document family as bytes.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: kodexa
3
- Version: 7.4.412538129491
3
+ Version: 7.4.412538433490
4
4
  Summary: Python SDK for the Kodexa Platform
5
5
  Author: Austin Redenbaugh
6
6
  Author-email: austin@kodexa.com
@@ -19,7 +19,7 @@ kodexa/model/utils.py,sha256=6R-3rFiW9irBwj0Mq5yhp7EDXkNUFaeFhr3bWmnlW4g,2961
19
19
  kodexa/pipeline/__init__.py,sha256=sA7f5D6qkdMrpp2xTIeefnrUBI6xxEEWostvxfX_1Cs,236
20
20
  kodexa/pipeline/pipeline.py,sha256=Z4O6UwoISeP_HMlxm6l6kbcvFBDw3Glm7lT4cUibri4,25461
21
21
  kodexa/platform/__init__.py,sha256=1O3oiWMg292NPL_NacKDnK1T3_R6cMorrPRue_9e-O4,216
22
- kodexa/platform/client.py,sha256=V-LAiT6PmbZ_6oKhMGnxJc2lJlOGgVH12g_vUJxVsiY,226970
22
+ kodexa/platform/client.py,sha256=Fvibf_arAlujA5jJQYKMnBi_KKpdUE7sdLQBcFLFliI,227736
23
23
  kodexa/platform/interaction.py,sha256=6zpcwXKNZstUGNS6m4JsoRXAqCZPJHWI-ZN3co8nnF0,1055
24
24
  kodexa/platform/kodexa.py,sha256=tPXHO500q3S75GhKGDcaxO51Viq2PNlHmAzpBZlahgo,34857
25
25
  kodexa/selectors/__init__.py,sha256=xA9-4vpyaAZWPSk3bh2kvDLkdv6XEmm7PjFbpziiTIk,100
@@ -44,7 +44,7 @@ kodexa/testing/test_utils.py,sha256=v44p__gE7ia67W7WeHN2HBFCWSCUrCZt7G4xBNCmwf8,
44
44
  kodexa/training/__init__.py,sha256=xs2L62YpRkIRfslQwtQZ5Yxjhm7sLzX2TrVX6EuBnZQ,52
45
45
  kodexa/training/train_utils.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
46
46
  kodexa/utils/__init__.py,sha256=Pnim1o9_db5YEnNvDTxpM7HG-qTlL6n8JwFwOafU9wo,5928
47
- kodexa-7.4.412538129491.dist-info/LICENSE,sha256=WNHhf_5RCaeuKWyq_K39vmp9F28LxKsB4SpomwSZ2L0,11357
48
- kodexa-7.4.412538129491.dist-info/METADATA,sha256=XuR5JDCwVKjupcd7J-NmJMGNV7Y6m7yZ3ARfmgOHv14,3528
49
- kodexa-7.4.412538129491.dist-info/WHEEL,sha256=Zb28QaM1gQi8f4VCBhsUklF61CTlNYfs9YAZn-TOGFk,88
50
- kodexa-7.4.412538129491.dist-info/RECORD,,
47
+ kodexa-7.4.412538433490.dist-info/LICENSE,sha256=WNHhf_5RCaeuKWyq_K39vmp9F28LxKsB4SpomwSZ2L0,11357
48
+ kodexa-7.4.412538433490.dist-info/METADATA,sha256=wkNEgKynrDMzrfIbgRjIa5t1L8cCZBN473-s_EopnnY,3528
49
+ kodexa-7.4.412538433490.dist-info/WHEEL,sha256=Zb28QaM1gQi8f4VCBhsUklF61CTlNYfs9YAZn-TOGFk,88
50
+ kodexa-7.4.412538433490.dist-info/RECORD,,