Skip to content

Commit

Permalink
feat: Update API, based on the latest lexicon schemas (#58)
Browse files Browse the repository at this point in the history
* Update API, based on the latest lexicon schemas

bluesky-social/atproto@cf848e8

* Fix agent and codegen

* Add new files...
  • Loading branch information
sugyan authored Nov 2, 2023
1 parent 0f4ddfa commit 83eaf24
Show file tree
Hide file tree
Showing 15 changed files with 248 additions and 6 deletions.
4 changes: 4 additions & 0 deletions atrium-api/src/agent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,13 @@ where
.session
.write()
.expect("write lock on session should not be poisoned");
let did_doc = session.as_ref().and_then(|s| s.did_doc.clone());
let email = session.as_ref().and_then(|s| s.email.clone());
let email_confirmed = session.as_ref().and_then(|s| s.email_confirmed);
session.replace(Session {
access_jwt: output.access_jwt,
did: output.did,
did_doc,
email,
email_confirmed,
handle: output.handle,
Expand Down Expand Up @@ -314,6 +316,7 @@ mod tests {
&crate::com::atproto::server::refresh_session::Output {
access_jwt: String::from("access"),
did: String::from("did"),
did_doc: None,
handle: String::from("handle"),
refresh_jwt: String::from("refresh"),
},
Expand Down Expand Up @@ -348,6 +351,7 @@ mod tests {
Session {
access_jwt: String::from("access"),
did: String::from("did"),
did_doc: None,
email: None,
email_confirmed: None,
handle: String::from("handle"),
Expand Down
2 changes: 2 additions & 0 deletions atrium-api/src/app/bsky/actor/defs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ pub struct ViewerState {
#[serde(skip_serializing_if = "Option::is_none")]
pub blocking: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub blocking_by_list: Option<crate::app::bsky::graph::defs::ListViewBasic>,
#[serde(skip_serializing_if = "Option::is_none")]
pub followed_by: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub following: Option<String>,
Expand Down
92 changes: 92 additions & 0 deletions atrium-api/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1350,6 +1350,29 @@ where
_ => Err(atrium_xrpc::error::Error::UnexpectedResponseType),
}
}
#[doc = "View details about an account."]
pub async fn get_account_info(
&self,
params: crate::com::atproto::admin::get_account_info::Parameters,
) -> Result<
crate::com::atproto::admin::get_account_info::Output,
atrium_xrpc::error::Error<crate::com::atproto::admin::get_account_info::Error>,
> {
let response = self
.xrpc
.send_xrpc::<_, (), _, _>(&atrium_xrpc::XrpcRequest {
method: http::Method::GET,
path: "com.atproto.admin.getAccountInfo".into(),
parameters: Some(params),
input: None,
encoding: None,
})
.await?;
match response {
atrium_xrpc::OutputDataOrBytes::Data(data) => Ok(data),
_ => Err(atrium_xrpc::error::Error::UnexpectedResponseType),
}
}
#[doc = "Admin view of invite codes"]
pub async fn get_invite_codes(
&self,
Expand Down Expand Up @@ -1511,6 +1534,29 @@ where
_ => Err(atrium_xrpc::error::Error::UnexpectedResponseType),
}
}
#[doc = "Fetch the service-specific the admin status of a subject (account, record, or blob)"]
pub async fn get_subject_status(
&self,
params: crate::com::atproto::admin::get_subject_status::Parameters,
) -> Result<
crate::com::atproto::admin::get_subject_status::Output,
atrium_xrpc::error::Error<crate::com::atproto::admin::get_subject_status::Error>,
> {
let response = self
.xrpc
.send_xrpc::<_, (), _, _>(&atrium_xrpc::XrpcRequest {
method: http::Method::GET,
path: "com.atproto.admin.getSubjectStatus".into(),
parameters: Some(params),
input: None,
encoding: None,
})
.await?;
match response {
atrium_xrpc::OutputDataOrBytes::Data(data) => Ok(data),
_ => Err(atrium_xrpc::error::Error::UnexpectedResponseType),
}
}
#[doc = "Resolve moderation reports by an action."]
pub async fn resolve_moderation_reports(
&self,
Expand Down Expand Up @@ -1672,6 +1718,29 @@ where
_ => Err(atrium_xrpc::error::Error::UnexpectedResponseType),
}
}
#[doc = "Update the service-specific admin status of a subject (account, record, or blob)"]
pub async fn update_subject_status(
&self,
input: crate::com::atproto::admin::update_subject_status::Input,
) -> Result<
crate::com::atproto::admin::update_subject_status::Output,
atrium_xrpc::error::Error<crate::com::atproto::admin::update_subject_status::Error>,
> {
let response = self
.xrpc
.send_xrpc::<(), _, _, _>(&atrium_xrpc::XrpcRequest {
method: http::Method::POST,
path: "com.atproto.admin.updateSubjectStatus".into(),
parameters: None,
input: Some(atrium_xrpc::InputDataOrBytes::Data(input)),
encoding: Some(String::from("application/json")),
})
.await?;
match response {
atrium_xrpc::OutputDataOrBytes::Data(data) => Ok(data),
_ => Err(atrium_xrpc::error::Error::UnexpectedResponseType),
}
}
}
impl<T> com::atproto::identity::Service<T>
where
Expand Down Expand Up @@ -2358,6 +2427,29 @@ where
_ => Err(atrium_xrpc::error::Error::UnexpectedResponseType),
}
}
#[doc = "Reserve a repo signing key for account creation."]
pub async fn reserve_signing_key(
&self,
input: crate::com::atproto::server::reserve_signing_key::Input,
) -> Result<
crate::com::atproto::server::reserve_signing_key::Output,
atrium_xrpc::error::Error<crate::com::atproto::server::reserve_signing_key::Error>,
> {
let response = self
.xrpc
.send_xrpc::<(), _, _, _>(&atrium_xrpc::XrpcRequest {
method: http::Method::POST,
path: "com.atproto.server.reserveSigningKey".into(),
parameters: None,
input: Some(atrium_xrpc::InputDataOrBytes::Data(input)),
encoding: Some(String::from("application/json")),
})
.await?;
match response {
atrium_xrpc::OutputDataOrBytes::Data(data) => Ok(data),
_ => Err(atrium_xrpc::error::Error::UnexpectedResponseType),
}
}
#[doc = "Reset a user account password using a token."]
pub async fn reset_password(
&self,
Expand Down
3 changes: 3 additions & 0 deletions atrium-api/src/com/atproto/admin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,20 @@ pub mod defs;
pub mod disable_account_invites;
pub mod disable_invite_codes;
pub mod enable_account_invites;
pub mod get_account_info;
pub mod get_invite_codes;
pub mod get_moderation_action;
pub mod get_moderation_actions;
pub mod get_moderation_report;
pub mod get_moderation_reports;
pub mod get_record;
pub mod get_repo;
pub mod get_subject_status;
pub mod resolve_moderation_reports;
pub mod reverse_moderation_action;
pub mod search_repos;
pub mod send_email;
pub mod take_moderation_action;
pub mod update_account_email;
pub mod update_account_handle;
pub mod update_subject_status;
32 changes: 32 additions & 0 deletions atrium-api/src/com/atproto/admin/defs.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,22 @@
// This file is generated by atrium-codegen. DO NOT EDIT.
#![doc = "Definitions for the `com.atproto.admin.defs` namespace."]
#[derive(serde :: Serialize, serde :: Deserialize, Debug, Clone, PartialEq, Eq)]
#[serde(rename_all = "camelCase")]
pub struct AccountView {
pub did: String,
#[serde(skip_serializing_if = "Option::is_none")]
pub email: Option<String>,
pub handle: String,
pub indexed_at: String,
#[serde(skip_serializing_if = "Option::is_none")]
pub invite_note: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub invited_by: Option<crate::com::atproto::server::defs::InviteCode>,
#[serde(skip_serializing_if = "Option::is_none")]
pub invites: Option<Vec<crate::com::atproto::server::defs::InviteCode>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub invites_disabled: Option<bool>,
}
#[doc = "Moderation action type: Acknowledge. Indicates that the content was reviewed and not considered to violate PDS rules."]
pub struct Acknowledge;
#[derive(serde :: Serialize, serde :: Deserialize, Debug, Clone, PartialEq, Eq)]
Expand Down Expand Up @@ -128,6 +145,14 @@ pub struct RecordViewNotFound {
}
#[derive(serde :: Serialize, serde :: Deserialize, Debug, Clone, PartialEq, Eq)]
#[serde(rename_all = "camelCase")]
pub struct RepoBlobRef {
pub cid: String,
pub did: String,
#[serde(skip_serializing_if = "Option::is_none")]
pub record_uri: Option<String>,
}
#[derive(serde :: Serialize, serde :: Deserialize, Debug, Clone, PartialEq, Eq)]
#[serde(rename_all = "camelCase")]
pub struct RepoRef {
pub did: String,
}
Expand Down Expand Up @@ -200,6 +225,13 @@ pub struct ReportViewDetail {
pub resolved_by_actions: Vec<crate::com::atproto::admin::defs::ActionView>,
pub subject: ReportViewDetailSubjectEnum,
}
#[derive(serde :: Serialize, serde :: Deserialize, Debug, Clone, PartialEq, Eq)]
#[serde(rename_all = "camelCase")]
pub struct StatusAttr {
pub applied: bool,
#[serde(skip_serializing_if = "Option::is_none")]
pub r#ref: Option<String>,
}
#[doc = "Moderation action type: Takedown. Indicates that content should not be served by the PDS."]
pub struct Takedown;
#[derive(serde :: Serialize, serde :: Deserialize, Debug, Clone, PartialEq, Eq)]
Expand Down
11 changes: 11 additions & 0 deletions atrium-api/src/com/atproto/admin/get_account_info.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// This file is generated by atrium-codegen. DO NOT EDIT.
#![doc = "Definitions for the `com.atproto.admin.getAccountInfo` namespace."]
#[derive(serde :: Serialize, serde :: Deserialize, Debug, Clone, PartialEq, Eq)]
#[serde(rename_all = "camelCase")]
pub struct Parameters {
pub did: String,
}
pub type Output = crate::com::atproto::admin::defs::AccountView;
#[derive(serde :: Serialize, serde :: Deserialize, Debug, Clone, PartialEq, Eq)]
#[serde(tag = "error", content = "message")]
pub enum Error {}
32 changes: 32 additions & 0 deletions atrium-api/src/com/atproto/admin/get_subject_status.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// This file is generated by atrium-codegen. DO NOT EDIT.
#![doc = "Definitions for the `com.atproto.admin.getSubjectStatus` namespace."]
#[derive(serde :: Serialize, serde :: Deserialize, Debug, Clone, PartialEq, Eq)]
#[serde(rename_all = "camelCase")]
pub struct Parameters {
#[serde(skip_serializing_if = "Option::is_none")]
pub blob: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub did: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub uri: Option<String>,
}
#[derive(serde :: Serialize, serde :: Deserialize, Debug, Clone, PartialEq, Eq)]
#[serde(rename_all = "camelCase")]
pub struct Output {
pub subject: OutputSubjectEnum,
#[serde(skip_serializing_if = "Option::is_none")]
pub takedown: Option<crate::com::atproto::admin::defs::StatusAttr>,
}
#[derive(serde :: Serialize, serde :: Deserialize, Debug, Clone, PartialEq, Eq)]
#[serde(tag = "error", content = "message")]
pub enum Error {}
#[derive(serde :: Serialize, serde :: Deserialize, Debug, Clone, PartialEq, Eq)]
#[serde(tag = "$type")]
pub enum OutputSubjectEnum {
#[serde(rename = "com.atproto.admin.defs#repoRef")]
ComAtprotoAdminDefsRepoRef(Box<crate::com::atproto::admin::defs::RepoRef>),
#[serde(rename = "com.atproto.repo.strongRef")]
ComAtprotoRepoStrongRefMain(Box<crate::com::atproto::repo::strong_ref::Main>),
#[serde(rename = "com.atproto.admin.defs#repoBlobRef")]
ComAtprotoAdminDefsRepoBlobRef(Box<crate::com::atproto::admin::defs::RepoBlobRef>),
}
2 changes: 0 additions & 2 deletions atrium-api/src/com/atproto/admin/search_repos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ pub struct Parameters {
#[serde(skip_serializing_if = "Option::is_none")]
pub cursor: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub invited_by: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub limit: Option<i32>,
#[serde(skip_serializing_if = "Option::is_none")]
pub q: Option<String>,
Expand Down
39 changes: 39 additions & 0 deletions atrium-api/src/com/atproto/admin/update_subject_status.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// This file is generated by atrium-codegen. DO NOT EDIT.
#![doc = "Definitions for the `com.atproto.admin.updateSubjectStatus` namespace."]
#[derive(serde :: Serialize, serde :: Deserialize, Debug, Clone, PartialEq, Eq)]
#[serde(rename_all = "camelCase")]
pub struct Input {
pub subject: InputSubjectEnum,
#[serde(skip_serializing_if = "Option::is_none")]
pub takedown: Option<crate::com::atproto::admin::defs::StatusAttr>,
}
#[derive(serde :: Serialize, serde :: Deserialize, Debug, Clone, PartialEq, Eq)]
#[serde(rename_all = "camelCase")]
pub struct Output {
pub subject: OutputSubjectEnum,
#[serde(skip_serializing_if = "Option::is_none")]
pub takedown: Option<crate::com::atproto::admin::defs::StatusAttr>,
}
#[derive(serde :: Serialize, serde :: Deserialize, Debug, Clone, PartialEq, Eq)]
#[serde(tag = "error", content = "message")]
pub enum Error {}
#[derive(serde :: Serialize, serde :: Deserialize, Debug, Clone, PartialEq, Eq)]
#[serde(tag = "$type")]
pub enum InputSubjectEnum {
#[serde(rename = "com.atproto.admin.defs#repoRef")]
ComAtprotoAdminDefsRepoRef(Box<crate::com::atproto::admin::defs::RepoRef>),
#[serde(rename = "com.atproto.repo.strongRef")]
ComAtprotoRepoStrongRefMain(Box<crate::com::atproto::repo::strong_ref::Main>),
#[serde(rename = "com.atproto.admin.defs#repoBlobRef")]
ComAtprotoAdminDefsRepoBlobRef(Box<crate::com::atproto::admin::defs::RepoBlobRef>),
}
#[derive(serde :: Serialize, serde :: Deserialize, Debug, Clone, PartialEq, Eq)]
#[serde(tag = "$type")]
pub enum OutputSubjectEnum {
#[serde(rename = "com.atproto.admin.defs#repoRef")]
ComAtprotoAdminDefsRepoRef(Box<crate::com::atproto::admin::defs::RepoRef>),
#[serde(rename = "com.atproto.repo.strongRef")]
ComAtprotoRepoStrongRefMain(Box<crate::com::atproto::repo::strong_ref::Main>),
#[serde(rename = "com.atproto.admin.defs#repoBlobRef")]
ComAtprotoAdminDefsRepoBlobRef(Box<crate::com::atproto::admin::defs::RepoBlobRef>),
}
1 change: 1 addition & 0 deletions atrium-api/src/com/atproto/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ pub mod request_account_delete;
pub mod request_email_confirmation;
pub mod request_email_update;
pub mod request_password_reset;
pub mod reserve_signing_key;
pub mod reset_password;
pub mod revoke_app_password;
pub mod update_email;
10 changes: 8 additions & 2 deletions atrium-api/src/com/atproto/server/create_account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,15 @@
pub struct Input {
#[serde(skip_serializing_if = "Option::is_none")]
pub did: Option<String>,
pub email: String,
#[serde(skip_serializing_if = "Option::is_none")]
pub email: Option<String>,
pub handle: String,
#[serde(skip_serializing_if = "Option::is_none")]
pub invite_code: Option<String>,
pub password: String,
#[serde(skip_serializing_if = "Option::is_none")]
pub password: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub plc_op: Option<crate::records::Record>,
#[serde(skip_serializing_if = "Option::is_none")]
pub recovery_key: Option<String>,
}
Expand All @@ -18,6 +22,8 @@ pub struct Input {
pub struct Output {
pub access_jwt: String,
pub did: String,
#[serde(skip_serializing_if = "Option::is_none")]
pub did_doc: Option<crate::records::Record>,
pub handle: String,
pub refresh_jwt: String,
}
Expand Down
2 changes: 2 additions & 0 deletions atrium-api/src/com/atproto/server/create_session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ pub struct Output {
pub access_jwt: String,
pub did: String,
#[serde(skip_serializing_if = "Option::is_none")]
pub did_doc: Option<crate::records::Record>,
#[serde(skip_serializing_if = "Option::is_none")]
pub email: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub email_confirmed: Option<bool>,
Expand Down
2 changes: 2 additions & 0 deletions atrium-api/src/com/atproto/server/refresh_session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
pub struct Output {
pub access_jwt: String,
pub did: String,
#[serde(skip_serializing_if = "Option::is_none")]
pub did_doc: Option<crate::records::Record>,
pub handle: String,
pub refresh_jwt: String,
}
Expand Down
18 changes: 18 additions & 0 deletions atrium-api/src/com/atproto/server/reserve_signing_key.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// This file is generated by atrium-codegen. DO NOT EDIT.
#![doc = "Definitions for the `com.atproto.server.reserveSigningKey` namespace."]
#[derive(serde :: Serialize, serde :: Deserialize, Debug, Clone, PartialEq, Eq)]
#[serde(rename_all = "camelCase")]
pub struct Input {
#[doc = "The did to reserve a new did:key for"]
#[serde(skip_serializing_if = "Option::is_none")]
pub did: Option<String>,
}
#[derive(serde :: Serialize, serde :: Deserialize, Debug, Clone, PartialEq, Eq)]
#[serde(rename_all = "camelCase")]
pub struct Output {
#[doc = "Public signing key in the form of a did:key."]
pub signing_key: String,
}
#[derive(serde :: Serialize, serde :: Deserialize, Debug, Clone, PartialEq, Eq)]
#[serde(tag = "error", content = "message")]
pub enum Error {}
Loading

0 comments on commit 83eaf24

Please sign in to comment.