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

//! Generated bindings for the `sh.tangled.pipeline` Lexicon namespace/module.
pub mod cancel_pipeline;
pub mod list_pipelines;
pub mod list_pipelines_by;
pub mod list_statuses;
pub mod list_statuses_by;
pub mod status;


#[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::collection::{Collection, RecordError};
use jacquard_common::types::string::{Did, AtUri, Cid};
use jacquard_common::types::uri::{RecordUri, UriError};
use jacquard_common::types::value::Data;
use jacquard_common::xrpc::XrpcResp;
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::sh_tangled::pipeline;

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct CloneOpts<S: BosStr = DefaultStr> {
    pub depth: i64,
    pub skip: bool,
    pub submodules: bool,
    #[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",
    rename = "sh.tangled.pipeline",
    tag = "$type",
    bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct Pipeline<S: BosStr = DefaultStr> {
    pub trigger_metadata: pipeline::TriggerMetadata<S>,
    pub workflows: Vec<pipeline::Workflow<S>>,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}

/// Typed wrapper for GetRecord response with this collection's record type.

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct PipelineGetRecordOutput<S: BosStr = DefaultStr> {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub cid: Option<Cid<S>>,
    pub uri: AtUri<S>,
    pub value: Pipeline<S>,
}


#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct ManualTriggerData<S: BosStr = DefaultStr> {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub inputs: Option<Vec<pipeline::Pair<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, Default)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct Pair<S: BosStr = DefaultStr> {
    pub key: S,
    pub value: 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, Default)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct PullRequestTriggerData<S: BosStr = DefaultStr> {
    pub action: S,
    pub source_branch: S,
    pub source_sha: S,
    pub target_branch: 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, Default)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct PushTriggerData<S: BosStr = DefaultStr> {
    pub new_sha: S,
    pub old_sha: S,
    pub r#ref: 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 TriggerMetadata<S: BosStr = DefaultStr> {
    pub kind: S,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub manual: Option<pipeline::ManualTriggerData<S>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub pull_request: Option<pipeline::PullRequestTriggerData<S>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub push: Option<pipeline::PushTriggerData<S>>,
    pub repo: pipeline::TriggerRepo<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 TriggerRepo<S: BosStr = DefaultStr> {
    pub default_branch: S,
    pub did: Did<S>,
    pub knot: S,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub repo: Option<S>,
    ///DID of the repo itself
    #[serde(skip_serializing_if = "Option::is_none")]
    pub repo_did: Option<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 Workflow<S: BosStr = DefaultStr> {
    pub clone: pipeline::CloneOpts<S>,
    pub engine: S,
    pub name: S,
    pub raw: S,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}

impl<S: BosStr> Pipeline<S> {
    pub fn uri(uri: S) -> Result<RecordUri<S, PipelineRecord>, UriError> {
        RecordUri::try_from_uri(AtUri::new(uri)?)
    }
}

impl<S: BosStr> LexiconSchema for CloneOpts<S> {
    fn nsid() -> &'static str {
        "sh.tangled.pipeline"
    }
    fn def_name() -> &'static str {
        "cloneOpts"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_sh_tangled_pipeline()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

/// Marker type for deserializing records from this collection.

#[derive(Debug, Serialize, Deserialize)]
pub struct PipelineRecord;
impl XrpcResp for PipelineRecord {
    const NSID: &'static str = "sh.tangled.pipeline";
    const ENCODING: &'static str = "application/json";
    type Output<S: BosStr> = PipelineGetRecordOutput<S>;
    type Err = RecordError;
}

impl<S: BosStr> From<PipelineGetRecordOutput<S>> for Pipeline<S> {
    fn from(output: PipelineGetRecordOutput<S>) -> Self {
        output.value
    }
}

impl<S: BosStr> Collection for Pipeline<S> {
    const NSID: &'static str = "sh.tangled.pipeline";
    type Record = PipelineRecord;
}

impl Collection for PipelineRecord {
    const NSID: &'static str = "sh.tangled.pipeline";
    type Record = PipelineRecord;
}

impl<S: BosStr> LexiconSchema for Pipeline<S> {
    fn nsid() -> &'static str {
        "sh.tangled.pipeline"
    }
    fn def_name() -> &'static str {
        "main"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_sh_tangled_pipeline()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

impl<S: BosStr> LexiconSchema for ManualTriggerData<S> {
    fn nsid() -> &'static str {
        "sh.tangled.pipeline"
    }
    fn def_name() -> &'static str {
        "manualTriggerData"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_sh_tangled_pipeline()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

impl<S: BosStr> LexiconSchema for Pair<S> {
    fn nsid() -> &'static str {
        "sh.tangled.pipeline"
    }
    fn def_name() -> &'static str {
        "pair"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_sh_tangled_pipeline()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

impl<S: BosStr> LexiconSchema for PullRequestTriggerData<S> {
    fn nsid() -> &'static str {
        "sh.tangled.pipeline"
    }
    fn def_name() -> &'static str {
        "pullRequestTriggerData"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_sh_tangled_pipeline()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        {
            let value = &self.source_sha;
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 40usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("source_sha"),
                    max: 40usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        {
            let value = &self.source_sha;
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) < 40usize {
                return Err(ConstraintError::MinLength {
                    path: ValidationPath::from_field("source_sha"),
                    min: 40usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        Ok(())
    }
}

impl<S: BosStr> LexiconSchema for PushTriggerData<S> {
    fn nsid() -> &'static str {
        "sh.tangled.pipeline"
    }
    fn def_name() -> &'static str {
        "pushTriggerData"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_sh_tangled_pipeline()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        {
            let value = &self.new_sha;
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 40usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("new_sha"),
                    max: 40usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        {
            let value = &self.new_sha;
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) < 40usize {
                return Err(ConstraintError::MinLength {
                    path: ValidationPath::from_field("new_sha"),
                    min: 40usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        {
            let value = &self.old_sha;
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 40usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("old_sha"),
                    max: 40usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        {
            let value = &self.old_sha;
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) < 40usize {
                return Err(ConstraintError::MinLength {
                    path: ValidationPath::from_field("old_sha"),
                    min: 40usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        Ok(())
    }
}

impl<S: BosStr> LexiconSchema for TriggerMetadata<S> {
    fn nsid() -> &'static str {
        "sh.tangled.pipeline"
    }
    fn def_name() -> &'static str {
        "triggerMetadata"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_sh_tangled_pipeline()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

impl<S: BosStr> LexiconSchema for TriggerRepo<S> {
    fn nsid() -> &'static str {
        "sh.tangled.pipeline"
    }
    fn def_name() -> &'static str {
        "triggerRepo"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_sh_tangled_pipeline()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

impl<S: BosStr> LexiconSchema for Workflow<S> {
    fn nsid() -> &'static str {
        "sh.tangled.pipeline"
    }
    fn def_name() -> &'static str {
        "workflow"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_sh_tangled_pipeline()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

pub mod clone_opts_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 Depth;
        type Skip;
        type Submodules;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type Depth = Unset;
        type Skip = Unset;
        type Submodules = Unset;
    }
    ///State transition - sets the `depth` field to Set
    pub struct SetDepth<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetDepth<St> {}
    impl<St: State> State for SetDepth<St> {
        type Depth = Set<members::depth>;
        type Skip = St::Skip;
        type Submodules = St::Submodules;
    }
    ///State transition - sets the `skip` field to Set
    pub struct SetSkip<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetSkip<St> {}
    impl<St: State> State for SetSkip<St> {
        type Depth = St::Depth;
        type Skip = Set<members::skip>;
        type Submodules = St::Submodules;
    }
    ///State transition - sets the `submodules` field to Set
    pub struct SetSubmodules<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetSubmodules<St> {}
    impl<St: State> State for SetSubmodules<St> {
        type Depth = St::Depth;
        type Skip = St::Skip;
        type Submodules = Set<members::submodules>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `depth` field
        pub struct depth(());
        ///Marker type for the `skip` field
        pub struct skip(());
        ///Marker type for the `submodules` field
        pub struct submodules(());
    }
}

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

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

impl<S: BosStr> CloneOpts<S> {
    /// Create a new builder for this type
    pub fn builder() -> CloneOptsBuilder<clone_opts_state::Empty, S> {
        CloneOptsBuilder::builder()
    }
}

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

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

impl<St, S: BosStr> CloneOptsBuilder<St, S>
where
    St: clone_opts_state::State,
    St::Depth: clone_opts_state::IsUnset,
{
    /// Set the `depth` field (required)
    pub fn depth(
        mut self,
        value: impl Into<i64>,
    ) -> CloneOptsBuilder<clone_opts_state::SetDepth<St>, S> {
        self._fields.0 = Option::Some(value.into());
        CloneOptsBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> CloneOptsBuilder<St, S>
where
    St: clone_opts_state::State,
    St::Skip: clone_opts_state::IsUnset,
{
    /// Set the `skip` field (required)
    pub fn skip(
        mut self,
        value: impl Into<bool>,
    ) -> CloneOptsBuilder<clone_opts_state::SetSkip<St>, S> {
        self._fields.1 = Option::Some(value.into());
        CloneOptsBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> CloneOptsBuilder<St, S>
where
    St: clone_opts_state::State,
    St::Submodules: clone_opts_state::IsUnset,
{
    /// Set the `submodules` field (required)
    pub fn submodules(
        mut self,
        value: impl Into<bool>,
    ) -> CloneOptsBuilder<clone_opts_state::SetSubmodules<St>, S> {
        self._fields.2 = Option::Some(value.into());
        CloneOptsBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> CloneOptsBuilder<St, S>
where
    St: clone_opts_state::State,
    St::Depth: clone_opts_state::IsSet,
    St::Skip: clone_opts_state::IsSet,
    St::Submodules: clone_opts_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> CloneOpts<S> {
        CloneOpts {
            depth: self._fields.0.unwrap(),
            skip: self._fields.1.unwrap(),
            submodules: 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>>,
    ) -> CloneOpts<S> {
        CloneOpts {
            depth: self._fields.0.unwrap(),
            skip: self._fields.1.unwrap(),
            submodules: self._fields.2.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}

fn lexicon_doc_sh_tangled_pipeline() -> 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("sh.tangled.pipeline"),
        defs: {
            let mut map = BTreeMap::new();
            map.insert(
                SmolStr::new_static("cloneOpts"),
                LexUserType::Object(LexObject {
                    required: Some(
                        vec![
                            SmolStr::new_static("skip"), SmolStr::new_static("depth"),
                            SmolStr::new_static("submodules")
                        ],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("depth"),
                            LexObjectProperty::Integer(LexInteger {
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("skip"),
                            LexObjectProperty::Boolean(LexBoolean {
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("submodules"),
                            LexObjectProperty::Boolean(LexBoolean {
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("main"),
                LexUserType::Record(LexRecord {
                    key: Some(CowStr::new_static("tid")),
                    record: LexRecordRecord::Object(LexObject {
                        required: Some(
                            vec![
                                SmolStr::new_static("triggerMetadata"),
                                SmolStr::new_static("workflows")
                            ],
                        ),
                        properties: {
                            #[allow(unused_mut)]
                            let mut map = BTreeMap::new();
                            map.insert(
                                SmolStr::new_static("triggerMetadata"),
                                LexObjectProperty::Ref(LexRef {
                                    r#ref: CowStr::new_static("#triggerMetadata"),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("workflows"),
                                LexObjectProperty::Array(LexArray {
                                    items: LexArrayItem::Ref(LexRef {
                                        r#ref: CowStr::new_static("#workflow"),
                                        ..Default::default()
                                    }),
                                    ..Default::default()
                                }),
                            );
                            map
                        },
                        ..Default::default()
                    }),
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("manualTriggerData"),
                LexUserType::Object(LexObject {
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("inputs"),
                            LexObjectProperty::Array(LexArray {
                                items: LexArrayItem::Ref(LexRef {
                                    r#ref: CowStr::new_static("#pair"),
                                    ..Default::default()
                                }),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("pair"),
                LexUserType::Object(LexObject {
                    required: Some(
                        vec![SmolStr::new_static("key"), SmolStr::new_static("value")],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("key"),
                            LexObjectProperty::String(LexString { ..Default::default() }),
                        );
                        map.insert(
                            SmolStr::new_static("value"),
                            LexObjectProperty::String(LexString { ..Default::default() }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("pullRequestTriggerData"),
                LexUserType::Object(LexObject {
                    required: Some(
                        vec![
                            SmolStr::new_static("sourceBranch"),
                            SmolStr::new_static("targetBranch"),
                            SmolStr::new_static("sourceSha"),
                            SmolStr::new_static("action")
                        ],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("action"),
                            LexObjectProperty::String(LexString { ..Default::default() }),
                        );
                        map.insert(
                            SmolStr::new_static("sourceBranch"),
                            LexObjectProperty::String(LexString { ..Default::default() }),
                        );
                        map.insert(
                            SmolStr::new_static("sourceSha"),
                            LexObjectProperty::String(LexString {
                                min_length: Some(40usize),
                                max_length: Some(40usize),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("targetBranch"),
                            LexObjectProperty::String(LexString { ..Default::default() }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("pushTriggerData"),
                LexUserType::Object(LexObject {
                    required: Some(
                        vec![
                            SmolStr::new_static("ref"), SmolStr::new_static("newSha"),
                            SmolStr::new_static("oldSha")
                        ],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("newSha"),
                            LexObjectProperty::String(LexString {
                                min_length: Some(40usize),
                                max_length: Some(40usize),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("oldSha"),
                            LexObjectProperty::String(LexString {
                                min_length: Some(40usize),
                                max_length: Some(40usize),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("ref"),
                            LexObjectProperty::String(LexString { ..Default::default() }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("triggerMetadata"),
                LexUserType::Object(LexObject {
                    required: Some(
                        vec![SmolStr::new_static("kind"), SmolStr::new_static("repo")],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("kind"),
                            LexObjectProperty::String(LexString { ..Default::default() }),
                        );
                        map.insert(
                            SmolStr::new_static("manual"),
                            LexObjectProperty::Ref(LexRef {
                                r#ref: CowStr::new_static("#manualTriggerData"),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("pullRequest"),
                            LexObjectProperty::Ref(LexRef {
                                r#ref: CowStr::new_static("#pullRequestTriggerData"),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("push"),
                            LexObjectProperty::Ref(LexRef {
                                r#ref: CowStr::new_static("#pushTriggerData"),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("repo"),
                            LexObjectProperty::Ref(LexRef {
                                r#ref: CowStr::new_static("#triggerRepo"),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("triggerRepo"),
                LexUserType::Object(LexObject {
                    required: Some(
                        vec![
                            SmolStr::new_static("knot"), SmolStr::new_static("did"),
                            SmolStr::new_static("defaultBranch")
                        ],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("defaultBranch"),
                            LexObjectProperty::String(LexString { ..Default::default() }),
                        );
                        map.insert(
                            SmolStr::new_static("did"),
                            LexObjectProperty::String(LexString {
                                format: Some(LexStringFormat::Did),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("knot"),
                            LexObjectProperty::String(LexString { ..Default::default() }),
                        );
                        map.insert(
                            SmolStr::new_static("repo"),
                            LexObjectProperty::String(LexString { ..Default::default() }),
                        );
                        map.insert(
                            SmolStr::new_static("repoDid"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static("DID of the repo itself"),
                                ),
                                format: Some(LexStringFormat::Did),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("workflow"),
                LexUserType::Object(LexObject {
                    required: Some(
                        vec![
                            SmolStr::new_static("name"), SmolStr::new_static("engine"),
                            SmolStr::new_static("clone"), SmolStr::new_static("raw")
                        ],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("clone"),
                            LexObjectProperty::Ref(LexRef {
                                r#ref: CowStr::new_static("#cloneOpts"),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("engine"),
                            LexObjectProperty::String(LexString { ..Default::default() }),
                        );
                        map.insert(
                            SmolStr::new_static("name"),
                            LexObjectProperty::String(LexString { ..Default::default() }),
                        );
                        map.insert(
                            SmolStr::new_static("raw"),
                            LexObjectProperty::String(LexString { ..Default::default() }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map
        },
        ..Default::default()
    }
}

pub mod pipeline_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 TriggerMetadata;
        type Workflows;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type TriggerMetadata = Unset;
        type Workflows = Unset;
    }
    ///State transition - sets the `trigger_metadata` field to Set
    pub struct SetTriggerMetadata<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetTriggerMetadata<St> {}
    impl<St: State> State for SetTriggerMetadata<St> {
        type TriggerMetadata = Set<members::trigger_metadata>;
        type Workflows = St::Workflows;
    }
    ///State transition - sets the `workflows` field to Set
    pub struct SetWorkflows<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetWorkflows<St> {}
    impl<St: State> State for SetWorkflows<St> {
        type TriggerMetadata = St::TriggerMetadata;
        type Workflows = Set<members::workflows>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `trigger_metadata` field
        pub struct trigger_metadata(());
        ///Marker type for the `workflows` field
        pub struct workflows(());
    }
}

/// Builder for constructing an instance of this type.
pub struct PipelineBuilder<St: pipeline_state::State, S: BosStr = DefaultStr> {
    _state: PhantomData<fn() -> St>,
    _fields: (Option<pipeline::TriggerMetadata<S>>, Option<Vec<pipeline::Workflow<S>>>),
    _type: PhantomData<fn() -> S>,
}

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

impl<S: BosStr> Pipeline<S> {
    /// Create a new builder for this type
    pub fn builder() -> PipelineBuilder<pipeline_state::Empty, S> {
        PipelineBuilder::builder()
    }
}

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

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

impl<St, S: BosStr> PipelineBuilder<St, S>
where
    St: pipeline_state::State,
    St::TriggerMetadata: pipeline_state::IsUnset,
{
    /// Set the `triggerMetadata` field (required)
    pub fn trigger_metadata(
        mut self,
        value: impl Into<pipeline::TriggerMetadata<S>>,
    ) -> PipelineBuilder<pipeline_state::SetTriggerMetadata<St>, S> {
        self._fields.0 = Option::Some(value.into());
        PipelineBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> PipelineBuilder<St, S>
where
    St: pipeline_state::State,
    St::Workflows: pipeline_state::IsUnset,
{
    /// Set the `workflows` field (required)
    pub fn workflows(
        mut self,
        value: impl Into<Vec<pipeline::Workflow<S>>>,
    ) -> PipelineBuilder<pipeline_state::SetWorkflows<St>, S> {
        self._fields.1 = Option::Some(value.into());
        PipelineBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> PipelineBuilder<St, S>
where
    St: pipeline_state::State,
    St::TriggerMetadata: pipeline_state::IsSet,
    St::Workflows: pipeline_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> Pipeline<S> {
        Pipeline {
            trigger_metadata: self._fields.0.unwrap(),
            workflows: 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>>) -> Pipeline<S> {
        Pipeline {
            trigger_metadata: self._fields.0.unwrap(),
            workflows: self._fields.1.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}

pub mod trigger_metadata_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 Kind;
        type Repo;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type Kind = Unset;
        type Repo = Unset;
    }
    ///State transition - sets the `kind` field to Set
    pub struct SetKind<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetKind<St> {}
    impl<St: State> State for SetKind<St> {
        type Kind = Set<members::kind>;
        type Repo = St::Repo;
    }
    ///State transition - sets the `repo` field to Set
    pub struct SetRepo<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetRepo<St> {}
    impl<St: State> State for SetRepo<St> {
        type Kind = St::Kind;
        type Repo = Set<members::repo>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `kind` field
        pub struct kind(());
        ///Marker type for the `repo` field
        pub struct repo(());
    }
}

/// Builder for constructing an instance of this type.
pub struct TriggerMetadataBuilder<
    St: trigger_metadata_state::State,
    S: BosStr = DefaultStr,
> {
    _state: PhantomData<fn() -> St>,
    _fields: (
        Option<S>,
        Option<pipeline::ManualTriggerData<S>>,
        Option<pipeline::PullRequestTriggerData<S>>,
        Option<pipeline::PushTriggerData<S>>,
        Option<pipeline::TriggerRepo<S>>,
    ),
    _type: PhantomData<fn() -> S>,
}

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

impl<S: BosStr> TriggerMetadata<S> {
    /// Create a new builder for this type
    pub fn builder() -> TriggerMetadataBuilder<trigger_metadata_state::Empty, S> {
        TriggerMetadataBuilder::builder()
    }
}

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

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

impl<St, S: BosStr> TriggerMetadataBuilder<St, S>
where
    St: trigger_metadata_state::State,
    St::Kind: trigger_metadata_state::IsUnset,
{
    /// Set the `kind` field (required)
    pub fn kind(
        mut self,
        value: impl Into<S>,
    ) -> TriggerMetadataBuilder<trigger_metadata_state::SetKind<St>, S> {
        self._fields.0 = Option::Some(value.into());
        TriggerMetadataBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St: trigger_metadata_state::State, S: BosStr> TriggerMetadataBuilder<St, S> {
    /// Set the `manual` field (optional)
    pub fn manual(
        mut self,
        value: impl Into<Option<pipeline::ManualTriggerData<S>>>,
    ) -> Self {
        self._fields.1 = value.into();
        self
    }
    /// Set the `manual` field to an Option value (optional)
    pub fn maybe_manual(
        mut self,
        value: Option<pipeline::ManualTriggerData<S>>,
    ) -> Self {
        self._fields.1 = value;
        self
    }
}

impl<St: trigger_metadata_state::State, S: BosStr> TriggerMetadataBuilder<St, S> {
    /// Set the `pullRequest` field (optional)
    pub fn pull_request(
        mut self,
        value: impl Into<Option<pipeline::PullRequestTriggerData<S>>>,
    ) -> Self {
        self._fields.2 = value.into();
        self
    }
    /// Set the `pullRequest` field to an Option value (optional)
    pub fn maybe_pull_request(
        mut self,
        value: Option<pipeline::PullRequestTriggerData<S>>,
    ) -> Self {
        self._fields.2 = value;
        self
    }
}

impl<St: trigger_metadata_state::State, S: BosStr> TriggerMetadataBuilder<St, S> {
    /// Set the `push` field (optional)
    pub fn push(
        mut self,
        value: impl Into<Option<pipeline::PushTriggerData<S>>>,
    ) -> Self {
        self._fields.3 = value.into();
        self
    }
    /// Set the `push` field to an Option value (optional)
    pub fn maybe_push(mut self, value: Option<pipeline::PushTriggerData<S>>) -> Self {
        self._fields.3 = value;
        self
    }
}

impl<St, S: BosStr> TriggerMetadataBuilder<St, S>
where
    St: trigger_metadata_state::State,
    St::Repo: trigger_metadata_state::IsUnset,
{
    /// Set the `repo` field (required)
    pub fn repo(
        mut self,
        value: impl Into<pipeline::TriggerRepo<S>>,
    ) -> TriggerMetadataBuilder<trigger_metadata_state::SetRepo<St>, S> {
        self._fields.4 = Option::Some(value.into());
        TriggerMetadataBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> TriggerMetadataBuilder<St, S>
where
    St: trigger_metadata_state::State,
    St::Kind: trigger_metadata_state::IsSet,
    St::Repo: trigger_metadata_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> TriggerMetadata<S> {
        TriggerMetadata {
            kind: self._fields.0.unwrap(),
            manual: self._fields.1,
            pull_request: self._fields.2,
            push: self._fields.3,
            repo: 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>>,
    ) -> TriggerMetadata<S> {
        TriggerMetadata {
            kind: self._fields.0.unwrap(),
            manual: self._fields.1,
            pull_request: self._fields.2,
            push: self._fields.3,
            repo: self._fields.4.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}

pub mod trigger_repo_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 DefaultBranch;
        type Did;
        type Knot;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type DefaultBranch = Unset;
        type Did = Unset;
        type Knot = Unset;
    }
    ///State transition - sets the `default_branch` field to Set
    pub struct SetDefaultBranch<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetDefaultBranch<St> {}
    impl<St: State> State for SetDefaultBranch<St> {
        type DefaultBranch = Set<members::default_branch>;
        type Did = St::Did;
        type Knot = St::Knot;
    }
    ///State transition - sets the `did` field to Set
    pub struct SetDid<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetDid<St> {}
    impl<St: State> State for SetDid<St> {
        type DefaultBranch = St::DefaultBranch;
        type Did = Set<members::did>;
        type Knot = St::Knot;
    }
    ///State transition - sets the `knot` field to Set
    pub struct SetKnot<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetKnot<St> {}
    impl<St: State> State for SetKnot<St> {
        type DefaultBranch = St::DefaultBranch;
        type Did = St::Did;
        type Knot = Set<members::knot>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `default_branch` field
        pub struct default_branch(());
        ///Marker type for the `did` field
        pub struct did(());
        ///Marker type for the `knot` field
        pub struct knot(());
    }
}

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

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

impl<S: BosStr> TriggerRepo<S> {
    /// Create a new builder for this type
    pub fn builder() -> TriggerRepoBuilder<trigger_repo_state::Empty, S> {
        TriggerRepoBuilder::builder()
    }
}

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

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

impl<St, S: BosStr> TriggerRepoBuilder<St, S>
where
    St: trigger_repo_state::State,
    St::DefaultBranch: trigger_repo_state::IsUnset,
{
    /// Set the `defaultBranch` field (required)
    pub fn default_branch(
        mut self,
        value: impl Into<S>,
    ) -> TriggerRepoBuilder<trigger_repo_state::SetDefaultBranch<St>, S> {
        self._fields.0 = Option::Some(value.into());
        TriggerRepoBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

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

impl<St, S: BosStr> TriggerRepoBuilder<St, S>
where
    St: trigger_repo_state::State,
    St::Knot: trigger_repo_state::IsUnset,
{
    /// Set the `knot` field (required)
    pub fn knot(
        mut self,
        value: impl Into<S>,
    ) -> TriggerRepoBuilder<trigger_repo_state::SetKnot<St>, S> {
        self._fields.2 = Option::Some(value.into());
        TriggerRepoBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St: trigger_repo_state::State, S: BosStr> TriggerRepoBuilder<St, S> {
    /// Set the `repo` field (optional)
    pub fn repo(mut self, value: impl Into<Option<S>>) -> Self {
        self._fields.3 = value.into();
        self
    }
    /// Set the `repo` field to an Option value (optional)
    pub fn maybe_repo(mut self, value: Option<S>) -> Self {
        self._fields.3 = value;
        self
    }
}

impl<St: trigger_repo_state::State, S: BosStr> TriggerRepoBuilder<St, S> {
    /// Set the `repoDid` field (optional)
    pub fn repo_did(mut self, value: impl Into<Option<Did<S>>>) -> Self {
        self._fields.4 = value.into();
        self
    }
    /// Set the `repoDid` field to an Option value (optional)
    pub fn maybe_repo_did(mut self, value: Option<Did<S>>) -> Self {
        self._fields.4 = value;
        self
    }
}

impl<St, S: BosStr> TriggerRepoBuilder<St, S>
where
    St: trigger_repo_state::State,
    St::DefaultBranch: trigger_repo_state::IsSet,
    St::Did: trigger_repo_state::IsSet,
    St::Knot: trigger_repo_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> TriggerRepo<S> {
        TriggerRepo {
            default_branch: self._fields.0.unwrap(),
            did: self._fields.1.unwrap(),
            knot: self._fields.2.unwrap(),
            repo: self._fields.3,
            repo_did: self._fields.4,
            extra_data: Default::default(),
        }
    }
    /// Build the final struct with custom extra_data.
    pub fn build_with_data(
        self,
        extra_data: BTreeMap<SmolStr, Data<S>>,
    ) -> TriggerRepo<S> {
        TriggerRepo {
            default_branch: self._fields.0.unwrap(),
            did: self._fields.1.unwrap(),
            knot: self._fields.2.unwrap(),
            repo: self._fields.3,
            repo_did: self._fields.4,
            extra_data: Some(extra_data),
        }
    }
}

pub mod workflow_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 Clone;
        type Engine;
        type Name;
        type Raw;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type Clone = Unset;
        type Engine = Unset;
        type Name = Unset;
        type Raw = Unset;
    }
    ///State transition - sets the `clone` field to Set
    pub struct SetClone<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetClone<St> {}
    impl<St: State> State for SetClone<St> {
        type Clone = Set<members::clone>;
        type Engine = St::Engine;
        type Name = St::Name;
        type Raw = St::Raw;
    }
    ///State transition - sets the `engine` field to Set
    pub struct SetEngine<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetEngine<St> {}
    impl<St: State> State for SetEngine<St> {
        type Clone = St::Clone;
        type Engine = Set<members::engine>;
        type Name = St::Name;
        type Raw = St::Raw;
    }
    ///State transition - sets the `name` field to Set
    pub struct SetName<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetName<St> {}
    impl<St: State> State for SetName<St> {
        type Clone = St::Clone;
        type Engine = St::Engine;
        type Name = Set<members::name>;
        type Raw = St::Raw;
    }
    ///State transition - sets the `raw` field to Set
    pub struct SetRaw<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetRaw<St> {}
    impl<St: State> State for SetRaw<St> {
        type Clone = St::Clone;
        type Engine = St::Engine;
        type Name = St::Name;
        type Raw = Set<members::raw>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `clone` field
        pub struct clone(());
        ///Marker type for the `engine` field
        pub struct engine(());
        ///Marker type for the `name` field
        pub struct name(());
        ///Marker type for the `raw` field
        pub struct raw(());
    }
}

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

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

impl<S: BosStr> Workflow<S> {
    /// Create a new builder for this type
    pub fn builder() -> WorkflowBuilder<workflow_state::Empty, S> {
        WorkflowBuilder::builder()
    }
}

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

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

impl<St, S: BosStr> WorkflowBuilder<St, S>
where
    St: workflow_state::State,
    St::Clone: workflow_state::IsUnset,
{
    /// Set the `clone` field (required)
    pub fn clone(
        mut self,
        value: impl Into<pipeline::CloneOpts<S>>,
    ) -> WorkflowBuilder<workflow_state::SetClone<St>, S> {
        self._fields.0 = Option::Some(value.into());
        WorkflowBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> WorkflowBuilder<St, S>
where
    St: workflow_state::State,
    St::Engine: workflow_state::IsUnset,
{
    /// Set the `engine` field (required)
    pub fn engine(
        mut self,
        value: impl Into<S>,
    ) -> WorkflowBuilder<workflow_state::SetEngine<St>, S> {
        self._fields.1 = Option::Some(value.into());
        WorkflowBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> WorkflowBuilder<St, S>
where
    St: workflow_state::State,
    St::Name: workflow_state::IsUnset,
{
    /// Set the `name` field (required)
    pub fn name(
        mut self,
        value: impl Into<S>,
    ) -> WorkflowBuilder<workflow_state::SetName<St>, S> {
        self._fields.2 = Option::Some(value.into());
        WorkflowBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> WorkflowBuilder<St, S>
where
    St: workflow_state::State,
    St::Raw: workflow_state::IsUnset,
{
    /// Set the `raw` field (required)
    pub fn raw(
        mut self,
        value: impl Into<S>,
    ) -> WorkflowBuilder<workflow_state::SetRaw<St>, S> {
        self._fields.3 = Option::Some(value.into());
        WorkflowBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> WorkflowBuilder<St, S>
where
    St: workflow_state::State,
    St::Clone: workflow_state::IsSet,
    St::Engine: workflow_state::IsSet,
    St::Name: workflow_state::IsSet,
    St::Raw: workflow_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> Workflow<S> {
        Workflow {
            clone: self._fields.0.unwrap(),
            engine: self._fields.1.unwrap(),
            name: self._fields.2.unwrap(),
            raw: self._fields.3.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>>) -> Workflow<S> {
        Workflow {
            clone: self._fields.0.unwrap(),
            engine: self._fields.1.unwrap(),
            name: self._fields.2.unwrap(),
            raw: self._fields.3.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}