#![allow(clippy::doc_markdown)]
use serde::{Deserialize, Serialize};
use super::common::*;
#[derive(Debug, thiserror::Error, PartialEq, Eq)]
pub enum BuildError {
#[error("missing required field: {0}")]
MissingField(&'static str),
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "kebab-case")]
pub struct Profile {
pub uuid: uuid::Uuid,
pub metadata: Metadata,
#[serde(default)]
pub imports: Vec<Import>,
#[serde(skip_serializing_if = "Option::is_none")]
pub merge: Option<Merge>,
#[serde(skip_serializing_if = "Option::is_none")]
pub modify: Option<Modify>,
#[serde(skip_serializing_if = "Option::is_none")]
pub back_matter: Option<BackMatter>,
}
#[must_use]
#[derive(Debug)]
pub struct ProfileBuilder {
uuid: Option<uuid::Uuid>,
metadata: Option<Metadata>,
imports: Vec<Import>,
merge: Option<Merge>,
modify: Option<Modify>,
back_matter: Option<BackMatter>,
}
impl ProfileBuilder {
pub fn new() -> Self {
Self {
uuid: None,
metadata: None,
imports: Vec::new(),
merge: None,
modify: None,
back_matter: None,
}
}
}
impl Default for ProfileBuilder {
fn default() -> Self {
Self::new()
}
}
impl ProfileBuilder {
pub fn uuid(mut self, v: impl Into<uuid::Uuid>) -> Self {
self.uuid = Some(v.into());
self
}
pub fn metadata(mut self, v: impl Into<Metadata>) -> Self {
self.metadata = Some(v.into());
self
}
pub fn imports(mut self, v: impl Into<Import>) -> Self {
self.imports.push(v.into());
self
}
pub fn merge(mut self, v: impl Into<Merge>) -> Self {
self.merge = Some(v.into());
self
}
pub fn modify(mut self, v: impl Into<Modify>) -> Self {
self.modify = Some(v.into());
self
}
pub fn back_matter(mut self, v: impl Into<BackMatter>) -> Self {
self.back_matter = Some(v.into());
self
}
pub fn build(self) -> ::core::result::Result<Profile, BuildError> {
let uuid = self
.uuid
.ok_or_else(|| BuildError::MissingField("required field `uuid` not set"))?;
let metadata = self
.metadata
.ok_or_else(|| BuildError::MissingField(
"required field `metadata` not set",
))?;
Ok(Profile {
uuid,
metadata,
imports: self.imports,
merge: self.merge,
modify: self.modify,
back_matter: self.back_matter,
})
}
}
impl Profile {
pub fn builder() -> ProfileBuilder {
ProfileBuilder::new()
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ImportChoice1 {
IncludeAll(IncludeAll),
SelectControlById(Vec<SelectControlById>),
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "kebab-case")]
pub struct Import {
pub href: crate::primitives::UriReference,
#[serde(skip_serializing_if = "Option::is_none")]
pub import_choice1: Option<ImportChoice1>,
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub exclude_controls: Vec<SelectControlById>,
}
#[must_use]
#[derive(Debug)]
pub struct ImportBuilder {
href: Option<crate::primitives::UriReference>,
import_choice1: Option<ImportChoice1>,
exclude_controls: Vec<SelectControlById>,
}
impl ImportBuilder {
pub fn new() -> Self {
Self {
href: None,
import_choice1: None,
exclude_controls: Vec::new(),
}
}
}
impl Default for ImportBuilder {
fn default() -> Self {
Self::new()
}
}
impl ImportBuilder {
pub fn href(mut self, v: impl Into<crate::primitives::UriReference>) -> Self {
self.href = Some(v.into());
self
}
pub fn import_choice1(mut self, v: impl Into<ImportChoice1>) -> Self {
self.import_choice1 = Some(v.into());
self
}
pub fn exclude_controls(mut self, v: impl Into<SelectControlById>) -> Self {
self.exclude_controls.push(v.into());
self
}
pub fn build(self) -> ::core::result::Result<Import, BuildError> {
let href = self
.href
.ok_or_else(|| BuildError::MissingField("required field `href` not set"))?;
Ok(Import {
href,
import_choice1: self.import_choice1,
exclude_controls: self.exclude_controls,
})
}
}
impl Import {
pub fn builder() -> ImportBuilder {
ImportBuilder::new()
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "kebab-case")]
pub struct Combine {
#[serde(skip_serializing_if = "Option::is_none")]
pub method: Option<String>,
}
#[must_use]
#[derive(Debug)]
pub struct CombineBuilder {
method: Option<String>,
}
impl CombineBuilder {
pub fn new() -> Self {
Self { method: None }
}
}
impl Default for CombineBuilder {
fn default() -> Self {
Self::new()
}
}
impl CombineBuilder {
pub fn method(mut self, v: impl Into<String>) -> Self {
self.method = Some(v.into());
self
}
pub fn build(self) -> ::core::result::Result<Combine, BuildError> {
Ok(Combine { method: self.method })
}
}
impl Combine {
pub fn builder() -> CombineBuilder {
CombineBuilder::new()
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(untagged)]
pub enum MergeChoice1 {}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "kebab-case")]
pub struct Merge {
#[serde(skip_serializing_if = "Option::is_none")]
pub combine: Option<Combine>,
#[serde(skip_serializing_if = "Option::is_none")]
pub merge_choice1: Option<MergeChoice1>,
}
#[must_use]
#[derive(Debug)]
pub struct MergeBuilder {
combine: Option<Combine>,
merge_choice1: Option<MergeChoice1>,
}
impl MergeBuilder {
pub fn new() -> Self {
Self {
combine: None,
merge_choice1: None,
}
}
}
impl Default for MergeBuilder {
fn default() -> Self {
Self::new()
}
}
impl MergeBuilder {
pub fn combine(mut self, v: impl Into<Combine>) -> Self {
self.combine = Some(v.into());
self
}
pub fn merge_choice1(mut self, v: impl Into<MergeChoice1>) -> Self {
self.merge_choice1 = Some(v.into());
self
}
pub fn build(self) -> ::core::result::Result<Merge, BuildError> {
Ok(Merge {
combine: self.combine,
merge_choice1: self.merge_choice1,
})
}
}
impl Merge {
pub fn builder() -> MergeBuilder {
MergeBuilder::new()
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(untagged)]
pub enum SetParameterChoice1 {
ParameterValue(Vec<String>),
ParameterSelection(Option<ParameterSelection>),
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "kebab-case")]
pub struct SetParameter {
pub param_id: String,
#[serde(skip_serializing_if = "Option::is_none")]
pub class: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub depends_on: Option<String>,
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub props: Vec<Property>,
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub links: Vec<Link>,
#[serde(skip_serializing_if = "Option::is_none")]
pub label: Option<crate::primitives::MarkupLine>,
#[serde(skip_serializing_if = "Option::is_none")]
pub usage: Option<crate::primitives::MarkupMultiline>,
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub constraints: Vec<ParameterConstraint>,
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub guidelines: Vec<ParameterGuideline>,
#[serde(skip_serializing_if = "Option::is_none")]
pub set_parameter_choice1: Option<SetParameterChoice1>,
}
#[must_use]
#[derive(Debug)]
pub struct SetParameterBuilder {
param_id: Option<String>,
class: Option<String>,
depends_on: Option<String>,
props: Vec<Property>,
links: Vec<Link>,
label: Option<crate::primitives::MarkupLine>,
usage: Option<crate::primitives::MarkupMultiline>,
constraints: Vec<ParameterConstraint>,
guidelines: Vec<ParameterGuideline>,
set_parameter_choice1: Option<SetParameterChoice1>,
}
impl SetParameterBuilder {
pub fn new() -> Self {
Self {
param_id: None,
class: None,
depends_on: None,
props: Vec::new(),
links: Vec::new(),
label: None,
usage: None,
constraints: Vec::new(),
guidelines: Vec::new(),
set_parameter_choice1: None,
}
}
}
impl Default for SetParameterBuilder {
fn default() -> Self {
Self::new()
}
}
impl SetParameterBuilder {
pub fn param_id(mut self, v: impl Into<String>) -> Self {
self.param_id = Some(v.into());
self
}
pub fn class(mut self, v: impl Into<String>) -> Self {
self.class = Some(v.into());
self
}
pub fn depends_on(mut self, v: impl Into<String>) -> Self {
self.depends_on = Some(v.into());
self
}
pub fn props(mut self, v: impl Into<Property>) -> Self {
self.props.push(v.into());
self
}
pub fn links(mut self, v: impl Into<Link>) -> Self {
self.links.push(v.into());
self
}
pub fn label(mut self, v: impl Into<crate::primitives::MarkupLine>) -> Self {
self.label = Some(v.into());
self
}
pub fn usage(mut self, v: impl Into<crate::primitives::MarkupMultiline>) -> Self {
self.usage = Some(v.into());
self
}
pub fn constraints(mut self, v: impl Into<ParameterConstraint>) -> Self {
self.constraints.push(v.into());
self
}
pub fn guidelines(mut self, v: impl Into<ParameterGuideline>) -> Self {
self.guidelines.push(v.into());
self
}
pub fn set_parameter_choice1(mut self, v: impl Into<SetParameterChoice1>) -> Self {
self.set_parameter_choice1 = Some(v.into());
self
}
pub fn build(self) -> ::core::result::Result<SetParameter, BuildError> {
let param_id = self
.param_id
.ok_or_else(|| BuildError::MissingField(
"required field `param-id` not set",
))?;
Ok(SetParameter {
param_id,
class: self.class,
depends_on: self.depends_on,
props: self.props,
links: self.links,
label: self.label,
usage: self.usage,
constraints: self.constraints,
guidelines: self.guidelines,
set_parameter_choice1: self.set_parameter_choice1,
})
}
}
impl SetParameter {
pub fn builder() -> SetParameterBuilder {
SetParameterBuilder::new()
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "kebab-case")]
pub struct Remove {
#[serde(skip_serializing_if = "Option::is_none")]
pub by_name: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub by_class: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub by_id: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub by_item_name: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub by_ns: Option<url::Url>,
#[serde(skip_serializing_if = "Option::is_none")]
pub remarks: Option<crate::primitives::MarkupMultiline>,
}
#[must_use]
#[derive(Debug)]
pub struct RemoveBuilder {
by_name: Option<String>,
by_class: Option<String>,
by_id: Option<String>,
by_item_name: Option<String>,
by_ns: Option<url::Url>,
remarks: Option<crate::primitives::MarkupMultiline>,
}
impl RemoveBuilder {
pub fn new() -> Self {
Self {
by_name: None,
by_class: None,
by_id: None,
by_item_name: None,
by_ns: None,
remarks: None,
}
}
}
impl Default for RemoveBuilder {
fn default() -> Self {
Self::new()
}
}
impl RemoveBuilder {
pub fn by_name(mut self, v: impl Into<String>) -> Self {
self.by_name = Some(v.into());
self
}
pub fn by_class(mut self, v: impl Into<String>) -> Self {
self.by_class = Some(v.into());
self
}
pub fn by_id(mut self, v: impl Into<String>) -> Self {
self.by_id = Some(v.into());
self
}
pub fn by_item_name(mut self, v: impl Into<String>) -> Self {
self.by_item_name = Some(v.into());
self
}
pub fn by_ns(mut self, v: impl Into<url::Url>) -> Self {
self.by_ns = Some(v.into());
self
}
pub fn remarks(mut self, v: impl Into<crate::primitives::MarkupMultiline>) -> Self {
self.remarks = Some(v.into());
self
}
pub fn build(self) -> ::core::result::Result<Remove, BuildError> {
Ok(Remove {
by_name: self.by_name,
by_class: self.by_class,
by_id: self.by_id,
by_item_name: self.by_item_name,
by_ns: self.by_ns,
remarks: self.remarks,
})
}
}
impl Remove {
pub fn builder() -> RemoveBuilder {
RemoveBuilder::new()
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "kebab-case")]
pub struct Add {
#[serde(skip_serializing_if = "Option::is_none")]
pub position: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub by_id: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub title: Option<crate::primitives::MarkupLine>,
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub params: Vec<Parameter>,
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub props: Vec<Property>,
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub links: Vec<Link>,
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub parts: Vec<Part>,
}
#[must_use]
#[derive(Debug)]
pub struct AddBuilder {
position: Option<String>,
by_id: Option<String>,
title: Option<crate::primitives::MarkupLine>,
params: Vec<Parameter>,
props: Vec<Property>,
links: Vec<Link>,
parts: Vec<Part>,
}
impl AddBuilder {
pub fn new() -> Self {
Self {
position: None,
by_id: None,
title: None,
params: Vec::new(),
props: Vec::new(),
links: Vec::new(),
parts: Vec::new(),
}
}
}
impl Default for AddBuilder {
fn default() -> Self {
Self::new()
}
}
impl AddBuilder {
pub fn position(mut self, v: impl Into<String>) -> Self {
self.position = Some(v.into());
self
}
pub fn by_id(mut self, v: impl Into<String>) -> Self {
self.by_id = Some(v.into());
self
}
pub fn title(mut self, v: impl Into<crate::primitives::MarkupLine>) -> Self {
self.title = Some(v.into());
self
}
pub fn params(mut self, v: impl Into<Parameter>) -> Self {
self.params.push(v.into());
self
}
pub fn props(mut self, v: impl Into<Property>) -> Self {
self.props.push(v.into());
self
}
pub fn links(mut self, v: impl Into<Link>) -> Self {
self.links.push(v.into());
self
}
pub fn parts(mut self, v: impl Into<Part>) -> Self {
self.parts.push(v.into());
self
}
pub fn build(self) -> ::core::result::Result<Add, BuildError> {
Ok(Add {
position: self.position,
by_id: self.by_id,
title: self.title,
params: self.params,
props: self.props,
links: self.links,
parts: self.parts,
})
}
}
impl Add {
pub fn builder() -> AddBuilder {
AddBuilder::new()
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "kebab-case")]
pub struct Alter {
pub control_id: String,
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub remove: Vec<Remove>,
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub add: Vec<Add>,
}
#[must_use]
#[derive(Debug)]
pub struct AlterBuilder {
control_id: Option<String>,
remove: Vec<Remove>,
add: Vec<Add>,
}
impl AlterBuilder {
pub fn new() -> Self {
Self {
control_id: None,
remove: Vec::new(),
add: Vec::new(),
}
}
}
impl Default for AlterBuilder {
fn default() -> Self {
Self::new()
}
}
impl AlterBuilder {
pub fn control_id(mut self, v: impl Into<String>) -> Self {
self.control_id = Some(v.into());
self
}
pub fn remove(mut self, v: impl Into<Remove>) -> Self {
self.remove.push(v.into());
self
}
pub fn add(mut self, v: impl Into<Add>) -> Self {
self.add.push(v.into());
self
}
pub fn build(self) -> ::core::result::Result<Alter, BuildError> {
let control_id = self
.control_id
.ok_or_else(|| BuildError::MissingField(
"required field `control-id` not set",
))?;
Ok(Alter {
control_id,
remove: self.remove,
add: self.add,
})
}
}
impl Alter {
pub fn builder() -> AlterBuilder {
AlterBuilder::new()
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "kebab-case")]
pub struct Modify {
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub set_parameter: Vec<SetParameter>,
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub alter: Vec<Alter>,
}
#[must_use]
#[derive(Debug)]
pub struct ModifyBuilder {
set_parameter: Vec<SetParameter>,
alter: Vec<Alter>,
}
impl ModifyBuilder {
pub fn new() -> Self {
Self {
set_parameter: Vec::new(),
alter: Vec::new(),
}
}
}
impl Default for ModifyBuilder {
fn default() -> Self {
Self::new()
}
}
impl ModifyBuilder {
pub fn set_parameter(mut self, v: impl Into<SetParameter>) -> Self {
self.set_parameter.push(v.into());
self
}
pub fn alter(mut self, v: impl Into<Alter>) -> Self {
self.alter.push(v.into());
self
}
pub fn build(self) -> ::core::result::Result<Modify, BuildError> {
Ok(Modify {
set_parameter: self.set_parameter,
alter: self.alter,
})
}
}
impl Modify {
pub fn builder() -> ModifyBuilder {
ModifyBuilder::new()
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(untagged)]
pub enum InsertControlsChoice1 {
IncludeAll(IncludeAll),
SelectControlById(Vec<SelectControlById>),
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "kebab-case")]
pub struct InsertControls {
#[serde(skip_serializing_if = "Option::is_none")]
pub order: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub insert_controls_choice1: Option<InsertControlsChoice1>,
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub exclude_controls: Vec<SelectControlById>,
}
#[must_use]
#[derive(Debug)]
pub struct InsertControlsBuilder {
order: Option<String>,
insert_controls_choice1: Option<InsertControlsChoice1>,
exclude_controls: Vec<SelectControlById>,
}
impl InsertControlsBuilder {
pub fn new() -> Self {
Self {
order: None,
insert_controls_choice1: None,
exclude_controls: Vec::new(),
}
}
}
impl Default for InsertControlsBuilder {
fn default() -> Self {
Self::new()
}
}
impl InsertControlsBuilder {
pub fn order(mut self, v: impl Into<String>) -> Self {
self.order = Some(v.into());
self
}
pub fn insert_controls_choice1(
mut self,
v: impl Into<InsertControlsChoice1>,
) -> Self {
self.insert_controls_choice1 = Some(v.into());
self
}
pub fn exclude_controls(mut self, v: impl Into<SelectControlById>) -> Self {
self.exclude_controls.push(v.into());
self
}
pub fn build(self) -> ::core::result::Result<InsertControls, BuildError> {
Ok(InsertControls {
order: self.order,
insert_controls_choice1: self.insert_controls_choice1,
exclude_controls: self.exclude_controls,
})
}
}
impl InsertControls {
pub fn builder() -> InsertControlsBuilder {
InsertControlsBuilder::new()
}
}