// @generated by jacquard-lexicon. DO NOT EDIT.
//
// Lexicon: tools.ozone.server.getConfig
//
// This file was automatically generated from Lexicon schemas.
// Any manual changes will be overwritten on the next regeneration.

#[allow(unused_imports)]
use alloc::collections::BTreeMap;

#[allow(unused_imports)]
use core::marker::PhantomData;
use jacquard_common::{CowStr, BosStr, DefaultStr, FromStaticStr};

#[allow(unused_imports)]
use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;
use jacquard_common::deps::smol_str::SmolStr;
use jacquard_common::types::string::{Did, UriValue};
use jacquard_common::types::value::Data;
use jacquard_derive::IntoStatic;
use jacquard_lexicon::lexicon::LexiconDoc;
use jacquard_lexicon::schema::LexiconSchema;

#[allow(unused_imports)]
use jacquard_lexicon::validation::{ConstraintError, ValidationPath};
use serde::{Serialize, Deserialize};
use crate::tools_ozone::server::get_config;

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct GetConfigOutput<S: BosStr = DefaultStr> {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub appview: Option<get_config::ServiceConfig<S>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub blob_divert: Option<get_config::ServiceConfig<S>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub chat: Option<get_config::ServiceConfig<S>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub pds: Option<get_config::ServiceConfig<S>>,
    ///The did of the verifier used for verification.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub verifier_did: Option<Did<S>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub viewer: Option<get_config::ViewerConfig<S>>,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}


#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct ServiceConfig<S: BosStr = DefaultStr> {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub url: Option<UriValue<S>>,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}


#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct ViewerConfig<S: BosStr = DefaultStr> {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub role: Option<ViewerConfigRole<S>>,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}


#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum ViewerConfigRole<S: BosStr = DefaultStr> {
    RoleAdmin,
    RoleModerator,
    RoleTriage,
    RoleVerifier,
    Other(S),
}

impl<S: BosStr> ViewerConfigRole<S> {
    pub fn as_str(&self) -> &str {
        match self {
            Self::RoleAdmin => "tools.ozone.team.defs#roleAdmin",
            Self::RoleModerator => "tools.ozone.team.defs#roleModerator",
            Self::RoleTriage => "tools.ozone.team.defs#roleTriage",
            Self::RoleVerifier => "tools.ozone.team.defs#roleVerifier",
            Self::Other(s) => s.as_ref(),
        }
    }
    /// Construct from a string-like value, matching known values.
    pub fn from_value(s: S) -> Self {
        match s.as_ref() {
            "tools.ozone.team.defs#roleAdmin" => Self::RoleAdmin,
            "tools.ozone.team.defs#roleModerator" => Self::RoleModerator,
            "tools.ozone.team.defs#roleTriage" => Self::RoleTriage,
            "tools.ozone.team.defs#roleVerifier" => Self::RoleVerifier,
            _ => Self::Other(s),
        }
    }
}

impl<S: BosStr> core::fmt::Display for ViewerConfigRole<S> {
    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
        write!(f, "{}", self.as_str())
    }
}

impl<S: BosStr> AsRef<str> for ViewerConfigRole<S> {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

impl<S: BosStr> Serialize for ViewerConfigRole<S> {
    fn serialize<Ser>(&self, serializer: Ser) -> Result<Ser::Ok, Ser::Error>
    where
        Ser: serde::Serializer,
    {
        serializer.serialize_str(self.as_str())
    }
}

impl<'de, S: Deserialize<'de> + BosStr> Deserialize<'de> for ViewerConfigRole<S> {
    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
    where
        D: serde::Deserializer<'de>,
    {
        let s = S::deserialize(deserializer)?;
        Ok(Self::from_value(s))
    }
}

impl<S: BosStr + Default> Default for ViewerConfigRole<S> {
    fn default() -> Self {
        Self::Other(Default::default())
    }
}

impl<S: BosStr> jacquard_common::IntoStatic for ViewerConfigRole<S>
where
    S: BosStr + jacquard_common::IntoStatic,
    S::Output: BosStr,
{
    type Output = ViewerConfigRole<S::Output>;
    fn into_static(self) -> Self::Output {
        match self {
            ViewerConfigRole::RoleAdmin => ViewerConfigRole::RoleAdmin,
            ViewerConfigRole::RoleModerator => ViewerConfigRole::RoleModerator,
            ViewerConfigRole::RoleTriage => ViewerConfigRole::RoleTriage,
            ViewerConfigRole::RoleVerifier => ViewerConfigRole::RoleVerifier,
            ViewerConfigRole::Other(v) => ViewerConfigRole::Other(v.into_static()),
        }
    }
}

/** Request marker for the `tools.ozone.server.getConfig` query.

This endpoint has no request parameters or input body; send this marker with `jacquard::Client`.*/

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Copy)]
pub struct GetConfig;
/** Response marker for the `tools.ozone.server.getConfig` query.

Implements `jacquard_common::xrpc::XrpcResp`; successful bodies decode as `Self::Output<S>`, which is `GetConfigOutput<S>` for this endpoint.*/
pub struct GetConfigResponse;
impl jacquard_common::xrpc::XrpcResp for GetConfigResponse {
    const NSID: &'static str = "tools.ozone.server.getConfig";
    const ENCODING: &'static str = "application/json";
    type Output<S: BosStr> = GetConfigOutput<S>;
    type Err = jacquard_common::xrpc::GenericError;
}

impl jacquard_common::xrpc::XrpcRequest for GetConfig {
    const NSID: &'static str = "tools.ozone.server.getConfig";
    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
    type Response = GetConfigResponse;
}

/** Endpoint marker for the `tools.ozone.server.getConfig` query.

Path: `/xrpc/tools.ozone.server.getConfig`. The request payload type is `GetConfig`; use this marker with lower-level `XrpcEndpoint` APIs when you need endpoint metadata.*/
pub struct GetConfigRequest;
impl jacquard_common::xrpc::XrpcEndpoint for GetConfigRequest {
    const PATH: &'static str = "/xrpc/tools.ozone.server.getConfig";
    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
    type Request<S: BosStr> = GetConfig;
    type Response = GetConfigResponse;
}

impl<S: BosStr> LexiconSchema for ServiceConfig<S> {
    fn nsid() -> &'static str {
        "tools.ozone.server.getConfig"
    }
    fn def_name() -> &'static str {
        "serviceConfig"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_tools_ozone_server_getConfig()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

impl<S: BosStr> LexiconSchema for ViewerConfig<S> {
    fn nsid() -> &'static str {
        "tools.ozone.server.getConfig"
    }
    fn def_name() -> &'static str {
        "viewerConfig"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_tools_ozone_server_getConfig()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

fn lexicon_doc_tools_ozone_server_getConfig() -> LexiconDoc<'static> {
    #[allow(unused_imports)]
    use jacquard_common::{CowStr, deps::smol_str::SmolStr, types::blob::MimeType};
    use jacquard_lexicon::lexicon::*;
    use alloc::collections::BTreeMap;
    LexiconDoc {
        lexicon: Lexicon::Lexicon1,
        id: CowStr::new_static("tools.ozone.server.getConfig"),
        defs: {
            let mut map = BTreeMap::new();
            map.insert(
                SmolStr::new_static("main"),
                LexUserType::XrpcQuery(LexXrpcQuery {
                    parameters: None,
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("serviceConfig"),
                LexUserType::Object(LexObject {
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("url"),
                            LexObjectProperty::String(LexString {
                                format: Some(LexStringFormat::Uri),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("viewerConfig"),
                LexUserType::Object(LexObject {
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("role"),
                            LexObjectProperty::String(LexString { ..Default::default() }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map
        },
        ..Default::default()
    }
}