-
Notifications
You must be signed in to change notification settings - Fork 4
/
server.proto
154 lines (135 loc) · 2.98 KB
/
server.proto
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
syntax = "proto3";
option go_package = "github.com/annetutil/gnetcli/pkg/server/proto;gnetcli";
package gnetcli;
import "google/api/annotations.proto";
import "google/protobuf/empty.proto";
message QA {
string question = 1;
string answer = 2;
}
message Credentials {
string login = 1;
string password = 2;
}
message CMD {
string host = 1;
string cmd = 2;
bool trace = 3;
repeated QA qa = 4;
double read_timeout = 5;
double cmd_timeout = 6;
bool string_result = 8;
}
message Device {
string name = 1;
string prompt_expression = 2;
string error_expression = 3;
string pager_expression = 4;
}
message CMDNetconf {
string host = 1;
string cmd = 2;
bool json = 3;
double read_timeout = 4; // read timeout in seconds
double cmd_timeout = 5; // command execution timeout in seconds
}
enum TraceOperation {
Operation_notset = 0;
Operation_unknown = 1;
Operation_write = 2;
Operation_read = 3;
}
enum DeviceResultStatus {
Device_notset = 0;
Device_ok = 1;
Device_error = 2;
}
message CMDTraceItem {
TraceOperation operation = 1;
bytes data = 2;
}
message HostParams {
string host = 1;
Credentials credentials = 2;
int32 port = 3;
string device = 4;
}
message CMDResult {
bytes out = 1;
string out_str = 2;
bytes error = 3;
string error_str = 4;
repeated CMDTraceItem trace = 5;
int32 status = 6;
}
message DeviceResult {
DeviceResultStatus res = 1;
string error = 2;
}
message FileDownloadRequest {
string host = 1;
repeated string paths = 2;
string device = 3;
Credentials credentials = 4;
}
enum FileStatus {
FileStatus_notset = 0;
FileStatus_ok = 1;
FileStatus_error = 2;
FileStatus_not_found = 3;
FileStatus_is_dir = 4;
}
message FileData {
string path = 1;
bytes data = 2;
FileStatus status = 3;
}
message FileUploadRequest {
string host = 1;
string device = 4;
repeated FileData files = 3;
Credentials credentials = 5;
}
message FilesResult {
repeated FileData files = 1;
}
service Gnetcli {
rpc SetupHostParams(HostParams) returns (google.protobuf.Empty) {
option (google.api.http) = {
post: "/api/v1/setup_host_params"
body: "*"
};
};
rpc Exec(CMD) returns (CMDResult) {
option (google.api.http) = {
post: "/api/v1/exec"
body: "*"
};
};
rpc ExecChat(stream CMD) returns (stream CMDResult) {};
rpc AddDevice(Device) returns (DeviceResult) {
option (google.api.http) = {
post: "/api/v1/add_device"
body: "*"
};
};
rpc ExecNetconf(CMDNetconf) returns (CMDResult) {
option (google.api.http) = {
post: "/api/v1/exec_netconf"
body: "*"
};
};
rpc ExecNetconfChat(stream CMDNetconf) returns (stream CMDResult) {};
rpc Download(FileDownloadRequest) returns (FilesResult) {
option (google.api.http) = {
post: "/api/v1/downloads"
body: "*"
};
};
rpc Upload(FileUploadRequest) returns (google.protobuf.Empty) {
option (google.api.http) = {
post: "/api/v1/upload"
body: "*"
};
};
}