// @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;

#[allow(unused_imports)]
use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;
use jacquard_common::types::string::{Did, Datetime};
use jacquard_derive::{IntoStatic, lexicon};
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;

#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct FailedScheduling<'a> {
    #[serde(borrow)]
    pub error: CowStr<'a>,
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub error_code: Option<CowStr<'a>>,
    #[serde(borrow)]
    pub subject: Did<'a>,
}


#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct ScheduleAction<'a> {
    #[serde(borrow)]
    pub action: schedule_action::Takedown<'a>,
    #[serde(borrow)]
    pub created_by: Did<'a>,
    ///This will be propagated to the moderation event when it is applied
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub mod_tool: Option<ModTool<'a>>,
    #[serde(borrow)]
    pub scheduling: schedule_action::SchedulingConfig<'a>,
    ///Array of DID subjects to schedule the action for
    #[serde(borrow)]
    pub subjects: Vec<Did<'a>>,
}


#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct ScheduleActionOutput<'a> {
    #[serde(flatten)]
    #[serde(borrow)]
    pub value: jacquard_common::types::value::Data<'a>,
}


#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct ScheduledActionResults<'a> {
    #[serde(borrow)]
    pub failed: Vec<schedule_action::FailedScheduling<'a>>,
    #[serde(borrow)]
    pub succeeded: Vec<Did<'a>>,
}

/// Configuration for when the action should be executed

#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase")]
pub struct SchedulingConfig<'a> {
    ///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>,
}

/// Schedule a takedown action

#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase")]
pub struct Takedown<'a> {
    ///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")]
    #[serde(borrow)]
    pub comment: Option<CowStr<'a>>,
    ///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")]
    #[serde(borrow)]
    pub email_content: Option<CowStr<'a>>,
    ///Subject of the email to be sent to the user upon takedown.
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub email_subject: Option<CowStr<'a>>,
    ///Names/Keywords of the policies that drove the decision.
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub policies: Option<Vec<CowStr<'a>>>,
    ///Severity level of the violation (e.g., 'sev-0', 'sev-1', 'sev-2', etc.).
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub severity_level: Option<CowStr<'a>>,
    ///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>,
}

impl<'a> LexiconSchema for FailedScheduling<'a> {
    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 type for tools.ozone.moderation.scheduleAction
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<'de> = ScheduleActionOutput<'de>;
    type Err<'de> = jacquard_common::xrpc::GenericError<'de>;
}

impl<'a> jacquard_common::xrpc::XrpcRequest for ScheduleAction<'a> {
    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 type for tools.ozone.moderation.scheduleAction
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<'de> = ScheduleAction<'de>;
    type Response = ScheduleActionResponse;
}

impl<'a> LexiconSchema for ScheduledActionResults<'a> {
    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<'a> LexiconSchema for SchedulingConfig<'a> {
    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<'a> LexiconSchema for Takedown<'a> {
    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 Subject;
        type Error;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type Subject = Unset;
        type Error = Unset;
    }
    ///State transition - sets the `subject` field to Set
    pub struct SetSubject<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetSubject<S> {}
    impl<S: State> State for SetSubject<S> {
        type Subject = Set<members::subject>;
        type Error = S::Error;
    }
    ///State transition - sets the `error` field to Set
    pub struct SetError<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetError<S> {}
    impl<S: State> State for SetError<S> {
        type Subject = S::Subject;
        type Error = Set<members::error>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `subject` field
        pub struct subject(());
        ///Marker type for the `error` field
        pub struct error(());
    }
}

/// Builder for constructing an instance of this type
pub struct FailedSchedulingBuilder<'a, S: failed_scheduling_state::State> {
    _state: PhantomData<fn() -> S>,
    _fields: (Option<CowStr<'a>>, Option<CowStr<'a>>, Option<Did<'a>>),
    _lifetime: PhantomData<&'a ()>,
}

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

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

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

impl<'a, S: failed_scheduling_state::State> FailedSchedulingBuilder<'a, S> {
    /// Set the `errorCode` field (optional)
    pub fn error_code(mut self, value: impl Into<Option<CowStr<'a>>>) -> 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<CowStr<'a>>) -> Self {
        self._fields.1 = value;
        self
    }
}

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

impl<'a, S> FailedSchedulingBuilder<'a, S>
where
    S: failed_scheduling_state::State,
    S::Subject: failed_scheduling_state::IsSet,
    S::Error: failed_scheduling_state::IsSet,
{
    /// Build the final struct
    pub fn build(self) -> FailedScheduling<'a> {
        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<
            jacquard_common::deps::smol_str::SmolStr,
            jacquard_common::types::value::Data<'a>,
        >,
    ) -> FailedScheduling<'a> {
        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 Subjects;
        type Scheduling;
        type Action;
        type CreatedBy;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type Subjects = Unset;
        type Scheduling = Unset;
        type Action = Unset;
        type CreatedBy = Unset;
    }
    ///State transition - sets the `subjects` field to Set
    pub struct SetSubjects<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetSubjects<S> {}
    impl<S: State> State for SetSubjects<S> {
        type Subjects = Set<members::subjects>;
        type Scheduling = S::Scheduling;
        type Action = S::Action;
        type CreatedBy = S::CreatedBy;
    }
    ///State transition - sets the `scheduling` field to Set
    pub struct SetScheduling<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetScheduling<S> {}
    impl<S: State> State for SetScheduling<S> {
        type Subjects = S::Subjects;
        type Scheduling = Set<members::scheduling>;
        type Action = S::Action;
        type CreatedBy = S::CreatedBy;
    }
    ///State transition - sets the `action` field to Set
    pub struct SetAction<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetAction<S> {}
    impl<S: State> State for SetAction<S> {
        type Subjects = S::Subjects;
        type Scheduling = S::Scheduling;
        type Action = Set<members::action>;
        type CreatedBy = S::CreatedBy;
    }
    ///State transition - sets the `created_by` field to Set
    pub struct SetCreatedBy<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetCreatedBy<S> {}
    impl<S: State> State for SetCreatedBy<S> {
        type Subjects = S::Subjects;
        type Scheduling = S::Scheduling;
        type Action = S::Action;
        type CreatedBy = Set<members::created_by>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `subjects` field
        pub struct subjects(());
        ///Marker type for the `scheduling` field
        pub struct scheduling(());
        ///Marker type for the `action` field
        pub struct action(());
        ///Marker type for the `created_by` field
        pub struct created_by(());
    }
}

/// Builder for constructing an instance of this type
pub struct ScheduleActionBuilder<'a, S: schedule_action_state::State> {
    _state: PhantomData<fn() -> S>,
    _fields: (
        Option<schedule_action::Takedown<'a>>,
        Option<Did<'a>>,
        Option<ModTool<'a>>,
        Option<schedule_action::SchedulingConfig<'a>>,
        Option<Vec<Did<'a>>>,
    ),
    _lifetime: PhantomData<&'a ()>,
}

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

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

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

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

impl<'a, S: schedule_action_state::State> ScheduleActionBuilder<'a, S> {
    /// Set the `modTool` field (optional)
    pub fn mod_tool(mut self, value: impl Into<Option<ModTool<'a>>>) -> 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<'a>>) -> Self {
        self._fields.2 = value;
        self
    }
}

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

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

impl<'a, S> ScheduleActionBuilder<'a, S>
where
    S: schedule_action_state::State,
    S::Subjects: schedule_action_state::IsSet,
    S::Scheduling: schedule_action_state::IsSet,
    S::Action: schedule_action_state::IsSet,
    S::CreatedBy: schedule_action_state::IsSet,
{
    /// Build the final struct
    pub fn build(self) -> ScheduleAction<'a> {
        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<
            jacquard_common::deps::smol_str::SmolStr,
            jacquard_common::types::value::Data<'a>,
        >,
    ) -> ScheduleAction<'a> {
        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<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetFailed<S> {}
    impl<S: State> State for SetFailed<S> {
        type Failed = Set<members::failed>;
        type Succeeded = S::Succeeded;
    }
    ///State transition - sets the `succeeded` field to Set
    pub struct SetSucceeded<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetSucceeded<S> {}
    impl<S: State> State for SetSucceeded<S> {
        type Failed = S::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<'a, S: scheduled_action_results_state::State> {
    _state: PhantomData<fn() -> S>,
    _fields: (Option<Vec<schedule_action::FailedScheduling<'a>>>, Option<Vec<Did<'a>>>),
    _lifetime: PhantomData<&'a ()>,
}

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

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

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

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

impl<'a, S> ScheduledActionResultsBuilder<'a, S>
where
    S: scheduled_action_results_state::State,
    S::Failed: scheduled_action_results_state::IsSet,
    S::Succeeded: scheduled_action_results_state::IsSet,
{
    /// Build the final struct
    pub fn build(self) -> ScheduledActionResults<'a> {
        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<
            jacquard_common::deps::smol_str::SmolStr,
            jacquard_common::types::value::Data<'a>,
        >,
    ) -> ScheduledActionResults<'a> {
        ScheduledActionResults {
            failed: self._fields.0.unwrap(),
            succeeded: self._fields.1.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}