dagster-dingtalk 0.1.44__py3-none-any.whl → 0.1.45__py3-none-any.whl

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.
@@ -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
@@ -821,6 +931,67 @@ class 文档文件__存储管理__文件传输:
821
931
  return response.json()
822
932
 
823
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
+
824
995
  # noinspection NonAsciiCharacters, PyPep8Naming
825
996
  class 互动卡片__:
826
997
  def __init__(self, _client:DingTalkClient):
@@ -850,7 +1021,7 @@ class 互动卡片__:
850
1021
 
851
1022
  open_space_id = f"dtv1.card//{';'.join(open_space_ids)}"
852
1023
 
853
- payload = {
1024
+ payload:dict = {
854
1025
  "cardTemplateId": card_template_id,
855
1026
  "outTrackId": out_track_id,
856
1027
  "openSpaceId": open_space_id,
@@ -1004,7 +1175,7 @@ class OA审批_审批实例__:
1004
1175
  }
1005
1176
  """
1006
1177
 
1007
- data = {
1178
+ data: dict = {
1008
1179
  'processInstanceId': instance_id,
1009
1180
  'text': text,
1010
1181
  'commentUserId': comment_user_id,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dagster-dingtalk
3
- Version: 0.1.44
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,9 +1,9 @@
1
1
  dagster_dingtalk/__init__.py,sha256=wg8o3Ys3BeHV-sMWr9A_xtUhOOgu3JUKsbkgwMgLttU,419
2
- dagster_dingtalk/app_client.py,sha256=SodIEp4LSDrvlUoSMqIBoSNTxq8EEx85Y0BPv5PDu4c,44707
2
+ dagster_dingtalk/app_client.py,sha256=4-atNlnybFsqg0DwijW4ynUA7bvM6FfhRZIGeietXL0,51237
3
3
  dagster_dingtalk/operations.py,sha256=yH_rXJpWc8rwzkiJqjqHKy5iIED0Xi3qbSOv6SVr-eA,3923
4
4
  dagster_dingtalk/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
5
  dagster_dingtalk/resources.py,sha256=VRQPehJX59SN7tCO5i6O7De9-HPwD8UIcRkQsqL6v9k,17868
6
6
  dagster_dingtalk/version.py,sha256=YUih-qXiPUqv2gSiXl1m22xIJL02nxLsc9JTVuaY_9E,25
7
- dagster_dingtalk-0.1.44.dist-info/METADATA,sha256=bRo4t_qR91dHXymKZZ57IWn3waUL_ji1yQgvamw4LjM,7757
8
- dagster_dingtalk-0.1.44.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
9
- dagster_dingtalk-0.1.44.dist-info/RECORD,,
7
+ dagster_dingtalk-0.1.45.dist-info/METADATA,sha256=75rStysM9BK_emql6v0b6jx37v0k7HUrig-ROL60MWY,7757
8
+ dagster_dingtalk-0.1.45.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
9
+ dagster_dingtalk-0.1.45.dist-info/RECORD,,