// @generated by jacquard-lexicon. DO NOT EDIT.
//
// Lexicon: tools.ozone.moderation.scheduleAction
//
// This file was automatically generated from Lexicon schemas.
// Any manual changes will be overwritten on the next regeneration.

#[allow(unused_imports)]
use alloc::collections::BTreeMap;

#[allow(unused_imports)]
use core::marker::PhantomData;
use jacquard_common::{CowStr, BosStr, DefaultStr, FromStaticStr};

#[allow(unused_imports)]
use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;
use jacquard_common::deps::smol_str::SmolStr;
use jacquard_common::types::string::{Did, Datetime};
use jacquard_common::types::value::Data;
use jacquard_derive::IntoStatic;
use jacquard_lexicon::lexicon::LexiconDoc;
use jacquard_lexicon::schema::LexiconSchema;

#[allow(unused_imports)]
use jacquard_lexicon::validation::{ConstraintError, ValidationPath};
use serde::{Serialize, Deserialize};
use crate::tools_ozone::moderation::ModTool;
use crate::tools_ozone::moderation::schedule_action;

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct FailedScheduling<S: BosStr = DefaultStr> {
    pub error: S,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub error_code: Option<S>,
    pub subject: Did<S>,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}


#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct ScheduleAction<S: BosStr = DefaultStr> {
    pub action: schedule_action::Takedown<S>,
    pub created_by: Did<S>,
    ///This will be propagated to the moderation event when it is applied
    #[serde(skip_serializing_if = "Option::is_none")]
    pub mod_tool: Option<ModTool<S>>,
    pub scheduling: schedule_action::SchedulingConfig<S>,
    ///Array of DID subjects to schedule the action for
    pub subjects: Vec<Did<S>>,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}


#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct ScheduleActionOutput<S: BosStr = DefaultStr> {
    #[serde(flatten)]
    pub value: Data<S>,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}


#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct ScheduledActionResults<S: BosStr = DefaultStr> {
    pub failed: Vec<schedule_action::FailedScheduling<S>>,
    pub succeeded: Vec<Did<S>>,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}

/// Configuration for when the action should be executed

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct SchedulingConfig<S: BosStr = DefaultStr> {
    ///Earliest time to execute the action (for randomized scheduling)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub execute_after: Option<Datetime>,
    ///Exact time to execute the action
    #[serde(skip_serializing_if = "Option::is_none")]
    pub execute_at: Option<Datetime>,
    ///Latest time to execute the action (for randomized scheduling)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub execute_until: Option<Datetime>,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}

/// Schedule a takedown action

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct Takedown<S: BosStr = DefaultStr> {
    ///If true, all other reports on content authored by this account will be resolved (acknowledged).
    #[serde(skip_serializing_if = "Option::is_none")]
    pub acknowledge_account_subjects: Option<bool>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub comment: Option<S>,
    ///Indicates how long the takedown should be in effect before automatically expiring.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub duration_in_hours: Option<i64>,
    ///Email content to be sent to the user upon takedown.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub email_content: Option<S>,
    ///Subject of the email to be sent to the user upon takedown.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub email_subject: Option<S>,
    ///Names/Keywords of the policies that drove the decision.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub policies: Option<Vec<S>>,
    ///Severity level of the violation (e.g., 'sev-0', 'sev-1', 'sev-2', etc.).
    #[serde(skip_serializing_if = "Option::is_none")]
    pub severity_level: Option<S>,
    ///Number of strikes to assign to the user when takedown is applied.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub strike_count: Option<i64>,
    ///When the strike should expire. If not provided, the strike never expires.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub strike_expires_at: Option<Datetime>,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}

impl<S: BosStr> LexiconSchema for FailedScheduling<S> {
    fn nsid() -> &'static str {
        "tools.ozone.moderation.scheduleAction"
    }
    fn def_name() -> &'static str {
        "failedScheduling"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_tools_ozone_moderation_scheduleAction()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

/** Response marker for the `tools.ozone.moderation.scheduleAction` procedure.

Implements `jacquard_common::xrpc::XrpcResp`; successful bodies decode as `Self::Output<S>`, which is `ScheduleActionOutput<S>` for this endpoint.*/
pub struct ScheduleActionResponse;
impl jacquard_common::xrpc::XrpcResp for ScheduleActionResponse {
    const NSID: &'static str = "tools.ozone.moderation.scheduleAction";
    const ENCODING: &'static str = "application/json";
    type Output<S: BosStr> = ScheduleActionOutput<S>;
    type Err = jacquard_common::xrpc::GenericError;
}

impl<S: BosStr> jacquard_common::xrpc::XrpcRequest for ScheduleAction<S> {
    const NSID: &'static str = "tools.ozone.moderation.scheduleAction";
    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Procedure(
        "application/json",
    );
    type Response = ScheduleActionResponse;
}

/** Endpoint marker for the `tools.ozone.moderation.scheduleAction` procedure.

Path: `/xrpc/tools.ozone.moderation.scheduleAction`. The request payload type is `ScheduleAction<S>`; send that request with `jacquard::Client` or use this marker through lower-level `XrpcEndpoint` APIs.*/
pub struct ScheduleActionRequest;
impl jacquard_common::xrpc::XrpcEndpoint for ScheduleActionRequest {
    const PATH: &'static str = "/xrpc/tools.ozone.moderation.scheduleAction";
    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Procedure(
        "application/json",
    );
    type Request<S: BosStr> = ScheduleAction<S>;
    type Response = ScheduleActionResponse;
}

impl<S: BosStr> LexiconSchema for ScheduledActionResults<S> {
    fn nsid() -> &'static str {
        "tools.ozone.moderation.scheduleAction"
    }
    fn def_name() -> &'static str {
        "scheduledActionResults"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_tools_ozone_moderation_scheduleAction()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

impl<S: BosStr> LexiconSchema for SchedulingConfig<S> {
    fn nsid() -> &'static str {
        "tools.ozone.moderation.scheduleAction"
    }
    fn def_name() -> &'static str {
        "schedulingConfig"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_tools_ozone_moderation_scheduleAction()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

impl<S: BosStr> LexiconSchema for Takedown<S> {
    fn nsid() -> &'static str {
        "tools.ozone.moderation.scheduleAction"
    }
    fn def_name() -> &'static str {
        "takedown"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_tools_ozone_moderation_scheduleAction()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        if let Some(ref value) = self.policies {
            #[allow(unused_comparisons)]
            if value.len() > 5usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("policies"),
                    max: 5usize,
                    actual: value.len(),
                });
            }
        }
        Ok(())
    }
}

pub mod failed_scheduling_state {

    pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
    #[allow(unused)]
    use ::core::marker::PhantomData;
    mod sealed {
        pub trait Sealed {}
    }
    /// State trait tracking which required fields have been set
    pub trait State: sealed::Sealed {
        type Error;
        type Subject;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type Error = Unset;
        type Subject = Unset;
    }
    ///State transition - sets the `error` field to Set
    pub struct SetError<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetError<St> {}
    impl<St: State> State for SetError<St> {
        type Error = Set<members::error>;
        type Subject = St::Subject;
    }
    ///State transition - sets the `subject` field to Set
    pub struct SetSubject<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetSubject<St> {}
    impl<St: State> State for SetSubject<St> {
        type Error = St::Error;
        type Subject = Set<members::subject>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `error` field
        pub struct error(());
        ///Marker type for the `subject` field
        pub struct subject(());
    }
}

/// Builder for constructing an instance of this type.
pub struct FailedSchedulingBuilder<
    St: failed_scheduling_state::State,
    S: BosStr = DefaultStr,
> {
    _state: PhantomData<fn() -> St>,
    _fields: (Option<S>, Option<S>, Option<Did<S>>),
    _type: PhantomData<fn() -> S>,
}

impl FailedScheduling<DefaultStr> {
    /// Create a new builder for this type, using the default string type (DefaultStr = SmolStr) if needed
    pub fn new() -> FailedSchedulingBuilder<failed_scheduling_state::Empty, DefaultStr> {
        FailedSchedulingBuilder::new()
    }
}

impl<S: BosStr> FailedScheduling<S> {
    /// Create a new builder for this type
    pub fn builder() -> FailedSchedulingBuilder<failed_scheduling_state::Empty, S> {
        FailedSchedulingBuilder::builder()
    }
}

impl FailedSchedulingBuilder<failed_scheduling_state::Empty, DefaultStr> {
    /// Create a new builder with all fields unset, using the default string type, if needed
    pub fn new() -> Self {
        FailedSchedulingBuilder {
            _state: PhantomData,
            _fields: (None, None, None),
            _type: PhantomData,
        }
    }
}

impl<S: BosStr> FailedSchedulingBuilder<failed_scheduling_state::Empty, S> {
    /// Create a new builder with all fields unset
    pub fn builder() -> Self {
        FailedSchedulingBuilder {
            _state: PhantomData,
            _fields: (None, None, None),
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> FailedSchedulingBuilder<St, S>
where
    St: failed_scheduling_state::State,
    St::Error: failed_scheduling_state::IsUnset,
{
    /// Set the `error` field (required)
    pub fn error(
        mut self,
        value: impl Into<S>,
    ) -> FailedSchedulingBuilder<failed_scheduling_state::SetError<St>, S> {
        self._fields.0 = Option::Some(value.into());
        FailedSchedulingBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St: failed_scheduling_state::State, S: BosStr> FailedSchedulingBuilder<St, S> {
    /// Set the `errorCode` field (optional)
    pub fn error_code(mut self, value: impl Into<Option<S>>) -> Self {
        self._fields.1 = value.into();
        self
    }
    /// Set the `errorCode` field to an Option value (optional)
    pub fn maybe_error_code(mut self, value: Option<S>) -> Self {
        self._fields.1 = value;
        self
    }
}

impl<St, S: BosStr> FailedSchedulingBuilder<St, S>
where
    St: failed_scheduling_state::State,
    St::Subject: failed_scheduling_state::IsUnset,
{
    /// Set the `subject` field (required)
    pub fn subject(
        mut self,
        value: impl Into<Did<S>>,
    ) -> FailedSchedulingBuilder<failed_scheduling_state::SetSubject<St>, S> {
        self._fields.2 = Option::Some(value.into());
        FailedSchedulingBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> FailedSchedulingBuilder<St, S>
where
    St: failed_scheduling_state::State,
    St::Error: failed_scheduling_state::IsSet,
    St::Subject: failed_scheduling_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> FailedScheduling<S> {
        FailedScheduling {
            error: self._fields.0.unwrap(),
            error_code: self._fields.1,
            subject: self._fields.2.unwrap(),
            extra_data: Default::default(),
        }
    }
    /// Build the final struct with custom extra_data.
    pub fn build_with_data(
        self,
        extra_data: BTreeMap<SmolStr, Data<S>>,
    ) -> FailedScheduling<S> {
        FailedScheduling {
            error: self._fields.0.unwrap(),
            error_code: self._fields.1,
            subject: self._fields.2.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}

fn lexicon_doc_tools_ozone_moderation_scheduleAction() -> LexiconDoc<'static> {
    #[allow(unused_imports)]
    use jacquard_common::{CowStr, deps::smol_str::SmolStr, types::blob::MimeType};
    use jacquard_lexicon::lexicon::*;
    use alloc::collections::BTreeMap;
    LexiconDoc {
        lexicon: Lexicon::Lexicon1,
        id: CowStr::new_static("tools.ozone.moderation.scheduleAction"),
        defs: {
            let mut map = BTreeMap::new();
            map.insert(
                SmolStr::new_static("failedScheduling"),
                LexUserType::Object(LexObject {
                    required: Some(
                        vec![
                            SmolStr::new_static("subject"), SmolStr::new_static("error")
                        ],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("error"),
                            LexObjectProperty::String(LexString { ..Default::default() }),
                        );
                        map.insert(
                            SmolStr::new_static("errorCode"),
                            LexObjectProperty::String(LexString { ..Default::default() }),
                        );
                        map.insert(
                            SmolStr::new_static("subject"),
                            LexObjectProperty::String(LexString {
                                format: Some(LexStringFormat::Did),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("main"),
                LexUserType::XrpcProcedure(LexXrpcProcedure {
                    input: Some(LexXrpcBody {
                        encoding: CowStr::new_static("application/json"),
                        schema: Some(
                            LexXrpcBodySchema::Object(LexObject {
                                required: Some(
                                    vec![
                                        SmolStr::new_static("action"),
                                        SmolStr::new_static("subjects"),
                                        SmolStr::new_static("createdBy"),
                                        SmolStr::new_static("scheduling")
                                    ],
                                ),
                                properties: {
                                    #[allow(unused_mut)]
                                    let mut map = BTreeMap::new();
                                    map.insert(
                                        SmolStr::new_static("action"),
                                        LexObjectProperty::Union(LexRefUnion {
                                            refs: vec![CowStr::new_static("#takedown")],
                                            ..Default::default()
                                        }),
                                    );
                                    map.insert(
                                        SmolStr::new_static("createdBy"),
                                        LexObjectProperty::String(LexString {
                                            format: Some(LexStringFormat::Did),
                                            ..Default::default()
                                        }),
                                    );
                                    map.insert(
                                        SmolStr::new_static("modTool"),
                                        LexObjectProperty::Ref(LexRef {
                                            r#ref: CowStr::new_static(
                                                "tools.ozone.moderation.defs#modTool",
                                            ),
                                            ..Default::default()
                                        }),
                                    );
                                    map.insert(
                                        SmolStr::new_static("scheduling"),
                                        LexObjectProperty::Ref(LexRef {
                                            r#ref: CowStr::new_static("#schedulingConfig"),
                                            ..Default::default()
                                        }),
                                    );
                                    map.insert(
                                        SmolStr::new_static("subjects"),
                                        LexObjectProperty::Array(LexArray {
                                            description: Some(
                                                CowStr::new_static(
                                                    "Array of DID subjects to schedule the action for",
                                                ),
                                            ),
                                            items: LexArrayItem::String(LexString {
                                                format: Some(LexStringFormat::Did),
                                                ..Default::default()
                                            }),
                                            max_length: Some(100usize),
                                            ..Default::default()
                                        }),
                                    );
                                    map
                                },
                                ..Default::default()
                            }),
                        ),
                        ..Default::default()
                    }),
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("scheduledActionResults"),
                LexUserType::Object(LexObject {
                    required: Some(
                        vec![
                            SmolStr::new_static("succeeded"),
                            SmolStr::new_static("failed")
                        ],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("failed"),
                            LexObjectProperty::Array(LexArray {
                                items: LexArrayItem::Ref(LexRef {
                                    r#ref: CowStr::new_static("#failedScheduling"),
                                    ..Default::default()
                                }),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("succeeded"),
                            LexObjectProperty::Array(LexArray {
                                items: LexArrayItem::String(LexString {
                                    format: Some(LexStringFormat::Did),
                                    ..Default::default()
                                }),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("schedulingConfig"),
                LexUserType::Object(LexObject {
                    description: Some(
                        CowStr::new_static(
                            "Configuration for when the action should be executed",
                        ),
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("executeAfter"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "Earliest time to execute the action (for randomized scheduling)",
                                    ),
                                ),
                                format: Some(LexStringFormat::Datetime),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("executeAt"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static("Exact time to execute the action"),
                                ),
                                format: Some(LexStringFormat::Datetime),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("executeUntil"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "Latest time to execute the action (for randomized scheduling)",
                                    ),
                                ),
                                format: Some(LexStringFormat::Datetime),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("takedown"),
                LexUserType::Object(LexObject {
                    description: Some(CowStr::new_static("Schedule a takedown action")),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("acknowledgeAccountSubjects"),
                            LexObjectProperty::Boolean(LexBoolean {
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("comment"),
                            LexObjectProperty::String(LexString { ..Default::default() }),
                        );
                        map.insert(
                            SmolStr::new_static("durationInHours"),
                            LexObjectProperty::Integer(LexInteger {
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("emailContent"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "Email content to be sent to the user upon takedown.",
                                    ),
                                ),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("emailSubject"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "Subject of the email to be sent to the user upon takedown.",
                                    ),
                                ),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("policies"),
                            LexObjectProperty::Array(LexArray {
                                description: Some(
                                    CowStr::new_static(
                                        "Names/Keywords of the policies that drove the decision.",
                                    ),
                                ),
                                items: LexArrayItem::String(LexString {
                                    ..Default::default()
                                }),
                                max_length: Some(5usize),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("severityLevel"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "Severity level of the violation (e.g., 'sev-0', 'sev-1', 'sev-2', etc.).",
                                    ),
                                ),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("strikeCount"),
                            LexObjectProperty::Integer(LexInteger {
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("strikeExpiresAt"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "When the strike should expire. If not provided, the strike never expires.",
                                    ),
                                ),
                                format: Some(LexStringFormat::Datetime),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map
        },
        ..Default::default()
    }
}

pub mod schedule_action_state {

    pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
    #[allow(unused)]
    use ::core::marker::PhantomData;
    mod sealed {
        pub trait Sealed {}
    }
    /// State trait tracking which required fields have been set
    pub trait State: sealed::Sealed {
        type Action;
        type CreatedBy;
        type Scheduling;
        type Subjects;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type Action = Unset;
        type CreatedBy = Unset;
        type Scheduling = Unset;
        type Subjects = Unset;
    }
    ///State transition - sets the `action` field to Set
    pub struct SetAction<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetAction<St> {}
    impl<St: State> State for SetAction<St> {
        type Action = Set<members::action>;
        type CreatedBy = St::CreatedBy;
        type Scheduling = St::Scheduling;
        type Subjects = St::Subjects;
    }
    ///State transition - sets the `created_by` field to Set
    pub struct SetCreatedBy<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetCreatedBy<St> {}
    impl<St: State> State for SetCreatedBy<St> {
        type Action = St::Action;
        type CreatedBy = Set<members::created_by>;
        type Scheduling = St::Scheduling;
        type Subjects = St::Subjects;
    }
    ///State transition - sets the `scheduling` field to Set
    pub struct SetScheduling<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetScheduling<St> {}
    impl<St: State> State for SetScheduling<St> {
        type Action = St::Action;
        type CreatedBy = St::CreatedBy;
        type Scheduling = Set<members::scheduling>;
        type Subjects = St::Subjects;
    }
    ///State transition - sets the `subjects` field to Set
    pub struct SetSubjects<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetSubjects<St> {}
    impl<St: State> State for SetSubjects<St> {
        type Action = St::Action;
        type CreatedBy = St::CreatedBy;
        type Scheduling = St::Scheduling;
        type Subjects = Set<members::subjects>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `action` field
        pub struct action(());
        ///Marker type for the `created_by` field
        pub struct created_by(());
        ///Marker type for the `scheduling` field
        pub struct scheduling(());
        ///Marker type for the `subjects` field
        pub struct subjects(());
    }
}

/// Builder for constructing an instance of this type.
pub struct ScheduleActionBuilder<
    St: schedule_action_state::State,
    S: BosStr = DefaultStr,
> {
    _state: PhantomData<fn() -> St>,
    _fields: (
        Option<schedule_action::Takedown<S>>,
        Option<Did<S>>,
        Option<ModTool<S>>,
        Option<schedule_action::SchedulingConfig<S>>,
        Option<Vec<Did<S>>>,
    ),
    _type: PhantomData<fn() -> S>,
}

impl ScheduleAction<DefaultStr> {
    /// Create a new builder for this type, using the default string type (DefaultStr = SmolStr) if needed
    pub fn new() -> ScheduleActionBuilder<schedule_action_state::Empty, DefaultStr> {
        ScheduleActionBuilder::new()
    }
}

impl<S: BosStr> ScheduleAction<S> {
    /// Create a new builder for this type
    pub fn builder() -> ScheduleActionBuilder<schedule_action_state::Empty, S> {
        ScheduleActionBuilder::builder()
    }
}

impl ScheduleActionBuilder<schedule_action_state::Empty, DefaultStr> {
    /// Create a new builder with all fields unset, using the default string type, if needed
    pub fn new() -> Self {
        ScheduleActionBuilder {
            _state: PhantomData,
            _fields: (None, None, None, None, None),
            _type: PhantomData,
        }
    }
}

impl<S: BosStr> ScheduleActionBuilder<schedule_action_state::Empty, S> {
    /// Create a new builder with all fields unset
    pub fn builder() -> Self {
        ScheduleActionBuilder {
            _state: PhantomData,
            _fields: (None, None, None, None, None),
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> ScheduleActionBuilder<St, S>
where
    St: schedule_action_state::State,
    St::Action: schedule_action_state::IsUnset,
{
    /// Set the `action` field (required)
    pub fn action(
        mut self,
        value: impl Into<schedule_action::Takedown<S>>,
    ) -> ScheduleActionBuilder<schedule_action_state::SetAction<St>, S> {
        self._fields.0 = Option::Some(value.into());
        ScheduleActionBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> ScheduleActionBuilder<St, S>
where
    St: schedule_action_state::State,
    St::CreatedBy: schedule_action_state::IsUnset,
{
    /// Set the `createdBy` field (required)
    pub fn created_by(
        mut self,
        value: impl Into<Did<S>>,
    ) -> ScheduleActionBuilder<schedule_action_state::SetCreatedBy<St>, S> {
        self._fields.1 = Option::Some(value.into());
        ScheduleActionBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St: schedule_action_state::State, S: BosStr> ScheduleActionBuilder<St, S> {
    /// Set the `modTool` field (optional)
    pub fn mod_tool(mut self, value: impl Into<Option<ModTool<S>>>) -> Self {
        self._fields.2 = value.into();
        self
    }
    /// Set the `modTool` field to an Option value (optional)
    pub fn maybe_mod_tool(mut self, value: Option<ModTool<S>>) -> Self {
        self._fields.2 = value;
        self
    }
}

impl<St, S: BosStr> ScheduleActionBuilder<St, S>
where
    St: schedule_action_state::State,
    St::Scheduling: schedule_action_state::IsUnset,
{
    /// Set the `scheduling` field (required)
    pub fn scheduling(
        mut self,
        value: impl Into<schedule_action::SchedulingConfig<S>>,
    ) -> ScheduleActionBuilder<schedule_action_state::SetScheduling<St>, S> {
        self._fields.3 = Option::Some(value.into());
        ScheduleActionBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> ScheduleActionBuilder<St, S>
where
    St: schedule_action_state::State,
    St::Subjects: schedule_action_state::IsUnset,
{
    /// Set the `subjects` field (required)
    pub fn subjects(
        mut self,
        value: impl Into<Vec<Did<S>>>,
    ) -> ScheduleActionBuilder<schedule_action_state::SetSubjects<St>, S> {
        self._fields.4 = Option::Some(value.into());
        ScheduleActionBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> ScheduleActionBuilder<St, S>
where
    St: schedule_action_state::State,
    St::Action: schedule_action_state::IsSet,
    St::CreatedBy: schedule_action_state::IsSet,
    St::Scheduling: schedule_action_state::IsSet,
    St::Subjects: schedule_action_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> ScheduleAction<S> {
        ScheduleAction {
            action: self._fields.0.unwrap(),
            created_by: self._fields.1.unwrap(),
            mod_tool: self._fields.2,
            scheduling: self._fields.3.unwrap(),
            subjects: self._fields.4.unwrap(),
            extra_data: Default::default(),
        }
    }
    /// Build the final struct with custom extra_data.
    pub fn build_with_data(
        self,
        extra_data: BTreeMap<SmolStr, Data<S>>,
    ) -> ScheduleAction<S> {
        ScheduleAction {
            action: self._fields.0.unwrap(),
            created_by: self._fields.1.unwrap(),
            mod_tool: self._fields.2,
            scheduling: self._fields.3.unwrap(),
            subjects: self._fields.4.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}

pub mod scheduled_action_results_state {

    pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
    #[allow(unused)]
    use ::core::marker::PhantomData;
    mod sealed {
        pub trait Sealed {}
    }
    /// State trait tracking which required fields have been set
    pub trait State: sealed::Sealed {
        type Failed;
        type Succeeded;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type Failed = Unset;
        type Succeeded = Unset;
    }
    ///State transition - sets the `failed` field to Set
    pub struct SetFailed<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetFailed<St> {}
    impl<St: State> State for SetFailed<St> {
        type Failed = Set<members::failed>;
        type Succeeded = St::Succeeded;
    }
    ///State transition - sets the `succeeded` field to Set
    pub struct SetSucceeded<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetSucceeded<St> {}
    impl<St: State> State for SetSucceeded<St> {
        type Failed = St::Failed;
        type Succeeded = Set<members::succeeded>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `failed` field
        pub struct failed(());
        ///Marker type for the `succeeded` field
        pub struct succeeded(());
    }
}

/// Builder for constructing an instance of this type.
pub struct ScheduledActionResultsBuilder<
    St: scheduled_action_results_state::State,
    S: BosStr = DefaultStr,
> {
    _state: PhantomData<fn() -> St>,
    _fields: (Option<Vec<schedule_action::FailedScheduling<S>>>, Option<Vec<Did<S>>>),
    _type: PhantomData<fn() -> S>,
}

impl ScheduledActionResults<DefaultStr> {
    /// Create a new builder for this type, using the default string type (DefaultStr = SmolStr) if needed
    pub fn new() -> ScheduledActionResultsBuilder<
        scheduled_action_results_state::Empty,
        DefaultStr,
    > {
        ScheduledActionResultsBuilder::new()
    }
}

impl<S: BosStr> ScheduledActionResults<S> {
    /// Create a new builder for this type
    pub fn builder() -> ScheduledActionResultsBuilder<
        scheduled_action_results_state::Empty,
        S,
    > {
        ScheduledActionResultsBuilder::builder()
    }
}

impl ScheduledActionResultsBuilder<scheduled_action_results_state::Empty, DefaultStr> {
    /// Create a new builder with all fields unset, using the default string type, if needed
    pub fn new() -> Self {
        ScheduledActionResultsBuilder {
            _state: PhantomData,
            _fields: (None, None),
            _type: PhantomData,
        }
    }
}

impl<S: BosStr> ScheduledActionResultsBuilder<scheduled_action_results_state::Empty, S> {
    /// Create a new builder with all fields unset
    pub fn builder() -> Self {
        ScheduledActionResultsBuilder {
            _state: PhantomData,
            _fields: (None, None),
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> ScheduledActionResultsBuilder<St, S>
where
    St: scheduled_action_results_state::State,
    St::Failed: scheduled_action_results_state::IsUnset,
{
    /// Set the `failed` field (required)
    pub fn failed(
        mut self,
        value: impl Into<Vec<schedule_action::FailedScheduling<S>>>,
    ) -> ScheduledActionResultsBuilder<
        scheduled_action_results_state::SetFailed<St>,
        S,
    > {
        self._fields.0 = Option::Some(value.into());
        ScheduledActionResultsBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> ScheduledActionResultsBuilder<St, S>
where
    St: scheduled_action_results_state::State,
    St::Succeeded: scheduled_action_results_state::IsUnset,
{
    /// Set the `succeeded` field (required)
    pub fn succeeded(
        mut self,
        value: impl Into<Vec<Did<S>>>,
    ) -> ScheduledActionResultsBuilder<
        scheduled_action_results_state::SetSucceeded<St>,
        S,
    > {
        self._fields.1 = Option::Some(value.into());
        ScheduledActionResultsBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> ScheduledActionResultsBuilder<St, S>
where
    St: scheduled_action_results_state::State,
    St::Failed: scheduled_action_results_state::IsSet,
    St::Succeeded: scheduled_action_results_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> ScheduledActionResults<S> {
        ScheduledActionResults {
            failed: self._fields.0.unwrap(),
            succeeded: self._fields.1.unwrap(),
            extra_data: Default::default(),
        }
    }
    /// Build the final struct with custom extra_data.
    pub fn build_with_data(
        self,
        extra_data: BTreeMap<SmolStr, Data<S>>,
    ) -> ScheduledActionResults<S> {
        ScheduledActionResults {
            failed: self._fields.0.unwrap(),
            succeeded: self._fields.1.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}