dagster-dingtalk 0.1.41__py3-none-any.whl → 0.1.42__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.
- dagster_dingtalk/app_client.py +217 -33
- dagster_dingtalk/version.py +1 -1
- {dagster_dingtalk-0.1.41.dist-info → dagster_dingtalk-0.1.42.dist-info}/METADATA +1 -1
- dagster_dingtalk-0.1.42.dist-info/RECORD +9 -0
- dagster_dingtalk-0.1.41.dist-info/RECORD +0 -9
- {dagster_dingtalk-0.1.41.dist-info → dagster_dingtalk-0.1.42.dist-info}/WHEEL +0 -0
dagster_dingtalk/app_client.py
CHANGED
@@ -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,
|
742
|
+
def 获取文件上传信息(self, parentDentryUuid:str, union_id:str) -> dict:
|
574
743
|
"""
|
575
|
-
|
744
|
+
接口版本:2024-01-05
|
576
745
|
|
577
|
-
|
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
|
751
|
+
:param parentDentryUuid: 父节点 dentryUuid,如果是空间根目录, 填空间根目录的dentryUuid。
|
582
752
|
|
583
753
|
:return:
|
584
754
|
{
|
585
|
-
|
586
|
-
|
587
|
-
|
588
|
-
|
589
|
-
|
590
|
-
|
591
|
-
|
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"/
|
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 提交文件(
|
608
|
-
|
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
|
617
|
-
:param
|
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,28 @@ class 文档文件__存储管理__文件传输:
|
|
627
803
|
"headerSignatureInfo": dict,
|
628
804
|
}
|
629
805
|
"""
|
630
|
-
|
631
|
-
|
632
|
-
|
633
|
-
|
634
|
-
|
635
|
-
)
|
806
|
+
|
807
|
+
if file_content:
|
808
|
+
file_content = file_path.read_bytes()
|
809
|
+
httpx.put(url=url, content=file_content, headers=headers)
|
810
|
+
elif file_path:
|
811
|
+
file_path = Path(file_path)
|
812
|
+
if not file_path.exists():
|
813
|
+
raise FileNotFoundError(f"文件路径不存在: {file_path}")
|
814
|
+
else:
|
815
|
+
with open(file_path, 'rb') as f:
|
816
|
+
httpx.put(url=url, files={"file": f}, headers=headers)
|
817
|
+
else:
|
818
|
+
raise FileNotFoundError(f"未提供任何文件路径或文件内容")
|
636
819
|
|
637
820
|
response = self.__client.api(
|
638
821
|
method="POST",
|
639
|
-
path=f"/v2.0/storage/spaces/files/{
|
822
|
+
path=f"/v2.0/storage/spaces/files/{parentDentryUuid}/commit?unionId={union_id}",
|
640
823
|
json={
|
641
824
|
"uploadKey": upload_key,
|
642
825
|
"name": file_path.split("/")[-1],
|
643
|
-
"convertToOnlineDoc": convert_to_online_doc
|
826
|
+
"convertToOnlineDoc": convert_to_online_doc,
|
827
|
+
"option": {"conflictStrategy": conflictStrategy}
|
644
828
|
}
|
645
829
|
)
|
646
830
|
return response.json()
|
dagster_dingtalk/version.py
CHANGED
@@ -1 +1 @@
|
|
1
|
-
__version__ = "0.26.
|
1
|
+
__version__ = "0.26.20"
|
@@ -0,0 +1,9 @@
|
|
1
|
+
dagster_dingtalk/__init__.py,sha256=wg8o3Ys3BeHV-sMWr9A_xtUhOOgu3JUKsbkgwMgLttU,419
|
2
|
+
dagster_dingtalk/app_client.py,sha256=-wGUXkET1Ne9jPZU-I025KvlYp1UIif3F15CbiC09ew,45293
|
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.42.dist-info/METADATA,sha256=OVSnNWd38BhPjPYv-vlOdrM5681DdP6O1epkV9PlFeY,7757
|
8
|
+
dagster_dingtalk-0.1.42.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
9
|
+
dagster_dingtalk-0.1.42.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,,
|
File without changes
|