Skip to main content

nominal_api/proto/
nominal.usage_tracking.v1.rs

1// This file is @generated by prost-build.
2/// A resource-opened event.
3#[derive(Clone, PartialEq, ::prost::Message)]
4pub struct ResourceOpenedEvent {
5    /// The type of resource that was opened.
6    #[prost(enumeration = "ResourceType", tag = "1")]
7    pub resource_type: i32,
8    /// The RID of the resource that was opened.
9    #[prost(string, tag = "2")]
10    pub rid: ::prost::alloc::string::String,
11    /// Whether the current user is the creator of the resource.
12    #[prost(bool, tag = "3")]
13    pub is_creator: bool,
14}
15/// Request to track a usage event.
16#[derive(Clone, PartialEq, ::prost::Message)]
17pub struct TrackEventRequest {
18    /// The workspace in which the event occurred.
19    #[prost(string, tag = "1")]
20    pub workspace_rid: ::prost::alloc::string::String,
21    /// The event to track. Exactly one must be set.
22    #[prost(oneof = "track_event_request::Event", tags = "2")]
23    pub event: ::core::option::Option<track_event_request::Event>,
24}
25/// Nested message and enum types in `TrackEventRequest`.
26pub mod track_event_request {
27    /// The event to track. Exactly one must be set.
28    #[derive(Clone, PartialEq, ::prost::Oneof)]
29    pub enum Event {
30        #[prost(message, tag = "2")]
31        ResourceOpened(super::ResourceOpenedEvent),
32    }
33}
34/// Response for tracking a usage event.
35#[derive(Clone, Copy, PartialEq, ::prost::Message)]
36pub struct TrackEventResponse {}
37/// The type of resource involved in a usage tracking event.
38/// buf:lint:ignore ENUM_VALUE_PREFIX
39#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
40#[repr(i32)]
41pub enum ResourceType {
42    Unspecified = 0,
43    Workbook = 1,
44    Checklist = 2,
45    Procedure = 3,
46}
47impl ResourceType {
48    /// String value of the enum field names used in the ProtoBuf definition.
49    ///
50    /// The values are not transformed in any way and thus are considered stable
51    /// (if the ProtoBuf definition does not change) and safe for programmatic use.
52    pub fn as_str_name(&self) -> &'static str {
53        match self {
54            Self::Unspecified => "RESOURCE_TYPE_UNSPECIFIED",
55            Self::Workbook => "RESOURCE_TYPE_WORKBOOK",
56            Self::Checklist => "RESOURCE_TYPE_CHECKLIST",
57            Self::Procedure => "RESOURCE_TYPE_PROCEDURE",
58        }
59    }
60    /// Creates an enum from field names used in the ProtoBuf definition.
61    pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
62        match value {
63            "RESOURCE_TYPE_UNSPECIFIED" => Some(Self::Unspecified),
64            "RESOURCE_TYPE_WORKBOOK" => Some(Self::Workbook),
65            "RESOURCE_TYPE_CHECKLIST" => Some(Self::Checklist),
66            "RESOURCE_TYPE_PROCEDURE" => Some(Self::Procedure),
67            _ => None,
68        }
69    }
70}
71/// Generated client implementations.
72pub mod usage_tracking_service_client {
73    #![allow(
74        unused_variables,
75        dead_code,
76        missing_docs,
77        clippy::wildcard_imports,
78        clippy::let_unit_value,
79    )]
80    use tonic::codegen::*;
81    use tonic::codegen::http::Uri;
82    /// Service for tracking usage events from the frontend.
83    #[derive(Debug, Clone)]
84    pub struct UsageTrackingServiceClient<T> {
85        inner: tonic::client::Grpc<T>,
86    }
87    impl UsageTrackingServiceClient<tonic::transport::Channel> {
88        /// Attempt to create a new client by connecting to a given endpoint.
89        pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
90        where
91            D: TryInto<tonic::transport::Endpoint>,
92            D::Error: Into<StdError>,
93        {
94            let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
95            Ok(Self::new(conn))
96        }
97    }
98    impl<T> UsageTrackingServiceClient<T>
99    where
100        T: tonic::client::GrpcService<tonic::body::Body>,
101        T::Error: Into<StdError>,
102        T::ResponseBody: Body<Data = Bytes> + std::marker::Send + 'static,
103        <T::ResponseBody as Body>::Error: Into<StdError> + std::marker::Send,
104    {
105        pub fn new(inner: T) -> Self {
106            let inner = tonic::client::Grpc::new(inner);
107            Self { inner }
108        }
109        pub fn with_origin(inner: T, origin: Uri) -> Self {
110            let inner = tonic::client::Grpc::with_origin(inner, origin);
111            Self { inner }
112        }
113        pub fn with_interceptor<F>(
114            inner: T,
115            interceptor: F,
116        ) -> UsageTrackingServiceClient<InterceptedService<T, F>>
117        where
118            F: tonic::service::Interceptor,
119            T::ResponseBody: Default,
120            T: tonic::codegen::Service<
121                http::Request<tonic::body::Body>,
122                Response = http::Response<
123                    <T as tonic::client::GrpcService<tonic::body::Body>>::ResponseBody,
124                >,
125            >,
126            <T as tonic::codegen::Service<
127                http::Request<tonic::body::Body>,
128            >>::Error: Into<StdError> + std::marker::Send + std::marker::Sync,
129        {
130            UsageTrackingServiceClient::new(InterceptedService::new(inner, interceptor))
131        }
132        /// Compress requests with the given encoding.
133        ///
134        /// This requires the server to support it otherwise it might respond with an
135        /// error.
136        #[must_use]
137        pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
138            self.inner = self.inner.send_compressed(encoding);
139            self
140        }
141        /// Enable decompressing responses.
142        #[must_use]
143        pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
144            self.inner = self.inner.accept_compressed(encoding);
145            self
146        }
147        /// Limits the maximum size of a decoded message.
148        ///
149        /// Default: `4MB`
150        #[must_use]
151        pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
152            self.inner = self.inner.max_decoding_message_size(limit);
153            self
154        }
155        /// Limits the maximum size of an encoded message.
156        ///
157        /// Default: `usize::MAX`
158        #[must_use]
159        pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
160            self.inner = self.inner.max_encoding_message_size(limit);
161            self
162        }
163        /// Tracks a usage event. Accepts an event with associated metadata and publishes
164        /// it as an internal usage tracking metric.
165        pub async fn track_event(
166            &mut self,
167            request: impl tonic::IntoRequest<super::TrackEventRequest>,
168        ) -> std::result::Result<
169            tonic::Response<super::TrackEventResponse>,
170            tonic::Status,
171        > {
172            self.inner
173                .ready()
174                .await
175                .map_err(|e| {
176                    tonic::Status::unknown(
177                        format!("Service was not ready: {}", e.into()),
178                    )
179                })?;
180            let codec = tonic::codec::ProstCodec::default();
181            let path = http::uri::PathAndQuery::from_static(
182                "/nominal.usage_tracking.v1.UsageTrackingService/TrackEvent",
183            );
184            let mut req = request.into_request();
185            req.extensions_mut()
186                .insert(
187                    GrpcMethod::new(
188                        "nominal.usage_tracking.v1.UsageTrackingService",
189                        "TrackEvent",
190                    ),
191                );
192            self.inner.unary(req, path, codec).await
193        }
194    }
195}