pytbox 0.0.1__py3-none-any.whl → 0.3.1__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.
Potentially problematic release.
This version of pytbox might be problematic. Click here for more details.
- pytbox/alert/alert_handler.py +139 -0
- pytbox/alert/ping.py +24 -0
- pytbox/alicloud/sls.py +9 -14
- pytbox/base.py +121 -0
- pytbox/categraf/build_config.py +143 -0
- pytbox/categraf/instances.toml +39 -0
- pytbox/categraf/jinja2/__init__.py +6 -0
- pytbox/categraf/jinja2/input.cpu/cpu.toml.j2 +5 -0
- pytbox/categraf/jinja2/input.disk/disk.toml.j2 +11 -0
- pytbox/categraf/jinja2/input.diskio/diskio.toml.j2 +6 -0
- pytbox/categraf/jinja2/input.dns_query/dns_query.toml.j2 +12 -0
- pytbox/categraf/jinja2/input.http_response/http_response.toml.j2 +9 -0
- pytbox/categraf/jinja2/input.mem/mem.toml.j2 +5 -0
- pytbox/categraf/jinja2/input.net/net.toml.j2 +11 -0
- pytbox/categraf/jinja2/input.net_response/net_response.toml.j2 +9 -0
- pytbox/categraf/jinja2/input.ping/ping.toml.j2 +11 -0
- pytbox/categraf/jinja2/input.prometheus/prometheus.toml.j2 +12 -0
- pytbox/categraf/jinja2/input.snmp/cisco_interface.toml.j2 +96 -0
- pytbox/categraf/jinja2/input.snmp/cisco_system.toml.j2 +41 -0
- pytbox/categraf/jinja2/input.snmp/h3c_interface.toml.j2 +96 -0
- pytbox/categraf/jinja2/input.snmp/h3c_system.toml.j2 +41 -0
- pytbox/categraf/jinja2/input.snmp/huawei_interface.toml.j2 +96 -0
- pytbox/categraf/jinja2/input.snmp/huawei_system.toml.j2 +41 -0
- pytbox/categraf/jinja2/input.snmp/ruijie_interface.toml.j2 +96 -0
- pytbox/categraf/jinja2/input.snmp/ruijie_system.toml.j2 +41 -0
- pytbox/categraf/jinja2/input.vsphere/vsphere.toml.j2 +211 -0
- pytbox/cli/__init__.py +7 -0
- pytbox/cli/categraf/__init__.py +7 -0
- pytbox/cli/categraf/commands.py +55 -0
- pytbox/cli/commands/vm.py +22 -0
- pytbox/cli/common/__init__.py +6 -0
- pytbox/cli/common/options.py +42 -0
- pytbox/cli/common/utils.py +269 -0
- pytbox/cli/formatters/__init__.py +7 -0
- pytbox/cli/formatters/output.py +155 -0
- pytbox/cli/main.py +24 -0
- pytbox/cli.py +9 -0
- pytbox/database/mongo.py +99 -0
- pytbox/database/victoriametrics.py +404 -0
- pytbox/dida365.py +11 -17
- pytbox/excel.py +64 -0
- pytbox/feishu/endpoints.py +12 -9
- pytbox/{logger.py → log/logger.py} +78 -30
- pytbox/{victorialog.py → log/victorialog.py} +2 -2
- pytbox/mail/alimail.py +142 -0
- pytbox/mail/client.py +171 -0
- pytbox/mail/mail_detail.py +30 -0
- pytbox/mingdao.py +164 -0
- pytbox/network/meraki.py +537 -0
- pytbox/notion.py +731 -0
- pytbox/pyjira.py +612 -0
- pytbox/utils/cronjob.py +79 -0
- pytbox/utils/env.py +2 -2
- pytbox/utils/load_config.py +132 -0
- pytbox/utils/load_vm_devfile.py +45 -0
- pytbox/utils/response.py +1 -1
- pytbox/utils/richutils.py +31 -0
- pytbox/utils/timeutils.py +479 -14
- pytbox/vmware.py +120 -0
- pytbox/win/ad.py +30 -0
- {pytbox-0.0.1.dist-info → pytbox-0.3.1.dist-info}/METADATA +13 -3
- pytbox-0.3.1.dist-info/RECORD +72 -0
- pytbox-0.3.1.dist-info/entry_points.txt +2 -0
- pytbox/common/base.py +0 -0
- pytbox/victoriametrics.py +0 -37
- pytbox-0.0.1.dist-info/RECORD +0 -21
- {pytbox-0.0.1.dist-info → pytbox-0.3.1.dist-info}/WHEEL +0 -0
- {pytbox-0.0.1.dist-info → pytbox-0.3.1.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
from dataclasses import dataclass
|
|
5
|
+
|
|
6
|
+
@dataclass
|
|
7
|
+
class MailDetail:
|
|
8
|
+
"""
|
|
9
|
+
邮件详情数据类。
|
|
10
|
+
|
|
11
|
+
Attributes:
|
|
12
|
+
uid: 邮件唯一标识符
|
|
13
|
+
send_from: 发件人邮箱地址
|
|
14
|
+
send_to: 收件人邮箱地址列表
|
|
15
|
+
cc: 抄送人邮箱地址列表
|
|
16
|
+
subject: 邮件主题
|
|
17
|
+
body_plain: 纯文本正文
|
|
18
|
+
body_html: HTML格式正文
|
|
19
|
+
attachment: 附件完整保存路径列表
|
|
20
|
+
"""
|
|
21
|
+
uid: str=None
|
|
22
|
+
sent_from: str=None
|
|
23
|
+
sent_to: list=None
|
|
24
|
+
date: str=None
|
|
25
|
+
cc: list=None
|
|
26
|
+
subject: str=None
|
|
27
|
+
body_plain: str=None
|
|
28
|
+
body_html: str=None
|
|
29
|
+
attachment: list=None
|
|
30
|
+
has_attachments: bool=False
|
pytbox/mingdao.py
ADDED
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
|
|
3
|
+
from typing import Literal, Type
|
|
4
|
+
|
|
5
|
+
import requests
|
|
6
|
+
|
|
7
|
+
from .utils.response import ReturnResponse
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class Mingdao:
|
|
11
|
+
'''
|
|
12
|
+
_summary_
|
|
13
|
+
'''
|
|
14
|
+
def __init__(self, app_key: str=None, sign: str=None, timeout: int=5):
|
|
15
|
+
self.base_url = "https://api.mingdao.com"
|
|
16
|
+
self.headers = {
|
|
17
|
+
'Content-Type': 'application/json;charset=UTF-8',
|
|
18
|
+
'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36'
|
|
19
|
+
}
|
|
20
|
+
self.timeout = timeout
|
|
21
|
+
self.app_key = app_key
|
|
22
|
+
self.sign = sign
|
|
23
|
+
|
|
24
|
+
def _build_api_request(self, api_url: str, method: Literal['GET', 'POST'], params: dict=None, body: dict=None, api_version: Literal['v1', 'v2']='v2'):
|
|
25
|
+
body['appKey'] = self.app_key
|
|
26
|
+
body['sign'] = self.sign
|
|
27
|
+
if not api_url.startswith('/'):
|
|
28
|
+
url = f'{self.base_url}/{api_version}/{api_url}'
|
|
29
|
+
else:
|
|
30
|
+
url = f'{self.base_url}/{api_version}{api_url}'
|
|
31
|
+
params = {
|
|
32
|
+
"appKey": self.app_key,
|
|
33
|
+
"sign": self.sign,
|
|
34
|
+
}
|
|
35
|
+
return requests.request(method, url, params=params, headers=self.headers, json=body, timeout=self.timeout)
|
|
36
|
+
|
|
37
|
+
def get_app_info(self) -> ReturnResponse:
|
|
38
|
+
'''
|
|
39
|
+
_summary_
|
|
40
|
+
|
|
41
|
+
Returns:
|
|
42
|
+
ReturnResponse: _description_
|
|
43
|
+
'''
|
|
44
|
+
r = self._build_api_request(api_url='/open/app/get', method='GET', body={}, api_version='v1')
|
|
45
|
+
return ReturnResponse(code=0, msg='获取应用信息成功', data=r.json())
|
|
46
|
+
|
|
47
|
+
def get_work_sheet_info(self, worksheet_id: str=None, table_name: str=None, worksheet_name: str=None):
|
|
48
|
+
if worksheet_name:
|
|
49
|
+
worksheet_id = self.get_work_sheet_id_by_name(table_name=table_name, worksheet_name=worksheet_name)
|
|
50
|
+
|
|
51
|
+
r = self._build_api_request(
|
|
52
|
+
api_url='open/worksheet/getWorksheetInfo',
|
|
53
|
+
method='POST',
|
|
54
|
+
body={
|
|
55
|
+
"worksheetId": worksheet_id,
|
|
56
|
+
}
|
|
57
|
+
)
|
|
58
|
+
return r.json()
|
|
59
|
+
|
|
60
|
+
def get_project_info(self, worksheet_id: str, keywords: str):
|
|
61
|
+
r = self._build_api_request(
|
|
62
|
+
api_url='open/worksheet/getFilterRows',
|
|
63
|
+
method='POST',
|
|
64
|
+
body={
|
|
65
|
+
"pageIndex": 1,
|
|
66
|
+
"pageSize": 100,
|
|
67
|
+
"worksheetId": worksheet_id,
|
|
68
|
+
"keyWords": keywords,
|
|
69
|
+
}
|
|
70
|
+
)
|
|
71
|
+
return r.json()
|
|
72
|
+
|
|
73
|
+
def get_work_sheet_id_by_name(self, table_name: str, worksheet_name: str, child_section: bool=False):
|
|
74
|
+
r = self.get_app_info()
|
|
75
|
+
for i in r.data['data']['sections']:
|
|
76
|
+
if table_name == i['name']:
|
|
77
|
+
if child_section:
|
|
78
|
+
for child in i['childSections'][0]['items']:
|
|
79
|
+
if child['name'] == worksheet_name:
|
|
80
|
+
return child['id']
|
|
81
|
+
else:
|
|
82
|
+
for item in i['items']:
|
|
83
|
+
if item['name'] == worksheet_name:
|
|
84
|
+
return item['id']
|
|
85
|
+
|
|
86
|
+
def get_control_id(self, table_name: str=None, worksheet_name: str=None, control_name: str=None):
|
|
87
|
+
r = self.get_work_sheet_info(table_name=table_name, worksheet_name=worksheet_name)
|
|
88
|
+
for control in r['data']['controls']:
|
|
89
|
+
if control['controlName'] == control_name:
|
|
90
|
+
return control['controlId']
|
|
91
|
+
return None
|
|
92
|
+
|
|
93
|
+
def get_value(self, table_name: str=None, worksheet_name: str=None, control_name: str=None, value_name: str=None):
|
|
94
|
+
control_id = self.get_control_id(table_name=table_name, worksheet_name=worksheet_name, control_name=control_name)
|
|
95
|
+
|
|
96
|
+
r = self._build_api_request(
|
|
97
|
+
api_url='open/worksheet/getFilterRows',
|
|
98
|
+
method='POST',
|
|
99
|
+
body={
|
|
100
|
+
"pageIndex": 1,
|
|
101
|
+
"pageSize": 100,
|
|
102
|
+
"worksheetId": self.get_work_sheet_id_by_name(table_name=table_name, worksheet_name=worksheet_name),
|
|
103
|
+
# "filters": filters
|
|
104
|
+
}
|
|
105
|
+
)
|
|
106
|
+
for row in r.json()['data']['rows']:
|
|
107
|
+
if row[control_id] == value_name:
|
|
108
|
+
return row['rowid']
|
|
109
|
+
|
|
110
|
+
def get_work_record(self,
|
|
111
|
+
worksheet_id: str=None,
|
|
112
|
+
project_control_id: str=None,
|
|
113
|
+
project_value: str=None,
|
|
114
|
+
complete_date_control_id: str=None,
|
|
115
|
+
complete_date: Literal['Today', '上个月', 'Last7Day', 'Last30Day']=None,
|
|
116
|
+
parse_control_id: bool=False,
|
|
117
|
+
page_size: int=100,
|
|
118
|
+
):
|
|
119
|
+
|
|
120
|
+
filters = []
|
|
121
|
+
if project_value:
|
|
122
|
+
filters.append({
|
|
123
|
+
"controlId": project_control_id,
|
|
124
|
+
"dataType": 29,
|
|
125
|
+
"spliceType": 1,
|
|
126
|
+
"filterType": 24,
|
|
127
|
+
"dateRange": 0,
|
|
128
|
+
"dateRangeType": 0,
|
|
129
|
+
"value": "",
|
|
130
|
+
"values": [
|
|
131
|
+
project_value
|
|
132
|
+
],
|
|
133
|
+
"minValue": "",
|
|
134
|
+
"maxValue": ""
|
|
135
|
+
})
|
|
136
|
+
|
|
137
|
+
if complete_date:
|
|
138
|
+
if complete_date == '上个月':
|
|
139
|
+
data_range = 8
|
|
140
|
+
elif complete_date == 'Today':
|
|
141
|
+
data_range = 1
|
|
142
|
+
elif complete_date == 'Last7Day':
|
|
143
|
+
data_range = 21
|
|
144
|
+
else:
|
|
145
|
+
data_range = 1
|
|
146
|
+
|
|
147
|
+
filters.append({
|
|
148
|
+
"controlId": complete_date_control_id,
|
|
149
|
+
"dataType": 15,
|
|
150
|
+
"spliceType": 1,
|
|
151
|
+
"filterType": 17,
|
|
152
|
+
"dateRange": data_range,
|
|
153
|
+
})
|
|
154
|
+
r = self._build_api_request(
|
|
155
|
+
api_url='open/worksheet/getFilterRows',
|
|
156
|
+
method='POST',
|
|
157
|
+
body={
|
|
158
|
+
"pageIndex": 1,
|
|
159
|
+
"pageSize": page_size,
|
|
160
|
+
"worksheetId": worksheet_id,
|
|
161
|
+
"filters": filters
|
|
162
|
+
}
|
|
163
|
+
)
|
|
164
|
+
return r.json()
|