jacquard_api/com_atproto/server/
create_session.rs

1// @generated by jacquard-lexicon. DO NOT EDIT.
2//
3// Lexicon: com.atproto.server.createSession
4//
5// This file was automatically generated from Lexicon schemas.
6// Any manual changes will be overwritten on the next regeneration.
7
8#[jacquard_derive::lexicon]
9#[derive(
10    serde::Serialize,
11    serde::Deserialize,
12    Debug,
13    Clone,
14    PartialEq,
15    Eq,
16    bon::Builder,
17    jacquard_derive::IntoStatic
18)]
19#[serde(rename_all = "camelCase")]
20#[builder(start_fn = new)]
21pub struct CreateSession<'a> {
22    ///When true, instead of throwing error for takendown accounts, a valid response with a narrow scoped token will be returned
23    #[serde(skip_serializing_if = "std::option::Option::is_none")]
24    pub allow_takendown: std::option::Option<bool>,
25    #[serde(skip_serializing_if = "std::option::Option::is_none")]
26    #[serde(borrow)]
27    #[builder(into)]
28    pub auth_factor_token: std::option::Option<jacquard_common::CowStr<'a>>,
29    ///Handle or other identifier supported by the server for the authenticating user.
30    #[serde(borrow)]
31    #[builder(into)]
32    pub identifier: jacquard_common::CowStr<'a>,
33    #[serde(borrow)]
34    #[builder(into)]
35    pub password: jacquard_common::CowStr<'a>,
36    #[serde(flatten)]
37    #[serde(borrow)]
38    #[builder(default)]
39    pub extra_data: ::std::collections::BTreeMap<
40        ::jacquard_common::smol_str::SmolStr,
41        ::jacquard_common::types::value::Data<'a>,
42    >,
43}
44
45#[jacquard_derive::lexicon]
46#[derive(
47    serde::Serialize,
48    serde::Deserialize,
49    Debug,
50    Clone,
51    PartialEq,
52    Eq,
53    jacquard_derive::IntoStatic
54)]
55#[serde(rename_all = "camelCase")]
56pub struct CreateSessionOutput<'a> {
57    #[serde(borrow)]
58    pub access_jwt: jacquard_common::CowStr<'a>,
59    #[serde(skip_serializing_if = "std::option::Option::is_none")]
60    pub active: std::option::Option<bool>,
61    #[serde(borrow)]
62    pub did: jacquard_common::types::string::Did<'a>,
63    #[serde(skip_serializing_if = "std::option::Option::is_none")]
64    #[serde(borrow)]
65    pub did_doc: std::option::Option<jacquard_common::types::value::Data<'a>>,
66    #[serde(skip_serializing_if = "std::option::Option::is_none")]
67    #[serde(borrow)]
68    pub email: std::option::Option<jacquard_common::CowStr<'a>>,
69    #[serde(skip_serializing_if = "std::option::Option::is_none")]
70    pub email_auth_factor: std::option::Option<bool>,
71    #[serde(skip_serializing_if = "std::option::Option::is_none")]
72    pub email_confirmed: std::option::Option<bool>,
73    #[serde(borrow)]
74    pub handle: jacquard_common::types::string::Handle<'a>,
75    #[serde(borrow)]
76    pub refresh_jwt: jacquard_common::CowStr<'a>,
77    ///If active=false, this optional field indicates a possible reason for why the account is not active. If active=false and no status is supplied, then the host makes no claim for why the repository is no longer being hosted.
78    #[serde(skip_serializing_if = "std::option::Option::is_none")]
79    #[serde(borrow)]
80    pub status: std::option::Option<jacquard_common::CowStr<'a>>,
81}
82
83#[jacquard_derive::open_union]
84#[derive(
85    serde::Serialize,
86    serde::Deserialize,
87    Debug,
88    Clone,
89    PartialEq,
90    Eq,
91    thiserror::Error,
92    miette::Diagnostic,
93    jacquard_derive::IntoStatic
94)]
95#[serde(tag = "error", content = "message")]
96#[serde(bound(deserialize = "'de: 'a"))]
97pub enum CreateSessionError<'a> {
98    #[serde(rename = "AccountTakedown")]
99    AccountTakedown(std::option::Option<String>),
100    #[serde(rename = "AuthFactorTokenRequired")]
101    AuthFactorTokenRequired(std::option::Option<String>),
102}
103
104impl std::fmt::Display for CreateSessionError<'_> {
105    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
106        match self {
107            Self::AccountTakedown(msg) => {
108                write!(f, "AccountTakedown")?;
109                if let Some(msg) = msg {
110                    write!(f, ": {}", msg)?;
111                }
112                Ok(())
113            }
114            Self::AuthFactorTokenRequired(msg) => {
115                write!(f, "AuthFactorTokenRequired")?;
116                if let Some(msg) = msg {
117                    write!(f, ": {}", msg)?;
118                }
119                Ok(())
120            }
121            Self::Unknown(err) => write!(f, "Unknown error: {:?}", err),
122        }
123    }
124}
125
126///Response type for
127///com.atproto.server.createSession
128pub struct CreateSessionResponse;
129impl jacquard_common::xrpc::XrpcResp for CreateSessionResponse {
130    const NSID: &'static str = "com.atproto.server.createSession";
131    const ENCODING: &'static str = "application/json";
132    type Output<'de> = CreateSessionOutput<'de>;
133    type Err<'de> = CreateSessionError<'de>;
134}
135
136impl<'de> jacquard_common::xrpc::XrpcRequest<'de> for CreateSession<'de> {
137    const NSID: &'static str = "com.atproto.server.createSession";
138    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Procedure(
139        "application/json",
140    );
141    type Response = CreateSessionResponse;
142}
143
144///Endpoint type for
145///com.atproto.server.createSession
146pub struct CreateSessionRequest;
147impl jacquard_common::xrpc::XrpcEndpoint for CreateSessionRequest {
148    const PATH: &'static str = "/xrpc/com.atproto.server.createSession";
149    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Procedure(
150        "application/json",
151    );
152    type Request<'de> = CreateSession<'de>;
153    type Response = CreateSessionResponse;
154}