openiap_proto/
agent.rs

1#![warn(missing_docs)]
2use super::openiap::{
3    Envelope, DeletePackageRequest, 
4    StartAgentRequest, StopAgentRequest, GetAgentLogRequest, GetAgentPodsRequest, DeleteAgentPodRequest, DeleteAgentRequest
5};
6
7impl DeletePackageRequest {
8    /// Creates a new `DeletePackageRequest` with the given `packageid`.
9    pub fn byid(packageid: &str) -> Self {
10        Self {
11            packageid: packageid.to_string(),
12        }
13    }
14    /// Converts the `DeletePackageRequest` to an `Envelope`.
15    pub fn to_envelope(&self) -> Envelope {
16        let any_message = prost_types::Any {
17            type_url: "type.googleapis.com/openiap.DeletePackageRequest".to_string(),
18            value: {
19                let mut buf = Vec::new();
20                prost::Message::encode(self, &mut buf).unwrap_or(());
21                buf
22            },
23        };
24        Envelope {
25            command: "deletepackage".into(),
26            data: Some(any_message.clone()),
27            ..Default::default() 
28        }
29    }
30}
31impl StartAgentRequest {
32    /// Creates a new `StartAgentRequest` with the given `agentid`.
33    pub fn byid(agentid: &str) -> Self {
34        Self {
35            agentid: agentid.to_string(),
36        }
37    }
38    /// Converts the `StartAgentRequest` to an `Envelope`.
39    pub fn to_envelope(&self) -> Envelope {
40        let any_message = prost_types::Any {
41            type_url: "type.googleapis.com/openiap.StartAgentRequest".to_string(),
42            value: {
43                let mut buf = Vec::new();
44                prost::Message::encode(self, &mut buf).unwrap_or(());
45                buf
46            },
47        };
48        Envelope {
49            command: "startagent".into(),
50            data: Some(any_message.clone()),
51            ..Default::default() 
52        }
53    }    
54}
55impl StopAgentRequest {
56    /// Creates a new `StopAgentRequest` with the given `agentid`.
57    pub fn byid(agentid: &str) -> Self {
58        Self {
59            agentid: agentid.to_string(),
60        }
61    }
62    /// Converts the `StopAgentRequest` to an `Envelope`.
63    pub fn to_envelope(&self) -> Envelope {
64        let any_message = prost_types::Any {
65            type_url: "type.googleapis.com/openiap.StopAgentRequest".to_string(),
66            value: {
67                let mut buf = Vec::new();
68                prost::Message::encode(self, &mut buf).unwrap_or(());
69                buf
70            },
71        };
72        Envelope {
73            command: "stopagent".into(),
74            data: Some(any_message.clone()),
75            ..Default::default() 
76        }
77    }    
78}
79impl GetAgentLogRequest {
80    /// Creates a new `GetAgentLogRequest` with the given `agentid`.
81    pub fn new(agentid: &str, podname: &str) -> Self {
82        Self {
83            agentid: agentid.to_string(),
84            podname: podname.to_string()
85        }
86    }
87    /// Converts the `GetAgentLogRequest` to an `Envelope`.
88    pub fn to_envelope(&self) -> Envelope {
89        let any_message = prost_types::Any {
90            type_url: "type.googleapis.com/openiap.GetAgentLogRequest".to_string(),
91            value: {
92                let mut buf = Vec::new();
93                prost::Message::encode(self, &mut buf).unwrap_or(());
94                buf
95            },
96        };
97        Envelope {
98            command: "getagentlog".into(),
99            data: Some(any_message.clone()),
100            ..Default::default() 
101        }
102    }    
103}
104impl GetAgentPodsRequest {
105    /// Creates a new `GetAgentPodsRequest` with the given `agentid`. Use include_stats to get memory and cpu usage per pod, this is expensive, avoid misuse.
106    pub fn byid(agentid: &str, include_stats: bool) -> Self {
107        Self {
108            agentid: agentid.to_string(),
109            stats: include_stats,
110        }
111    }
112    /// Converts the `GetAgentPodsRequest` to an `Envelope`.
113    pub fn to_envelope(&self) -> Envelope {
114        let any_message = prost_types::Any {
115            type_url: "type.googleapis.com/openiap.GetAgentPodsRequest".to_string(),
116            value: {
117                let mut buf = Vec::new();
118                prost::Message::encode(self, &mut buf).unwrap_or(());
119                buf
120            },
121        };
122        Envelope {
123            command: "getagentpods".into(),
124            data: Some(any_message.clone()),
125            ..Default::default() 
126        }
127    }    
128}
129impl DeleteAgentPodRequest {
130    /// Creates a new `DeleteAgentPodRequest` with the given `agentid` and `podname`.
131    pub fn byid(agentid: &str, podname: &str) -> Self {
132        Self {
133            agentid: agentid.to_string(),
134            podname: podname.to_string(),
135        }
136    }
137    /// Converts the `DeleteAgentPodRequest` to an `Envelope`.
138    pub fn to_envelope(&self) -> Envelope {
139        let any_message = prost_types::Any {
140            type_url: "type.googleapis.com/openiap.DeleteAgentPodRequest".to_string(),
141            value: {
142                let mut buf = Vec::new();
143                prost::Message::encode(self, &mut buf).unwrap_or(());
144                buf
145            },
146        };
147        Envelope {
148            command: "deleteagentpod".into(),
149            data: Some(any_message.clone()),
150            ..Default::default() 
151        }
152    }    
153}
154impl DeleteAgentRequest {
155    /// Creates a new `DeleteAgentRequest` with the given `agentid`.
156    pub fn byid(agentid: &str) -> Self {
157        Self {
158            agentid: agentid.to_string(),
159        }
160    }
161    /// Converts the `DeleteAgentRequest` to an `Envelope`.
162    pub fn to_envelope(&self) -> Envelope {
163        let any_message = prost_types::Any {
164            type_url: "type.googleapis.com/openiap.DeleteAgentRequest".to_string(),
165            value: {
166                let mut buf = Vec::new();
167                prost::Message::encode(self, &mut buf).unwrap_or(());
168                buf
169            },
170        };
171        Envelope {
172            command: "deleteagent".into(),
173            data: Some(any_message.clone()),
174            ..Default::default() 
175        }
176    }    
177}