use serde::{Deserialize, Serialize};
use schemars::JsonSchema;
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema)]
#[serde(untagged)]
#[schemars(rename = "functions.InlineProfileOrRemoteCommitOptional")]
pub enum InlineProfileOrRemoteCommitOptional {
#[schemars(title = "Inline")]
Inline(InlineProfile),
#[schemars(title = "Remote")]
Remote(crate::RemotePathCommitOptional),
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema)]
#[serde(untagged)]
#[schemars(rename = "functions.Profile")]
pub enum Profile {
#[schemars(title = "Remote")]
Remote(RemoteProfile),
#[schemars(title = "Inline")]
Inline(InlineProfile),
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema)]
#[serde(untagged)]
#[schemars(rename = "functions.RemoteProfile")]
pub enum RemoteProfile {
#[schemars(title = "Tasks")]
Tasks(RemoteTasksProfile),
#[schemars(title = "Auto")]
Auto(crate::swarm::RemoteSwarmBase),
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema)]
#[serde(untagged)]
#[schemars(rename = "functions.InlineProfile")]
pub enum InlineProfile {
#[schemars(title = "Tasks")]
Tasks(InlineTasksProfile),
#[schemars(title = "Auto")]
Auto(crate::swarm::InlineSwarmBase),
}
impl<'a> arbitrary::Arbitrary<'a> for InlineProfile {
fn arbitrary(u: &mut arbitrary::Unstructured<'a>) -> arbitrary::Result<Self> {
Ok(InlineProfile::Tasks(u.arbitrary()?))
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, arbitrary::Arbitrary)]
#[schemars(rename = "functions.InlineTasksProfile")]
pub struct InlineTasksProfile {
pub tasks: Vec<TaskProfile>,
#[serde(skip_serializing_if = "Option::is_none")]
#[schemars(extend("omitempty" = true))]
pub weights: Option<crate::Weights>,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema)]
#[schemars(rename = "functions.RemoteTasksProfile")]
pub struct RemoteTasksProfile {
pub description: String,
#[serde(flatten)]
#[schemars(schema_with = "crate::flatten_schema::<InlineTasksProfile>")]
pub inner: InlineTasksProfile,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema)]
#[serde(untagged)]
#[schemars(rename = "functions.TaskProfile")]
pub enum TaskProfile {
#[schemars(title = "Remote")]
Remote(crate::RemotePath),
#[schemars(title = "Inline")]
Inline(InlineProfile),
#[schemars(title = "Placeholder")]
Placeholder {},
}
impl<'a> arbitrary::Arbitrary<'a> for TaskProfile {
fn arbitrary(u: &mut arbitrary::Unstructured<'a>) -> arbitrary::Result<Self> {
if u.arbitrary().unwrap_or(false) {
Ok(TaskProfile::Inline(u.arbitrary()?))
} else if u.arbitrary().unwrap_or(false) {
Ok(TaskProfile::Remote(u.arbitrary()?))
} else {
Ok(TaskProfile::Placeholder {})
}
}
}