zulip_api/message/realm_authentication_method.rs
1use serde::{Deserialize, Serialize};
2
3use crate::{field_access, impl_default, impl_display};
4
5/// Represents the properties of an authentication method for the organization - its enabled status and availability for use by the organization.
6///
7/// Modified from `openapi-generator-cli` output:
8///
9/// ```shell,no_build,no_run
10/// $ openapi-generator-cli generate -g rust -i ./zerver/openapi/zulip.yaml -o zulip-openapi --skip-validate-spec
11/// ```
12///
13/// ```text
14/// /*
15/// * Zulip REST API
16/// *
17/// * Powerful open source group chat
18/// *
19/// * The version of the OpenAPI document: 1.0.0
20/// *
21/// * Generated by: https://openapi-generator.tech
22/// */
23/// ```
24///
25/// See [zerver/openapi/zulip.yaml](https://github.com/zulip/zulip/blob/main/zerver/openapi/zulip.yaml) for the original OpenAPI configuration.
26///
27/// Configuration slightly modified to work with the Rust generator of [`openapi-generator-cli`](https://openapi-generator.tech).
28#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
29pub struct RealmAuthenticationMethod {
30 #[serde(skip_serializing_if = "Option::is_none")]
31 enabled: Option<bool>,
32 #[serde(skip_serializing_if = "Option::is_none")]
33 available: Option<bool>,
34 #[serde(skip_serializing_if = "Option::is_none")]
35 unavailable_reason: Option<String>,
36}
37
38impl RealmAuthenticationMethod {
39 /// Creates a new [RealmAuthenticationMethod].
40 pub const fn new() -> Self {
41 Self {
42 enabled: None,
43 available: None,
44 unavailable_reason: None,
45 }
46 }
47}
48
49field_access! {
50 RealmAuthenticationMethod {
51 /// Boolean describing whether the authentication method (i.e. its key) is enabled in this organization.
52 enabled: option { bool },
53 /// Boolean describing whether the authentication method is available for use. If false, the organization is not eligible to enable the authentication method.
54 available: option { bool },
55 }
56}
57
58field_access! {
59 RealmAuthenticationMethod {
60 /// Reason why the authentication method is unavailable.
61 ///
62 /// This field is optional and is only present when 'available' is false.
63 unavailable_reason: option_cow_deref { str, String },
64 }
65}
66
67impl_default!(RealmAuthenticationMethod);
68impl_display!(RealmAuthenticationMethod);