#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ApiKey {
#[prost(string, tag = "1")]
pub rid: ::prost::alloc::string::String,
#[prost(string, tag = "2")]
pub display_name: ::prost::alloc::string::String,
#[prost(string, tag = "3")]
pub created_by: ::prost::alloc::string::String,
#[prost(message, optional, tag = "4")]
pub create_time: ::core::option::Option<
super::super::super::super::google::protobuf::Timestamp,
>,
#[prost(message, optional, tag = "5")]
pub expire_time: ::core::option::Option<
super::super::super::super::google::protobuf::Timestamp,
>,
#[prost(bool, tag = "6")]
pub is_deleted: bool,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct CreateApiKeyRequest {
#[prost(message, optional, tag = "1")]
pub api_key: ::core::option::Option<ApiKey>,
#[prost(int64, optional, tag = "2")]
pub expires_after_days: ::core::option::Option<i64>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct CreateApiKeyResponse {
#[prost(message, optional, tag = "1")]
pub api_key: ::core::option::Option<ApiKey>,
#[prost(string, tag = "2")]
pub api_key_value: ::prost::alloc::string::String,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ListApiKeysRequest {
#[prost(enumeration = "ApiKeyListScope", tag = "1")]
pub scope: i32,
#[prost(int32, optional, tag = "2")]
pub page_size: ::core::option::Option<i32>,
#[prost(string, optional, tag = "3")]
pub page_token: ::core::option::Option<::prost::alloc::string::String>,
#[prost(bool, tag = "4")]
pub include_deleted: bool,
#[prost(bool, tag = "5")]
pub include_expired: bool,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ListApiKeysResponse {
#[prost(message, repeated, tag = "1")]
pub api_keys: ::prost::alloc::vec::Vec<ApiKey>,
#[prost(string, optional, tag = "2")]
pub next_page_token: ::core::option::Option<::prost::alloc::string::String>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct DeleteApiKeyRequest {
#[prost(string, tag = "1")]
pub api_key_rid: ::prost::alloc::string::String,
}
#[derive(Clone, Copy, PartialEq, ::prost::Message)]
pub struct DeleteApiKeyResponse {}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum ApiKeyError {
Unspecified = 0,
InvalidRid = 1,
InvalidExpiry = 2,
InvalidPageToken = 3,
InvalidListScope = 4,
UnrepresentableStoredTimestamp = 5,
}
impl ApiKeyError {
pub fn as_str_name(&self) -> &'static str {
match self {
Self::Unspecified => "API_KEY_ERROR_UNSPECIFIED",
Self::InvalidRid => "API_KEY_ERROR_INVALID_RID",
Self::InvalidExpiry => "API_KEY_ERROR_INVALID_EXPIRY",
Self::InvalidPageToken => "API_KEY_ERROR_INVALID_PAGE_TOKEN",
Self::InvalidListScope => "API_KEY_ERROR_INVALID_LIST_SCOPE",
Self::UnrepresentableStoredTimestamp => {
"API_KEY_ERROR_UNREPRESENTABLE_STORED_TIMESTAMP"
}
}
}
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"API_KEY_ERROR_UNSPECIFIED" => Some(Self::Unspecified),
"API_KEY_ERROR_INVALID_RID" => Some(Self::InvalidRid),
"API_KEY_ERROR_INVALID_EXPIRY" => Some(Self::InvalidExpiry),
"API_KEY_ERROR_INVALID_PAGE_TOKEN" => Some(Self::InvalidPageToken),
"API_KEY_ERROR_INVALID_LIST_SCOPE" => Some(Self::InvalidListScope),
"API_KEY_ERROR_UNREPRESENTABLE_STORED_TIMESTAMP" => {
Some(Self::UnrepresentableStoredTimestamp)
}
_ => None,
}
}
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum ApiKeyListScope {
Unspecified = 0,
CurrentOrganization = 1,
CurrentUser = 2,
}
impl ApiKeyListScope {
pub fn as_str_name(&self) -> &'static str {
match self {
Self::Unspecified => "API_KEY_LIST_SCOPE_UNSPECIFIED",
Self::CurrentOrganization => "API_KEY_LIST_SCOPE_CURRENT_ORGANIZATION",
Self::CurrentUser => "API_KEY_LIST_SCOPE_CURRENT_USER",
}
}
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"API_KEY_LIST_SCOPE_UNSPECIFIED" => Some(Self::Unspecified),
"API_KEY_LIST_SCOPE_CURRENT_ORGANIZATION" => Some(Self::CurrentOrganization),
"API_KEY_LIST_SCOPE_CURRENT_USER" => Some(Self::CurrentUser),
_ => None,
}
}
}
pub mod api_key_service_client {
#![allow(
unused_variables,
dead_code,
missing_docs,
clippy::wildcard_imports,
clippy::let_unit_value,
)]
use tonic::codegen::*;
use tonic::codegen::http::Uri;
#[derive(Debug, Clone)]
pub struct ApiKeyServiceClient<T> {
inner: tonic::client::Grpc<T>,
}
impl ApiKeyServiceClient<tonic::transport::Channel> {
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> ApiKeyServiceClient<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,
) -> ApiKeyServiceClient<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,
{
ApiKeyServiceClient::new(InterceptedService::new(inner, interceptor))
}
#[must_use]
pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.inner = self.inner.send_compressed(encoding);
self
}
#[must_use]
pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.inner = self.inner.accept_compressed(encoding);
self
}
#[must_use]
pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
self.inner = self.inner.max_decoding_message_size(limit);
self
}
#[must_use]
pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
self.inner = self.inner.max_encoding_message_size(limit);
self
}
pub async fn create_api_key(
&mut self,
request: impl tonic::IntoRequest<super::CreateApiKeyRequest>,
) -> std::result::Result<
tonic::Response<super::CreateApiKeyResponse>,
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.authorization.apikeys.v1.ApiKeyService/CreateApiKey",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(
GrpcMethod::new(
"nominal.authorization.apikeys.v1.ApiKeyService",
"CreateApiKey",
),
);
self.inner.unary(req, path, codec).await
}
pub async fn list_api_keys(
&mut self,
request: impl tonic::IntoRequest<super::ListApiKeysRequest>,
) -> std::result::Result<
tonic::Response<super::ListApiKeysResponse>,
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.authorization.apikeys.v1.ApiKeyService/ListApiKeys",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(
GrpcMethod::new(
"nominal.authorization.apikeys.v1.ApiKeyService",
"ListApiKeys",
),
);
self.inner.unary(req, path, codec).await
}
pub async fn delete_api_key(
&mut self,
request: impl tonic::IntoRequest<super::DeleteApiKeyRequest>,
) -> std::result::Result<
tonic::Response<super::DeleteApiKeyResponse>,
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.authorization.apikeys.v1.ApiKeyService/DeleteApiKey",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(
GrpcMethod::new(
"nominal.authorization.apikeys.v1.ApiKeyService",
"DeleteApiKey",
),
);
self.inner.unary(req, path, codec).await
}
}
}