dagster-dingtalk 0.1.43__tar.gz → 0.1.45__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (23) hide show
  1. {dagster_dingtalk-0.1.43 → dagster_dingtalk-0.1.45}/.idea/workspace.xml +2 -1
  2. {dagster_dingtalk-0.1.43 → dagster_dingtalk-0.1.45}/PKG-INFO +1 -1
  3. {dagster_dingtalk-0.1.43 → dagster_dingtalk-0.1.45}/pyproject.toml +1 -1
  4. {dagster_dingtalk-0.1.43 → dagster_dingtalk-0.1.45}/src/dagster_dingtalk/app_client.py +184 -21
  5. {dagster_dingtalk-0.1.43 → dagster_dingtalk-0.1.45}/.gitignore +0 -0
  6. {dagster_dingtalk-0.1.43 → dagster_dingtalk-0.1.45}/.idea/.gitignore +0 -0
  7. {dagster_dingtalk-0.1.43 → dagster_dingtalk-0.1.45}/.idea/MarsCodeWorkspaceAppSettings.xml +0 -0
  8. {dagster_dingtalk-0.1.43 → dagster_dingtalk-0.1.45}/.idea/dagster-dingtalk.iml +0 -0
  9. {dagster_dingtalk-0.1.43 → dagster_dingtalk-0.1.45}/.idea/deployment.xml +0 -0
  10. {dagster_dingtalk-0.1.43 → dagster_dingtalk-0.1.45}/.idea/dictionaries/admin.xml +0 -0
  11. {dagster_dingtalk-0.1.43 → dagster_dingtalk-0.1.45}/.idea/inspectionProfiles/Project_Default.xml +0 -0
  12. {dagster_dingtalk-0.1.43 → dagster_dingtalk-0.1.45}/.idea/inspectionProfiles/profiles_settings.xml +0 -0
  13. {dagster_dingtalk-0.1.43 → dagster_dingtalk-0.1.45}/.idea/misc.xml +0 -0
  14. {dagster_dingtalk-0.1.43 → dagster_dingtalk-0.1.45}/.idea/modules.xml +0 -0
  15. {dagster_dingtalk-0.1.43 → dagster_dingtalk-0.1.45}/.idea/vcs.xml +0 -0
  16. {dagster_dingtalk-0.1.43 → dagster_dingtalk-0.1.45}/.python-version +0 -0
  17. {dagster_dingtalk-0.1.43 → dagster_dingtalk-0.1.45}/README.md +0 -0
  18. {dagster_dingtalk-0.1.43 → dagster_dingtalk-0.1.45}/desktop.ini +0 -0
  19. {dagster_dingtalk-0.1.43 → dagster_dingtalk-0.1.45}/src/dagster_dingtalk/__init__.py +0 -0
  20. {dagster_dingtalk-0.1.43 → dagster_dingtalk-0.1.45}/src/dagster_dingtalk/operations.py +0 -0
  21. {dagster_dingtalk-0.1.43 → dagster_dingtalk-0.1.45}/src/dagster_dingtalk/py.typed +0 -0
  22. {dagster_dingtalk-0.1.43 → dagster_dingtalk-0.1.45}/src/dagster_dingtalk/resources.py +0 -0
  23. {dagster_dingtalk-0.1.43 → dagster_dingtalk-0.1.45}/src/dagster_dingtalk/version.py +0 -0
@@ -147,7 +147,8 @@
147
147
  <workItem from="1746881612246" duration="131000" />
148
148
  <workItem from="1748502555257" duration="70000" />
149
149
  <workItem from="1749879333099" duration="4165000" />
150
- <workItem from="1749889527048" duration="48000" />
150
+ <workItem from="1749889527048" duration="3459000" />
151
+ <workItem from="1750078149869" duration="2177000" />
151
152
  </task>
152
153
  <task id="LOCAL-00001" summary="更改目录结构以便于使用 uv 构建和发布包">
153
154
  <option name="closed" value="true" />
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dagster-dingtalk
3
- Version: 0.1.43
3
+ Version: 0.1.45
4
4
  Summary: A dagster plugin for the DingTalk
5
5
  Author-email: YiZixuan <sqkkyzx@qq.com>
6
6
  Requires-Python: >=3.11
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "dagster-dingtalk"
3
- version = "0.1.43"
3
+ version = "0.1.45"
4
4
  description = "A dagster plugin for the DingTalk"
5
5
  readme = "README.md"
6
6
  authors = [
@@ -5,7 +5,7 @@ import time
5
5
  from datetime import datetime
6
6
  from enum import Enum
7
7
  from pathlib import Path
8
- from typing import List, Literal
8
+ from typing import List, Literal, Tuple
9
9
 
10
10
  import httpx
11
11
  from httpx import Client
@@ -533,6 +533,7 @@ class 文档文件__:
533
533
  self.__client:DingTalkClient = _client
534
534
  self.群文件 = 文档文件__群文件(_client)
535
535
  self.媒体文件 = 文档文件__媒体文件(_client)
536
+ self.搜索 = 文档文件__搜索(_client)
536
537
  self.存储管理 = 文档文件__存储管理(_client)
537
538
  self.文件传输 = 文档文件__存储管理__文件传输(_client)
538
539
 
@@ -727,11 +728,120 @@ class 文档文件__媒体文件:
727
728
  return response.json()
728
729
 
729
730
 
731
+ # noinspection NonAsciiCharacters, PyPep8Naming
732
+ class 文档文件__搜索:
733
+ def __init__(self, _client:DingTalkClient):
734
+ self.__client:DingTalkClient = _client
735
+
736
+ def 搜索文件(
737
+ self, operatorId:str, keyword:str, nextToken:str=None, maxResults:int=50,
738
+ dentryCategories:List[str]=None, creatorIds:List[str]=None, modifierIds:List[str]=None,
739
+ createTimeRange:Tuple[datetime, datetime]=None, visitTimeRange:Tuple[datetime, datetime]=None
740
+ ) -> dict:
741
+ """
742
+ 接口版本:2023-06-06
743
+
744
+ 调用本接口,根据操作者unionId和关键词信息,获取文件信息。
745
+
746
+ https://open.dingtalk.com/document/orgapp/search-for-files
747
+
748
+ :param nextToken:
749
+ :param operatorId: 操作人unionId。
750
+ :param keyword: 搜索关键词。
751
+ :param nextToken: 分页游标。首次拉取不用传。
752
+ :param maxResults: 分页大小,默认值50。最大值50。
753
+ :param dentryCategories: 限定文件类别。
754
+ :param creatorIds: 限定创建者。
755
+ :param modifierIds: 限定修改者。
756
+ :param createTimeRange: 限定创建时间范围。
757
+ :param visitTimeRange: 限定访问时间范围。
758
+
759
+ :return:
760
+ {
761
+ "items" : [ {
762
+ "dentryUuid" : "*****",
763
+ "name" : "name",
764
+ "creator" : {
765
+ "userId" : "01472825524039877041",
766
+ "name" : "user_name"
767
+ },
768
+ "modifier" : {
769
+ "userId" : "01472825524039877041",
770
+ "name" : "user_name"
771
+ }
772
+ } ],
773
+ "nextToken" : "next_token"
774
+ }
775
+ """
776
+ option = {}
777
+ if nextToken:
778
+ option["nextToken"] = nextToken
779
+ if maxResults:
780
+ option["maxResults"] = maxResults
781
+ if dentryCategories:
782
+ option["dentryCategories"] = dentryCategories
783
+ if creatorIds:
784
+ option["creatorIds"] = creatorIds
785
+ if modifierIds:
786
+ option["modifierIds"] = modifierIds
787
+ if createTimeRange:
788
+ option["createTimeRange"] = {"createTimeRange": {"startTime": createTimeRange[0].timestamp(), "endTime": createTimeRange[1].timestamp()}}
789
+ if visitTimeRange:
790
+ option["visitTimeRange"] = {"visitTimeRange": {"startTime": visitTimeRange[0].timestamp(), "endTime": visitTimeRange[1].timestamp()}}
791
+
792
+ response = self.__client.api(
793
+ method="POST",
794
+ path=f"/v2.0/storage/dentries/search",
795
+ params={"operatorId": operatorId},
796
+ json={"keyword": keyword, "option": option}
797
+ )
798
+ return response.json()
799
+
800
+ def 搜索知识库(self, operatorId:str, keyword:str, nextToken:str=None, maxResults:int=50):
801
+ """
802
+ 接口版本:2023-06-06
803
+
804
+ 调用本接口,根据操作人unionId和关键词信息,搜索知识库信息。
805
+
806
+ https://open.dingtalk.com/document/orgapp/search-knowledge-base
807
+
808
+ :param nextToken:
809
+ :param operatorId: 操作人unionId。
810
+ :param keyword: 搜索关键词。
811
+ :param nextToken: 分页游标。首次拉取不用传。
812
+ :param maxResults: 分页大小,默认值50。最大值50。
813
+
814
+ :return:
815
+ {
816
+ "items" : [ {
817
+ "workspaceId" : "By8jQS1ZYjGn5b0M",
818
+ "name" : "workspace_name",
819
+ "url" : "workspace_url"
820
+ } ],
821
+ "nextToken" : "next_token"
822
+ }
823
+ """
824
+ option = {}
825
+ if nextToken:
826
+ option["nextToken"] = nextToken
827
+ if maxResults:
828
+ option["maxResults"] = maxResults
829
+
830
+ response = self.__client.api(
831
+ method="POST",
832
+ path=f"/v2.0/storage/workspaces/search",
833
+ params={"operatorId": operatorId},
834
+ json={"keyword": keyword, "option": option}
835
+ )
836
+ return response.json()
837
+
838
+
730
839
  # noinspection NonAsciiCharacters, PyPep8Naming
731
840
  class 文档文件__存储管理:
732
841
  def __init__(self, _client:DingTalkClient):
733
842
  self.__client:DingTalkClient = _client
734
843
  self.文件传输 = 文档文件__存储管理__文件传输(self.__client)
844
+ self.文件管理 = 文档文件__存储管理__文件管理(self.__client)
735
845
 
736
846
 
737
847
  # noinspection NonAsciiCharacters, PyPep8Naming
@@ -776,7 +886,7 @@ class 文档文件__存储管理__文件传输:
776
886
 
777
887
  def 提交文件(
778
888
  self, parentDentryUuid:str, upload_key:str, url:str, headers:dict, file_content: bytes,
779
- file_path:Path|str, union_id:str, convert_to_online_doc:bool = False,
889
+ file_name:str, union_id:str, convert_to_online_doc:bool = False,
780
890
  conflictStrategy:Literal['AUTO_RENAME', 'OVERWRITE', 'RETURN_DENTRY_IF_EXISTS', 'RETURN_ERROR_IF_EXISTS'] = 'AUTO_RENAME'
781
891
  ) -> dict:
782
892
  """
@@ -784,13 +894,14 @@ class 文档文件__存储管理__文件传输:
784
894
 
785
895
  调用本接口,上传图片、语音媒体资源文件以及普通文件,接口返回媒体资源标识 media_id。
786
896
 
787
- https://open.dingtalk.com/document/orgapp/upload-media-files
897
+ https://open.dingtalk.com/document/orgapp/submittal-file
898
+
788
899
  :param parentDentryUuid: 父节点 dentryUuid。如果是空间根目录,填空间根目录的dentryUuid。
789
900
  :param upload_key: 添加文件唯一标识。
790
901
  :param url: 获取文件上传信息得到的 resourceUrl。
791
902
  :param headers: 获取文件上传信息得到的 headers。
792
- :param file_content: 文件字节内容,如果提供了 file_content,则忽略 file_path。
793
- :param file_path: 文件路径,如果提供了 file_content,则忽略 file_path。
903
+ :param file_content: 文件字节内容。
904
+ :param file_name: 文件的名称,带后缀。
794
905
  :param union_id: 操作者unionId。
795
906
  :param convert_to_online_doc: 是否转换成在线文档。默认值 False
796
907
  :param conflictStrategy: 文件名称冲突策略。AUTO_RENAME:自动重命名,默认值 OVERWRITE:覆盖 RETURN_DENTRY_IF_EXISTS:返回已存在文件 RETURN_ERROR_IF_EXISTS:文件已存在时报错
@@ -804,31 +915,83 @@ class 文档文件__存储管理__文件传输:
804
915
  }
805
916
  """
806
917
 
807
- if file_content:
808
- httpx.put(url=url, content=file_content, headers=headers)
809
- elif file_path:
810
- file_path = Path(file_path)
811
- if not file_path.exists():
812
- raise FileNotFoundError(f"文件路径不存在: {file_path}")
813
- else:
814
- with open(file_path, 'rb') as f:
815
- httpx.put(url=url, files={"file": f}, headers=headers)
816
- else:
817
- raise FileNotFoundError(f"未提供任何文件路径或文件内容")
818
-
918
+ httpx.put(url=url, content=file_content, headers=headers)
819
919
  response = self.__client.api(
820
920
  method="POST",
821
921
  path=f"/v2.0/storage/spaces/files/{parentDentryUuid}/commit?unionId={union_id}",
822
922
  json={
823
923
  "uploadKey": upload_key,
824
- "name": file_path.split("/")[-1],
924
+ "name": file_name,
825
925
  "convertToOnlineDoc": convert_to_online_doc,
826
- "option": {"conflictStrategy": conflictStrategy}
926
+ "option": {
927
+ "conflictStrategy": conflictStrategy
928
+ }
827
929
  }
828
930
  )
829
931
  return response.json()
830
932
 
831
933
 
934
+ # noinspection NonAsciiCharacters, PyPep8Naming
935
+ class 文档文件__存储管理__文件管理:
936
+ def __init__(self, _client:DingTalkClient):
937
+ self.__client:DingTalkClient = _client
938
+
939
+ def 添加文件夹(
940
+ self, spaceId:str, parentId:str, union_id:str, name:str,
941
+ conflictStrategy:Literal['AUTO_RENAME', 'OVERWRITE', 'RETURN_DENTRY_IF_EXISTS', 'RETURN_ERROR_IF_EXISTS'] = 'OVERWRITE'
942
+ ) -> dict:
943
+ """
944
+ 接口版本:2023-06-06
945
+
946
+ 调用本接口,在存储空间内添加文件夹。
947
+
948
+ https://open.dingtalk.com/document/orgapp/add-folder
949
+
950
+ :param spaceId: 空间Id。
951
+ :param parentId: 父目录Id。根目录时,该参数是0。
952
+ :param union_id: 操作者unionId。
953
+ :param name: 文件夹的名称。
954
+ :param conflictStrategy: 文件名称冲突策略。AUTO_RENAME:自动重命名,默认值 OVERWRITE:覆盖 RETURN_DENTRY_IF_EXISTS:返回已存在文件 RETURN_ERROR_IF_EXISTS:文件已存在时报错
955
+
956
+ :return:
957
+ """
958
+ response = self.__client.api(
959
+ method="POST",
960
+ path=f"/v1.0/storage/spaces/{spaceId}/dentries/{parentId}/folders",
961
+ params={'unionId': union_id},
962
+ json={
963
+ "name": name,
964
+ "option": {
965
+ "conflictStrategy": conflictStrategy
966
+ }
967
+ }
968
+ )
969
+ return response.json()
970
+
971
+ def 重命名文件或文件夹(self, spaceId:str, dentryId:str, union_id:str, new_name:str) -> dict:
972
+ """
973
+ 接口版本:2023-06-06
974
+
975
+ 调用本接口,在存储空间内添加文件夹。
976
+
977
+ https://open.dingtalk.com/document/orgapp/add-folder
978
+
979
+ :param spaceId: 空间Id。
980
+ :param dentryId: 文件或文件夹Id。
981
+ :param union_id: 操作者unionId。
982
+ :param new_name: 文件或文件夹的新名称。
983
+
984
+ :return:
985
+ """
986
+ response = self.__client.api(
987
+ method="POST",
988
+ path=f"/v1.0/storage/spaces/{spaceId}/dentries/{dentryId}/rename",
989
+ params={'unionId': union_id},
990
+ json={"newName": new_name}
991
+ )
992
+ return response.json()
993
+
994
+
832
995
  # noinspection NonAsciiCharacters, PyPep8Naming
833
996
  class 互动卡片__:
834
997
  def __init__(self, _client:DingTalkClient):
@@ -858,7 +1021,7 @@ class 互动卡片__:
858
1021
 
859
1022
  open_space_id = f"dtv1.card//{';'.join(open_space_ids)}"
860
1023
 
861
- payload = {
1024
+ payload:dict = {
862
1025
  "cardTemplateId": card_template_id,
863
1026
  "outTrackId": out_track_id,
864
1027
  "openSpaceId": open_space_id,
@@ -1012,7 +1175,7 @@ class OA审批_审批实例__:
1012
1175
  }
1013
1176
  """
1014
1177
 
1015
- data = {
1178
+ data: dict = {
1016
1179
  'processInstanceId': instance_id,
1017
1180
  'text': text,
1018
1181
  'commentUserId': comment_user_id,