atrium_api/com/atproto/repo/
apply_writes.rs

1// @generated - This file is generated by atrium-codegen. DO NOT EDIT.
2//!Definitions for the `com.atproto.repo.applyWrites` namespace.
3pub const NSID: &str = "com.atproto.repo.applyWrites";
4#[derive(serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq)]
5#[serde(rename_all = "camelCase")]
6pub struct InputData {
7    ///The handle or DID of the repo (aka, current account).
8    pub repo: crate::types::string::AtIdentifier,
9    ///If provided, the entire operation will fail if the current repo commit CID does not match this value. Used to prevent conflicting repo mutations.
10    #[serde(skip_serializing_if = "core::option::Option::is_none")]
11    pub swap_commit: core::option::Option<crate::types::string::Cid>,
12    ///Can be set to 'false' to skip Lexicon schema validation of record data across all operations, 'true' to require it, or leave unset to validate only for known Lexicons.
13    #[serde(skip_serializing_if = "core::option::Option::is_none")]
14    pub validate: core::option::Option<bool>,
15    pub writes: Vec<InputWritesItem>,
16}
17pub type Input = crate::types::Object<InputData>;
18#[derive(serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq)]
19#[serde(rename_all = "camelCase")]
20pub struct OutputData {
21    #[serde(skip_serializing_if = "core::option::Option::is_none")]
22    pub commit: core::option::Option<crate::com::atproto::repo::defs::CommitMeta>,
23    #[serde(skip_serializing_if = "core::option::Option::is_none")]
24    pub results: core::option::Option<Vec<OutputResultsItem>>,
25}
26pub type Output = crate::types::Object<OutputData>;
27#[derive(serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq)]
28#[serde(tag = "error", content = "message")]
29pub enum Error {
30    ///Indicates that the 'swapCommit' parameter did not match current commit.
31    InvalidSwap(Option<String>),
32}
33impl std::fmt::Display for Error {
34    fn fmt(&self, _f: &mut std::fmt::Formatter) -> std::fmt::Result {
35        match self {
36            Error::InvalidSwap(msg) => {
37                write!(_f, "InvalidSwap")?;
38                if let Some(msg) = msg {
39                    write!(_f, ": {msg}")?;
40                }
41            }
42        }
43        Ok(())
44    }
45}
46///Operation which creates a new record.
47#[derive(serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq)]
48#[serde(rename_all = "camelCase")]
49pub struct CreateData {
50    pub collection: crate::types::string::Nsid,
51    ///NOTE: maxLength is redundant with record-key format. Keeping it temporarily to ensure backwards compatibility.
52    #[serde(skip_serializing_if = "core::option::Option::is_none")]
53    pub rkey: core::option::Option<crate::types::string::RecordKey>,
54    pub value: crate::types::Unknown,
55}
56pub type Create = crate::types::Object<CreateData>;
57#[derive(serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq)]
58#[serde(rename_all = "camelCase")]
59pub struct CreateResultData {
60    pub cid: crate::types::string::Cid,
61    pub uri: String,
62    #[serde(skip_serializing_if = "core::option::Option::is_none")]
63    pub validation_status: core::option::Option<String>,
64}
65pub type CreateResult = crate::types::Object<CreateResultData>;
66///Operation which deletes an existing record.
67#[derive(serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq)]
68#[serde(rename_all = "camelCase")]
69pub struct DeleteData {
70    pub collection: crate::types::string::Nsid,
71    pub rkey: crate::types::string::RecordKey,
72}
73pub type Delete = crate::types::Object<DeleteData>;
74#[derive(serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq)]
75#[serde(rename_all = "camelCase")]
76pub struct DeleteResultData {}
77pub type DeleteResult = crate::types::Object<DeleteResultData>;
78///Operation which updates an existing record.
79#[derive(serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq)]
80#[serde(rename_all = "camelCase")]
81pub struct UpdateData {
82    pub collection: crate::types::string::Nsid,
83    pub rkey: crate::types::string::RecordKey,
84    pub value: crate::types::Unknown,
85}
86pub type Update = crate::types::Object<UpdateData>;
87#[derive(serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq)]
88#[serde(rename_all = "camelCase")]
89pub struct UpdateResultData {
90    pub cid: crate::types::string::Cid,
91    pub uri: String,
92    #[serde(skip_serializing_if = "core::option::Option::is_none")]
93    pub validation_status: core::option::Option<String>,
94}
95pub type UpdateResult = crate::types::Object<UpdateResultData>;
96#[derive(serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq)]
97#[serde(tag = "$type")]
98pub enum InputWritesItem {
99    #[serde(rename = "com.atproto.repo.applyWrites#create")]
100    Create(Box<Create>),
101    #[serde(rename = "com.atproto.repo.applyWrites#update")]
102    Update(Box<Update>),
103    #[serde(rename = "com.atproto.repo.applyWrites#delete")]
104    Delete(Box<Delete>),
105}
106#[derive(serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq)]
107#[serde(tag = "$type")]
108pub enum OutputResultsItem {
109    #[serde(rename = "com.atproto.repo.applyWrites#createResult")]
110    CreateResult(Box<CreateResult>),
111    #[serde(rename = "com.atproto.repo.applyWrites#updateResult")]
112    UpdateResult(Box<UpdateResult>),
113    #[serde(rename = "com.atproto.repo.applyWrites#deleteResult")]
114    DeleteResult(Box<DeleteResult>),
115}