pub mod id;
#[derive(Debug, Clone)]
pub struct DirClient<T> {
client: T,
path: String,
}
impl<T> DirClient<T>
where
T: crate::client::Client,
{
pub fn new(client: T, parent_path: &str) -> Self {
Self {
client,
path: format!("{}{}", parent_path, "/dir"),
}
}
}
impl<T> DirClient<T>
where
T: crate::client::Client,
{
#[doc = "List directory mapping"]
#[doc = ""]
#[doc = "Only lists entries where you have 'Mapping.Modify', 'Mapping.Use' or 'Mapping.Audit' permissions on '/mapping/dir/\\<id\\>'."]
pub async fn get(&self, params: GetParams) -> Result<Vec<GetOutputItems>, T::Error> {
let path = self.path.to_string();
let optional_vec: Option<Vec<GetOutputItems>> = self.client.get(&path, ¶ms).await?;
Ok(optional_vec.unwrap_or_default())
}
}
impl<T> DirClient<T>
where
T: crate::client::Client,
{
#[doc = "Create a new directory mapping."]
#[doc = ""]
#[doc = "Permission check: perm(\"/mapping/dir\", [\"Mapping.Modify\"])"]
pub async fn post(&self, params: PostParams) -> Result<(), T::Error> {
let path = self.path.to_string();
self.client.post(&path, ¶ms).await
}
}
impl ChecksGetOutputItemsChecksItems {
pub fn new(message: String, severity: Severity) -> Self {
Self {
message,
severity,
additional_properties: ::std::default::Default::default(),
}
}
}
#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize)]
pub struct ChecksGetOutputItemsChecksItems {
#[doc = "The message of the error"]
#[doc = ""]
pub message: String,
#[doc = "The severity of the error"]
#[doc = ""]
pub severity: Severity,
#[serde(
flatten,
default,
skip_serializing_if = "::std::collections::HashMap::is_empty"
)]
pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
}
impl GetOutputItems {
pub fn new(description: String, id: String, map: Vec<String>) -> Self {
Self {
description,
id,
map,
checks: ::std::default::Default::default(),
additional_properties: ::std::default::Default::default(),
}
}
}
#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize)]
pub struct GetOutputItems {
#[serde(skip_serializing_if = "::std::vec::Vec::is_empty", default)]
#[doc = "A list of checks, only present if 'check-node' is set."]
#[doc = ""]
pub checks: Vec<ChecksGetOutputItemsChecksItems>,
#[doc = "A description of the logical mapping."]
#[doc = ""]
pub description: String,
#[doc = "The logical ID of the mapping."]
#[doc = ""]
pub id: String,
#[serde(skip_serializing_if = "::std::vec::Vec::is_empty", default)]
#[doc = "The entries of the mapping."]
#[doc = ""]
pub map: Vec<String>,
#[serde(
flatten,
default,
skip_serializing_if = "::std::collections::HashMap::is_empty"
)]
pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
}
#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize, Default)]
pub struct GetParams {
#[serde(rename = "check-node")]
#[serde(skip_serializing_if = "Option::is_none", default)]
#[doc = "If given, checks the configurations on the given node for correctness, and adds relevant diagnostics for the directory to the response."]
#[doc = ""]
pub check_node: Option<String>,
#[serde(
flatten,
default,
skip_serializing_if = "::std::collections::HashMap::is_empty"
)]
pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
}
impl PostParams {
pub fn new(id: String, map: Vec<String>) -> Self {
Self {
id,
map,
description: ::std::default::Default::default(),
additional_properties: ::std::default::Default::default(),
}
}
}
#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize)]
pub struct PostParams {
#[serde(skip_serializing_if = "Option::is_none", default)]
#[doc = "Description of the directory mapping"]
#[doc = ""]
pub description: Option<DescriptionStr>,
#[doc = "The ID of the directory mapping"]
#[doc = ""]
pub id: String,
#[serde(skip_serializing_if = "::std::vec::Vec::is_empty", default)]
#[doc = "A list of maps for the cluster nodes."]
#[doc = ""]
pub map: Vec<String>,
#[serde(
flatten,
default,
skip_serializing_if = "::std::collections::HashMap::is_empty"
)]
pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
}
#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize, PartialEq)]
#[doc = "The severity of the error"]
#[doc = ""]
pub enum Severity {
#[serde(rename = "error")]
Error,
#[serde(rename = "warning")]
Warning,
}
impl TryFrom<&str> for Severity {
type Error = String;
fn try_from(value: &str) -> Result<Self, <Self as TryFrom<&str>>::Error> {
match value {
"error" => Ok(Self::Error),
"warning" => Ok(Self::Warning),
v => Err(format!("Unknown variant {v}")),
}
}
}
#[derive(Debug, Clone, PartialEq, PartialOrd)]
pub struct DescriptionStr {
value: String,
}
impl crate::types::bounded_string::BoundedString for DescriptionStr {
const MIN_LENGTH: Option<usize> = None::<usize>;
const MAX_LENGTH: Option<usize> = Some(4096usize);
const DEFAULT: Option<&'static str> = None::<&'static str>;
const PATTERN: Option<&'static str> = None::<&'static str>;
const TYPE_DESCRIPTION: &'static str = "a string with length at most 4096";
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 DescriptionStr {
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 DescriptionStr {
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 DescriptionStr {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: ::serde::Deserializer<'de>,
{
crate::types::bounded_string::deserialize_bounded_string(deserializer)
}
}
impl<T> DirClient<T>
where
T: crate::client::Client,
{
pub fn id(&self, id: &str) -> id::IdClient<T> {
id::IdClient::<T>::new(self.client.clone(), &self.path, id)
}
}