slim_controller/api/gen/
controller.proto.v1.rs

1// This file is @generated by prost-build.
2#[derive(Clone, PartialEq, ::prost::Message)]
3pub struct ControlMessage {
4    #[prost(string, tag = "1")]
5    pub message_id: ::prost::alloc::string::String,
6    #[prost(
7        oneof = "control_message::Payload",
8        tags = "2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20"
9    )]
10    pub payload: ::core::option::Option<control_message::Payload>,
11}
12/// Nested message and enum types in `ControlMessage`.
13pub mod control_message {
14    #[derive(Clone, PartialEq, ::prost::Oneof)]
15    pub enum Payload {
16        #[prost(message, tag = "2")]
17        ConfigCommand(super::ConfigurationCommand),
18        #[prost(message, tag = "3")]
19        Ack(super::Ack),
20        #[prost(message, tag = "4")]
21        SubscriptionListRequest(super::SubscriptionListRequest),
22        #[prost(message, tag = "5")]
23        SubscriptionListResponse(super::SubscriptionListResponse),
24        #[prost(message, tag = "6")]
25        ConnectionListRequest(super::ConnectionListRequest),
26        #[prost(message, tag = "7")]
27        ConnectionListResponse(super::ConnectionListResponse),
28        #[prost(message, tag = "8")]
29        RegisterNodeRequest(super::RegisterNodeRequest),
30        #[prost(message, tag = "9")]
31        RegisterNodeResponse(super::RegisterNodeResponse),
32        #[prost(message, tag = "10")]
33        DeregisterNodeRequest(super::DeregisterNodeRequest),
34        #[prost(message, tag = "11")]
35        DeregisterNodeResponse(super::DeregisterNodeResponse),
36        #[prost(message, tag = "12")]
37        CreateChannelRequest(super::CreateChannelRequest),
38        #[prost(message, tag = "13")]
39        CreateChannelResponse(super::CreateChannelResponse),
40        #[prost(message, tag = "14")]
41        DeleteChannelRequest(super::DeleteChannelRequest),
42        #[prost(message, tag = "15")]
43        AddParticipantRequest(super::AddParticipantRequest),
44        #[prost(message, tag = "16")]
45        DeleteParticipantRequest(super::DeleteParticipantRequest),
46        #[prost(message, tag = "17")]
47        ListChannelRequest(super::ListChannelsRequest),
48        #[prost(message, tag = "18")]
49        ListChannelResponse(super::ListChannelsResponse),
50        #[prost(message, tag = "19")]
51        ListParticipantsRequest(super::ListParticipantsRequest),
52        #[prost(message, tag = "20")]
53        ListParticipantsResponse(super::ListParticipantsResponse),
54    }
55}
56#[derive(Clone, PartialEq, ::prost::Message)]
57pub struct Connection {
58    #[prost(string, tag = "1")]
59    pub connection_id: ::prost::alloc::string::String,
60    #[prost(string, tag = "2")]
61    pub config_data: ::prost::alloc::string::String,
62}
63#[derive(Clone, PartialEq, ::prost::Message)]
64pub struct Subscription {
65    #[prost(string, tag = "1")]
66    pub component_0: ::prost::alloc::string::String,
67    #[prost(string, tag = "2")]
68    pub component_1: ::prost::alloc::string::String,
69    #[prost(string, tag = "3")]
70    pub component_2: ::prost::alloc::string::String,
71    #[prost(message, optional, tag = "4")]
72    pub id: ::core::option::Option<u64>,
73    #[prost(string, tag = "5")]
74    pub connection_id: ::prost::alloc::string::String,
75}
76#[derive(Clone, PartialEq, ::prost::Message)]
77pub struct ConfigurationCommand {
78    #[prost(message, repeated, tag = "1")]
79    pub connections_to_create: ::prost::alloc::vec::Vec<Connection>,
80    #[prost(message, repeated, tag = "2")]
81    pub subscriptions_to_set: ::prost::alloc::vec::Vec<Subscription>,
82    #[prost(message, repeated, tag = "3")]
83    pub subscriptions_to_delete: ::prost::alloc::vec::Vec<Subscription>,
84}
85#[derive(Clone, PartialEq, ::prost::Message)]
86pub struct Ack {
87    #[prost(string, tag = "1")]
88    pub original_message_id: ::prost::alloc::string::String,
89    #[prost(bool, tag = "2")]
90    pub success: bool,
91    #[prost(string, repeated, tag = "3")]
92    pub messages: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
93}
94#[derive(Clone, Copy, PartialEq, ::prost::Message)]
95pub struct SubscriptionListRequest {}
96#[derive(Clone, PartialEq, ::prost::Message)]
97pub struct SubscriptionListResponse {
98    #[prost(message, repeated, tag = "1")]
99    pub entries: ::prost::alloc::vec::Vec<SubscriptionEntry>,
100}
101#[derive(Clone, PartialEq, ::prost::Message)]
102pub struct SubscriptionEntry {
103    #[prost(string, tag = "1")]
104    pub component_0: ::prost::alloc::string::String,
105    #[prost(string, tag = "2")]
106    pub component_1: ::prost::alloc::string::String,
107    #[prost(string, tag = "3")]
108    pub component_2: ::prost::alloc::string::String,
109    #[prost(message, optional, tag = "4")]
110    pub id: ::core::option::Option<u64>,
111    #[prost(message, repeated, tag = "5")]
112    pub local_connections: ::prost::alloc::vec::Vec<ConnectionEntry>,
113    #[prost(message, repeated, tag = "6")]
114    pub remote_connections: ::prost::alloc::vec::Vec<ConnectionEntry>,
115}
116#[derive(Clone, PartialEq, ::prost::Message)]
117pub struct ConnectionEntry {
118    #[prost(uint64, tag = "1")]
119    pub id: u64,
120    #[prost(enumeration = "ConnectionType", tag = "2")]
121    pub connection_type: i32,
122    #[prost(string, tag = "3")]
123    pub config_data: ::prost::alloc::string::String,
124}
125#[derive(Clone, Copy, PartialEq, ::prost::Message)]
126pub struct ConnectionListRequest {}
127#[derive(Clone, PartialEq, ::prost::Message)]
128pub struct ConnectionListResponse {
129    #[prost(message, repeated, tag = "1")]
130    pub entries: ::prost::alloc::vec::Vec<ConnectionEntry>,
131}
132#[derive(Clone, PartialEq, ::prost::Message)]
133pub struct Node {
134    #[prost(string, tag = "1")]
135    pub id: ::prost::alloc::string::String,
136}
137#[derive(Clone, PartialEq, ::prost::Message)]
138pub struct RegisterNodeRequest {
139    #[prost(string, tag = "1")]
140    pub node_id: ::prost::alloc::string::String,
141}
142#[derive(Clone, Copy, PartialEq, ::prost::Message)]
143pub struct RegisterNodeResponse {
144    #[prost(bool, tag = "1")]
145    pub success: bool,
146}
147#[derive(Clone, PartialEq, ::prost::Message)]
148pub struct DeregisterNodeRequest {
149    #[prost(message, optional, tag = "1")]
150    pub node: ::core::option::Option<Node>,
151}
152#[derive(Clone, Copy, PartialEq, ::prost::Message)]
153pub struct DeregisterNodeResponse {
154    #[prost(bool, tag = "1")]
155    pub success: bool,
156}
157#[derive(Clone, PartialEq, ::prost::Message)]
158pub struct CreateChannelRequest {
159    /// list of moderators for the channel (e.g. spiffe SVID)
160    #[prost(string, repeated, tag = "1")]
161    pub moderators: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
162}
163#[derive(Clone, PartialEq, ::prost::Message)]
164pub struct CreateChannelResponse {
165    /// ID of the channel, to which clients will subscribe (e.g. spiffe SVID)
166    #[prost(string, tag = "1")]
167    pub channel_id: ::prost::alloc::string::String,
168}
169#[derive(Clone, PartialEq, ::prost::Message)]
170pub struct DeleteChannelRequest {
171    /// ID of the channel
172    #[prost(string, tag = "1")]
173    pub channel_id: ::prost::alloc::string::String,
174}
175#[derive(Clone, PartialEq, ::prost::Message)]
176pub struct AddParticipantRequest {
177    /// ID of the channel
178    #[prost(string, tag = "1")]
179    pub channel_id: ::prost::alloc::string::String,
180    /// ID of participant (e.g. spiffe SVID)
181    #[prost(string, tag = "2")]
182    pub participant_id: ::prost::alloc::string::String,
183}
184#[derive(Clone, PartialEq, ::prost::Message)]
185pub struct DeleteParticipantRequest {
186    /// ID of the channel
187    #[prost(string, tag = "1")]
188    pub channel_id: ::prost::alloc::string::String,
189    /// ID of participant (e.g. spiffe SVID)
190    #[prost(string, tag = "2")]
191    pub participant_id: ::prost::alloc::string::String,
192}
193#[derive(Clone, Copy, PartialEq, ::prost::Message)]
194pub struct ListChannelsRequest {}
195#[derive(Clone, PartialEq, ::prost::Message)]
196pub struct ListChannelsResponse {
197    /// IDs of the channels available in the control plane
198    #[prost(string, repeated, tag = "1")]
199    pub channel_id: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
200}
201#[derive(Clone, PartialEq, ::prost::Message)]
202pub struct ListParticipantsRequest {
203    /// ID of the channel
204    #[prost(string, tag = "1")]
205    pub channel_id: ::prost::alloc::string::String,
206}
207#[derive(Clone, PartialEq, ::prost::Message)]
208pub struct ListParticipantsResponse {
209    /// list of participants in the channel
210    #[prost(string, repeated, tag = "1")]
211    pub participant_id: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
212}
213#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
214#[repr(i32)]
215pub enum ConnectionType {
216    Local = 0,
217    Remote = 1,
218}
219impl ConnectionType {
220    /// String value of the enum field names used in the ProtoBuf definition.
221    ///
222    /// The values are not transformed in any way and thus are considered stable
223    /// (if the ProtoBuf definition does not change) and safe for programmatic use.
224    pub fn as_str_name(&self) -> &'static str {
225        match self {
226            Self::Local => "CONNECTION_TYPE_LOCAL",
227            Self::Remote => "CONNECTION_TYPE_REMOTE",
228        }
229    }
230    /// Creates an enum from field names used in the ProtoBuf definition.
231    pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
232        match value {
233            "CONNECTION_TYPE_LOCAL" => Some(Self::Local),
234            "CONNECTION_TYPE_REMOTE" => Some(Self::Remote),
235            _ => None,
236        }
237    }
238}
239/// Generated client implementations.
240pub mod controller_service_client {
241    #![allow(
242        unused_variables,
243        dead_code,
244        missing_docs,
245        clippy::wildcard_imports,
246        clippy::let_unit_value,
247    )]
248    use tonic::codegen::*;
249    use tonic::codegen::http::Uri;
250    #[derive(Debug, Clone)]
251    pub struct ControllerServiceClient<T> {
252        inner: tonic::client::Grpc<T>,
253    }
254    impl ControllerServiceClient<tonic::transport::Channel> {
255        /// Attempt to create a new client by connecting to a given endpoint.
256        pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
257        where
258            D: TryInto<tonic::transport::Endpoint>,
259            D::Error: Into<StdError>,
260        {
261            let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
262            Ok(Self::new(conn))
263        }
264    }
265    impl<T> ControllerServiceClient<T>
266    where
267        T: tonic::client::GrpcService<tonic::body::Body>,
268        T::Error: Into<StdError>,
269        T::ResponseBody: Body<Data = Bytes> + std::marker::Send + 'static,
270        <T::ResponseBody as Body>::Error: Into<StdError> + std::marker::Send,
271    {
272        pub fn new(inner: T) -> Self {
273            let inner = tonic::client::Grpc::new(inner);
274            Self { inner }
275        }
276        pub fn with_origin(inner: T, origin: Uri) -> Self {
277            let inner = tonic::client::Grpc::with_origin(inner, origin);
278            Self { inner }
279        }
280        pub fn with_interceptor<F>(
281            inner: T,
282            interceptor: F,
283        ) -> ControllerServiceClient<InterceptedService<T, F>>
284        where
285            F: tonic::service::Interceptor,
286            T::ResponseBody: Default,
287            T: tonic::codegen::Service<
288                http::Request<tonic::body::Body>,
289                Response = http::Response<
290                    <T as tonic::client::GrpcService<tonic::body::Body>>::ResponseBody,
291                >,
292            >,
293            <T as tonic::codegen::Service<
294                http::Request<tonic::body::Body>,
295            >>::Error: Into<StdError> + std::marker::Send + std::marker::Sync,
296        {
297            ControllerServiceClient::new(InterceptedService::new(inner, interceptor))
298        }
299        /// Compress requests with the given encoding.
300        ///
301        /// This requires the server to support it otherwise it might respond with an
302        /// error.
303        #[must_use]
304        pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
305            self.inner = self.inner.send_compressed(encoding);
306            self
307        }
308        /// Enable decompressing responses.
309        #[must_use]
310        pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
311            self.inner = self.inner.accept_compressed(encoding);
312            self
313        }
314        /// Limits the maximum size of a decoded message.
315        ///
316        /// Default: `4MB`
317        #[must_use]
318        pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
319            self.inner = self.inner.max_decoding_message_size(limit);
320            self
321        }
322        /// Limits the maximum size of an encoded message.
323        ///
324        /// Default: `usize::MAX`
325        #[must_use]
326        pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
327            self.inner = self.inner.max_encoding_message_size(limit);
328            self
329        }
330        pub async fn open_control_channel(
331            &mut self,
332            request: impl tonic::IntoStreamingRequest<Message = super::ControlMessage>,
333        ) -> std::result::Result<
334            tonic::Response<tonic::codec::Streaming<super::ControlMessage>>,
335            tonic::Status,
336        > {
337            self.inner
338                .ready()
339                .await
340                .map_err(|e| {
341                    tonic::Status::unknown(
342                        format!("Service was not ready: {}", e.into()),
343                    )
344                })?;
345            let codec = tonic::codec::ProstCodec::default();
346            let path = http::uri::PathAndQuery::from_static(
347                "/controller.proto.v1.ControllerService/OpenControlChannel",
348            );
349            let mut req = request.into_streaming_request();
350            req.extensions_mut()
351                .insert(
352                    GrpcMethod::new(
353                        "controller.proto.v1.ControllerService",
354                        "OpenControlChannel",
355                    ),
356                );
357            self.inner.streaming(req, path, codec).await
358        }
359    }
360}
361/// Generated server implementations.
362pub mod controller_service_server {
363    #![allow(
364        unused_variables,
365        dead_code,
366        missing_docs,
367        clippy::wildcard_imports,
368        clippy::let_unit_value,
369    )]
370    use tonic::codegen::*;
371    /// Generated trait containing gRPC methods that should be implemented for use with ControllerServiceServer.
372    #[async_trait]
373    pub trait ControllerService: std::marker::Send + std::marker::Sync + 'static {
374        /// Server streaming response type for the OpenControlChannel method.
375        type OpenControlChannelStream: tonic::codegen::tokio_stream::Stream<
376                Item = std::result::Result<super::ControlMessage, tonic::Status>,
377            >
378            + std::marker::Send
379            + 'static;
380        async fn open_control_channel(
381            &self,
382            request: tonic::Request<tonic::Streaming<super::ControlMessage>>,
383        ) -> std::result::Result<
384            tonic::Response<Self::OpenControlChannelStream>,
385            tonic::Status,
386        >;
387    }
388    #[derive(Debug)]
389    pub struct ControllerServiceServer<T> {
390        inner: Arc<T>,
391        accept_compression_encodings: EnabledCompressionEncodings,
392        send_compression_encodings: EnabledCompressionEncodings,
393        max_decoding_message_size: Option<usize>,
394        max_encoding_message_size: Option<usize>,
395    }
396    impl<T> ControllerServiceServer<T> {
397        pub fn new(inner: T) -> Self {
398            Self::from_arc(Arc::new(inner))
399        }
400        pub fn from_arc(inner: Arc<T>) -> Self {
401            Self {
402                inner,
403                accept_compression_encodings: Default::default(),
404                send_compression_encodings: Default::default(),
405                max_decoding_message_size: None,
406                max_encoding_message_size: None,
407            }
408        }
409        pub fn with_interceptor<F>(
410            inner: T,
411            interceptor: F,
412        ) -> InterceptedService<Self, F>
413        where
414            F: tonic::service::Interceptor,
415        {
416            InterceptedService::new(Self::new(inner), interceptor)
417        }
418        /// Enable decompressing requests with the given encoding.
419        #[must_use]
420        pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
421            self.accept_compression_encodings.enable(encoding);
422            self
423        }
424        /// Compress responses with the given encoding, if the client supports it.
425        #[must_use]
426        pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
427            self.send_compression_encodings.enable(encoding);
428            self
429        }
430        /// Limits the maximum size of a decoded message.
431        ///
432        /// Default: `4MB`
433        #[must_use]
434        pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
435            self.max_decoding_message_size = Some(limit);
436            self
437        }
438        /// Limits the maximum size of an encoded message.
439        ///
440        /// Default: `usize::MAX`
441        #[must_use]
442        pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
443            self.max_encoding_message_size = Some(limit);
444            self
445        }
446    }
447    impl<T, B> tonic::codegen::Service<http::Request<B>> for ControllerServiceServer<T>
448    where
449        T: ControllerService,
450        B: Body + std::marker::Send + 'static,
451        B::Error: Into<StdError> + std::marker::Send + 'static,
452    {
453        type Response = http::Response<tonic::body::Body>;
454        type Error = std::convert::Infallible;
455        type Future = BoxFuture<Self::Response, Self::Error>;
456        fn poll_ready(
457            &mut self,
458            _cx: &mut Context<'_>,
459        ) -> Poll<std::result::Result<(), Self::Error>> {
460            Poll::Ready(Ok(()))
461        }
462        fn call(&mut self, req: http::Request<B>) -> Self::Future {
463            match req.uri().path() {
464                "/controller.proto.v1.ControllerService/OpenControlChannel" => {
465                    #[allow(non_camel_case_types)]
466                    struct OpenControlChannelSvc<T: ControllerService>(pub Arc<T>);
467                    impl<
468                        T: ControllerService,
469                    > tonic::server::StreamingService<super::ControlMessage>
470                    for OpenControlChannelSvc<T> {
471                        type Response = super::ControlMessage;
472                        type ResponseStream = T::OpenControlChannelStream;
473                        type Future = BoxFuture<
474                            tonic::Response<Self::ResponseStream>,
475                            tonic::Status,
476                        >;
477                        fn call(
478                            &mut self,
479                            request: tonic::Request<
480                                tonic::Streaming<super::ControlMessage>,
481                            >,
482                        ) -> Self::Future {
483                            let inner = Arc::clone(&self.0);
484                            let fut = async move {
485                                <T as ControllerService>::open_control_channel(
486                                        &inner,
487                                        request,
488                                    )
489                                    .await
490                            };
491                            Box::pin(fut)
492                        }
493                    }
494                    let accept_compression_encodings = self.accept_compression_encodings;
495                    let send_compression_encodings = self.send_compression_encodings;
496                    let max_decoding_message_size = self.max_decoding_message_size;
497                    let max_encoding_message_size = self.max_encoding_message_size;
498                    let inner = self.inner.clone();
499                    let fut = async move {
500                        let method = OpenControlChannelSvc(inner);
501                        let codec = tonic::codec::ProstCodec::default();
502                        let mut grpc = tonic::server::Grpc::new(codec)
503                            .apply_compression_config(
504                                accept_compression_encodings,
505                                send_compression_encodings,
506                            )
507                            .apply_max_message_size_config(
508                                max_decoding_message_size,
509                                max_encoding_message_size,
510                            );
511                        let res = grpc.streaming(method, req).await;
512                        Ok(res)
513                    };
514                    Box::pin(fut)
515                }
516                _ => {
517                    Box::pin(async move {
518                        let mut response = http::Response::new(
519                            tonic::body::Body::default(),
520                        );
521                        let headers = response.headers_mut();
522                        headers
523                            .insert(
524                                tonic::Status::GRPC_STATUS,
525                                (tonic::Code::Unimplemented as i32).into(),
526                            );
527                        headers
528                            .insert(
529                                http::header::CONTENT_TYPE,
530                                tonic::metadata::GRPC_CONTENT_TYPE,
531                            );
532                        Ok(response)
533                    })
534                }
535            }
536        }
537    }
538    impl<T> Clone for ControllerServiceServer<T> {
539        fn clone(&self) -> Self {
540            let inner = self.inner.clone();
541            Self {
542                inner,
543                accept_compression_encodings: self.accept_compression_encodings,
544                send_compression_encodings: self.send_compression_encodings,
545                max_decoding_message_size: self.max_decoding_message_size,
546                max_encoding_message_size: self.max_encoding_message_size,
547            }
548        }
549    }
550    /// Generated gRPC service name
551    pub const SERVICE_NAME: &str = "controller.proto.v1.ControllerService";
552    impl<T> tonic::server::NamedService for ControllerServiceServer<T> {
553        const NAME: &'static str = SERVICE_NAME;
554    }
555}