// @generated by jacquard-lexicon. DO NOT EDIT.
//
// Lexicon: ooo.bsky.hds.server.describeServer
//
// 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::ooo_bsky::hds::server::describe_server;

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct Contact<S: BosStr = DefaultStr> {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub email: Option<S>,
    #[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 Links<S: BosStr = DefaultStr> {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub privacy_policy: Option<UriValue<S>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub terms_of_service: 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)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct DescribeServerOutput<S: BosStr = DefaultStr> {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub contact: Option<describe_server::Contact<S>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub description: Option<S>,
    pub did: Did<S>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub links: Option<describe_server::Links<S>>,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}

impl<S: BosStr> LexiconSchema for Contact<S> {
    fn nsid() -> &'static str {
        "ooo.bsky.hds.server.describeServer"
    }
    fn def_name() -> &'static str {
        "contact"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_ooo_bsky_hds_server_describeServer()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

impl<S: BosStr> LexiconSchema for Links<S> {
    fn nsid() -> &'static str {
        "ooo.bsky.hds.server.describeServer"
    }
    fn def_name() -> &'static str {
        "links"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_ooo_bsky_hds_server_describeServer()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

/** Request marker for the `ooo.bsky.hds.server.describeServer` 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 DescribeServer;
/** Response marker for the `ooo.bsky.hds.server.describeServer` query.

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

impl jacquard_common::xrpc::XrpcRequest for DescribeServer {
    const NSID: &'static str = "ooo.bsky.hds.server.describeServer";
    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
    type Response = DescribeServerResponse;
}

/** Endpoint marker for the `ooo.bsky.hds.server.describeServer` query.

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

fn lexicon_doc_ooo_bsky_hds_server_describeServer() -> 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("ooo.bsky.hds.server.describeServer"),
        defs: {
            let mut map = BTreeMap::new();
            map.insert(
                SmolStr::new_static("contact"),
                LexUserType::Object(LexObject {
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("email"),
                            LexObjectProperty::String(LexString { ..Default::default() }),
                        );
                        map.insert(
                            SmolStr::new_static("url"),
                            LexObjectProperty::String(LexString {
                                format: Some(LexStringFormat::Uri),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("links"),
                LexUserType::Object(LexObject {
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("privacyPolicy"),
                            LexObjectProperty::String(LexString {
                                format: Some(LexStringFormat::Uri),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("termsOfService"),
                            LexObjectProperty::String(LexString {
                                format: Some(LexStringFormat::Uri),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("main"),
                LexUserType::XrpcQuery(LexXrpcQuery {
                    parameters: None,
                    ..Default::default()
                }),
            );
            map
        },
        ..Default::default()
    }
}