-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapi.proto
162 lines (140 loc) · 3.75 KB
/
api.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
155
156
157
158
159
160
161
162
// Copyright 2020 Teserakt AG
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
syntax = "proto3";
package pb;
import "google/protobuf/timestamp.proto";
import "google/api/annotations.proto";
import "protoc-gen-swagger/options/annotations.proto";
option (grpc.gateway.protoc_gen_swagger.options.openapiv2_swagger) = {
host : "127.0.0.1:8886"
info : {title : "c2ae-api";};
schemes : HTTPS;
consumes : "application/json";
produces : "application/json";
};
service C2AutomationEngine {
// Retrieve list of existing rules
rpc ListRules (ListRulesRequest) returns (RulesResponse) {
option (google.api.http) = {
get: "/rules"
};
}
// Retrieve a single rule, by its ID
rpc GetRule(GetRuleRequest) returns (RuleResponse) {
option (google.api.http) = {
get: "/rules/{ruleId}"
};
}
// Create a new rule
rpc AddRule (AddRuleRequest) returns (RuleResponse) {
option (google.api.http) = {
post: "/rules"
body: "*"
};
}
// Update an existing rule
rpc UpdateRule (UpdateRuleRequest) returns (RuleResponse) {
option (google.api.http) = {
put: "/rules"
body: "*"
};
}
// Remove a rule
rpc DeleteRule (DeleteRuleRequest) returns (DeleteRuleResponse) {
option (google.api.http) = {
delete: "/rules/{ruleId}"
};
}
rpc HealthCheck(HealthCheckRequest) returns (HealthCheckResponse) {
option (google.api.http) = {
get: "/health-check"
};
}
}
// List of supported ActionType
enum ActionType {
UNDEFINED_ACTION = 0;
KEY_ROTATION = 1;
// Extended as more actions get added ...
}
// List of supported TargetType
enum TargetType {
ANY = 0;
TOPIC = 1;
CLIENT = 2;
}
// List of supported TriggerType
enum TriggerType {
UNDEFINED_TRIGGER = 0;
TIME_INTERVAL = 1;
EVENT = 2;
// Extended as more triggers get added ...
}
message Rule {
int32 id = 1;
string description = 2;
ActionType action = 3;
google.protobuf.Timestamp lastExecuted = 4;
repeated Trigger triggers = 5;
repeated Target targets = 6;
}
message Target {
int32 id = 1;
TargetType type = 2;
string expr = 3;
}
message Trigger {
int32 id = 1;
TriggerType type = 2;
bytes settings = 3;
}
message RulesResponse {
repeated Rule rules = 1;
}
message RuleResponse {
Rule rule = 1;
}
message ListRulesRequest {
// Empty for now, can add pagination or whatever filter here.
}
message GetRuleRequest {
int32 ruleId = 1;
}
message AddRuleRequest {
string description = 1;
ActionType action = 2;
repeated Trigger triggers = 3;
repeated Target targets = 4;
}
// UpdateRuleRequest will fetch the rule identified by ruleId,
// and override its description, action, triggers and targets values
// with those provided.
message UpdateRuleRequest {
int32 ruleId = 1;
string description = 2;
ActionType action = 3;
repeated Trigger triggers = 4;
repeated Target targets = 5;
}
message DeleteRuleRequest {
int32 ruleId = 1;
}
message DeleteRuleResponse {
int32 ruleId = 1;
}
message HealthCheckRequest {}
message HealthCheckResponse {
int64 Code = 1;
string Status = 2;
}