Skip to main content

nominal_api_proto/proto/
nominal.sql.v1.rs

1// This file is @generated by prost-build.
2#[derive(Clone, PartialEq, ::prost::Message)]
3pub struct SqlQueryLogEvent {
4    #[prost(string, tag = "1")]
5    pub query_id: ::prost::alloc::string::String,
6    #[prost(enumeration = "SqlQueryEventType", tag = "2")]
7    pub event_type: i32,
8    #[prost(string, tag = "3")]
9    pub workspace_rid: ::prost::alloc::string::String,
10    #[prost(string, tag = "4")]
11    pub user_rid: ::prost::alloc::string::String,
12    #[prost(enumeration = "SqlQueryBackend", repeated, tag = "5")]
13    pub backends: ::prost::alloc::vec::Vec<i32>,
14    #[prost(enumeration = "SqlQueryStatus", optional, tag = "6")]
15    pub status: ::core::option::Option<i32>,
16    #[prost(string, tag = "7")]
17    pub query_text: ::prost::alloc::string::String,
18    #[prost(message, optional, tag = "8")]
19    pub event_time: ::core::option::Option<
20        super::super::super::google::protobuf::Timestamp,
21    >,
22    #[prost(message, optional, tag = "9")]
23    pub started_at: ::core::option::Option<
24        super::super::super::google::protobuf::Timestamp,
25    >,
26    #[prost(message, optional, tag = "10")]
27    pub finished_at: ::core::option::Option<
28        super::super::super::google::protobuf::Timestamp,
29    >,
30    #[prost(int64, optional, tag = "11")]
31    pub duration_ms: ::core::option::Option<i64>,
32}
33#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
34#[repr(i32)]
35pub enum SqlQueryEventType {
36    QueryStart = 0,
37    QueryFinish = 1,
38}
39impl SqlQueryEventType {
40    /// String value of the enum field names used in the ProtoBuf definition.
41    ///
42    /// The values are not transformed in any way and thus are considered stable
43    /// (if the ProtoBuf definition does not change) and safe for programmatic use.
44    pub fn as_str_name(&self) -> &'static str {
45        match self {
46            Self::QueryStart => "SQL_QUERY_EVENT_TYPE_QUERY_START",
47            Self::QueryFinish => "SQL_QUERY_EVENT_TYPE_QUERY_FINISH",
48        }
49    }
50    /// Creates an enum from field names used in the ProtoBuf definition.
51    pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
52        match value {
53            "SQL_QUERY_EVENT_TYPE_QUERY_START" => Some(Self::QueryStart),
54            "SQL_QUERY_EVENT_TYPE_QUERY_FINISH" => Some(Self::QueryFinish),
55            _ => None,
56        }
57    }
58}
59#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
60#[repr(i32)]
61pub enum SqlQueryBackend {
62    Clickhouse = 0,
63    Postgres = 1,
64}
65impl SqlQueryBackend {
66    /// String value of the enum field names used in the ProtoBuf definition.
67    ///
68    /// The values are not transformed in any way and thus are considered stable
69    /// (if the ProtoBuf definition does not change) and safe for programmatic use.
70    pub fn as_str_name(&self) -> &'static str {
71        match self {
72            Self::Clickhouse => "SQL_QUERY_BACKEND_CLICKHOUSE",
73            Self::Postgres => "SQL_QUERY_BACKEND_POSTGRES",
74        }
75    }
76    /// Creates an enum from field names used in the ProtoBuf definition.
77    pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
78        match value {
79            "SQL_QUERY_BACKEND_CLICKHOUSE" => Some(Self::Clickhouse),
80            "SQL_QUERY_BACKEND_POSTGRES" => Some(Self::Postgres),
81            _ => None,
82        }
83    }
84}
85#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
86#[repr(i32)]
87pub enum SqlQueryStatus {
88    Succeeded = 0,
89    Failed = 1,
90    Throttled = 2,
91    TimedOut = 3,
92}
93impl SqlQueryStatus {
94    /// String value of the enum field names used in the ProtoBuf definition.
95    ///
96    /// The values are not transformed in any way and thus are considered stable
97    /// (if the ProtoBuf definition does not change) and safe for programmatic use.
98    pub fn as_str_name(&self) -> &'static str {
99        match self {
100            Self::Succeeded => "SQL_QUERY_STATUS_SUCCEEDED",
101            Self::Failed => "SQL_QUERY_STATUS_FAILED",
102            Self::Throttled => "SQL_QUERY_STATUS_THROTTLED",
103            Self::TimedOut => "SQL_QUERY_STATUS_TIMED_OUT",
104        }
105    }
106    /// Creates an enum from field names used in the ProtoBuf definition.
107    pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
108        match value {
109            "SQL_QUERY_STATUS_SUCCEEDED" => Some(Self::Succeeded),
110            "SQL_QUERY_STATUS_FAILED" => Some(Self::Failed),
111            "SQL_QUERY_STATUS_THROTTLED" => Some(Self::Throttled),
112            "SQL_QUERY_STATUS_TIMED_OUT" => Some(Self::TimedOut),
113            _ => None,
114        }
115    }
116}
117#[derive(Clone, PartialEq, ::prost::Message)]
118pub struct SqlServiceQueryRequest {
119    #[prost(string, tag = "1")]
120    pub query: ::prost::alloc::string::String,
121    #[prost(int32, optional, tag = "2")]
122    pub max_rows: ::core::option::Option<i32>,
123    #[prost(string, tag = "3")]
124    pub workspace_rid: ::prost::alloc::string::String,
125}
126#[derive(Clone, PartialEq, ::prost::Message)]
127pub struct SqlServiceQueryResponse {
128    #[prost(bytes = "vec", tag = "1")]
129    pub arrow_payload: ::prost::alloc::vec::Vec<u8>,
130    #[prost(string, tag = "2")]
131    pub query_id: ::prost::alloc::string::String,
132}
133#[derive(Clone, PartialEq, ::prost::Message)]
134pub struct SqlServiceExportRequest {
135    #[prost(string, tag = "1")]
136    pub query: ::prost::alloc::string::String,
137    #[prost(string, tag = "2")]
138    pub workspace_rid: ::prost::alloc::string::String,
139}
140#[derive(Clone, PartialEq, ::prost::Message)]
141pub struct SqlServiceExportResponse {
142    #[prost(string, tag = "1")]
143    pub presigned_url: ::prost::alloc::string::String,
144    #[prost(string, tag = "2")]
145    pub query_id: ::prost::alloc::string::String,
146}
147#[derive(Clone, Copy, PartialEq, ::prost::Message)]
148pub struct GetSqlCatalogRequest {}
149#[derive(Clone, PartialEq, ::prost::Message)]
150pub struct SqlCatalogColumn {
151    #[prost(string, tag = "1")]
152    pub name: ::prost::alloc::string::String,
153    #[prost(string, tag = "2")]
154    pub r#type: ::prost::alloc::string::String,
155    #[prost(bool, tag = "3")]
156    pub nullable: bool,
157}
158#[derive(Clone, PartialEq, ::prost::Message)]
159pub struct SqlCatalogTable {
160    #[prost(string, tag = "1")]
161    pub name: ::prost::alloc::string::String,
162    #[prost(message, repeated, tag = "2")]
163    pub columns: ::prost::alloc::vec::Vec<SqlCatalogColumn>,
164}
165#[derive(Clone, PartialEq, ::prost::Message)]
166pub struct SqlCatalogFunction {
167    #[prost(string, tag = "1")]
168    pub name: ::prost::alloc::string::String,
169}
170#[derive(Clone, PartialEq, ::prost::Message)]
171pub struct SqlCatalog {
172    #[prost(message, repeated, tag = "1")]
173    pub tables: ::prost::alloc::vec::Vec<SqlCatalogTable>,
174    #[prost(message, repeated, tag = "2")]
175    pub functions: ::prost::alloc::vec::Vec<SqlCatalogFunction>,
176}
177#[derive(Clone, PartialEq, ::prost::Message)]
178pub struct GetSqlCatalogResponse {
179    #[prost(message, optional, tag = "1")]
180    pub sql_catalog: ::core::option::Option<SqlCatalog>,
181}
182#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
183#[repr(i32)]
184pub enum SqlError {
185    Unspecified = 0,
186    InvalidQuery = 1,
187    DatasetsNotFound = 2,
188    ExecutionFailed = 3,
189    ExportNotSupportedForBackend = 4,
190    ExportNotConfigured = 5,
191    QueryTimeout = 6,
192    ResourceExhausted = 7,
193    DatasetStorageTypeNotSupported = 8,
194}
195impl SqlError {
196    /// String value of the enum field names used in the ProtoBuf definition.
197    ///
198    /// The values are not transformed in any way and thus are considered stable
199    /// (if the ProtoBuf definition does not change) and safe for programmatic use.
200    pub fn as_str_name(&self) -> &'static str {
201        match self {
202            Self::Unspecified => "SQL_ERROR_UNSPECIFIED",
203            Self::InvalidQuery => "SQL_ERROR_INVALID_QUERY",
204            Self::DatasetsNotFound => "SQL_ERROR_DATASETS_NOT_FOUND",
205            Self::ExecutionFailed => "SQL_ERROR_EXECUTION_FAILED",
206            Self::ExportNotSupportedForBackend => {
207                "SQL_ERROR_EXPORT_NOT_SUPPORTED_FOR_BACKEND"
208            }
209            Self::ExportNotConfigured => "SQL_ERROR_EXPORT_NOT_CONFIGURED",
210            Self::QueryTimeout => "SQL_ERROR_QUERY_TIMEOUT",
211            Self::ResourceExhausted => "SQL_ERROR_RESOURCE_EXHAUSTED",
212            Self::DatasetStorageTypeNotSupported => {
213                "SQL_ERROR_DATASET_STORAGE_TYPE_NOT_SUPPORTED"
214            }
215        }
216    }
217    /// Creates an enum from field names used in the ProtoBuf definition.
218    pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
219        match value {
220            "SQL_ERROR_UNSPECIFIED" => Some(Self::Unspecified),
221            "SQL_ERROR_INVALID_QUERY" => Some(Self::InvalidQuery),
222            "SQL_ERROR_DATASETS_NOT_FOUND" => Some(Self::DatasetsNotFound),
223            "SQL_ERROR_EXECUTION_FAILED" => Some(Self::ExecutionFailed),
224            "SQL_ERROR_EXPORT_NOT_SUPPORTED_FOR_BACKEND" => {
225                Some(Self::ExportNotSupportedForBackend)
226            }
227            "SQL_ERROR_EXPORT_NOT_CONFIGURED" => Some(Self::ExportNotConfigured),
228            "SQL_ERROR_QUERY_TIMEOUT" => Some(Self::QueryTimeout),
229            "SQL_ERROR_RESOURCE_EXHAUSTED" => Some(Self::ResourceExhausted),
230            "SQL_ERROR_DATASET_STORAGE_TYPE_NOT_SUPPORTED" => {
231                Some(Self::DatasetStorageTypeNotSupported)
232            }
233            _ => None,
234        }
235    }
236}
237/// Generated client implementations.
238pub mod sql_service_client {
239    #![allow(
240        unused_variables,
241        dead_code,
242        missing_docs,
243        clippy::wildcard_imports,
244        clippy::let_unit_value,
245    )]
246    use tonic::codegen::*;
247    use tonic::codegen::http::Uri;
248    #[derive(Debug, Clone)]
249    pub struct SqlServiceClient<T> {
250        inner: tonic::client::Grpc<T>,
251    }
252    impl SqlServiceClient<tonic::transport::Channel> {
253        /// Attempt to create a new client by connecting to a given endpoint.
254        pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
255        where
256            D: TryInto<tonic::transport::Endpoint>,
257            D::Error: Into<StdError>,
258        {
259            let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
260            Ok(Self::new(conn))
261        }
262    }
263    impl<T> SqlServiceClient<T>
264    where
265        T: tonic::client::GrpcService<tonic::body::Body>,
266        T::Error: Into<StdError>,
267        T::ResponseBody: Body<Data = Bytes> + std::marker::Send + 'static,
268        <T::ResponseBody as Body>::Error: Into<StdError> + std::marker::Send,
269    {
270        pub fn new(inner: T) -> Self {
271            let inner = tonic::client::Grpc::new(inner);
272            Self { inner }
273        }
274        pub fn with_origin(inner: T, origin: Uri) -> Self {
275            let inner = tonic::client::Grpc::with_origin(inner, origin);
276            Self { inner }
277        }
278        pub fn with_interceptor<F>(
279            inner: T,
280            interceptor: F,
281        ) -> SqlServiceClient<InterceptedService<T, F>>
282        where
283            F: tonic::service::Interceptor,
284            T::ResponseBody: Default,
285            T: tonic::codegen::Service<
286                http::Request<tonic::body::Body>,
287                Response = http::Response<
288                    <T as tonic::client::GrpcService<tonic::body::Body>>::ResponseBody,
289                >,
290            >,
291            <T as tonic::codegen::Service<
292                http::Request<tonic::body::Body>,
293            >>::Error: Into<StdError> + std::marker::Send + std::marker::Sync,
294        {
295            SqlServiceClient::new(InterceptedService::new(inner, interceptor))
296        }
297        /// Compress requests with the given encoding.
298        ///
299        /// This requires the server to support it otherwise it might respond with an
300        /// error.
301        #[must_use]
302        pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
303            self.inner = self.inner.send_compressed(encoding);
304            self
305        }
306        /// Enable decompressing responses.
307        #[must_use]
308        pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
309            self.inner = self.inner.accept_compressed(encoding);
310            self
311        }
312        /// Limits the maximum size of a decoded message.
313        ///
314        /// Default: `4MB`
315        #[must_use]
316        pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
317            self.inner = self.inner.max_decoding_message_size(limit);
318            self
319        }
320        /// Limits the maximum size of an encoded message.
321        ///
322        /// Default: `usize::MAX`
323        #[must_use]
324        pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
325            self.inner = self.inner.max_encoding_message_size(limit);
326            self
327        }
328        pub async fn query(
329            &mut self,
330            request: impl tonic::IntoRequest<super::SqlServiceQueryRequest>,
331        ) -> std::result::Result<
332            tonic::Response<tonic::codec::Streaming<super::SqlServiceQueryResponse>>,
333            tonic::Status,
334        > {
335            self.inner
336                .ready()
337                .await
338                .map_err(|e| {
339                    tonic::Status::unknown(
340                        format!("Service was not ready: {}", e.into()),
341                    )
342                })?;
343            let codec = tonic::codec::ProstCodec::default();
344            let path = http::uri::PathAndQuery::from_static(
345                "/nominal.sql.v1.SqlService/Query",
346            );
347            let mut req = request.into_request();
348            req.extensions_mut()
349                .insert(GrpcMethod::new("nominal.sql.v1.SqlService", "Query"));
350            self.inner.server_streaming(req, path, codec).await
351        }
352        pub async fn export(
353            &mut self,
354            request: impl tonic::IntoRequest<super::SqlServiceExportRequest>,
355        ) -> std::result::Result<
356            tonic::Response<super::SqlServiceExportResponse>,
357            tonic::Status,
358        > {
359            self.inner
360                .ready()
361                .await
362                .map_err(|e| {
363                    tonic::Status::unknown(
364                        format!("Service was not ready: {}", e.into()),
365                    )
366                })?;
367            let codec = tonic::codec::ProstCodec::default();
368            let path = http::uri::PathAndQuery::from_static(
369                "/nominal.sql.v1.SqlService/Export",
370            );
371            let mut req = request.into_request();
372            req.extensions_mut()
373                .insert(GrpcMethod::new("nominal.sql.v1.SqlService", "Export"));
374            self.inner.unary(req, path, codec).await
375        }
376        pub async fn get_sql_catalog(
377            &mut self,
378            request: impl tonic::IntoRequest<super::GetSqlCatalogRequest>,
379        ) -> std::result::Result<
380            tonic::Response<super::GetSqlCatalogResponse>,
381            tonic::Status,
382        > {
383            self.inner
384                .ready()
385                .await
386                .map_err(|e| {
387                    tonic::Status::unknown(
388                        format!("Service was not ready: {}", e.into()),
389                    )
390                })?;
391            let codec = tonic::codec::ProstCodec::default();
392            let path = http::uri::PathAndQuery::from_static(
393                "/nominal.sql.v1.SqlService/GetSqlCatalog",
394            );
395            let mut req = request.into_request();
396            req.extensions_mut()
397                .insert(GrpcMethod::new("nominal.sql.v1.SqlService", "GetSqlCatalog"));
398            self.inner.unary(req, path, codec).await
399        }
400    }
401}