pub mod tokenid;
#[derive(Debug, Clone)]
pub struct TokenClient<T> {
client: T,
path: String,
}
impl<T> TokenClient<T>
where
T: crate::client::Client,
{
pub fn new(client: T, parent_path: &str) -> Self {
Self {
client,
path: format!("{}{}", parent_path, "/token"),
}
}
}
impl<T> TokenClient<T>
where
T: crate::client::Client,
{
#[doc = "Get user API tokens."]
#[doc = ""]
#[doc = "Permission check: or(userid-param(\"self\"), userid-group([\"User.Modify\"]))"]
pub async fn get(&self) -> Result<Vec<GetOutputItems>, T::Error> {
let path = self.path.to_string();
let optional_vec: Option<Vec<GetOutputItems>> = self.client.get(&path, &()).await?;
Ok(optional_vec.unwrap_or_default())
}
}
impl GetOutputItems {
pub fn new(tokenid: TokenidStr) -> Self {
Self {
tokenid,
comment: ::std::default::Default::default(),
expire: ::std::default::Default::default(),
privsep: ::std::default::Default::default(),
additional_properties: ::std::default::Default::default(),
}
}
}
#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize)]
pub struct GetOutputItems {
#[serde(skip_serializing_if = "Option::is_none", default)]
pub comment: Option<String>,
#[serde(
serialize_with = "crate::types::serialize_unsigned_int_optional",
deserialize_with = "crate::types::deserialize_unsigned_int_optional"
)]
#[serde(skip_serializing_if = "Option::is_none", default)]
#[doc = "API token expiration date (seconds since epoch). '0' means no expiration date."]
#[doc = ""]
pub expire: Option<u64>,
#[serde(
serialize_with = "crate::types::serialize_bool_optional",
deserialize_with = "crate::types::deserialize_bool_optional"
)]
#[serde(skip_serializing_if = "Option::is_none", default)]
#[doc = "Restrict API token privileges with separate ACLs (default), or give full privileges of corresponding user."]
#[doc = ""]
pub privsep: Option<bool>,
#[doc = "User-specific token identifier."]
#[doc = ""]
pub tokenid: TokenidStr,
#[serde(
flatten,
default,
skip_serializing_if = "::std::collections::HashMap::is_empty"
)]
pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
}
#[derive(Debug, Clone, PartialEq, PartialOrd)]
pub struct TokenidStr {
value: String,
}
impl crate::types::bounded_string::BoundedString for TokenidStr {
const MIN_LENGTH: Option<usize> = None::<usize>;
const MAX_LENGTH: Option<usize> = None::<usize>;
const DEFAULT: Option<&'static str> = None::<&'static str>;
const PATTERN: Option<&'static str> = Some("(?^:[A-Za-z][A-Za-z0-9\\.\\-_]+)");
const TYPE_DESCRIPTION: &'static str =
"a string with pattern r\"(?^:[A-Za-z][A-Za-z0-9\\.\\-_]+)\" and no length constraints";
fn get_value(&self) -> &str {
&self.value
}
fn new(value: String) -> Result<Self, crate::types::bounded_string::BoundedStringError> {
Self::validate(&value)?;
Ok(Self { value })
}
}
impl std::convert::TryFrom<String> for TokenidStr {
type Error = crate::types::bounded_string::BoundedStringError;
fn try_from(value: String) -> Result<Self, Self::Error> {
crate::types::bounded_string::BoundedString::new(value)
}
}
impl ::serde::Serialize for TokenidStr {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: ::serde::Serializer,
{
crate::types::bounded_string::serialize_bounded_string(self, serializer)
}
}
impl<'de> ::serde::Deserialize<'de> for TokenidStr {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: ::serde::Deserializer<'de>,
{
crate::types::bounded_string::deserialize_bounded_string(deserializer)
}
}
impl<T> TokenClient<T>
where
T: crate::client::Client,
{
pub fn tokenid(&self, tokenid: &str) -> tokenid::TokenidClient<T> {
tokenid::TokenidClient::<T>::new(self.client.clone(), &self.path, tokenid)
}
}