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