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)]
18#[serde(rename_all = "camelCase")]
19#[builder(start_fn = new)]
20pub struct CreateSession<'a> {
21 ///When true, instead of throwing error for takendown accounts, a valid response with a narrow scoped token will be returned
22 #[serde(skip_serializing_if = "std::option::Option::is_none")]
23 pub allow_takendown: std::option::Option<bool>,
24 #[serde(skip_serializing_if = "std::option::Option::is_none")]
25 #[serde(borrow)]
26 #[builder(into)]
27 pub auth_factor_token: std::option::Option<jacquard_common::CowStr<'a>>,
28 ///Handle or other identifier supported by the server for the authenticating user.
29 #[serde(borrow)]
30 #[builder(into)]
31 pub identifier: jacquard_common::CowStr<'a>,
32 #[serde(borrow)]
33 #[builder(into)]
34 pub password: jacquard_common::CowStr<'a>,
35 #[serde(flatten)]
36 #[serde(borrow)]
37 #[builder(default)]
38 pub extra_data: ::std::collections::BTreeMap<
39 ::jacquard_common::smol_str::SmolStr,
40 ::jacquard_common::types::value::Data<'a>,
41 >,
42}
43
44impl jacquard_common::IntoStatic for CreateSession<'_> {
45 type Output = CreateSession<'static>;
46 fn into_static(self) -> Self::Output {
47 CreateSession {
48 allow_takendown: self.allow_takendown.into_static(),
49 auth_factor_token: self.auth_factor_token.into_static(),
50 identifier: self.identifier.into_static(),
51 password: self.password.into_static(),
52 extra_data: self.extra_data.into_static(),
53 }
54 }
55}
56
57#[jacquard_derive::lexicon]
58#[derive(serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq)]
59#[serde(rename_all = "camelCase")]
60pub struct CreateSessionOutput<'a> {
61 #[serde(borrow)]
62 pub access_jwt: jacquard_common::CowStr<'a>,
63 #[serde(skip_serializing_if = "std::option::Option::is_none")]
64 pub active: std::option::Option<bool>,
65 #[serde(borrow)]
66 pub did: jacquard_common::types::string::Did<'a>,
67 #[serde(skip_serializing_if = "std::option::Option::is_none")]
68 #[serde(borrow)]
69 pub did_doc: std::option::Option<jacquard_common::types::value::Data<'a>>,
70 #[serde(skip_serializing_if = "std::option::Option::is_none")]
71 #[serde(borrow)]
72 pub email: std::option::Option<jacquard_common::CowStr<'a>>,
73 #[serde(skip_serializing_if = "std::option::Option::is_none")]
74 pub email_auth_factor: std::option::Option<bool>,
75 #[serde(skip_serializing_if = "std::option::Option::is_none")]
76 pub email_confirmed: std::option::Option<bool>,
77 #[serde(borrow)]
78 pub handle: jacquard_common::types::string::Handle<'a>,
79 #[serde(borrow)]
80 pub refresh_jwt: jacquard_common::CowStr<'a>,
81 ///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.
82 #[serde(skip_serializing_if = "std::option::Option::is_none")]
83 #[serde(borrow)]
84 pub status: std::option::Option<jacquard_common::CowStr<'a>>,
85}
86
87impl jacquard_common::IntoStatic for CreateSessionOutput<'_> {
88 type Output = CreateSessionOutput<'static>;
89 fn into_static(self) -> Self::Output {
90 CreateSessionOutput {
91 access_jwt: self.access_jwt.into_static(),
92 active: self.active.into_static(),
93 did: self.did.into_static(),
94 did_doc: self.did_doc.into_static(),
95 email: self.email.into_static(),
96 email_auth_factor: self.email_auth_factor.into_static(),
97 email_confirmed: self.email_confirmed.into_static(),
98 handle: self.handle.into_static(),
99 refresh_jwt: self.refresh_jwt.into_static(),
100 status: self.status.into_static(),
101 extra_data: self.extra_data.into_static(),
102 }
103 }
104}
105
106#[jacquard_derive::open_union]
107#[derive(
108 serde::Serialize,
109 serde::Deserialize,
110 Debug,
111 Clone,
112 PartialEq,
113 Eq,
114 thiserror::Error,
115 miette::Diagnostic
116)]
117#[serde(tag = "error", content = "message")]
118#[serde(bound(deserialize = "'de: 'a"))]
119pub enum CreateSessionError<'a> {
120 #[serde(rename = "AccountTakedown")]
121 AccountTakedown(std::option::Option<String>),
122 #[serde(rename = "AuthFactorTokenRequired")]
123 AuthFactorTokenRequired(std::option::Option<String>),
124}
125
126impl std::fmt::Display for CreateSessionError<'_> {
127 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
128 match self {
129 Self::AccountTakedown(msg) => {
130 write!(f, "AccountTakedown")?;
131 if let Some(msg) = msg {
132 write!(f, ": {}", msg)?;
133 }
134 Ok(())
135 }
136 Self::AuthFactorTokenRequired(msg) => {
137 write!(f, "AuthFactorTokenRequired")?;
138 if let Some(msg) = msg {
139 write!(f, ": {}", msg)?;
140 }
141 Ok(())
142 }
143 Self::Unknown(err) => write!(f, "Unknown error: {:?}", err),
144 }
145 }
146}
147
148impl jacquard_common::IntoStatic for CreateSessionError<'_> {
149 type Output = CreateSessionError<'static>;
150 fn into_static(self) -> Self::Output {
151 match self {
152 CreateSessionError::AccountTakedown(v) => {
153 CreateSessionError::AccountTakedown(v.into_static())
154 }
155 CreateSessionError::AuthFactorTokenRequired(v) => {
156 CreateSessionError::AuthFactorTokenRequired(v.into_static())
157 }
158 CreateSessionError::Unknown(v) => {
159 CreateSessionError::Unknown(v.into_static())
160 }
161 }
162 }
163}
164
165impl jacquard_common::types::xrpc::XrpcRequest for CreateSession<'_> {
166 const NSID: &'static str = "com.atproto.server.createSession";
167 const METHOD: jacquard_common::types::xrpc::XrpcMethod = jacquard_common::types::xrpc::XrpcMethod::Procedure(
168 "application/json",
169 );
170 const OUTPUT_ENCODING: &'static str = "application/json";
171 type Output<'de> = CreateSessionOutput<'de>;
172 type Err<'de> = CreateSessionError<'de>;
173}