-
Notifications
You must be signed in to change notification settings - Fork 27
/
comms_rpc.go
120 lines (92 loc) · 3.24 KB
/
comms_rpc.go
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
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
package fleet
const CurrentRPCSchemaVersion = "1.0"
type RPC struct {
SchemaVersion string `json:"schema_version"`
Func string `json:"func"`
Payload interface{} `json:"payload"`
}
// Core -> Edge
const GroupMembershipRPCFunc = "group_membership"
type GroupMembershipRPC struct {
SchemaVersion string `json:"schema_version"`
Func string `json:"func"`
Payload GroupMembershipRPCPayload `json:"payload"`
}
type GroupMembershipData struct {
Name string `json:"name"`
ChannelID string `json:"channel_id"`
}
type GroupMembershipRPCPayload struct {
Groups []GroupMembershipData `json:"groups"`
FullList bool `json:"full_list"`
}
const AgentPolicyRPCFunc = "agent_policy"
type AgentPolicyRPC struct {
SchemaVersion string `json:"schema_version"`
Func string `json:"func"`
Payload []AgentPolicyRPCPayload `json:"payload"`
}
type AgentPolicyRPCPayload struct {
Action string `json:"action"`
ID string `json:"id"`
DatasetID string `json:"dataset_id"`
Name string `json:"name"`
Backend string `json:"backend"`
Version int32 `json:"version"`
Data interface{} `json:"data"`
}
const GroupRemovedRPCFunc = "group_removed"
type GroupRemovedRPC struct {
SchemaVersion string `json:"schema_version"`
Func string `json:"func"`
Payload GroupRemovedRPCPayload `json:"payload"`
}
type GroupRemovedRPCPayload struct {
AgentGroupID string `json:"agent_group_id"`
ChannelID string `json:"channel_id"`
}
const DatasetRemovedRPCFunc = "dataset_removed"
type DatasetRemovedRPC struct {
SchemaVersion string `json:"schema_version"`
Func string `json:"func"`
Payload DatasetRemovedRPCPayload `json:"payload"`
}
type DatasetRemovedRPCPayload struct {
DatasetID string `json:"dataset_id"`
PolicyID string `json:"policy_id"`
}
const AgentStopRPCFunc = "agent_stop"
type AgentStopRPCPayload struct {
Reason string `json:"reason"`
}
type AgentStopRPC struct {
SchemaVersion string `json:"schema_version"`
Func string `json:"func"`
Payload AgentStopRPCPayload `json:"payload"`
}
// Edge -> Core
const GroupMembershipReqRPCFunc = "group_membership_req"
type GroupMembershipReqRPCPayload struct {
// empty
}
const AgentPoliciesReqRPCFunc = "agent_policies_req"
type AgentPoliciesReqRPCPayload struct {
// empty
}
const AgentMetricsRPCFunc = "agent_metrics"
type AgentMetricsRPC struct {
SchemaVersion string `json:"schema_version"`
Func string `json:"func"`
Payload []AgentMetricsRPCPayload `json:"payload"`
}
type AgentMetricsRPCPayload struct {
PolicyID string `json:"policy_id"`
PolicyName string `json:"policy_name"`
Datasets []string `json:"datasets"`
Format string `json:"format"`
BEVersion string `json:"be_version"`
Data []byte `json:"data"`
}