#[allow(unused_imports)]
use alloc::collections::BTreeMap;
#[allow(unused_imports)]
use core::marker::PhantomData;
use jacquard_common::CowStr;
use jacquard_common::types::string::{Did, Datetime};
use jacquard_derive::{IntoStatic, lexicon};
use serde::{Serialize, Deserialize};
use crate::tools_ozone::moderation::ScheduledActionView;
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct ListScheduledActions<'a> {
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub cursor: Option<CowStr<'a>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub ends_before: Option<Datetime>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(default = "_default_list_scheduled_actions_limit")]
pub limit: Option<i64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub starts_after: Option<Datetime>,
#[serde(borrow)]
pub statuses: Vec<CowStr<'a>>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub subjects: Option<Vec<Did<'a>>>,
}
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct ListScheduledActionsOutput<'a> {
#[serde(borrow)]
pub actions: Vec<ScheduledActionView<'a>>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub cursor: Option<CowStr<'a>>,
}
pub struct ListScheduledActionsResponse;
impl jacquard_common::xrpc::XrpcResp for ListScheduledActionsResponse {
const NSID: &'static str = "tools.ozone.moderation.listScheduledActions";
const ENCODING: &'static str = "application/json";
type Output<'de> = ListScheduledActionsOutput<'de>;
type Err<'de> = jacquard_common::xrpc::GenericError<'de>;
}
impl<'a> jacquard_common::xrpc::XrpcRequest for ListScheduledActions<'a> {
const NSID: &'static str = "tools.ozone.moderation.listScheduledActions";
const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Procedure(
"application/json",
);
type Response = ListScheduledActionsResponse;
}
pub struct ListScheduledActionsRequest;
impl jacquard_common::xrpc::XrpcEndpoint for ListScheduledActionsRequest {
const PATH: &'static str = "/xrpc/tools.ozone.moderation.listScheduledActions";
const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Procedure(
"application/json",
);
type Request<'de> = ListScheduledActions<'de>;
type Response = ListScheduledActionsResponse;
}
fn _default_list_scheduled_actions_limit() -> Option<i64> {
Some(50i64)
}
pub mod list_scheduled_actions_state {
pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
#[allow(unused)]
use ::core::marker::PhantomData;
mod sealed {
pub trait Sealed {}
}
pub trait State: sealed::Sealed {
type Statuses;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Statuses = Unset;
}
pub struct SetStatuses<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetStatuses<S> {}
impl<S: State> State for SetStatuses<S> {
type Statuses = Set<members::statuses>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct statuses(());
}
}
pub struct ListScheduledActionsBuilder<'a, S: list_scheduled_actions_state::State> {
_state: PhantomData<fn() -> S>,
_fields: (
Option<CowStr<'a>>,
Option<Datetime>,
Option<i64>,
Option<Datetime>,
Option<Vec<CowStr<'a>>>,
Option<Vec<Did<'a>>>,
),
_lifetime: PhantomData<&'a ()>,
}
impl<'a> ListScheduledActions<'a> {
pub fn new() -> ListScheduledActionsBuilder<
'a,
list_scheduled_actions_state::Empty,
> {
ListScheduledActionsBuilder::new()
}
}
impl<'a> ListScheduledActionsBuilder<'a, list_scheduled_actions_state::Empty> {
pub fn new() -> Self {
ListScheduledActionsBuilder {
_state: PhantomData,
_fields: (None, None, None, None, None, None),
_lifetime: PhantomData,
}
}
}
impl<'a, S: list_scheduled_actions_state::State> ListScheduledActionsBuilder<'a, S> {
pub fn cursor(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
self._fields.0 = value.into();
self
}
pub fn maybe_cursor(mut self, value: Option<CowStr<'a>>) -> Self {
self._fields.0 = value;
self
}
}
impl<'a, S: list_scheduled_actions_state::State> ListScheduledActionsBuilder<'a, S> {
pub fn ends_before(mut self, value: impl Into<Option<Datetime>>) -> Self {
self._fields.1 = value.into();
self
}
pub fn maybe_ends_before(mut self, value: Option<Datetime>) -> Self {
self._fields.1 = value;
self
}
}
impl<'a, S: list_scheduled_actions_state::State> ListScheduledActionsBuilder<'a, S> {
pub fn limit(mut self, value: impl Into<Option<i64>>) -> Self {
self._fields.2 = value.into();
self
}
pub fn maybe_limit(mut self, value: Option<i64>) -> Self {
self._fields.2 = value;
self
}
}
impl<'a, S: list_scheduled_actions_state::State> ListScheduledActionsBuilder<'a, S> {
pub fn starts_after(mut self, value: impl Into<Option<Datetime>>) -> Self {
self._fields.3 = value.into();
self
}
pub fn maybe_starts_after(mut self, value: Option<Datetime>) -> Self {
self._fields.3 = value;
self
}
}
impl<'a, S> ListScheduledActionsBuilder<'a, S>
where
S: list_scheduled_actions_state::State,
S::Statuses: list_scheduled_actions_state::IsUnset,
{
pub fn statuses(
mut self,
value: impl Into<Vec<CowStr<'a>>>,
) -> ListScheduledActionsBuilder<'a, list_scheduled_actions_state::SetStatuses<S>> {
self._fields.4 = Option::Some(value.into());
ListScheduledActionsBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S: list_scheduled_actions_state::State> ListScheduledActionsBuilder<'a, S> {
pub fn subjects(mut self, value: impl Into<Option<Vec<Did<'a>>>>) -> Self {
self._fields.5 = value.into();
self
}
pub fn maybe_subjects(mut self, value: Option<Vec<Did<'a>>>) -> Self {
self._fields.5 = value;
self
}
}
impl<'a, S> ListScheduledActionsBuilder<'a, S>
where
S: list_scheduled_actions_state::State,
S::Statuses: list_scheduled_actions_state::IsSet,
{
pub fn build(self) -> ListScheduledActions<'a> {
ListScheduledActions {
cursor: self._fields.0,
ends_before: self._fields.1,
limit: self._fields.2.or_else(|| Some(50i64)),
starts_after: self._fields.3,
statuses: self._fields.4.unwrap(),
subjects: self._fields.5,
extra_data: Default::default(),
}
}
pub fn build_with_data(
self,
extra_data: BTreeMap<
jacquard_common::deps::smol_str::SmolStr,
jacquard_common::types::value::Data<'a>,
>,
) -> ListScheduledActions<'a> {
ListScheduledActions {
cursor: self._fields.0,
ends_before: self._fields.1,
limit: self._fields.2.or_else(|| Some(50i64)),
starts_after: self._fields.3,
statuses: self._fields.4.unwrap(),
subjects: self._fields.5,
extra_data: Some(extra_data),
}
}
}