dagster-dingtalk 0.1.41__py3-none-any.whl → 0.1.43__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.
@@ -531,10 +531,170 @@ class 待办任务__:
531
531
  class 文档文件__:
532
532
  def __init__(self, _client:DingTalkClient):
533
533
  self.__client:DingTalkClient = _client
534
+ self.群文件 = 文档文件__群文件(_client)
534
535
  self.媒体文件 = 文档文件__媒体文件(_client)
536
+ self.存储管理 = 文档文件__存储管理(_client)
535
537
  self.文件传输 = 文档文件__存储管理__文件传输(_client)
536
538
 
537
539
 
540
+ # noinspection NonAsciiCharacters, PyPep8Naming
541
+ class 文档文件__群文件:
542
+ def __init__(self, _client:DingTalkClient):
543
+ self.__client:DingTalkClient = _client
544
+
545
+ def 获取群存储空间信息(self, unionId:str, openConversationId:str) -> dict:
546
+ """
547
+ 接口版本:2025-01-14
548
+
549
+ 调用本接口,可获取某个指定群的存储空间信息,包括群存储空间的ID、群存储空间创建的时间和修改时间等。
550
+
551
+ https://open.dingtalk.com/document/orgapp/obtain-group-storage-space-information
552
+
553
+ :param unionId: 操作人的unionId。
554
+ :param openConversationId: 会话openConversationId。
555
+
556
+ :return:
557
+ {
558
+ "space" : {
559
+ "spaceId" : "798****",
560
+ "corpId" : "ding1234****",
561
+ "createTime" : "2022-01-01T10:00:00Z",
562
+ "modifiedTime" : "2022-01-01T10:00:00Z"
563
+ }
564
+ }
565
+ """
566
+ response = self.__client.api(
567
+ method="POST",
568
+ path=f"/v1.0/convFile/conversations/spaces/query?unionId={unionId}",
569
+ json={'openConversationId': openConversationId}
570
+ )
571
+ return response.json()
572
+
573
+ def 以应用身份发送文件给指定用户(self, unionId:str, spaceId:str, dentryId:str) -> dict:
574
+ """
575
+ 接口版本:2023-01-18
576
+
577
+ 调用本接口可以把存储空间内的文件发送给用户。例如,以当前应用的身份给接收人发送一条工作通知。
578
+
579
+ https://open.dingtalk.com/document/orgapp/sends-a-storage-file-to-a-specified-user
580
+
581
+ :param unionId: 操作人的unionId。
582
+ :param spaceId: 文件所在空间ID。
583
+ :param dentryId: 文件ID。
584
+
585
+ :return:
586
+ {
587
+ "file" : {
588
+ "id" : "674****",
589
+ "conversationId" : "cidB1*****",
590
+ "spaceId" : "864*****",
591
+ "parentId" : "0",
592
+ "type" : "FILE",
593
+ "name" : "测试文件.xls",
594
+ "size" : 256,
595
+ "path" : "/测试文件.xls",
596
+ "version" : 1,
597
+ "status" : "NORMAL",
598
+ "extension" : "xls",
599
+ "creatorId" : "cHtUY****",
600
+ "modifierId" : "cHtUY****",
601
+ "createTime" : "2022-01-01T10:00:00Z",
602
+ "modifiedTime" : "2022-01-01T10:00:00Z"
603
+ }
604
+ }
605
+ """
606
+ response = self.__client.api(
607
+ method="POST",
608
+ path=f"/v1.0/convFile/apps/conversations/files/send?unionId={unionId}",
609
+ json={"spaceId" : spaceId, "dentryId" : dentryId}
610
+ )
611
+ return response.json()
612
+
613
+ def 发送文件到指定会话(self, unionId:str, spaceId:str, dentryId:str, openConversationId:str) -> dict:
614
+ """
615
+ 接口版本:2023-01-18
616
+
617
+ 调用本接口,可实现将存储空间内的文件发送到指定群内。
618
+
619
+ https://open.dingtalk.com/document/orgapp/send-file-to-specified-session
620
+
621
+ :param unionId: 操作人的unionId。
622
+ :param spaceId: 文件所在空间ID。
623
+ :param dentryId: 文件ID。
624
+ :param openConversationId: 会话openConversationId。
625
+
626
+ :return:
627
+ {
628
+ "file" : {
629
+ "id" : "897*****",
630
+ "conversationId" : "cid+vIrz*****",
631
+ "spaceId" : "865*****",
632
+ "parentId" : "parent_id",
633
+ "type" : "FILE",
634
+ "name" : "测试文件.txt",
635
+ "size" : 256,
636
+ "path" : "./测试文件.txt",
637
+ "version" : 1,
638
+ "status" : "NORMAL",
639
+ "extension" : "txt",
640
+ "creatorId" : "chy*****",
641
+ "modifierId" : "chy*****",
642
+ "createTime" : "2022-01-01T10:00:00Z",
643
+ "modifiedTime" : "2022-01-01T10:00:00Z",
644
+ "uuid" : "123*****"
645
+ }
646
+ }
647
+ """
648
+ response = self.__client.api(
649
+ method="POST",
650
+ path=f"/v1.0/convFile/conversations/files/send?unionId={unionId}",
651
+ json={"spaceId": spaceId, "dentryId": dentryId, "openConversationId": openConversationId}
652
+ )
653
+ return response.json()
654
+
655
+ def 发送文件链接到指定会话(self, unionId:str, spaceId:str, dentryId:str, openConversationId:str) -> dict:
656
+ """
657
+ 接口版本:2023-01-18
658
+
659
+ 调用本接口,可实现发送文件链接到指定群内。
660
+
661
+ https://open.dingtalk.com/document/orgapp/send-a-file-link-to-the-specified-session
662
+
663
+ :param unionId: 操作人的unionId。
664
+ :param spaceId: 文件所在空间ID。
665
+ :param dentryId: 文件ID。
666
+ :param openConversationId: 会话openConversationId。
667
+
668
+ :return:
669
+ {
670
+ "file" : {
671
+ "id" : "file_id",
672
+ "conversationId" : "open_conversation_id",
673
+ "spaceId" : "space_id",
674
+ "parentId" : "parent_id",
675
+ "type" : "file",
676
+ "name" : "file_name",
677
+ "size" : 256,
678
+ "path" : "file_path",
679
+ "version" : 1,
680
+ "status" : "NORMAL",
681
+ "extension" : "txt",
682
+ "creatorId" : "creator_id",
683
+ "modifierId" : "modified_id",
684
+ "createTime" : "2022-01-01T10:00:00Z",
685
+ "modifiedTime" : "2022-01-01T10:00:00Z",
686
+ "uuid" : "uuid"
687
+ }
688
+ }
689
+ """
690
+ response = self.__client.api(
691
+ method="POST",
692
+ path=f"/v1.0/convFile/conversations/files/links/send?unionId={unionId}",
693
+ json={"spaceId": spaceId, "dentryId": dentryId, "openConversationId": openConversationId}
694
+ )
695
+ return response.json()
696
+
697
+
538
698
  # noinspection NonAsciiCharacters, PyPep8Naming
539
699
  class 文档文件__媒体文件:
540
700
  def __init__(self, _client:DingTalkClient):
@@ -542,6 +702,8 @@ class 文档文件__媒体文件:
542
702
 
543
703
  def 上传媒体文件(self, file_path:Path|str, media_type:Literal['image', 'voice', 'video', 'file']) -> dict:
544
704
  """
705
+ 接口版本:2023-05-24
706
+
545
707
  调用本接口,上传图片、语音媒体资源文件以及普通文件,接口返回媒体资源标识 media_id。
546
708
 
547
709
  https://open.dingtalk.com/document/orgapp/upload-media-files
@@ -565,59 +727,73 @@ class 文档文件__媒体文件:
565
727
  return response.json()
566
728
 
567
729
 
730
+ # noinspection NonAsciiCharacters, PyPep8Naming
731
+ class 文档文件__存储管理:
732
+ def __init__(self, _client:DingTalkClient):
733
+ self.__client:DingTalkClient = _client
734
+ self.文件传输 = 文档文件__存储管理__文件传输(self.__client)
735
+
736
+
568
737
  # noinspection NonAsciiCharacters, PyPep8Naming
569
738
  class 文档文件__存储管理__文件传输:
570
739
  def __init__(self, _client:DingTalkClient):
571
740
  self.__client:DingTalkClient = _client
572
741
 
573
- def 获取文件上传信息(self, space_id:int, union_id:str, multi_part:bool = False) -> dict:
742
+ def 获取文件上传信息(self, parentDentryUuid:str, union_id:str) -> dict:
574
743
  """
575
- 调用本接口,上传图片、语音媒体资源文件以及普通文件,接口返回媒体资源标识 media_id。
744
+ 接口版本:2024-01-05
576
745
 
577
- https://open.dingtalk.com/document/orgapp/upload-media-files
746
+ 调用本接口,获取文件上传信息。
747
+
748
+ https://open.dingtalk.com/document/orgapp/obtain-file-upload-informations
578
749
 
579
- :param space_id: 空间Id。
580
750
  :param union_id: 操作者unionId。
581
- :param multi_part: 是否需要分片上传。默认值为 False
751
+ :param parentDentryUuid: 父节点 dentryUuid,如果是空间根目录, 填空间根目录的dentryUuid。
582
752
 
583
753
  :return:
584
754
  {
585
- "uploadKey": str,
586
- "storageDriver": str,
587
- "protocol": str,
588
- "headerSignatureInfo": {
589
- "resourceUrls" : ["resourceUrl"],
590
- "headers" : {
591
- "key" : "header_value"
592
- },
593
- }
755
+ "uploadKey" : "upload_key",
756
+ "storageDriver" : "DINGTALK",
757
+ "protocol" : "HEADER_SIGNATURE",
758
+ "headerSignatureInfo" : {
759
+ "resourceUrls" : [ "resourceUrl" ],
760
+ "headers" : {
761
+ "key" : "header_value"
762
+ },
763
+ "expirationSeconds" : 900,
764
+ "region" : "ZHANGJIAKOU",
765
+ "internalResourceUrls" : [ "internalResourceUrl" ]
766
+ }
594
767
  }
595
768
  """
596
769
  response = self.__client.api(
597
770
  method="POST",
598
- path=f"/v1.0/storage/spaces/{space_id}/files/uploadInfos/query",
771
+ path=f"/v2.0/storage/spaces/files/{parentDentryUuid}/uploadInfos/query",
599
772
  params={'unionId': union_id},
600
- json={
601
- "protocol": "HEADER_SIGNATURE",
602
- "multipart": multi_part
603
- }
773
+ json={"protocol" : "HEADER_SIGNATURE"}
604
774
  )
605
775
  return response.json()
606
776
 
607
- def 提交文件(self, url:str, headers:dict, file_path:Path|str, space_id:int, union_id:str,
608
- upload_key:str, convert_to_online_doc:bool = False) -> dict:
777
+ def 提交文件(
778
+ 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,
780
+ conflictStrategy:Literal['AUTO_RENAME', 'OVERWRITE', 'RETURN_DENTRY_IF_EXISTS', 'RETURN_ERROR_IF_EXISTS'] = 'AUTO_RENAME'
781
+ ) -> dict:
609
782
  """
783
+ 接口版本:2023-07-06
784
+
610
785
  调用本接口,上传图片、语音媒体资源文件以及普通文件,接口返回媒体资源标识 media_id。
611
786
 
612
787
  https://open.dingtalk.com/document/orgapp/upload-media-files
613
-
788
+ :param parentDentryUuid: 父节点 dentryUuid。如果是空间根目录,填空间根目录的dentryUuid。
789
+ :param upload_key: 添加文件唯一标识。
614
790
  :param url: 获取文件上传信息得到的 resourceUrl。
615
791
  :param headers: 获取文件上传信息得到的 headers。
616
- :param file_path: 文件路径
617
- :param space_id: 空间Id
792
+ :param file_content: 文件字节内容,如果提供了 file_content,则忽略 file_path。
793
+ :param file_path: 文件路径,如果提供了 file_content,则忽略 file_path
618
794
  :param union_id: 操作者unionId。
619
- :param upload_key: 添加文件唯一标识。
620
795
  :param convert_to_online_doc: 是否转换成在线文档。默认值 False
796
+ :param conflictStrategy: 文件名称冲突策略。AUTO_RENAME:自动重命名,默认值 OVERWRITE:覆盖 RETURN_DENTRY_IF_EXISTS:返回已存在文件 RETURN_ERROR_IF_EXISTS:文件已存在时报错
621
797
 
622
798
  :return:
623
799
  {
@@ -627,20 +803,27 @@ class 文档文件__存储管理__文件传输:
627
803
  "headerSignatureInfo": dict,
628
804
  }
629
805
  """
630
- with open(file_path, 'rb') as f:
631
- httpx.put(
632
- url=url,
633
- files={"file":f},
634
- headers=headers
635
- )
806
+
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"未提供任何文件路径或文件内容")
636
818
 
637
819
  response = self.__client.api(
638
820
  method="POST",
639
- path=f"/v2.0/storage/spaces/files/{space_id}/commit?unionId={union_id}",
821
+ path=f"/v2.0/storage/spaces/files/{parentDentryUuid}/commit?unionId={union_id}",
640
822
  json={
641
823
  "uploadKey": upload_key,
642
824
  "name": file_path.split("/")[-1],
643
- "convertToOnlineDoc": convert_to_online_doc
825
+ "convertToOnlineDoc": convert_to_online_doc,
826
+ "option": {"conflictStrategy": conflictStrategy}
644
827
  }
645
828
  )
646
829
  return response.json()
@@ -1 +1 @@
1
- __version__ = "0.26.17"
1
+ __version__ = "0.26.20"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dagster-dingtalk
3
- Version: 0.1.41
3
+ Version: 0.1.43
4
4
  Summary: A dagster plugin for the DingTalk
5
5
  Author-email: YiZixuan <sqkkyzx@qq.com>
6
6
  Requires-Python: >=3.11
@@ -0,0 +1,9 @@
1
+ dagster_dingtalk/__init__.py,sha256=wg8o3Ys3BeHV-sMWr9A_xtUhOOgu3JUKsbkgwMgLttU,419
2
+ dagster_dingtalk/app_client.py,sha256=n4l2va3KesfxFLuAX6fMJE_LVGATKE9msZ8cbobYSEs,45242
3
+ dagster_dingtalk/operations.py,sha256=yH_rXJpWc8rwzkiJqjqHKy5iIED0Xi3qbSOv6SVr-eA,3923
4
+ dagster_dingtalk/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
+ dagster_dingtalk/resources.py,sha256=VRQPehJX59SN7tCO5i6O7De9-HPwD8UIcRkQsqL6v9k,17868
6
+ dagster_dingtalk/version.py,sha256=YUih-qXiPUqv2gSiXl1m22xIJL02nxLsc9JTVuaY_9E,25
7
+ dagster_dingtalk-0.1.43.dist-info/METADATA,sha256=lpvIsLOInpOVoTXl6bILXfPvIYjBdCy0uFZ5woWYESw,7757
8
+ dagster_dingtalk-0.1.43.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
9
+ dagster_dingtalk-0.1.43.dist-info/RECORD,,
@@ -1,9 +0,0 @@
1
- dagster_dingtalk/__init__.py,sha256=wg8o3Ys3BeHV-sMWr9A_xtUhOOgu3JUKsbkgwMgLttU,419
2
- dagster_dingtalk/app_client.py,sha256=nqY_ZCB0q7ptnUJHzbU6DfOzTsnokDC5bNTK0ZO4dAM,37632
3
- dagster_dingtalk/operations.py,sha256=yH_rXJpWc8rwzkiJqjqHKy5iIED0Xi3qbSOv6SVr-eA,3923
4
- dagster_dingtalk/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
- dagster_dingtalk/resources.py,sha256=VRQPehJX59SN7tCO5i6O7De9-HPwD8UIcRkQsqL6v9k,17868
6
- dagster_dingtalk/version.py,sha256=l6BoE6WwDO3mK3_UIExcLpdbrlScT4OmrRrRnFiM2H8,25
7
- dagster_dingtalk-0.1.41.dist-info/METADATA,sha256=gymhLK8HaE6WkXx895D7eESkeRsk33jpxJR_7_2BQhQ,7757
8
- dagster_dingtalk-0.1.41.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
9
- dagster_dingtalk-0.1.41.dist-info/RECORD,,