pub mod userid;
#[derive(Debug, Clone)]
pub struct UsersClient<T> {
client: T,
path: String,
}
impl<T> UsersClient<T>
where
T: crate::client::Client,
{
pub fn new(client: T, parent_path: &str) -> Self {
Self {
client,
path: format!("{}{}", parent_path, "/users"),
}
}
}
impl<T> UsersClient<T>
where
T: crate::client::Client,
{
#[doc = "User index."]
#[doc = ""]
#[doc = "The returned list is restricted to users where you have 'User.Modify' or 'Sys.Audit' permissions on '/access/groups' or on a group the user belongs too. But it always includes the current (authenticated) user."]
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> UsersClient<T>
where
T: crate::client::Client,
{
#[doc = "Create new user."]
#[doc = ""]
#[doc = "Permission check: and(userid-param(\"Realm.AllocateUser\"), userid-group([\"User.Modify\"], groups_param=\"create\"))"]
#[doc = "You need 'Realm.AllocateUser' on '/access/realm/\\<realm\\>' on the realm of user \\<userid\\>, and 'User.Modify' permissions to '/access/groups/\\<group\\>' for any group specified (or 'User.Modify' on '/access/groups' if you pass no groups."]
pub async fn post(&self, params: PostParams) -> Result<(), T::Error> {
let path = self.path.to_string();
self.client.post(&path, ¶ms).await
}
}
impl GetOutputItems {
pub fn new(userid: UseridStr) -> Self {
Self {
userid,
comment: ::std::default::Default::default(),
email: ::std::default::Default::default(),
enable: ::std::default::Default::default(),
expire: ::std::default::Default::default(),
firstname: ::std::default::Default::default(),
groups: ::std::default::Default::default(),
keys: ::std::default::Default::default(),
lastname: ::std::default::Default::default(),
realm_type: ::std::default::Default::default(),
tfa_locked_until: ::std::default::Default::default(),
tokens: ::std::default::Default::default(),
totp_locked: ::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<CommentStr>,
#[serde(skip_serializing_if = "Option::is_none", default)]
pub email: Option<EmailStr>,
#[serde(
serialize_with = "crate::types::serialize_bool_optional",
deserialize_with = "crate::types::deserialize_bool_optional"
)]
#[serde(skip_serializing_if = "Option::is_none", default)]
#[doc = "Enable the account (default). You can set this to '0' to disable the account"]
#[doc = ""]
pub enable: Option<bool>,
#[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 = "Account expiration date (seconds since epoch). '0' means no expiration date."]
#[doc = ""]
pub expire: Option<u64>,
#[serde(skip_serializing_if = "Option::is_none", default)]
pub firstname: Option<FirstnameStr>,
#[serde(skip_serializing_if = "Option::is_none", default)]
pub groups: Option<String>,
#[serde(skip_serializing_if = "Option::is_none", default)]
#[doc = "Keys for two factor auth (yubico)."]
#[doc = ""]
pub keys: Option<KeysStr>,
#[serde(skip_serializing_if = "Option::is_none", default)]
pub lastname: Option<LastnameStr>,
#[serde(rename = "realm-type")]
#[serde(skip_serializing_if = "Option::is_none", default)]
#[doc = "The type of the users realm"]
#[doc = ""]
pub realm_type: Option<String>,
#[serde(rename = "tfa-locked-until")]
#[serde(
serialize_with = "crate::types::serialize_int_optional",
deserialize_with = "crate::types::deserialize_int_optional"
)]
#[serde(skip_serializing_if = "Option::is_none", default)]
#[doc = "Contains a timestamp until when a user is locked out of 2nd factors."]
#[doc = ""]
pub tfa_locked_until: Option<i64>,
#[serde(skip_serializing_if = "::std::vec::Vec::is_empty", default)]
pub tokens: Vec<TokensGetOutputItemsTokensItems>,
#[serde(rename = "totp-locked")]
#[serde(
serialize_with = "crate::types::serialize_bool_optional",
deserialize_with = "crate::types::deserialize_bool_optional"
)]
#[serde(skip_serializing_if = "Option::is_none", default)]
#[doc = "True if the user is currently locked out of TOTP factors."]
#[doc = ""]
pub totp_locked: Option<bool>,
#[doc = "Full User ID, in the `name@realm` format."]
#[doc = ""]
pub userid: UseridStr,
#[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(
serialize_with = "crate::types::serialize_bool_optional",
deserialize_with = "crate::types::deserialize_bool_optional"
)]
#[serde(skip_serializing_if = "Option::is_none", default)]
#[doc = "Optional filter for enable property."]
#[doc = ""]
pub enabled: Option<bool>,
#[serde(
serialize_with = "crate::types::serialize_bool_optional",
deserialize_with = "crate::types::deserialize_bool_optional"
)]
#[serde(skip_serializing_if = "Option::is_none", default)]
#[doc = "Include group and token information."]
#[doc = ""]
pub full: Option<bool>,
#[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(userid: UseridStr) -> Self {
Self {
userid,
comment: ::std::default::Default::default(),
email: ::std::default::Default::default(),
enable: ::std::default::Default::default(),
expire: ::std::default::Default::default(),
firstname: ::std::default::Default::default(),
groups: ::std::default::Default::default(),
keys: ::std::default::Default::default(),
lastname: ::std::default::Default::default(),
password: ::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)]
pub comment: Option<CommentStr>,
#[serde(skip_serializing_if = "Option::is_none", default)]
pub email: Option<EmailStr>,
#[serde(
serialize_with = "crate::types::serialize_bool_optional",
deserialize_with = "crate::types::deserialize_bool_optional"
)]
#[serde(skip_serializing_if = "Option::is_none", default)]
#[doc = "Enable the account (default). You can set this to '0' to disable the account"]
#[doc = ""]
pub enable: Option<bool>,
#[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 = "Account expiration date (seconds since epoch). '0' means no expiration date."]
#[doc = ""]
pub expire: Option<u64>,
#[serde(skip_serializing_if = "Option::is_none", default)]
pub firstname: Option<FirstnameStr>,
#[serde(skip_serializing_if = "Option::is_none", default)]
pub groups: Option<String>,
#[serde(skip_serializing_if = "Option::is_none", default)]
#[doc = "Keys for two factor auth (yubico)."]
#[doc = ""]
pub keys: Option<KeysStr>,
#[serde(skip_serializing_if = "Option::is_none", default)]
pub lastname: Option<LastnameStr>,
#[serde(skip_serializing_if = "Option::is_none", default)]
#[doc = "Initial password."]
#[doc = ""]
pub password: Option<PasswordStr>,
#[doc = "Full User ID, in the `name@realm` format."]
#[doc = ""]
pub userid: UseridStr,
#[serde(
flatten,
default,
skip_serializing_if = "::std::collections::HashMap::is_empty"
)]
pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
}
impl TokensGetOutputItemsTokensItems {
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 TokensGetOutputItemsTokensItems {
#[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 CommentStr {
value: String,
}
impl crate::types::bounded_string::BoundedString for CommentStr {
const MIN_LENGTH: Option<usize> = None::<usize>;
const MAX_LENGTH: Option<usize> = Some(2048usize);
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 2048";
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 CommentStr {
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 CommentStr {
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 CommentStr {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: ::serde::Deserializer<'de>,
{
crate::types::bounded_string::deserialize_bounded_string(deserializer)
}
}
#[derive(Debug, Clone, PartialEq, PartialOrd)]
pub struct EmailStr {
value: String,
}
impl crate::types::bounded_string::BoundedString for EmailStr {
const MIN_LENGTH: Option<usize> = None::<usize>;
const MAX_LENGTH: Option<usize> = Some(254usize);
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 254";
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 EmailStr {
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 EmailStr {
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 EmailStr {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: ::serde::Deserializer<'de>,
{
crate::types::bounded_string::deserialize_bounded_string(deserializer)
}
}
#[derive(Debug, Clone, PartialEq, PartialOrd)]
pub struct FirstnameStr {
value: String,
}
impl crate::types::bounded_string::BoundedString for FirstnameStr {
const MIN_LENGTH: Option<usize> = None::<usize>;
const MAX_LENGTH: Option<usize> = Some(1024usize);
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 1024";
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 FirstnameStr {
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 FirstnameStr {
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 FirstnameStr {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: ::serde::Deserializer<'de>,
{
crate::types::bounded_string::deserialize_bounded_string(deserializer)
}
}
#[derive(Debug, Clone, PartialEq, PartialOrd)]
pub struct KeysStr {
value: String,
}
impl crate::types::bounded_string::BoundedString for KeysStr {
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("[0-9a-zA-Z!=]{0,4096}");
const TYPE_DESCRIPTION: &'static str =
"a string with pattern r\"[0-9a-zA-Z!=]{0,4096}\" 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 KeysStr {
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 KeysStr {
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 KeysStr {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: ::serde::Deserializer<'de>,
{
crate::types::bounded_string::deserialize_bounded_string(deserializer)
}
}
#[derive(Debug, Clone, PartialEq, PartialOrd)]
pub struct LastnameStr {
value: String,
}
impl crate::types::bounded_string::BoundedString for LastnameStr {
const MIN_LENGTH: Option<usize> = None::<usize>;
const MAX_LENGTH: Option<usize> = Some(1024usize);
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 1024";
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 LastnameStr {
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 LastnameStr {
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 LastnameStr {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: ::serde::Deserializer<'de>,
{
crate::types::bounded_string::deserialize_bounded_string(deserializer)
}
}
#[derive(Debug, Clone, PartialEq, PartialOrd)]
pub struct PasswordStr {
value: String,
}
impl crate::types::bounded_string::BoundedString for PasswordStr {
const MIN_LENGTH: Option<usize> = Some(8usize);
const MAX_LENGTH: Option<usize> = Some(64usize);
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 between 8 and 64";
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 PasswordStr {
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 PasswordStr {
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 PasswordStr {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: ::serde::Deserializer<'de>,
{
crate::types::bounded_string::deserialize_bounded_string(deserializer)
}
}
#[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)
}
}
#[derive(Debug, Clone, PartialEq, PartialOrd)]
pub struct UseridStr {
value: String,
}
impl crate::types::bounded_string::BoundedString for UseridStr {
const MIN_LENGTH: Option<usize> = None::<usize>;
const MAX_LENGTH: Option<usize> = Some(64usize);
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 64";
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 UseridStr {
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 UseridStr {
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 UseridStr {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: ::serde::Deserializer<'de>,
{
crate::types::bounded_string::deserialize_bounded_string(deserializer)
}
}
impl<T> UsersClient<T>
where
T: crate::client::Client,
{
pub fn userid(&self, userid: &str) -> userid::UseridClient<T> {
userid::UseridClient::<T>::new(self.client.clone(), &self.path, userid)
}
}