// This file is @generated by prost-build.
/// Picosecond precision timestamp type, represented by an epoch time in seconds, a nanosecond offset, and optional
/// picosecond offset. The nanosecond offset is from the start of the epoch second, so must be less than 1 billion. The
/// optional picosecond offset is only used for picosecond-precision data sources and is from the start of the
/// nanosecond, so must be less than 1000.
#[derive(Clone, Copy, PartialEq, ::prost::Message)]
pub struct Timestamp {
    #[prost(int64, tag = "1")]
    pub seconds: i64,
    #[prost(int64, tag = "2")]
    pub nanos: i64,
    #[prost(int32, tag = "3")]
    pub picos: i32,
}
#[derive(Clone, Copy, PartialEq, ::prost::Message)]
pub struct Range {
    #[prost(message, optional, tag = "1")]
    pub start_time_inclusive: ::core::option::Option<Timestamp>,
    #[prost(message, optional, tag = "2")]
    pub end_time_exclusive: ::core::option::Option<Timestamp>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct TagValues {
    /// All the allowed values the tag can have. Tag values are opaque and will be passed back to the server in future
    /// calls. The values are expected to be unique.
    #[prost(string, repeated, tag = "1")]
    pub values: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ChannelMetadata {
    /// Channels are opaque values that will be passed back to the server in future calls.
    #[prost(string, tag = "1")]
    pub channel: ::prost::alloc::string::String,
    /// Every value in the channel is expected to have the same type.
    #[prost(enumeration = "DataType", tag = "2")]
    pub data_type: i32,
    /// All the possible tags and their values associated with the channel.
    #[prost(map = "string, message", tag = "3")]
    pub all_tag_values: ::std::collections::HashMap<
        ::prost::alloc::string::String,
        TagValues,
    >,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ListChannelsRequest {
    /// The max number of elements returned in the response, the actual number can be lower but should never exceed this.
    #[prost(int32, tag = "1")]
    pub page_size: i32,
    /// The time range for which we want to see channels which exist
    #[prost(message, optional, tag = "2")]
    pub range: ::core::option::Option<Range>,
    /// Where to continue paging from in subsequent requests. This will be empty on the first call.
    #[prost(string, optional, tag = "3")]
    pub page_token: ::core::option::Option<::prost::alloc::string::String>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ListChannelsResponse {
    #[prost(message, repeated, tag = "1")]
    pub channels: ::prost::alloc::vec::Vec<ChannelMetadata>,
    #[prost(string, optional, tag = "2")]
    pub page_token: ::core::option::Option<::prost::alloc::string::String>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct QueryChannelRequest {
    /// The channel should be a value that was previously returned by a ListChannels call.
    #[prost(string, tag = "1")]
    pub channel: ::prost::alloc::string::String,
    /// The tag name/value pairs to filter on.
    #[prost(map = "string, string", tag = "2")]
    pub tags: ::std::collections::HashMap<
        ::prost::alloc::string::String,
        ::prost::alloc::string::String,
    >,
    /// The time range to filter on.
    #[prost(message, optional, tag = "3")]
    pub range: ::core::option::Option<Range>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct IntPoints {
    #[prost(message, repeated, tag = "1")]
    pub timestamps: ::prost::alloc::vec::Vec<Timestamp>,
    #[prost(int64, repeated, tag = "2")]
    pub values: ::prost::alloc::vec::Vec<i64>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct DoublePoints {
    #[prost(message, repeated, tag = "1")]
    pub timestamps: ::prost::alloc::vec::Vec<Timestamp>,
    #[prost(double, repeated, tag = "2")]
    pub values: ::prost::alloc::vec::Vec<f64>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct StringPoints {
    #[prost(message, repeated, tag = "1")]
    pub timestamps: ::prost::alloc::vec::Vec<Timestamp>,
    #[prost(string, repeated, tag = "2")]
    pub values: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct QueryChannelResponse {
    #[prost(oneof = "query_channel_response::Values", tags = "1, 2, 3")]
    pub values: ::core::option::Option<query_channel_response::Values>,
}
/// Nested message and enum types in `QueryChannelResponse`.
pub mod query_channel_response {
    #[derive(Clone, PartialEq, ::prost::Oneof)]
    pub enum Values {
        #[prost(message, tag = "1")]
        Ints(super::IntPoints),
        #[prost(message, tag = "2")]
        Doubles(super::DoublePoints),
        #[prost(message, tag = "3")]
        Strings(super::StringPoints),
    }
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum DataType {
    Unspecified = 0,
    Int = 1,
    Double = 2,
    String = 3,
}
impl DataType {
    /// String value of the enum field names used in the ProtoBuf definition.
    ///
    /// The values are not transformed in any way and thus are considered stable
    /// (if the ProtoBuf definition does not change) and safe for programmatic use.
    pub fn as_str_name(&self) -> &'static str {
        match self {
            Self::Unspecified => "DATA_TYPE_UNSPECIFIED",
            Self::Int => "DATA_TYPE_INT",
            Self::Double => "DATA_TYPE_DOUBLE",
            Self::String => "DATA_TYPE_STRING",
        }
    }
    /// Creates an enum from field names used in the ProtoBuf definition.
    pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
        match value {
            "DATA_TYPE_UNSPECIFIED" => Some(Self::Unspecified),
            "DATA_TYPE_INT" => Some(Self::Int),
            "DATA_TYPE_DOUBLE" => Some(Self::Double),
            "DATA_TYPE_STRING" => Some(Self::String),
            _ => None,
        }
    }
}
/// Generated client implementations.
pub mod connections_service_client {
    #![allow(
        unused_variables,
        dead_code,
        missing_docs,
        clippy::wildcard_imports,
        clippy::let_unit_value,
    )]
    use tonic::codegen::*;
    use tonic::codegen::http::Uri;
    /// *
    /// Defines the interface for how Nominal expects to interact with custom connection implementations. All sources of
    /// time series data is abstracted by a channel identifier, allowing for flexibility of the underlying data source
    /// implementations.
    ///
    /// The authorization credentials are passed as http headers as:
    ///     "Authorization: Bearer <token>"
    #[derive(Debug, Clone)]
    pub struct ConnectionsServiceClient<T> {
        inner: tonic::client::Grpc<T>,
    }
    impl ConnectionsServiceClient<tonic::transport::Channel> {
        /// Attempt to create a new client by connecting to a given endpoint.
        pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
        where
            D: TryInto<tonic::transport::Endpoint>,
            D::Error: Into<StdError>,
        {
            let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
            Ok(Self::new(conn))
        }
    }
    impl<T> ConnectionsServiceClient<T>
    where
        T: tonic::client::GrpcService<tonic::body::Body>,
        T::Error: Into<StdError>,
        T::ResponseBody: Body<Data = Bytes> + std::marker::Send + 'static,
        <T::ResponseBody as Body>::Error: Into<StdError> + std::marker::Send,
    {
        pub fn new(inner: T) -> Self {
            let inner = tonic::client::Grpc::new(inner);
            Self { inner }
        }
        pub fn with_origin(inner: T, origin: Uri) -> Self {
            let inner = tonic::client::Grpc::with_origin(inner, origin);
            Self { inner }
        }
        pub fn with_interceptor<F>(
            inner: T,
            interceptor: F,
        ) -> ConnectionsServiceClient<InterceptedService<T, F>>
        where
            F: tonic::service::Interceptor,
            T::ResponseBody: Default,
            T: tonic::codegen::Service<
                http::Request<tonic::body::Body>,
                Response = http::Response<
                    <T as tonic::client::GrpcService<tonic::body::Body>>::ResponseBody,
                >,
            >,
            <T as tonic::codegen::Service<
                http::Request<tonic::body::Body>,
            >>::Error: Into<StdError> + std::marker::Send + std::marker::Sync,
        {
            ConnectionsServiceClient::new(InterceptedService::new(inner, interceptor))
        }
        /// Compress requests with the given encoding.
        ///
        /// This requires the server to support it otherwise it might respond with an
        /// error.
        #[must_use]
        pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
            self.inner = self.inner.send_compressed(encoding);
            self
        }
        /// Enable decompressing responses.
        #[must_use]
        pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
            self.inner = self.inner.accept_compressed(encoding);
            self
        }
        /// Limits the maximum size of a decoded message.
        ///
        /// Default: `4MB`
        #[must_use]
        pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
            self.inner = self.inner.max_decoding_message_size(limit);
            self
        }
        /// Limits the maximum size of an encoded message.
        ///
        /// Default: `usize::MAX`
        #[must_use]
        pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
            self.inner = self.inner.max_encoding_message_size(limit);
            self
        }
        /// *
        /// Paging endpoint to list all the channels and their allowed tag values. Callers should expect that more results are
        /// available as long as ListChannelsResponse continues to return a pageToken and will pass in this pageToken in the
        /// next ListChannelsRequest.
        pub async fn list_channels(
            &mut self,
            request: impl tonic::IntoRequest<super::ListChannelsRequest>,
        ) -> std::result::Result<
            tonic::Response<super::ListChannelsResponse>,
            tonic::Status,
        > {
            self.inner
                .ready()
                .await
                .map_err(|e| {
                    tonic::Status::unknown(
                        format!("Service was not ready: {}", e.into()),
                    )
                })?;
            let codec = tonic::codec::ProstCodec::default();
            let path = http::uri::PathAndQuery::from_static(
                "/nominal.connections.v1.ConnectionsService/ListChannels",
            );
            let mut req = request.into_request();
            req.extensions_mut()
                .insert(
                    GrpcMethod::new(
                        "nominal.connections.v1.ConnectionsService",
                        "ListChannels",
                    ),
                );
            self.inner.unary(req, path, codec).await
        }
        /// *
        /// Endpoint to query a given channel for time series data for a given set of tags and time range. The response is a
        /// stream of points.
        pub async fn query_channel(
            &mut self,
            request: impl tonic::IntoRequest<super::QueryChannelRequest>,
        ) -> std::result::Result<
            tonic::Response<tonic::codec::Streaming<super::QueryChannelResponse>>,
            tonic::Status,
        > {
            self.inner
                .ready()
                .await
                .map_err(|e| {
                    tonic::Status::unknown(
                        format!("Service was not ready: {}", e.into()),
                    )
                })?;
            let codec = tonic::codec::ProstCodec::default();
            let path = http::uri::PathAndQuery::from_static(
                "/nominal.connections.v1.ConnectionsService/QueryChannel",
            );
            let mut req = request.into_request();
            req.extensions_mut()
                .insert(
                    GrpcMethod::new(
                        "nominal.connections.v1.ConnectionsService",
                        "QueryChannel",
                    ),
                );
            self.inner.server_streaming(req, path, codec).await
        }
    }
}
