Skip to content

Commit ab99cec

Browse files
committed
feat: Add CollectorRule api to Identity-v2
Signed-off-by: lhhyung <[email protected]>
1 parent a96cdcc commit ab99cec

File tree

1 file changed

+299
-0
lines changed

1 file changed

+299
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,299 @@
1+
// A CollectorRule is a cloud service resource filtering the raw data from the Collector. The Cloud Service resource is created after the raw data is filtered by the CollectorRule.
2+
syntax = "proto3";
3+
4+
package spaceone.api.inventory_v2.v1;
5+
6+
option go_package = "github.com/cloudforet-io/api/dist/go/spaceone/api/inventory-v2/v1";
7+
8+
import "google/protobuf/empty.proto";
9+
import "google/protobuf/struct.proto";
10+
import "google/api/annotations.proto";
11+
import "spaceone/api/core/v2/query.proto";
12+
13+
14+
service CollectorRule {
15+
16+
// Creates a new CollectorRule. When creating the cloud service, this method can apply two types of conditions: mapping projects where the cloud service incurred to the Cloud Service, and mapping cloud service accounts to the Cloud Service. By adjusting the `condition_policy` parameter, the CollectorRule can be applied when all conditions are met, applied when any of the conditions are met, or always applied regardless of whether the conditions are met.
17+
rpc create (CreateCollectorRuleRequest) returns (CollectorRuleInfo) {
18+
option (google.api.http) = {
19+
post: "/inventory-v2/v1/collector-rule/create"
20+
body: "*"
21+
};
22+
}
23+
24+
// Updates a specific CollectorRule. You can make changes in CollectorRule settings, including filtering conditions.
25+
rpc update (UpdateCollectorRuleRequest) returns (CollectorRuleInfo) {
26+
option (google.api.http) = {
27+
post: "/inventory-v2/v1/collector-rule/update"
28+
body: "*"
29+
};
30+
}
31+
32+
// Changes the priority order of the CollectorRules to apply. If there are multiple CollectorRules applied in a specific service account, the priority order of the resources is required. This method changes the priority order to apply CollectorRules.
33+
rpc change_order (ChangeCollectorRuleOrderRequest) returns (CollectorRuleInfo) {
34+
option (google.api.http) = {
35+
post: "/inventory-v2/v1/collector-rule/change-order"
36+
body: "*"
37+
};
38+
}
39+
40+
// Deletes a specific CollectorRule. You must specify the `collector_rule_id` of the CollectorRule to delete.
41+
rpc delete (CollectorRuleRequest) returns (google.protobuf.Empty) {
42+
option (google.api.http) = {
43+
post: "/inventory-v2/v1/collector-rule/delete"
44+
body: "*"
45+
};
46+
}
47+
48+
// Gets a specific CollectorRule. Prints detailed information about the CollectorRule, including `conditions_policy` and conditions applied to Collector.
49+
rpc get (CollectorRuleRequest) returns (CollectorRuleInfo) {
50+
option (google.api.http) = {
51+
post: "/inventory-v2/v1/collector-rule/get"
52+
body: "*"
53+
};
54+
}
55+
56+
// Gets a list of all CollectorRules. You can use a query to get a filtered list of CollectorRules.
57+
rpc list (CollectorRuleQuery) returns (CollectorRulesInfo) {
58+
option (google.api.http) = {
59+
post: "/inventory-v2/v1/collector-rule/list"
60+
body: "*"
61+
};
62+
}
63+
64+
rpc stat (CollectorRuleStatQuery) returns (google.protobuf.Struct) {
65+
option (google.api.http) = {
66+
post: "/inventory-v2/v1/collector-rule/stat"
67+
body: "*"
68+
};
69+
}
70+
}
71+
72+
enum ConditionsPolicy {
73+
NONE = 0;
74+
ALL = 1;
75+
ANY = 2;
76+
ALWAYS = 3;
77+
}
78+
79+
message CollectorRuleCondition {
80+
string key = 1;
81+
string value = 2;
82+
string operator = 3;
83+
}
84+
85+
message MatchRule {
86+
string source = 1;
87+
string target = 2;
88+
}
89+
90+
message CollectorRuleActions {
91+
string change_project = 1;
92+
MatchRule match_project = 2;
93+
MatchRule match_service_account = 3;
94+
google.protobuf.Struct add_additional_info = 4;
95+
}
96+
97+
message CollectorRuleOptions {
98+
bool stop_processing = 1;
99+
}
100+
101+
//{
102+
// "name": "match_service_account_test",
103+
// "conditions_policy": "ALWAYS",
104+
// "actions": {
105+
// "match_service_account": {"source": "account", "target": "data.project_id"}
106+
// },
107+
// "options": {"stop_processing": true},
108+
// "tags": {"b": "c", "a": "b"},
109+
// "collector_id": "collector-2e39891cbbb5"
110+
//}
111+
message CreateCollectorRuleRequest {
112+
string collector_id = 1;
113+
// +optional
114+
string name = 2;
115+
// +optional
116+
repeated CollectorRuleCondition conditions = 3;
117+
ConditionsPolicy conditions_policy = 4;
118+
CollectorRuleActions actions = 5;
119+
// +optional
120+
CollectorRuleOptions options = 6;
121+
// +optional
122+
google.protobuf.Struct tags = 7;
123+
}
124+
125+
//{
126+
// "collector_rule_id": "collector-rule-c8055231e212",
127+
// "name": "match_service_account_test",
128+
// "conditions_policy": "ALWAYS",
129+
// "actions": {
130+
// "match_service_account": {
131+
// "source": "account",
132+
// "target": "data.project_id"
133+
// }
134+
// },
135+
// "options": {
136+
// "stop_processing": true
137+
// },
138+
// "tags": {"b": "c", "a": "b"}
139+
//}
140+
message UpdateCollectorRuleRequest {
141+
string collector_rule_id = 1;
142+
// +optional
143+
string name = 2;
144+
// +optional
145+
repeated CollectorRuleCondition conditions = 3;
146+
// +optional
147+
ConditionsPolicy conditions_policy = 4;
148+
// +optional
149+
CollectorRuleActions actions = 5;
150+
// +optional
151+
CollectorRuleOptions options = 6;
152+
// +optional
153+
google.protobuf.Struct tags = 7;
154+
}
155+
156+
//{
157+
// "collector_rule_id": "collector-rule-c8055231e212",
158+
// "order": 2
159+
//}
160+
message ChangeCollectorRuleOrderRequest {
161+
string collector_rule_id = 1;
162+
int32 order = 2;
163+
}
164+
165+
//{
166+
// "collector_rule_id": "collector-rule-c8055231e212",
167+
//}
168+
message CollectorRuleRequest {
169+
string collector_rule_id = 1;
170+
}
171+
172+
//{
173+
// "query": {}
174+
//}
175+
message CollectorRuleQuery {
176+
enum RuleType {
177+
RULE_TYPE_NONE = 0;
178+
MANAGED = 1;
179+
CUSTOM = 2;
180+
}
181+
182+
// +optional
183+
spaceone.api.core.v2.Query query = 1;
184+
// +optional
185+
string collector_rule_id = 2;
186+
// +optional
187+
string name = 3;
188+
// +optional
189+
RuleType rule_type = 4;
190+
// +optional
191+
string workspace_id = 21;
192+
// +optional
193+
string collector_id = 22;
194+
}
195+
196+
//{
197+
// "collector_rule_id": "collector-rule-c8055231e212",
198+
// "name": "match_service_account_test",
199+
// "order": 2,
200+
// "conditions_policy": "ALWAYS",
201+
// "actions": {
202+
// "match_service_account": {
203+
// "source": "account",
204+
// "target": "data.project_id"
205+
// }
206+
// },
207+
// "options": {
208+
// "stop_processing": true
209+
// },
210+
// "tags": {
211+
// "a": "b",
212+
// "b": "c"
213+
// },
214+
// "collector_id": "collector-2e39891cbbb5",
215+
// "domain_id": "domain-58010aa2e451",
216+
// "created_at": "2022-07-19T10:13:28.335Z"
217+
//}
218+
message CollectorRuleInfo {
219+
enum ResourceGroup {
220+
RESOURCE_GROUP_NONE = 0;
221+
DOMAIN = 1;
222+
WORKSPACE = 2;
223+
}
224+
enum RuleType {
225+
RULE_TYPE_NONE = 0;
226+
MANAGED = 1;
227+
CUSTOM = 2;
228+
}
229+
230+
string collector_rule_id = 1;
231+
string name = 2;
232+
RuleType rule_type = 3;
233+
int32 order = 4;
234+
repeated CollectorRuleCondition conditions = 5;
235+
ConditionsPolicy conditions_policy = 6;
236+
CollectorRuleActions actions = 7;
237+
CollectorRuleOptions options = 8;
238+
google.protobuf.Struct tags = 9;
239+
240+
ResourceGroup resource_group = 20;
241+
string domain_id = 21;
242+
string workspace_id = 22;
243+
string collector_id = 23;
244+
245+
string created_at = 31;
246+
string updated_at = 32;
247+
}
248+
249+
//{
250+
// "results": [
251+
// {
252+
// "collector_rule_id": "collector-rule-c8055231e212",
253+
// "name": "match_service_account",
254+
// "order": 1,
255+
// "conditions_policy": "ALWAYS",
256+
// "actions": {
257+
// "match_service_account": {
258+
// "source": "account",
259+
// "target": "data.project_id"
260+
// }
261+
// },
262+
// "options": {
263+
// "stop_processing": true
264+
// },
265+
// "tags": {},
266+
// "collector_id": "collector-2e39891cbbb5",
267+
// "domain_id": "domain-58010aa2e451",
268+
// "created_at": "2022-05-25T16:01:51.858Z"
269+
// },
270+
// {
271+
// "collector_rule_id": "collector-rule-t3345231e167",
272+
// "name": "match_service_account",
273+
// "order": 1,
274+
// "conditions_policy": "ALWAYS",
275+
// "actions": {
276+
// "match_service_account": {
277+
// "source": "account",
278+
// "target": "data.account_id"
279+
// }
280+
// },
281+
// "options": {
282+
// "stop_processing": true
283+
// },
284+
// "tags": {},
285+
// "collector_id": "collector-7163022d49a1",
286+
// "domain_id": "domain-58010aa2e451",
287+
// "created_at": "2022-06-03T16:00:54.099Z"
288+
// }
289+
// ],
290+
// "total_count": 2
291+
//}
292+
message CollectorRulesInfo {
293+
repeated CollectorRuleInfo results = 1;
294+
int32 total_count = 2;
295+
}
296+
297+
message CollectorRuleStatQuery {
298+
spaceone.api.core.v2.StatisticsQuery query = 1;
299+
}

0 commit comments

Comments
 (0)