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)]
94#[serde(tag = "error", content = "message")]
95#[serde(bound(deserialize = "'de: 'a"))]
96pub enum CreateSessionError<'a> {
97    #[serde(rename = "AccountTakedown")]
98    AccountTakedown(std::option::Option<String>),
99    #[serde(rename = "AuthFactorTokenRequired")]
100    AuthFactorTokenRequired(std::option::Option<String>),
101}
102
103impl std::fmt::Display for CreateSessionError<'_> {
104    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
105        match self {
106            Self::AccountTakedown(msg) => {
107                write!(f, "AccountTakedown")?;
108                if let Some(msg) = msg {
109                    write!(f, ": {}", msg)?;
110                }
111                Ok(())
112            }
113            Self::AuthFactorTokenRequired(msg) => {
114                write!(f, "AuthFactorTokenRequired")?;
115                if let Some(msg) = msg {
116                    write!(f, ": {}", msg)?;
117                }
118                Ok(())
119            }
120            Self::Unknown(err) => write!(f, "Unknown error: {:?}", err),
121        }
122    }
123}
124
125impl jacquard_common::IntoStatic for CreateSessionError<'_> {
126    type Output = CreateSessionError<'static>;
127    fn into_static(self) -> Self::Output {
128        match self {
129            CreateSessionError::AccountTakedown(v) => {
130                CreateSessionError::AccountTakedown(v.into_static())
131            }
132            CreateSessionError::AuthFactorTokenRequired(v) => {
133                CreateSessionError::AuthFactorTokenRequired(v.into_static())
134            }
135            CreateSessionError::Unknown(v) => {
136                CreateSessionError::Unknown(v.into_static())
137            }
138        }
139    }
140}
141
142///Response type for
143///com.atproto.server.createSession
144pub struct CreateSessionResponse;
145impl jacquard_common::xrpc::XrpcResp for CreateSessionResponse {
146    const NSID: &'static str = "com.atproto.server.createSession";
147    const ENCODING: &'static str = "application/json";
148    type Output<'de> = CreateSessionOutput<'de>;
149    type Err<'de> = CreateSessionError<'de>;
150}
151
152impl<'de> jacquard_common::xrpc::XrpcRequest<'de> for CreateSession<'de> {
153    const NSID: &'static str = "com.atproto.server.createSession";
154    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Procedure(
155        "application/json",
156    );
157    type Response = CreateSessionResponse;
158}
159
160///Endpoint type for
161///com.atproto.server.createSession
162pub struct CreateSessionRequest;
163impl jacquard_common::xrpc::XrpcEndpoint for CreateSessionRequest {
164    const PATH: &'static str = "/xrpc/com.atproto.server.createSession";
165    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Procedure(
166        "application/json",
167    );
168    type Request<'de> = CreateSession<'de>;
169    type Response = CreateSessionResponse;
170}