dts-dance 0.1.7__py3-none-any.whl → 0.1.9__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.
@@ -1,12 +1,13 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dts-dance
3
- Version: 0.1.7
3
+ Version: 0.1.9
4
4
  Summary: dts dance lib
5
5
  Keywords: observation,tools
6
6
  Requires-Python: >=3.12
7
- Requires-Dist: loguru==0.7.3
8
- Requires-Dist: pyyaml==6.0.3
9
- Requires-Dist: requests==2.32.5
7
+ Requires-Dist: boto3<2.0.0,>=1.42.27
8
+ Requires-Dist: loguru<0.8.0,>=0.7.3
9
+ Requires-Dist: pyyaml<7.0.0,>=6.0.3
10
+ Requires-Dist: requests<3.0.0,>=2.32.5
10
11
  Description-Content-Type: text/markdown
11
12
 
12
13
  # dts-dance
@@ -1,13 +1,13 @@
1
1
  dtsdance/__init__.py,sha256=Yl_jEZ5weYfcrklnDvwB4wSgCOvMBLRRgWx0gHs3qfM,49
2
2
  dtsdance/bytecloud.py,sha256=joixJEQxX9k3VqFDNrccTVSI2WVdxdZ1JyuWFVF9zjo,4998
3
- dtsdance/dflow.py,sha256=pLhx9G3YTiCrz8VcycyTMedREShWN4RsxDmaRTwRhdA,3649
3
+ dtsdance/dflow.py,sha256=gow-zCX5lbQqqW2MRWvWynej7pZ_TQ5NmOb__j2aQT4,5497
4
4
  dtsdance/dsyncer.py,sha256=1OateZLGekYP_EF9_oAHqsj4sdQm6ahIoRllEgT9Y3I,11142
5
5
  dtsdance/feishu_base.py,sha256=2j4ZM4PFqJ-9EhC6DQ1OmAg--3VBGZyyRuxyjL0j6OU,3733
6
6
  dtsdance/feishu_table.py,sha256=ZUeoKrM4nmm5hFhc3vWOVYeLP390orm-284Od92G4iQ,8424
7
7
  dtsdance/metrics_fe.py,sha256=uPdbjGaaYBOv-rK7lKUx6aVT5Sj6ZkW9m06NyqMrPf0,18990
8
- dtsdance/s3.py,sha256=EMY5uDnqRUuHnZQBkquLdQjLR5I51LuCpCPNsDz0Z0w,1340
8
+ dtsdance/s3.py,sha256=Bh-cwLksfO5PewNtIzE_Md3rRLDLI1DUVoOD7Pou5T8,1294
9
9
  dtsdance/spacex.py,sha256=wgbuwDTLXopJnLn2puX-9MfeVXvi_nQ3C9uN8McoJf4,2113
10
10
  dtsdance/tcc.py,sha256=M_0cOVYyvUgjnC1uKWdz3YgRplafQUqX39gX_YEg8eE,6563
11
- dts_dance-0.1.7.dist-info/METADATA,sha256=u1kzvSXzkE4j1olIgqAz3uXYSy8ZU2xIAcMt2sOUliQ,735
12
- dts_dance-0.1.7.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
13
- dts_dance-0.1.7.dist-info/RECORD,,
11
+ dts_dance-0.1.9.dist-info/METADATA,sha256=IbvejpKLh-EM12cf9XtlwCVkUbD5jjvRc_Pz7PA_5b8,793
12
+ dts_dance-0.1.9.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
13
+ dts_dance-0.1.9.dist-info/RECORD,,
dtsdance/dflow.py CHANGED
@@ -3,6 +3,7 @@ from loguru import logger
3
3
  from .bytecloud import ByteCloudHelper
4
4
  import requests
5
5
 
6
+
6
7
  class DFlowHelper:
7
8
 
8
9
  def __init__(self, bytecloud_helper: ByteCloudHelper) -> None:
@@ -112,3 +113,61 @@ class DFlowHelper:
112
113
  # 根据环境生成对应的 scope 参数
113
114
  env_info = self.bytecloud_helper.get_env_info(env)
114
115
  return f"{env_info.endpoint}/bytedts/datasync/detail/{task_id}?scope={env}"
116
+
117
+ def init_resources(self, env: str, ctrl_env: str) -> bool:
118
+ """
119
+ 初始化 CTRL 环境资源
120
+
121
+ Args:
122
+ env: 环境名称
123
+ ctrl_env: 控制环境
124
+
125
+ Returns:
126
+ bool: CTRL 环境资源初始化结果
127
+ """
128
+ # 构建 API URL
129
+ env_info = self.bytecloud_helper.get_env_info(env)
130
+ url = f"{env_info.endpoint}/api/v1/bytedts/api/bytedts/v3/InitSystemResource"
131
+
132
+ # 准备请求头
133
+ headers = self._build_headers(env)
134
+
135
+ # 构建请求数据
136
+ json_data = {"ctrl_env": ctrl_env}
137
+
138
+ response_data = self._make_request("POST", url, headers, json_data)
139
+
140
+ message = response_data.get("message")
141
+ logger.info(f"int_resources {env} {ctrl_env}, message: {message}")
142
+
143
+ return message == "ok"
144
+
145
+ def list_resources(self, env: str, ctrl_env: str) -> list[str]:
146
+ """
147
+ 列举 CTRL 环境资源列表
148
+
149
+ Args:
150
+ env: 环境名称
151
+ ctrl_env: 控制环境
152
+
153
+ Returns:
154
+ list[str]: CTRL 环境资源列表
155
+ """
156
+ # 构建 API URL
157
+ env_info = self.bytecloud_helper.get_env_info(env)
158
+ url = f"{env_info.endpoint}/api/v1/bytedts/api/bytedts/v3/DescribeResources"
159
+
160
+ # 准备请求头
161
+ headers = self._build_headers(env)
162
+
163
+ # 构建请求数据
164
+ json_data = {"offset": 0, "limit": 10, "ctrl_env": ctrl_env}
165
+
166
+ response_data = self._make_request("POST", url, headers, json_data)
167
+
168
+ try:
169
+ data = cast(dict, response_data.get("data", {}))
170
+ items = cast(list, data.get("items", []))
171
+ return [item["name"] for item in items]
172
+ except (KeyError, AttributeError, Exception) as e:
173
+ raise Exception(f"无法从响应中提取 CTRL 环境资源列表数据: {str(e)}")
dtsdance/s3.py CHANGED
@@ -1,7 +1,6 @@
1
1
  import os
2
2
  from typing import Optional
3
3
  import boto3
4
- from botocore.exceptions import ClientError
5
4
  from loguru import logger
6
5
 
7
6
 
@@ -35,6 +34,6 @@ class S3Client:
35
34
  file_url = f"{self.base_url}/{s3_file_name}"
36
35
  logger.info(f"文件已成功上传到 S3: {file_url}")
37
36
  return file_url
38
- except ClientError as e:
37
+ except Exception as e:
39
38
  logger.error(f"上传文件到 S3 时出错: {e}")
40
39
  return None