nz-sdk 0.1.0__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.
- nz_sdk/__init__.py +98 -0
- nz_sdk/__main__.py +8 -0
- nz_sdk/_proto/__init__.py +5 -0
- nz_sdk/_proto/nezha_pb2.py +59 -0
- nz_sdk/_proto/nezha_pb2.pyi +153 -0
- nz_sdk/_proto/nezha_pb2_grpc.py +312 -0
- nz_sdk/_x509.py +204 -0
- nz_sdk/agent.py +632 -0
- nz_sdk/cli.py +276 -0
- nz_sdk/client.py +336 -0
- nz_sdk/config.py +549 -0
- nz_sdk/metrics/__init__.py +49 -0
- nz_sdk/metrics/circuit_breaker.py +37 -0
- nz_sdk/metrics/collector.py +440 -0
- nz_sdk/metrics/disk.py +114 -0
- nz_sdk/metrics/geoip.py +188 -0
- nz_sdk/metrics/gpu.py +251 -0
- nz_sdk/metrics/nic.py +105 -0
- nz_sdk/py.typed +0 -0
- nz_sdk/tasks/__init__.py +180 -0
- nz_sdk/tasks/command.py +135 -0
- nz_sdk/tasks/config_ops.py +226 -0
- nz_sdk/tasks/iostream/__init__.py +94 -0
- nz_sdk/tasks/iostream/fm.py +345 -0
- nz_sdk/tasks/iostream/framing.py +182 -0
- nz_sdk/tasks/iostream/fs_transfer.py +394 -0
- nz_sdk/tasks/iostream/nat.py +203 -0
- nz_sdk/tasks/iostream/terminal.py +303 -0
- nz_sdk/tasks/mcp.py +867 -0
- nz_sdk/tasks/probes.py +355 -0
- nz_sdk/types.py +180 -0
- nz_sdk-0.1.0.dist-info/METADATA +149 -0
- nz_sdk-0.1.0.dist-info/RECORD +36 -0
- nz_sdk-0.1.0.dist-info/WHEEL +5 -0
- nz_sdk-0.1.0.dist-info/entry_points.txt +2 -0
- nz_sdk-0.1.0.dist-info/top_level.txt +1 -0
nz_sdk/__init__.py
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
"""nz-sdk: Wire-compatible native Python SDK and drop-in CLI for Nezha Monitoring."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
__version__ = "0.1.0"
|
|
6
|
+
|
|
7
|
+
from .agent import NezhaAgent, SyncNezhaAgent
|
|
8
|
+
from .client import NezhaClient, build_auth_metadata
|
|
9
|
+
from .config import (
|
|
10
|
+
UPSTREAM_CONFIG_KEYS,
|
|
11
|
+
AgentConfig,
|
|
12
|
+
ConfigValidationError,
|
|
13
|
+
generate_uuid,
|
|
14
|
+
is_valid_transfer_secret,
|
|
15
|
+
is_valid_uuid,
|
|
16
|
+
load_config,
|
|
17
|
+
save_config,
|
|
18
|
+
)
|
|
19
|
+
from .metrics import PsutilCollector
|
|
20
|
+
from .types import (
|
|
21
|
+
GeoIPInfo,
|
|
22
|
+
GPUStat,
|
|
23
|
+
HostInfo,
|
|
24
|
+
HostState,
|
|
25
|
+
SensorTemperature,
|
|
26
|
+
SystemCollector,
|
|
27
|
+
TaskHandler,
|
|
28
|
+
TaskRequest,
|
|
29
|
+
TaskResponse,
|
|
30
|
+
TaskType,
|
|
31
|
+
TaskTypeApplyConfig,
|
|
32
|
+
TaskTypeCommand,
|
|
33
|
+
TaskTypeExec,
|
|
34
|
+
TaskTypeFM,
|
|
35
|
+
TaskTypeFsDelete,
|
|
36
|
+
TaskTypeFsList,
|
|
37
|
+
TaskTypeFsRead,
|
|
38
|
+
TaskTypeFsTransfer,
|
|
39
|
+
TaskTypeFsWrite,
|
|
40
|
+
TaskTypeHTTPGet,
|
|
41
|
+
TaskTypeICMPPing,
|
|
42
|
+
TaskTypeKeepalive,
|
|
43
|
+
TaskTypeNAT,
|
|
44
|
+
TaskTypeReportConfig,
|
|
45
|
+
TaskTypeReportHostInfoDeprecated,
|
|
46
|
+
TaskTypeServerTransferApply,
|
|
47
|
+
TaskTypeTCPPing,
|
|
48
|
+
TaskTypeTerminal,
|
|
49
|
+
TaskTypeTerminalGRPC,
|
|
50
|
+
TaskTypeUpgrade,
|
|
51
|
+
)
|
|
52
|
+
|
|
53
|
+
__all__ = [
|
|
54
|
+
"__version__",
|
|
55
|
+
"AgentConfig",
|
|
56
|
+
"ConfigValidationError",
|
|
57
|
+
"GPUStat",
|
|
58
|
+
"GeoIPInfo",
|
|
59
|
+
"HostInfo",
|
|
60
|
+
"HostState",
|
|
61
|
+
"NezhaAgent",
|
|
62
|
+
"NezhaClient",
|
|
63
|
+
"PsutilCollector",
|
|
64
|
+
"SensorTemperature",
|
|
65
|
+
"SyncNezhaAgent",
|
|
66
|
+
"SystemCollector",
|
|
67
|
+
"TaskHandler",
|
|
68
|
+
"TaskRequest",
|
|
69
|
+
"TaskResponse",
|
|
70
|
+
"TaskType",
|
|
71
|
+
"TaskTypeApplyConfig",
|
|
72
|
+
"TaskTypeCommand",
|
|
73
|
+
"TaskTypeExec",
|
|
74
|
+
"TaskTypeFM",
|
|
75
|
+
"TaskTypeFsDelete",
|
|
76
|
+
"TaskTypeFsList",
|
|
77
|
+
"TaskTypeFsRead",
|
|
78
|
+
"TaskTypeFsTransfer",
|
|
79
|
+
"TaskTypeFsWrite",
|
|
80
|
+
"TaskTypeHTTPGet",
|
|
81
|
+
"TaskTypeICMPPing",
|
|
82
|
+
"TaskTypeKeepalive",
|
|
83
|
+
"TaskTypeNAT",
|
|
84
|
+
"TaskTypeReportConfig",
|
|
85
|
+
"TaskTypeReportHostInfoDeprecated",
|
|
86
|
+
"TaskTypeServerTransferApply",
|
|
87
|
+
"TaskTypeTCPPing",
|
|
88
|
+
"TaskTypeTerminal",
|
|
89
|
+
"TaskTypeTerminalGRPC",
|
|
90
|
+
"TaskTypeUpgrade",
|
|
91
|
+
"UPSTREAM_CONFIG_KEYS",
|
|
92
|
+
"build_auth_metadata",
|
|
93
|
+
"generate_uuid",
|
|
94
|
+
"is_valid_transfer_secret",
|
|
95
|
+
"is_valid_uuid",
|
|
96
|
+
"load_config",
|
|
97
|
+
"save_config",
|
|
98
|
+
]
|
nz_sdk/__main__.py
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
|
3
|
+
# NO CHECKED-IN PROTOBUF GENCODE
|
|
4
|
+
# source: nezha.proto
|
|
5
|
+
# Protobuf Python Version: 7.35.1
|
|
6
|
+
"""Generated protocol buffer code."""
|
|
7
|
+
from google.protobuf import descriptor as _descriptor
|
|
8
|
+
from google.protobuf import descriptor_pool as _descriptor_pool
|
|
9
|
+
from google.protobuf import runtime_version as _runtime_version
|
|
10
|
+
from google.protobuf import symbol_database as _symbol_database
|
|
11
|
+
from google.protobuf.internal import builder as _builder
|
|
12
|
+
_runtime_version.ValidateProtobufRuntimeVersion(
|
|
13
|
+
_runtime_version.Domain.PUBLIC,
|
|
14
|
+
7,
|
|
15
|
+
35,
|
|
16
|
+
1,
|
|
17
|
+
'',
|
|
18
|
+
'nezha.proto'
|
|
19
|
+
)
|
|
20
|
+
# @@protoc_insertion_point(imports)
|
|
21
|
+
|
|
22
|
+
_sym_db = _symbol_database.Default()
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x0bnezha.proto\x12\x05proto\"\xd1\x01\n\x04Host\x12\x10\n\x08platform\x18\x01 \x01(\t\x12\x18\n\x10platform_version\x18\x02 \x01(\t\x12\x0b\n\x03\x63pu\x18\x03 \x03(\t\x12\x11\n\tmem_total\x18\x04 \x01(\x04\x12\x12\n\ndisk_total\x18\x05 \x01(\x04\x12\x12\n\nswap_total\x18\x06 \x01(\x04\x12\x0c\n\x04\x61rch\x18\x07 \x01(\t\x12\x16\n\x0evirtualization\x18\x08 \x01(\t\x12\x11\n\tboot_time\x18\t \x01(\x04\x12\x0f\n\x07version\x18\n \x01(\t\x12\x0b\n\x03gpu\x18\x0b \x03(\t\"\x94\x03\n\x05State\x12\x0b\n\x03\x63pu\x18\x01 \x01(\x01\x12\x10\n\x08mem_used\x18\x02 \x01(\x04\x12\x11\n\tswap_used\x18\x03 \x01(\x04\x12\x11\n\tdisk_used\x18\x04 \x01(\x04\x12\x17\n\x0fnet_in_transfer\x18\x05 \x01(\x04\x12\x18\n\x10net_out_transfer\x18\x06 \x01(\x04\x12\x14\n\x0cnet_in_speed\x18\x07 \x01(\x04\x12\x15\n\rnet_out_speed\x18\x08 \x01(\x04\x12\x0e\n\x06uptime\x18\t \x01(\x04\x12\r\n\x05load1\x18\n \x01(\x01\x12\r\n\x05load5\x18\x0b \x01(\x01\x12\x0e\n\x06load15\x18\x0c \x01(\x01\x12\x16\n\x0etcp_conn_count\x18\r \x01(\x04\x12\x16\n\x0eudp_conn_count\x18\x0e \x01(\x04\x12\x15\n\rprocess_count\x18\x0f \x01(\x04\x12\x34\n\x0ctemperatures\x18\x10 \x03(\x0b\x32\x1e.proto.State_SensorTemperature\x12\x0b\n\x03gpu\x18\x11 \x03(\x01\x12\x1e\n\x04gpus\x18\x12 \x03(\x0b\x32\x10.proto.State_GPU\"K\n\tState_GPU\x12\x13\n\x0butilization\x18\x01 \x01(\x01\x12\x13\n\x0bmemory_used\x18\x02 \x01(\x04\x12\x14\n\x0cmemory_total\x18\x03 \x01(\x04\"<\n\x17State_SensorTemperature\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x13\n\x0btemperature\x18\x02 \x01(\x01\".\n\x04Task\x12\n\n\x02id\x18\x01 \x01(\x04\x12\x0c\n\x04type\x18\x02 \x01(\x04\x12\x0c\n\x04\x64\x61ta\x18\x03 \x01(\t\"W\n\nTaskResult\x12\n\n\x02id\x18\x01 \x01(\x04\x12\x0c\n\x04type\x18\x02 \x01(\x04\x12\r\n\x05\x64\x65lay\x18\x03 \x01(\x02\x12\x0c\n\x04\x64\x61ta\x18\x04 \x01(\t\x12\x12\n\nsuccessful\x18\x05 \x01(\x08\"\x19\n\x07Receipt\x12\x0e\n\x06proced\x18\x01 \x01(\x08\"\x1d\n\rUint64Receipt\x12\x0c\n\x04\x64\x61ta\x18\x01 \x01(\x04\"\x1c\n\x0cIOStreamData\x12\x0c\n\x04\x64\x61ta\x18\x01 \x01(\x0c\"_\n\x05GeoIP\x12\x0c\n\x04use6\x18\x01 \x01(\x08\x12\x15\n\x02ip\x18\x02 \x01(\x0b\x32\t.proto.IP\x12\x14\n\x0c\x63ountry_code\x18\x03 \x01(\t\x12\x1b\n\x13\x64\x61shboard_boot_time\x18\x04 \x01(\x04\" \n\x02IP\x12\x0c\n\x04ipv4\x18\x01 \x01(\t\x12\x0c\n\x04ipv6\x18\x02 \x01(\t2\xd2\x02\n\x0cNezhaService\x12\x37\n\x11ReportSystemState\x12\x0c.proto.State\x1a\x0e.proto.Receipt\"\x00(\x01\x30\x01\x12\x31\n\x10ReportSystemInfo\x12\x0b.proto.Host\x1a\x0e.proto.Receipt\"\x00\x12\x33\n\x0bRequestTask\x12\x11.proto.TaskResult\x1a\x0b.proto.Task\"\x00(\x01\x30\x01\x12:\n\x08IOStream\x12\x13.proto.IOStreamData\x1a\x13.proto.IOStreamData\"\x00(\x01\x30\x01\x12+\n\x0bReportGeoIP\x12\x0c.proto.GeoIP\x1a\x0c.proto.GeoIP\"\x00\x12\x38\n\x11ReportSystemInfo2\x12\x0b.proto.Host\x1a\x14.proto.Uint64Receipt\"\x00\x42\tZ\x07./protob\x06proto3')
|
|
28
|
+
|
|
29
|
+
_globals = globals()
|
|
30
|
+
_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals)
|
|
31
|
+
_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'nezha_pb2', _globals)
|
|
32
|
+
if not _descriptor._USE_C_DESCRIPTORS:
|
|
33
|
+
_globals['DESCRIPTOR']._loaded_options = None
|
|
34
|
+
_globals['DESCRIPTOR']._serialized_options = b'Z\007./proto'
|
|
35
|
+
_globals['_HOST']._serialized_start=23
|
|
36
|
+
_globals['_HOST']._serialized_end=232
|
|
37
|
+
_globals['_STATE']._serialized_start=235
|
|
38
|
+
_globals['_STATE']._serialized_end=639
|
|
39
|
+
_globals['_STATE_GPU']._serialized_start=641
|
|
40
|
+
_globals['_STATE_GPU']._serialized_end=716
|
|
41
|
+
_globals['_STATE_SENSORTEMPERATURE']._serialized_start=718
|
|
42
|
+
_globals['_STATE_SENSORTEMPERATURE']._serialized_end=778
|
|
43
|
+
_globals['_TASK']._serialized_start=780
|
|
44
|
+
_globals['_TASK']._serialized_end=826
|
|
45
|
+
_globals['_TASKRESULT']._serialized_start=828
|
|
46
|
+
_globals['_TASKRESULT']._serialized_end=915
|
|
47
|
+
_globals['_RECEIPT']._serialized_start=917
|
|
48
|
+
_globals['_RECEIPT']._serialized_end=942
|
|
49
|
+
_globals['_UINT64RECEIPT']._serialized_start=944
|
|
50
|
+
_globals['_UINT64RECEIPT']._serialized_end=973
|
|
51
|
+
_globals['_IOSTREAMDATA']._serialized_start=975
|
|
52
|
+
_globals['_IOSTREAMDATA']._serialized_end=1003
|
|
53
|
+
_globals['_GEOIP']._serialized_start=1005
|
|
54
|
+
_globals['_GEOIP']._serialized_end=1100
|
|
55
|
+
_globals['_IP']._serialized_start=1102
|
|
56
|
+
_globals['_IP']._serialized_end=1134
|
|
57
|
+
_globals['_NEZHASERVICE']._serialized_start=1137
|
|
58
|
+
_globals['_NEZHASERVICE']._serialized_end=1475
|
|
59
|
+
# @@protoc_insertion_point(module_scope)
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
from google.protobuf.internal import containers as _containers
|
|
2
|
+
from google.protobuf import descriptor as _descriptor
|
|
3
|
+
from google.protobuf import message as _message
|
|
4
|
+
from collections.abc import Iterable as _Iterable, Mapping as _Mapping
|
|
5
|
+
from typing import ClassVar as _ClassVar, Optional as _Optional, Union as _Union
|
|
6
|
+
|
|
7
|
+
DESCRIPTOR: _descriptor.FileDescriptor
|
|
8
|
+
|
|
9
|
+
class Host(_message.Message):
|
|
10
|
+
__slots__ = ("platform", "platform_version", "cpu", "mem_total", "disk_total", "swap_total", "arch", "virtualization", "boot_time", "version", "gpu")
|
|
11
|
+
PLATFORM_FIELD_NUMBER: _ClassVar[int]
|
|
12
|
+
PLATFORM_VERSION_FIELD_NUMBER: _ClassVar[int]
|
|
13
|
+
CPU_FIELD_NUMBER: _ClassVar[int]
|
|
14
|
+
MEM_TOTAL_FIELD_NUMBER: _ClassVar[int]
|
|
15
|
+
DISK_TOTAL_FIELD_NUMBER: _ClassVar[int]
|
|
16
|
+
SWAP_TOTAL_FIELD_NUMBER: _ClassVar[int]
|
|
17
|
+
ARCH_FIELD_NUMBER: _ClassVar[int]
|
|
18
|
+
VIRTUALIZATION_FIELD_NUMBER: _ClassVar[int]
|
|
19
|
+
BOOT_TIME_FIELD_NUMBER: _ClassVar[int]
|
|
20
|
+
VERSION_FIELD_NUMBER: _ClassVar[int]
|
|
21
|
+
GPU_FIELD_NUMBER: _ClassVar[int]
|
|
22
|
+
platform: str
|
|
23
|
+
platform_version: str
|
|
24
|
+
cpu: _containers.RepeatedScalarFieldContainer[str]
|
|
25
|
+
mem_total: int
|
|
26
|
+
disk_total: int
|
|
27
|
+
swap_total: int
|
|
28
|
+
arch: str
|
|
29
|
+
virtualization: str
|
|
30
|
+
boot_time: int
|
|
31
|
+
version: str
|
|
32
|
+
gpu: _containers.RepeatedScalarFieldContainer[str]
|
|
33
|
+
def __init__(self, platform: _Optional[str] = ..., platform_version: _Optional[str] = ..., cpu: _Optional[_Iterable[str]] = ..., mem_total: _Optional[int] = ..., disk_total: _Optional[int] = ..., swap_total: _Optional[int] = ..., arch: _Optional[str] = ..., virtualization: _Optional[str] = ..., boot_time: _Optional[int] = ..., version: _Optional[str] = ..., gpu: _Optional[_Iterable[str]] = ...) -> None: ...
|
|
34
|
+
|
|
35
|
+
class State(_message.Message):
|
|
36
|
+
__slots__ = ("cpu", "mem_used", "swap_used", "disk_used", "net_in_transfer", "net_out_transfer", "net_in_speed", "net_out_speed", "uptime", "load1", "load5", "load15", "tcp_conn_count", "udp_conn_count", "process_count", "temperatures", "gpu", "gpus")
|
|
37
|
+
CPU_FIELD_NUMBER: _ClassVar[int]
|
|
38
|
+
MEM_USED_FIELD_NUMBER: _ClassVar[int]
|
|
39
|
+
SWAP_USED_FIELD_NUMBER: _ClassVar[int]
|
|
40
|
+
DISK_USED_FIELD_NUMBER: _ClassVar[int]
|
|
41
|
+
NET_IN_TRANSFER_FIELD_NUMBER: _ClassVar[int]
|
|
42
|
+
NET_OUT_TRANSFER_FIELD_NUMBER: _ClassVar[int]
|
|
43
|
+
NET_IN_SPEED_FIELD_NUMBER: _ClassVar[int]
|
|
44
|
+
NET_OUT_SPEED_FIELD_NUMBER: _ClassVar[int]
|
|
45
|
+
UPTIME_FIELD_NUMBER: _ClassVar[int]
|
|
46
|
+
LOAD1_FIELD_NUMBER: _ClassVar[int]
|
|
47
|
+
LOAD5_FIELD_NUMBER: _ClassVar[int]
|
|
48
|
+
LOAD15_FIELD_NUMBER: _ClassVar[int]
|
|
49
|
+
TCP_CONN_COUNT_FIELD_NUMBER: _ClassVar[int]
|
|
50
|
+
UDP_CONN_COUNT_FIELD_NUMBER: _ClassVar[int]
|
|
51
|
+
PROCESS_COUNT_FIELD_NUMBER: _ClassVar[int]
|
|
52
|
+
TEMPERATURES_FIELD_NUMBER: _ClassVar[int]
|
|
53
|
+
GPU_FIELD_NUMBER: _ClassVar[int]
|
|
54
|
+
GPUS_FIELD_NUMBER: _ClassVar[int]
|
|
55
|
+
cpu: float
|
|
56
|
+
mem_used: int
|
|
57
|
+
swap_used: int
|
|
58
|
+
disk_used: int
|
|
59
|
+
net_in_transfer: int
|
|
60
|
+
net_out_transfer: int
|
|
61
|
+
net_in_speed: int
|
|
62
|
+
net_out_speed: int
|
|
63
|
+
uptime: int
|
|
64
|
+
load1: float
|
|
65
|
+
load5: float
|
|
66
|
+
load15: float
|
|
67
|
+
tcp_conn_count: int
|
|
68
|
+
udp_conn_count: int
|
|
69
|
+
process_count: int
|
|
70
|
+
temperatures: _containers.RepeatedCompositeFieldContainer[State_SensorTemperature]
|
|
71
|
+
gpu: _containers.RepeatedScalarFieldContainer[float]
|
|
72
|
+
gpus: _containers.RepeatedCompositeFieldContainer[State_GPU]
|
|
73
|
+
def __init__(self, cpu: _Optional[float] = ..., mem_used: _Optional[int] = ..., swap_used: _Optional[int] = ..., disk_used: _Optional[int] = ..., net_in_transfer: _Optional[int] = ..., net_out_transfer: _Optional[int] = ..., net_in_speed: _Optional[int] = ..., net_out_speed: _Optional[int] = ..., uptime: _Optional[int] = ..., load1: _Optional[float] = ..., load5: _Optional[float] = ..., load15: _Optional[float] = ..., tcp_conn_count: _Optional[int] = ..., udp_conn_count: _Optional[int] = ..., process_count: _Optional[int] = ..., temperatures: _Optional[_Iterable[_Union[State_SensorTemperature, _Mapping]]] = ..., gpu: _Optional[_Iterable[float]] = ..., gpus: _Optional[_Iterable[_Union[State_GPU, _Mapping]]] = ...) -> None: ...
|
|
74
|
+
|
|
75
|
+
class State_GPU(_message.Message):
|
|
76
|
+
__slots__ = ("utilization", "memory_used", "memory_total")
|
|
77
|
+
UTILIZATION_FIELD_NUMBER: _ClassVar[int]
|
|
78
|
+
MEMORY_USED_FIELD_NUMBER: _ClassVar[int]
|
|
79
|
+
MEMORY_TOTAL_FIELD_NUMBER: _ClassVar[int]
|
|
80
|
+
utilization: float
|
|
81
|
+
memory_used: int
|
|
82
|
+
memory_total: int
|
|
83
|
+
def __init__(self, utilization: _Optional[float] = ..., memory_used: _Optional[int] = ..., memory_total: _Optional[int] = ...) -> None: ...
|
|
84
|
+
|
|
85
|
+
class State_SensorTemperature(_message.Message):
|
|
86
|
+
__slots__ = ("name", "temperature")
|
|
87
|
+
NAME_FIELD_NUMBER: _ClassVar[int]
|
|
88
|
+
TEMPERATURE_FIELD_NUMBER: _ClassVar[int]
|
|
89
|
+
name: str
|
|
90
|
+
temperature: float
|
|
91
|
+
def __init__(self, name: _Optional[str] = ..., temperature: _Optional[float] = ...) -> None: ...
|
|
92
|
+
|
|
93
|
+
class Task(_message.Message):
|
|
94
|
+
__slots__ = ("id", "type", "data")
|
|
95
|
+
ID_FIELD_NUMBER: _ClassVar[int]
|
|
96
|
+
TYPE_FIELD_NUMBER: _ClassVar[int]
|
|
97
|
+
DATA_FIELD_NUMBER: _ClassVar[int]
|
|
98
|
+
id: int
|
|
99
|
+
type: int
|
|
100
|
+
data: str
|
|
101
|
+
def __init__(self, id: _Optional[int] = ..., type: _Optional[int] = ..., data: _Optional[str] = ...) -> None: ...
|
|
102
|
+
|
|
103
|
+
class TaskResult(_message.Message):
|
|
104
|
+
__slots__ = ("id", "type", "delay", "data", "successful")
|
|
105
|
+
ID_FIELD_NUMBER: _ClassVar[int]
|
|
106
|
+
TYPE_FIELD_NUMBER: _ClassVar[int]
|
|
107
|
+
DELAY_FIELD_NUMBER: _ClassVar[int]
|
|
108
|
+
DATA_FIELD_NUMBER: _ClassVar[int]
|
|
109
|
+
SUCCESSFUL_FIELD_NUMBER: _ClassVar[int]
|
|
110
|
+
id: int
|
|
111
|
+
type: int
|
|
112
|
+
delay: float
|
|
113
|
+
data: str
|
|
114
|
+
successful: bool
|
|
115
|
+
def __init__(self, id: _Optional[int] = ..., type: _Optional[int] = ..., delay: _Optional[float] = ..., data: _Optional[str] = ..., successful: _Optional[bool] = ...) -> None: ...
|
|
116
|
+
|
|
117
|
+
class Receipt(_message.Message):
|
|
118
|
+
__slots__ = ("proced",)
|
|
119
|
+
PROCED_FIELD_NUMBER: _ClassVar[int]
|
|
120
|
+
proced: bool
|
|
121
|
+
def __init__(self, proced: _Optional[bool] = ...) -> None: ...
|
|
122
|
+
|
|
123
|
+
class Uint64Receipt(_message.Message):
|
|
124
|
+
__slots__ = ("data",)
|
|
125
|
+
DATA_FIELD_NUMBER: _ClassVar[int]
|
|
126
|
+
data: int
|
|
127
|
+
def __init__(self, data: _Optional[int] = ...) -> None: ...
|
|
128
|
+
|
|
129
|
+
class IOStreamData(_message.Message):
|
|
130
|
+
__slots__ = ("data",)
|
|
131
|
+
DATA_FIELD_NUMBER: _ClassVar[int]
|
|
132
|
+
data: bytes
|
|
133
|
+
def __init__(self, data: _Optional[bytes] = ...) -> None: ...
|
|
134
|
+
|
|
135
|
+
class GeoIP(_message.Message):
|
|
136
|
+
__slots__ = ("use6", "ip", "country_code", "dashboard_boot_time")
|
|
137
|
+
USE6_FIELD_NUMBER: _ClassVar[int]
|
|
138
|
+
IP_FIELD_NUMBER: _ClassVar[int]
|
|
139
|
+
COUNTRY_CODE_FIELD_NUMBER: _ClassVar[int]
|
|
140
|
+
DASHBOARD_BOOT_TIME_FIELD_NUMBER: _ClassVar[int]
|
|
141
|
+
use6: bool
|
|
142
|
+
ip: IP
|
|
143
|
+
country_code: str
|
|
144
|
+
dashboard_boot_time: int
|
|
145
|
+
def __init__(self, use6: _Optional[bool] = ..., ip: _Optional[_Union[IP, _Mapping]] = ..., country_code: _Optional[str] = ..., dashboard_boot_time: _Optional[int] = ...) -> None: ...
|
|
146
|
+
|
|
147
|
+
class IP(_message.Message):
|
|
148
|
+
__slots__ = ("ipv4", "ipv6")
|
|
149
|
+
IPV4_FIELD_NUMBER: _ClassVar[int]
|
|
150
|
+
IPV6_FIELD_NUMBER: _ClassVar[int]
|
|
151
|
+
ipv4: str
|
|
152
|
+
ipv6: str
|
|
153
|
+
def __init__(self, ipv4: _Optional[str] = ..., ipv6: _Optional[str] = ...) -> None: ...
|
|
@@ -0,0 +1,312 @@
|
|
|
1
|
+
# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT!
|
|
2
|
+
"""Client and server classes corresponding to protobuf-defined services."""
|
|
3
|
+
import grpc
|
|
4
|
+
import warnings
|
|
5
|
+
|
|
6
|
+
from . import nezha_pb2 as nezha__pb2
|
|
7
|
+
|
|
8
|
+
GRPC_GENERATED_VERSION = '1.85.4'
|
|
9
|
+
GRPC_VERSION = grpc.__version__
|
|
10
|
+
_version_not_supported = False
|
|
11
|
+
|
|
12
|
+
try:
|
|
13
|
+
from grpc._utilities import first_version_is_lower
|
|
14
|
+
_version_not_supported = first_version_is_lower(GRPC_VERSION, GRPC_GENERATED_VERSION)
|
|
15
|
+
except ImportError:
|
|
16
|
+
_version_not_supported = True
|
|
17
|
+
|
|
18
|
+
if _version_not_supported:
|
|
19
|
+
raise RuntimeError(
|
|
20
|
+
f'The grpc package installed is at version {GRPC_VERSION},'
|
|
21
|
+
+ ' but the generated code in nezha_pb2_grpc.py depends on'
|
|
22
|
+
+ f' grpcio>={GRPC_GENERATED_VERSION}.'
|
|
23
|
+
+ f' Please upgrade your grpc module to grpcio>={GRPC_GENERATED_VERSION}'
|
|
24
|
+
+ f' or downgrade your generated code using grpcio-tools<={GRPC_VERSION}.'
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
class NezhaServiceStub:
|
|
29
|
+
"""Missing associated documentation comment in .proto file."""
|
|
30
|
+
|
|
31
|
+
def __init__(self, channel):
|
|
32
|
+
"""Constructor.
|
|
33
|
+
|
|
34
|
+
Args:
|
|
35
|
+
channel: A grpc.Channel.
|
|
36
|
+
"""
|
|
37
|
+
self.ReportSystemState = channel.stream_stream(
|
|
38
|
+
'/proto.NezhaService/ReportSystemState',
|
|
39
|
+
request_serializer=nezha__pb2.State.SerializeToString,
|
|
40
|
+
response_deserializer=nezha__pb2.Receipt.FromString,
|
|
41
|
+
_registered_method=True)
|
|
42
|
+
self.ReportSystemInfo = channel.unary_unary(
|
|
43
|
+
'/proto.NezhaService/ReportSystemInfo',
|
|
44
|
+
request_serializer=nezha__pb2.Host.SerializeToString,
|
|
45
|
+
response_deserializer=nezha__pb2.Receipt.FromString,
|
|
46
|
+
_registered_method=True)
|
|
47
|
+
self.RequestTask = channel.stream_stream(
|
|
48
|
+
'/proto.NezhaService/RequestTask',
|
|
49
|
+
request_serializer=nezha__pb2.TaskResult.SerializeToString,
|
|
50
|
+
response_deserializer=nezha__pb2.Task.FromString,
|
|
51
|
+
_registered_method=True)
|
|
52
|
+
self.IOStream = channel.stream_stream(
|
|
53
|
+
'/proto.NezhaService/IOStream',
|
|
54
|
+
request_serializer=nezha__pb2.IOStreamData.SerializeToString,
|
|
55
|
+
response_deserializer=nezha__pb2.IOStreamData.FromString,
|
|
56
|
+
_registered_method=True)
|
|
57
|
+
self.ReportGeoIP = channel.unary_unary(
|
|
58
|
+
'/proto.NezhaService/ReportGeoIP',
|
|
59
|
+
request_serializer=nezha__pb2.GeoIP.SerializeToString,
|
|
60
|
+
response_deserializer=nezha__pb2.GeoIP.FromString,
|
|
61
|
+
_registered_method=True)
|
|
62
|
+
self.ReportSystemInfo2 = channel.unary_unary(
|
|
63
|
+
'/proto.NezhaService/ReportSystemInfo2',
|
|
64
|
+
request_serializer=nezha__pb2.Host.SerializeToString,
|
|
65
|
+
response_deserializer=nezha__pb2.Uint64Receipt.FromString,
|
|
66
|
+
_registered_method=True)
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
class NezhaServiceServicer:
|
|
70
|
+
"""Missing associated documentation comment in .proto file."""
|
|
71
|
+
|
|
72
|
+
def ReportSystemState(self, request_iterator, context):
|
|
73
|
+
"""Missing associated documentation comment in .proto file."""
|
|
74
|
+
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
|
|
75
|
+
context.set_details('Method not implemented!')
|
|
76
|
+
raise NotImplementedError('Method not implemented!')
|
|
77
|
+
|
|
78
|
+
def ReportSystemInfo(self, request, context):
|
|
79
|
+
"""Missing associated documentation comment in .proto file."""
|
|
80
|
+
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
|
|
81
|
+
context.set_details('Method not implemented!')
|
|
82
|
+
raise NotImplementedError('Method not implemented!')
|
|
83
|
+
|
|
84
|
+
def RequestTask(self, request_iterator, context):
|
|
85
|
+
"""Missing associated documentation comment in .proto file."""
|
|
86
|
+
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
|
|
87
|
+
context.set_details('Method not implemented!')
|
|
88
|
+
raise NotImplementedError('Method not implemented!')
|
|
89
|
+
|
|
90
|
+
def IOStream(self, request_iterator, context):
|
|
91
|
+
"""Missing associated documentation comment in .proto file."""
|
|
92
|
+
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
|
|
93
|
+
context.set_details('Method not implemented!')
|
|
94
|
+
raise NotImplementedError('Method not implemented!')
|
|
95
|
+
|
|
96
|
+
def ReportGeoIP(self, request, context):
|
|
97
|
+
"""Missing associated documentation comment in .proto file."""
|
|
98
|
+
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
|
|
99
|
+
context.set_details('Method not implemented!')
|
|
100
|
+
raise NotImplementedError('Method not implemented!')
|
|
101
|
+
|
|
102
|
+
def ReportSystemInfo2(self, request, context):
|
|
103
|
+
"""Missing associated documentation comment in .proto file."""
|
|
104
|
+
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
|
|
105
|
+
context.set_details('Method not implemented!')
|
|
106
|
+
raise NotImplementedError('Method not implemented!')
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
def add_NezhaServiceServicer_to_server(servicer, server):
|
|
110
|
+
rpc_method_handlers = {
|
|
111
|
+
'ReportSystemState': grpc.stream_stream_rpc_method_handler(
|
|
112
|
+
servicer.ReportSystemState,
|
|
113
|
+
request_deserializer=nezha__pb2.State.FromString,
|
|
114
|
+
response_serializer=nezha__pb2.Receipt.SerializeToString,
|
|
115
|
+
),
|
|
116
|
+
'ReportSystemInfo': grpc.unary_unary_rpc_method_handler(
|
|
117
|
+
servicer.ReportSystemInfo,
|
|
118
|
+
request_deserializer=nezha__pb2.Host.FromString,
|
|
119
|
+
response_serializer=nezha__pb2.Receipt.SerializeToString,
|
|
120
|
+
),
|
|
121
|
+
'RequestTask': grpc.stream_stream_rpc_method_handler(
|
|
122
|
+
servicer.RequestTask,
|
|
123
|
+
request_deserializer=nezha__pb2.TaskResult.FromString,
|
|
124
|
+
response_serializer=nezha__pb2.Task.SerializeToString,
|
|
125
|
+
),
|
|
126
|
+
'IOStream': grpc.stream_stream_rpc_method_handler(
|
|
127
|
+
servicer.IOStream,
|
|
128
|
+
request_deserializer=nezha__pb2.IOStreamData.FromString,
|
|
129
|
+
response_serializer=nezha__pb2.IOStreamData.SerializeToString,
|
|
130
|
+
),
|
|
131
|
+
'ReportGeoIP': grpc.unary_unary_rpc_method_handler(
|
|
132
|
+
servicer.ReportGeoIP,
|
|
133
|
+
request_deserializer=nezha__pb2.GeoIP.FromString,
|
|
134
|
+
response_serializer=nezha__pb2.GeoIP.SerializeToString,
|
|
135
|
+
),
|
|
136
|
+
'ReportSystemInfo2': grpc.unary_unary_rpc_method_handler(
|
|
137
|
+
servicer.ReportSystemInfo2,
|
|
138
|
+
request_deserializer=nezha__pb2.Host.FromString,
|
|
139
|
+
response_serializer=nezha__pb2.Uint64Receipt.SerializeToString,
|
|
140
|
+
),
|
|
141
|
+
}
|
|
142
|
+
generic_handler = grpc.method_handlers_generic_handler(
|
|
143
|
+
'proto.NezhaService', rpc_method_handlers)
|
|
144
|
+
server.add_generic_rpc_handlers((generic_handler,))
|
|
145
|
+
server.add_registered_method_handlers('proto.NezhaService', rpc_method_handlers)
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
# This class is part of an EXPERIMENTAL API.
|
|
149
|
+
class NezhaService:
|
|
150
|
+
"""Missing associated documentation comment in .proto file."""
|
|
151
|
+
|
|
152
|
+
@staticmethod
|
|
153
|
+
def ReportSystemState(request_iterator,
|
|
154
|
+
target,
|
|
155
|
+
options=(),
|
|
156
|
+
channel_credentials=None,
|
|
157
|
+
call_credentials=None,
|
|
158
|
+
insecure=False,
|
|
159
|
+
compression=None,
|
|
160
|
+
wait_for_ready=None,
|
|
161
|
+
timeout=None,
|
|
162
|
+
metadata=None):
|
|
163
|
+
return grpc.experimental.stream_stream(
|
|
164
|
+
request_iterator,
|
|
165
|
+
target,
|
|
166
|
+
'/proto.NezhaService/ReportSystemState',
|
|
167
|
+
nezha__pb2.State.SerializeToString,
|
|
168
|
+
nezha__pb2.Receipt.FromString,
|
|
169
|
+
options,
|
|
170
|
+
channel_credentials,
|
|
171
|
+
insecure,
|
|
172
|
+
call_credentials,
|
|
173
|
+
compression,
|
|
174
|
+
wait_for_ready,
|
|
175
|
+
timeout,
|
|
176
|
+
metadata,
|
|
177
|
+
_registered_method=True)
|
|
178
|
+
|
|
179
|
+
@staticmethod
|
|
180
|
+
def ReportSystemInfo(request,
|
|
181
|
+
target,
|
|
182
|
+
options=(),
|
|
183
|
+
channel_credentials=None,
|
|
184
|
+
call_credentials=None,
|
|
185
|
+
insecure=False,
|
|
186
|
+
compression=None,
|
|
187
|
+
wait_for_ready=None,
|
|
188
|
+
timeout=None,
|
|
189
|
+
metadata=None):
|
|
190
|
+
return grpc.experimental.unary_unary(
|
|
191
|
+
request,
|
|
192
|
+
target,
|
|
193
|
+
'/proto.NezhaService/ReportSystemInfo',
|
|
194
|
+
nezha__pb2.Host.SerializeToString,
|
|
195
|
+
nezha__pb2.Receipt.FromString,
|
|
196
|
+
options,
|
|
197
|
+
channel_credentials,
|
|
198
|
+
insecure,
|
|
199
|
+
call_credentials,
|
|
200
|
+
compression,
|
|
201
|
+
wait_for_ready,
|
|
202
|
+
timeout,
|
|
203
|
+
metadata,
|
|
204
|
+
_registered_method=True)
|
|
205
|
+
|
|
206
|
+
@staticmethod
|
|
207
|
+
def RequestTask(request_iterator,
|
|
208
|
+
target,
|
|
209
|
+
options=(),
|
|
210
|
+
channel_credentials=None,
|
|
211
|
+
call_credentials=None,
|
|
212
|
+
insecure=False,
|
|
213
|
+
compression=None,
|
|
214
|
+
wait_for_ready=None,
|
|
215
|
+
timeout=None,
|
|
216
|
+
metadata=None):
|
|
217
|
+
return grpc.experimental.stream_stream(
|
|
218
|
+
request_iterator,
|
|
219
|
+
target,
|
|
220
|
+
'/proto.NezhaService/RequestTask',
|
|
221
|
+
nezha__pb2.TaskResult.SerializeToString,
|
|
222
|
+
nezha__pb2.Task.FromString,
|
|
223
|
+
options,
|
|
224
|
+
channel_credentials,
|
|
225
|
+
insecure,
|
|
226
|
+
call_credentials,
|
|
227
|
+
compression,
|
|
228
|
+
wait_for_ready,
|
|
229
|
+
timeout,
|
|
230
|
+
metadata,
|
|
231
|
+
_registered_method=True)
|
|
232
|
+
|
|
233
|
+
@staticmethod
|
|
234
|
+
def IOStream(request_iterator,
|
|
235
|
+
target,
|
|
236
|
+
options=(),
|
|
237
|
+
channel_credentials=None,
|
|
238
|
+
call_credentials=None,
|
|
239
|
+
insecure=False,
|
|
240
|
+
compression=None,
|
|
241
|
+
wait_for_ready=None,
|
|
242
|
+
timeout=None,
|
|
243
|
+
metadata=None):
|
|
244
|
+
return grpc.experimental.stream_stream(
|
|
245
|
+
request_iterator,
|
|
246
|
+
target,
|
|
247
|
+
'/proto.NezhaService/IOStream',
|
|
248
|
+
nezha__pb2.IOStreamData.SerializeToString,
|
|
249
|
+
nezha__pb2.IOStreamData.FromString,
|
|
250
|
+
options,
|
|
251
|
+
channel_credentials,
|
|
252
|
+
insecure,
|
|
253
|
+
call_credentials,
|
|
254
|
+
compression,
|
|
255
|
+
wait_for_ready,
|
|
256
|
+
timeout,
|
|
257
|
+
metadata,
|
|
258
|
+
_registered_method=True)
|
|
259
|
+
|
|
260
|
+
@staticmethod
|
|
261
|
+
def ReportGeoIP(request,
|
|
262
|
+
target,
|
|
263
|
+
options=(),
|
|
264
|
+
channel_credentials=None,
|
|
265
|
+
call_credentials=None,
|
|
266
|
+
insecure=False,
|
|
267
|
+
compression=None,
|
|
268
|
+
wait_for_ready=None,
|
|
269
|
+
timeout=None,
|
|
270
|
+
metadata=None):
|
|
271
|
+
return grpc.experimental.unary_unary(
|
|
272
|
+
request,
|
|
273
|
+
target,
|
|
274
|
+
'/proto.NezhaService/ReportGeoIP',
|
|
275
|
+
nezha__pb2.GeoIP.SerializeToString,
|
|
276
|
+
nezha__pb2.GeoIP.FromString,
|
|
277
|
+
options,
|
|
278
|
+
channel_credentials,
|
|
279
|
+
insecure,
|
|
280
|
+
call_credentials,
|
|
281
|
+
compression,
|
|
282
|
+
wait_for_ready,
|
|
283
|
+
timeout,
|
|
284
|
+
metadata,
|
|
285
|
+
_registered_method=True)
|
|
286
|
+
|
|
287
|
+
@staticmethod
|
|
288
|
+
def ReportSystemInfo2(request,
|
|
289
|
+
target,
|
|
290
|
+
options=(),
|
|
291
|
+
channel_credentials=None,
|
|
292
|
+
call_credentials=None,
|
|
293
|
+
insecure=False,
|
|
294
|
+
compression=None,
|
|
295
|
+
wait_for_ready=None,
|
|
296
|
+
timeout=None,
|
|
297
|
+
metadata=None):
|
|
298
|
+
return grpc.experimental.unary_unary(
|
|
299
|
+
request,
|
|
300
|
+
target,
|
|
301
|
+
'/proto.NezhaService/ReportSystemInfo2',
|
|
302
|
+
nezha__pb2.Host.SerializeToString,
|
|
303
|
+
nezha__pb2.Uint64Receipt.FromString,
|
|
304
|
+
options,
|
|
305
|
+
channel_credentials,
|
|
306
|
+
insecure,
|
|
307
|
+
call_credentials,
|
|
308
|
+
compression,
|
|
309
|
+
wait_for_ready,
|
|
310
|
+
timeout,
|
|
311
|
+
metadata,
|
|
312
|
+
_registered_method=True)
|