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    #[prost(enumeration = "SqlServiceQueryResultFormat", tag = "4")]
126    pub result_format: i32,
127}
128#[derive(Clone, PartialEq, ::prost::Message)]
129pub struct SqlServiceQueryResponse {
130    #[deprecated]
131    #[prost(bytes = "vec", tag = "1")]
132    pub arrow_payload: ::prost::alloc::vec::Vec<u8>,
133    #[prost(string, tag = "2")]
134    pub query_id: ::prost::alloc::string::String,
135    #[prost(bytes = "vec", tag = "3")]
136    pub payload: ::prost::alloc::vec::Vec<u8>,
137}
138#[derive(Clone, PartialEq, ::prost::Message)]
139pub struct SqlServiceExportRequest {
140    #[prost(string, tag = "1")]
141    pub query: ::prost::alloc::string::String,
142    #[prost(string, tag = "2")]
143    pub workspace_rid: ::prost::alloc::string::String,
144}
145#[derive(Clone, PartialEq, ::prost::Message)]
146pub struct SqlServiceExportResponse {
147    #[prost(string, tag = "1")]
148    pub presigned_url: ::prost::alloc::string::String,
149    #[prost(string, tag = "2")]
150    pub query_id: ::prost::alloc::string::String,
151}
152#[derive(Clone, Copy, PartialEq, ::prost::Message)]
153pub struct GetSqlCatalogRequest {}
154#[derive(Clone, PartialEq, ::prost::Message)]
155pub struct SqlCatalogColumn {
156    #[prost(string, tag = "1")]
157    pub name: ::prost::alloc::string::String,
158    #[prost(string, tag = "2")]
159    pub r#type: ::prost::alloc::string::String,
160    #[prost(bool, tag = "3")]
161    pub nullable: bool,
162}
163#[derive(Clone, PartialEq, ::prost::Message)]
164pub struct SqlCatalogTable {
165    #[prost(string, tag = "1")]
166    pub name: ::prost::alloc::string::String,
167    #[prost(message, repeated, tag = "2")]
168    pub columns: ::prost::alloc::vec::Vec<SqlCatalogColumn>,
169}
170#[derive(Clone, PartialEq, ::prost::Message)]
171pub struct SqlCatalogFunction {
172    #[prost(string, tag = "1")]
173    pub name: ::prost::alloc::string::String,
174}
175#[derive(Clone, PartialEq, ::prost::Message)]
176pub struct SqlCatalog {
177    #[prost(message, repeated, tag = "1")]
178    pub tables: ::prost::alloc::vec::Vec<SqlCatalogTable>,
179    #[prost(message, repeated, tag = "2")]
180    pub functions: ::prost::alloc::vec::Vec<SqlCatalogFunction>,
181}
182#[derive(Clone, PartialEq, ::prost::Message)]
183pub struct GetSqlCatalogResponse {
184    #[prost(message, optional, tag = "1")]
185    pub sql_catalog: ::core::option::Option<SqlCatalog>,
186}
187#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
188#[repr(i32)]
189pub enum SqlError {
190    Unspecified = 0,
191    InvalidQuery = 1,
192    DatasetsNotFound = 2,
193    ExecutionFailed = 3,
194    ExportNotSupportedForBackend = 4,
195    ExportNotConfigured = 5,
196    QueryTimeout = 6,
197    ResourceExhausted = 7,
198    DatasetStorageTypeNotSupported = 8,
199    DataNotFoundForType = 9,
200}
201impl SqlError {
202    /// String value of the enum field names used in the ProtoBuf definition.
203    ///
204    /// The values are not transformed in any way and thus are considered stable
205    /// (if the ProtoBuf definition does not change) and safe for programmatic use.
206    pub fn as_str_name(&self) -> &'static str {
207        match self {
208            Self::Unspecified => "SQL_ERROR_UNSPECIFIED",
209            Self::InvalidQuery => "SQL_ERROR_INVALID_QUERY",
210            Self::DatasetsNotFound => "SQL_ERROR_DATASETS_NOT_FOUND",
211            Self::ExecutionFailed => "SQL_ERROR_EXECUTION_FAILED",
212            Self::ExportNotSupportedForBackend => {
213                "SQL_ERROR_EXPORT_NOT_SUPPORTED_FOR_BACKEND"
214            }
215            Self::ExportNotConfigured => "SQL_ERROR_EXPORT_NOT_CONFIGURED",
216            Self::QueryTimeout => "SQL_ERROR_QUERY_TIMEOUT",
217            Self::ResourceExhausted => "SQL_ERROR_RESOURCE_EXHAUSTED",
218            Self::DatasetStorageTypeNotSupported => {
219                "SQL_ERROR_DATASET_STORAGE_TYPE_NOT_SUPPORTED"
220            }
221            Self::DataNotFoundForType => "SQL_ERROR_DATA_NOT_FOUND_FOR_TYPE",
222        }
223    }
224    /// Creates an enum from field names used in the ProtoBuf definition.
225    pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
226        match value {
227            "SQL_ERROR_UNSPECIFIED" => Some(Self::Unspecified),
228            "SQL_ERROR_INVALID_QUERY" => Some(Self::InvalidQuery),
229            "SQL_ERROR_DATASETS_NOT_FOUND" => Some(Self::DatasetsNotFound),
230            "SQL_ERROR_EXECUTION_FAILED" => Some(Self::ExecutionFailed),
231            "SQL_ERROR_EXPORT_NOT_SUPPORTED_FOR_BACKEND" => {
232                Some(Self::ExportNotSupportedForBackend)
233            }
234            "SQL_ERROR_EXPORT_NOT_CONFIGURED" => Some(Self::ExportNotConfigured),
235            "SQL_ERROR_QUERY_TIMEOUT" => Some(Self::QueryTimeout),
236            "SQL_ERROR_RESOURCE_EXHAUSTED" => Some(Self::ResourceExhausted),
237            "SQL_ERROR_DATASET_STORAGE_TYPE_NOT_SUPPORTED" => {
238                Some(Self::DatasetStorageTypeNotSupported)
239            }
240            "SQL_ERROR_DATA_NOT_FOUND_FOR_TYPE" => Some(Self::DataNotFoundForType),
241            _ => None,
242        }
243    }
244}
245#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
246#[repr(i32)]
247pub enum SqlServiceQueryResultFormat {
248    Unspecified = 0,
249    ArrowStream = 1,
250    JsonLines = 2,
251    Csv = 3,
252}
253impl SqlServiceQueryResultFormat {
254    /// String value of the enum field names used in the ProtoBuf definition.
255    ///
256    /// The values are not transformed in any way and thus are considered stable
257    /// (if the ProtoBuf definition does not change) and safe for programmatic use.
258    pub fn as_str_name(&self) -> &'static str {
259        match self {
260            Self::Unspecified => "SQL_SERVICE_QUERY_RESULT_FORMAT_UNSPECIFIED",
261            Self::ArrowStream => "SQL_SERVICE_QUERY_RESULT_FORMAT_ARROW_STREAM",
262            Self::JsonLines => "SQL_SERVICE_QUERY_RESULT_FORMAT_JSON_LINES",
263            Self::Csv => "SQL_SERVICE_QUERY_RESULT_FORMAT_CSV",
264        }
265    }
266    /// Creates an enum from field names used in the ProtoBuf definition.
267    pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
268        match value {
269            "SQL_SERVICE_QUERY_RESULT_FORMAT_UNSPECIFIED" => Some(Self::Unspecified),
270            "SQL_SERVICE_QUERY_RESULT_FORMAT_ARROW_STREAM" => Some(Self::ArrowStream),
271            "SQL_SERVICE_QUERY_RESULT_FORMAT_JSON_LINES" => Some(Self::JsonLines),
272            "SQL_SERVICE_QUERY_RESULT_FORMAT_CSV" => Some(Self::Csv),
273            _ => None,
274        }
275    }
276}
277/// Generated client implementations.
278pub mod sql_service_client {
279    #![allow(
280        unused_variables,
281        dead_code,
282        missing_docs,
283        clippy::wildcard_imports,
284        clippy::let_unit_value,
285    )]
286    use tonic::codegen::*;
287    use tonic::codegen::http::Uri;
288    #[derive(Debug, Clone)]
289    pub struct SqlServiceClient<T> {
290        inner: tonic::client::Grpc<T>,
291    }
292    impl SqlServiceClient<tonic::transport::Channel> {
293        /// Attempt to create a new client by connecting to a given endpoint.
294        pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
295        where
296            D: TryInto<tonic::transport::Endpoint>,
297            D::Error: Into<StdError>,
298        {
299            let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
300            Ok(Self::new(conn))
301        }
302    }
303    impl<T> SqlServiceClient<T>
304    where
305        T: tonic::client::GrpcService<tonic::body::Body>,
306        T::Error: Into<StdError>,
307        T::ResponseBody: Body<Data = Bytes> + std::marker::Send + 'static,
308        <T::ResponseBody as Body>::Error: Into<StdError> + std::marker::Send,
309    {
310        pub fn new(inner: T) -> Self {
311            let inner = tonic::client::Grpc::new(inner);
312            Self { inner }
313        }
314        pub fn with_origin(inner: T, origin: Uri) -> Self {
315            let inner = tonic::client::Grpc::with_origin(inner, origin);
316            Self { inner }
317        }
318        pub fn with_interceptor<F>(
319            inner: T,
320            interceptor: F,
321        ) -> SqlServiceClient<InterceptedService<T, F>>
322        where
323            F: tonic::service::Interceptor,
324            T::ResponseBody: Default,
325            T: tonic::codegen::Service<
326                http::Request<tonic::body::Body>,
327                Response = http::Response<
328                    <T as tonic::client::GrpcService<tonic::body::Body>>::ResponseBody,
329                >,
330            >,
331            <T as tonic::codegen::Service<
332                http::Request<tonic::body::Body>,
333            >>::Error: Into<StdError> + std::marker::Send + std::marker::Sync,
334        {
335            SqlServiceClient::new(InterceptedService::new(inner, interceptor))
336        }
337        /// Compress requests with the given encoding.
338        ///
339        /// This requires the server to support it otherwise it might respond with an
340        /// error.
341        #[must_use]
342        pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
343            self.inner = self.inner.send_compressed(encoding);
344            self
345        }
346        /// Enable decompressing responses.
347        #[must_use]
348        pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
349            self.inner = self.inner.accept_compressed(encoding);
350            self
351        }
352        /// Limits the maximum size of a decoded message.
353        ///
354        /// Default: `4MB`
355        #[must_use]
356        pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
357            self.inner = self.inner.max_decoding_message_size(limit);
358            self
359        }
360        /// Limits the maximum size of an encoded message.
361        ///
362        /// Default: `usize::MAX`
363        #[must_use]
364        pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
365            self.inner = self.inner.max_encoding_message_size(limit);
366            self
367        }
368        pub async fn query(
369            &mut self,
370            request: impl tonic::IntoRequest<super::SqlServiceQueryRequest>,
371        ) -> std::result::Result<
372            tonic::Response<tonic::codec::Streaming<super::SqlServiceQueryResponse>>,
373            tonic::Status,
374        > {
375            self.inner
376                .ready()
377                .await
378                .map_err(|e| {
379                    tonic::Status::unknown(
380                        format!("Service was not ready: {}", e.into()),
381                    )
382                })?;
383            let codec = tonic::codec::ProstCodec::default();
384            let path = http::uri::PathAndQuery::from_static(
385                "/nominal.sql.v1.SqlService/Query",
386            );
387            let mut req = request.into_request();
388            req.extensions_mut()
389                .insert(GrpcMethod::new("nominal.sql.v1.SqlService", "Query"));
390            self.inner.server_streaming(req, path, codec).await
391        }
392        pub async fn export(
393            &mut self,
394            request: impl tonic::IntoRequest<super::SqlServiceExportRequest>,
395        ) -> std::result::Result<
396            tonic::Response<super::SqlServiceExportResponse>,
397            tonic::Status,
398        > {
399            self.inner
400                .ready()
401                .await
402                .map_err(|e| {
403                    tonic::Status::unknown(
404                        format!("Service was not ready: {}", e.into()),
405                    )
406                })?;
407            let codec = tonic::codec::ProstCodec::default();
408            let path = http::uri::PathAndQuery::from_static(
409                "/nominal.sql.v1.SqlService/Export",
410            );
411            let mut req = request.into_request();
412            req.extensions_mut()
413                .insert(GrpcMethod::new("nominal.sql.v1.SqlService", "Export"));
414            self.inner.unary(req, path, codec).await
415        }
416        pub async fn get_sql_catalog(
417            &mut self,
418            request: impl tonic::IntoRequest<super::GetSqlCatalogRequest>,
419        ) -> std::result::Result<
420            tonic::Response<super::GetSqlCatalogResponse>,
421            tonic::Status,
422        > {
423            self.inner
424                .ready()
425                .await
426                .map_err(|e| {
427                    tonic::Status::unknown(
428                        format!("Service was not ready: {}", e.into()),
429                    )
430                })?;
431            let codec = tonic::codec::ProstCodec::default();
432            let path = http::uri::PathAndQuery::from_static(
433                "/nominal.sql.v1.SqlService/GetSqlCatalog",
434            );
435            let mut req = request.into_request();
436            req.extensions_mut()
437                .insert(GrpcMethod::new("nominal.sql.v1.SqlService", "GetSqlCatalog"));
438            self.inner.unary(req, path, codec).await
439        }
440    }
441}