dagster-dingtalk 0.1.16b1__py3-none-any.whl → 0.1.17__py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,9 +1,9 @@
1
1
  # noinspection PyProtectedMember
2
- from dagster._core.libraries import DagsterLibraryRegistry
3
- from dagster_dingtalk.version import __version__
2
+ # from dagster._core.libraries import DagsterLibraryRegistry
3
+ # from dagster_dingtalk.version import __version__
4
4
 
5
5
  from dagster_dingtalk.resources import DingTalkAppResource, DingTalkWebhookResource
6
6
  from dagster_dingtalk.app_client import DingTalkClient as DingTalkAppClient
7
- import dagster_dingtalk.operations as DingTalkOp
7
+ import dagster_dingtalk.operations as dingtalk_op
8
8
 
9
- DagsterLibraryRegistry.register("dagster-dingtalk", __version__)
9
+ # DagsterLibraryRegistry.register("dagster-dingtalk", __version__)
@@ -4,7 +4,7 @@ import time
4
4
  from datetime import datetime
5
5
  from enum import Enum
6
6
  from pathlib import Path
7
- from typing import List, Literal, Dict, Tuple
7
+ from typing import List, Literal
8
8
 
9
9
  import httpx
10
10
  from httpx import Client
@@ -30,6 +30,7 @@ class DingTalkClient:
30
30
  self.文档文件 = 文档文件_API(self)
31
31
  self.互动卡片 = 互动卡片_API(self)
32
32
  self.OA审批 = OA审批_API(self)
33
+ self.即时通信 = 即时通信_API(self)
33
34
 
34
35
  def __get_access_token(self) -> str:
35
36
  access_token_cache = Path("/tmp/.dingtalk_cache")
@@ -576,3 +577,39 @@ class OA审批_审批钉盘_API:
576
577
  "agentId" : self.__client.agent_id
577
578
  })
578
579
  return response.json()
580
+
581
+ # noinspection NonAsciiCharacters
582
+ class 即时通信_API:
583
+ def __init__(self, _client:DingTalkClient):
584
+ self.__client:DingTalkClient = _client
585
+
586
+ # noinspection NonAsciiCharacters
587
+ class 即时通信_工作通知_API:
588
+ def __init__(self, _client:DingTalkClient):
589
+ self.__client:DingTalkClient = _client
590
+
591
+ def 发送工作通知(self, msg:dict, to_all_user:bool=True, user_list:List[str]|None=None, dept_id_list:List[str]|None=None) -> dict:
592
+ """
593
+ 工作通知消息是以某个应用的名义推送到员工的工作通知消息,例如生日祝福、入职提醒等。可以发送文本、语音、链接等。
594
+
595
+ 注意:
596
+ 1. 企业内部应用发送消息单次最多只能给5000人发送。
597
+ 2. 企业内部应用每天给每个员工最多可发送500条消息通知。
598
+ 3. 该接口是异步发送消息,接口返回成功并不表示用户一定会收到消息,需要通过获取工作通知消息的发送结果接口查询是否给用户发送成功。
599
+
600
+ :param msg: 消息数据格式参考 https://open.dingtalk.com/document/orgapp/message-types-and-data-format?spm=ding_open_doc.document.0.0.74742580198aRf
601
+ :param to_all_user: 是否发送给企业全部用户。如果为否,则必须传入 user_list 或 dept_id_list
602
+ :param user_list: 接收者的 userid 列表,最大用户列表长度 100。
603
+ :param dept_id_list: 接收者的部门 id 列表,最大列表长度 20 。接收者是部门 ID 时,包括子部门下的所有用户。
604
+ :return:
605
+ """
606
+ response = self.__client.oapi.post(
607
+ url="/topapi/message/corpconversation/asyncsend_v2",
608
+ json={
609
+ "agent_id" : self.__client.agent_id,
610
+ "to_all_user": to_all_user,
611
+ "userid_list" : ','.join(user_list) if user_list else None,
612
+ "dept_id_list" : ','.join(dept_id_list) if dept_id_list else None,
613
+ "msg": msg
614
+ })
615
+ return response.json()
@@ -9,7 +9,7 @@ from .resources import DingTalkWebhookResource
9
9
  "text": In(str),
10
10
  "at": In(default_value=None, description="@列表,传List[str]解析为userId,传List[int]解析为phone,传ALL解析为全部。")
11
11
  })
12
- def op_send_simple_text(context: OpExecutionContext, text, at):
12
+ def op_send_text(context: OpExecutionContext, text, at):
13
13
  webhook:DingTalkWebhookResource = context.resources.dingtalk_webhook
14
14
  if isinstance(at, str) and at == 'ALL':
15
15
  webhook.send_text(text=text, at_all=True)
@@ -25,9 +25,9 @@ def op_send_simple_text(context: OpExecutionContext, text, at):
25
25
  @op(description="钉钉Webhook发送Markdown消息",
26
26
  required_resource_keys={'dingtalk_webhook'},
27
27
  ins={
28
- "text": In(str),
29
- "title": In(str, default_value=''),
30
- "at": In(default_value=None, description="@列表,传List[str]解析为userId,传List[int]解析为phone,传ALL解析为全部。")
28
+ "text": In(str, description="Markdown 内容"),
29
+ "title": In(str, default_value='', description="标题"),
30
+ "at": In(default_value=None, description="List[str] @userIds ,传 List[int] @mobiles ,传 \"ALL\" @所有人。")
31
31
  })
32
32
  def op_send_markdown(context: OpExecutionContext, text, title, at):
33
33
  webhook:DingTalkWebhookResource = context.resources.dingtalk_webhook
@@ -1 +1 @@
1
- __version__ = "0.1.16b1"
1
+ # __version__ = "0.1.17"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: dagster-dingtalk
3
- Version: 0.1.16b1
3
+ Version: 0.1.17
4
4
  Summary: A dagster plugin for the DingTalk
5
5
  Author: YiZixuan
6
6
  Author-email: sqkkyzx@qq.com
@@ -11,7 +11,7 @@ Classifier: Programming Language :: Python :: 3.11
11
11
  Classifier: Programming Language :: Python :: 3.12
12
12
  Requires-Dist: dagster (>=1.8.10)
13
13
  Requires-Dist: httpx (>=0.27.2,<0.28.0)
14
- Requires-Dist: pydantic (>=2.9.2,<3.0.0)
14
+ Requires-Dist: pydantic (>=2.9.2)
15
15
  Description-Content-Type: text/markdown
16
16
 
17
17
  # 钉钉与 Dagster 集成
@@ -0,0 +1,8 @@
1
+ dagster_dingtalk/__init__.py,sha256=jAyn67nRx5wU0YYWDMRINn7Tt3joP5IXsztTtyMbxsE,424
2
+ dagster_dingtalk/app_client.py,sha256=Ihf1ixCN7iSzzrnQKjbML9Z-OHJODt3gu2jt17QV8hU,25930
3
+ dagster_dingtalk/operations.py,sha256=C1wwXCW7mpKhLC1-Y7TCP_72L9e93a9ceVHRWhNda-Q,3891
4
+ dagster_dingtalk/resources.py,sha256=1u8-oXRa7H_e0CAYkTJDxbjEmt3ZcD_ntBNvrS_rwr8,17430
5
+ dagster_dingtalk/version.py,sha256=ncWWGHPke5qy2-s8w3nAgDE4R__CZi-Q7CLWtmtkbvA,25
6
+ dagster_dingtalk-0.1.17.dist-info/METADATA,sha256=ytVf6824NylG8jv-sbdbeqBKl-bgWOgZ0keYKqV2zCk,8004
7
+ dagster_dingtalk-0.1.17.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
8
+ dagster_dingtalk-0.1.17.dist-info/RECORD,,
@@ -1,8 +0,0 @@
1
- dagster_dingtalk/__init__.py,sha256=bwTTfzEBjve2on30l5LjJc61VctkXDmPZ5uUHXiYtGY,417
2
- dagster_dingtalk/app_client.py,sha256=VNCZhZZ3IntleW5zcUeevtnvtfTnaaRDh3nMJow4btg,23814
3
- dagster_dingtalk/operations.py,sha256=28nDXEB1bpnRLYasuv2dLaRW_k0n5r2UEjykhkRBXYI,3859
4
- dagster_dingtalk/resources.py,sha256=1u8-oXRa7H_e0CAYkTJDxbjEmt3ZcD_ntBNvrS_rwr8,17430
5
- dagster_dingtalk/version.py,sha256=L8ZmyoPbH56EgRSd-sK2okBGO1uzIGJYlnTqGP-JLcE,25
6
- dagster_dingtalk-0.1.16b1.dist-info/METADATA,sha256=A_dTb6e80UxGiFuOpScMWdqSK8bjzFtXWuq0IdCDCJE,8013
7
- dagster_dingtalk-0.1.16b1.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
8
- dagster_dingtalk-0.1.16b1.dist-info/RECORD,,