From 2605bfb0487c26c67fa8dbd94c6512393f7813a6 Mon Sep 17 00:00:00 2001 From: John Vandenberg Date: Fri, 8 Dec 2023 11:07:07 +0800 Subject: [PATCH] Update buildomat sample OpenAPI --- .../tests/output/buildomat-builder-tagged.out | 11086 +++++++++++++--- .../tests/output/buildomat-builder.out | 11086 +++++++++++++--- .../tests/output/buildomat-cli.out | 3261 ++++- .../tests/output/buildomat-httpmock.out | 4041 +++++- .../tests/output/buildomat-positional.out | 2547 +++- progenitor/tests/build_buildomat.rs | 10 +- sample_openapi/buildomat.json | 3074 ++++- 7 files changed, 30037 insertions(+), 5068 deletions(-) diff --git a/progenitor-impl/tests/output/buildomat-builder-tagged.out b/progenitor-impl/tests/output/buildomat-builder-tagged.out index 832b351d..e223cd6b 100644 --- a/progenitor-impl/tests/output/buildomat-builder-tagged.out +++ b/progenitor-impl/tests/output/buildomat-builder-tagged.out @@ -8,1888 +8,9084 @@ pub mod types { #[allow(unused_imports)] use std::convert::TryFrom; #[derive(Clone, Debug, Deserialize, Serialize)] - pub struct Task { - pub id: String, - pub name: String, - pub output_rules: Vec, - pub script: String, - pub state: String, + pub struct DependSubmit { + pub copy_outputs: bool, + pub on_completed: bool, + pub on_failed: bool, + pub prior_job: String, } - impl From<&Task> for Task { - fn from(value: &Task) -> Self { + impl From<&DependSubmit> for DependSubmit { + fn from(value: &DependSubmit) -> Self { value.clone() } } - impl Task { - pub fn builder() -> builder::Task { - builder::Task::default() + impl DependSubmit { + pub fn builder() -> builder::DependSubmit { + builder::DependSubmit::default() } } + ///Error information from a response. #[derive(Clone, Debug, Deserialize, Serialize)] - pub struct TaskEvent { - pub payload: String, - pub seq: u32, - pub stream: String, - pub time: chrono::DateTime, + pub struct Error { + #[serde(default, skip_serializing_if = "Option::is_none")] + pub error_code: Option, + pub message: String, + pub request_id: String, } - impl From<&TaskEvent> for TaskEvent { - fn from(value: &TaskEvent) -> Self { + impl From<&Error> for Error { + fn from(value: &Error) -> Self { value.clone() } } - impl TaskEvent { - pub fn builder() -> builder::TaskEvent { - builder::TaskEvent::default() + impl Error { + pub fn builder() -> builder::Error { + builder::Error::default() } } #[derive(Clone, Debug, Deserialize, Serialize)] - pub struct TaskOutput { - pub id: String, - pub path: String, - pub size: u64, + pub struct FactoryAddresses { + pub cidr: String, + pub count: u32, + pub first: String, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub gateway: Option, + pub name: String, + pub routed: bool, } - impl From<&TaskOutput> for TaskOutput { - fn from(value: &TaskOutput) -> Self { + impl From<&FactoryAddresses> for FactoryAddresses { + fn from(value: &FactoryAddresses) -> Self { value.clone() } } - impl TaskOutput { - pub fn builder() -> builder::TaskOutput { - builder::TaskOutput::default() + impl FactoryAddresses { + pub fn builder() -> builder::FactoryAddresses { + builder::FactoryAddresses::default() } } #[derive(Clone, Debug, Deserialize, Serialize)] - pub struct TaskSubmit { + pub struct FactoryCreate { pub name: String, - #[serde(default, skip_serializing_if = "Vec::is_empty")] - pub output_rules: Vec, - pub script: String, } - impl From<&TaskSubmit> for TaskSubmit { - fn from(value: &TaskSubmit) -> Self { + impl From<&FactoryCreate> for FactoryCreate { + fn from(value: &FactoryCreate) -> Self { value.clone() } } - impl TaskSubmit { - pub fn builder() -> builder::TaskSubmit { - builder::TaskSubmit::default() + impl FactoryCreate { + pub fn builder() -> builder::FactoryCreate { + builder::FactoryCreate::default() } } #[derive(Clone, Debug, Deserialize, Serialize)] - pub struct TaskSubmitResult { + pub struct FactoryCreateResult { pub id: String, + pub name: String, + pub token: String, } - impl From<&TaskSubmitResult> for TaskSubmitResult { - fn from(value: &TaskSubmitResult) -> Self { + impl From<&FactoryCreateResult> for FactoryCreateResult { + fn from(value: &FactoryCreateResult) -> Self { value.clone() } } - impl TaskSubmitResult { - pub fn builder() -> builder::TaskSubmitResult { - builder::TaskSubmitResult::default() + impl FactoryCreateResult { + pub fn builder() -> builder::FactoryCreateResult { + builder::FactoryCreateResult::default() } } #[derive(Clone, Debug, Deserialize, Serialize)] - pub struct UploadedChunk { - pub id: String, + pub struct FactoryLease { + pub job: String, + pub target: String, } - impl From<&UploadedChunk> for UploadedChunk { - fn from(value: &UploadedChunk) -> Self { + impl From<&FactoryLease> for FactoryLease { + fn from(value: &FactoryLease) -> Self { value.clone() } } - impl UploadedChunk { - pub fn builder() -> builder::UploadedChunk { - builder::UploadedChunk::default() + impl FactoryLease { + pub fn builder() -> builder::FactoryLease { + builder::FactoryLease::default() } } #[derive(Clone, Debug, Deserialize, Serialize)] - pub struct UserCreate { - pub name: String, + pub struct FactoryLeaseResult { + #[serde(default, skip_serializing_if = "Option::is_none")] + pub lease: Option, } - impl From<&UserCreate> for UserCreate { - fn from(value: &UserCreate) -> Self { + impl From<&FactoryLeaseResult> for FactoryLeaseResult { + fn from(value: &FactoryLeaseResult) -> Self { value.clone() } } - impl UserCreate { - pub fn builder() -> builder::UserCreate { - builder::UserCreate::default() + impl FactoryLeaseResult { + pub fn builder() -> builder::FactoryLeaseResult { + builder::FactoryLeaseResult::default() } } #[derive(Clone, Debug, Deserialize, Serialize)] - pub struct UserCreateResult { - pub id: String, - pub name: String, - pub token: String, + #[serde(tag = "v")] + pub enum FactoryMetadata { + #[serde(rename = "1")] + _1 { + #[serde(default, skip_serializing_if = "Vec::is_empty")] + addresses: Vec, + }, } - impl From<&UserCreateResult> for UserCreateResult { - fn from(value: &UserCreateResult) -> Self { + impl From<&FactoryMetadata> for FactoryMetadata { + fn from(value: &FactoryMetadata) -> Self { value.clone() } } - impl UserCreateResult { - pub fn builder() -> builder::UserCreateResult { - builder::UserCreateResult::default() - } - } - #[derive(Clone, Debug, Deserialize, Serialize)] - pub struct WhoamiResult { - pub id: String, - pub name: String, + pub struct FactoryPingResult { + pub ok: bool, } - impl From<&WhoamiResult> for WhoamiResult { - fn from(value: &WhoamiResult) -> Self { + impl From<&FactoryPingResult> for FactoryPingResult { + fn from(value: &FactoryPingResult) -> Self { value.clone() } } - impl WhoamiResult { - pub fn builder() -> builder::WhoamiResult { - builder::WhoamiResult::default() + impl FactoryPingResult { + pub fn builder() -> builder::FactoryPingResult { + builder::FactoryPingResult::default() } } #[derive(Clone, Debug, Deserialize, Serialize)] - pub struct Worker { - pub deleted: bool, - pub id: String, - #[serde(default, skip_serializing_if = "Option::is_none")] - pub instance_id: Option, - #[serde(default, skip_serializing_if = "Option::is_none")] - pub lastping: Option>, - pub recycle: bool, - pub tasks: Vec, + pub struct FactoryWhatsNext { + pub supported_targets: Vec, } - impl From<&Worker> for Worker { - fn from(value: &Worker) -> Self { + impl From<&FactoryWhatsNext> for FactoryWhatsNext { + fn from(value: &FactoryWhatsNext) -> Self { value.clone() } } - impl Worker { - pub fn builder() -> builder::Worker { - builder::Worker::default() + impl FactoryWhatsNext { + pub fn builder() -> builder::FactoryWhatsNext { + builder::FactoryWhatsNext::default() } } #[derive(Clone, Debug, Deserialize, Serialize)] - pub struct WorkerAddOutput { - pub chunks: Vec, - pub path: String, - pub size: i64, + pub struct FactoryWorker { + pub bootstrap: String, + pub id: String, + pub online: bool, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub private: Option, + pub recycle: bool, } - impl From<&WorkerAddOutput> for WorkerAddOutput { - fn from(value: &WorkerAddOutput) -> Self { + impl From<&FactoryWorker> for FactoryWorker { + fn from(value: &FactoryWorker) -> Self { value.clone() } } - impl WorkerAddOutput { - pub fn builder() -> builder::WorkerAddOutput { - builder::WorkerAddOutput::default() + impl FactoryWorker { + pub fn builder() -> builder::FactoryWorker { + builder::FactoryWorker::default() } } #[derive(Clone, Debug, Deserialize, Serialize)] - pub struct WorkerAppendTask { + pub struct FactoryWorkerAppend { pub payload: String, pub stream: String, pub time: chrono::DateTime, } - impl From<&WorkerAppendTask> for WorkerAppendTask { - fn from(value: &WorkerAppendTask) -> Self { + impl From<&FactoryWorkerAppend> for FactoryWorkerAppend { + fn from(value: &FactoryWorkerAppend) -> Self { value.clone() } } - impl WorkerAppendTask { - pub fn builder() -> builder::WorkerAppendTask { - builder::WorkerAppendTask::default() + impl FactoryWorkerAppend { + pub fn builder() -> builder::FactoryWorkerAppend { + builder::FactoryWorkerAppend::default() } } #[derive(Clone, Debug, Deserialize, Serialize)] - pub struct WorkerBootstrap { - pub bootstrap: String, - pub token: String, + pub struct FactoryWorkerAppendResult { + pub retry: bool, } - impl From<&WorkerBootstrap> for WorkerBootstrap { - fn from(value: &WorkerBootstrap) -> Self { + impl From<&FactoryWorkerAppendResult> for FactoryWorkerAppendResult { + fn from(value: &FactoryWorkerAppendResult) -> Self { value.clone() } } - impl WorkerBootstrap { - pub fn builder() -> builder::WorkerBootstrap { - builder::WorkerBootstrap::default() + impl FactoryWorkerAppendResult { + pub fn builder() -> builder::FactoryWorkerAppendResult { + builder::FactoryWorkerAppendResult::default() } } #[derive(Clone, Debug, Deserialize, Serialize)] - pub struct WorkerBootstrapResult { - pub id: String, + pub struct FactoryWorkerAssociate { + #[serde(default, skip_serializing_if = "Option::is_none")] + pub metadata: Option, + pub private: String, } - impl From<&WorkerBootstrapResult> for WorkerBootstrapResult { - fn from(value: &WorkerBootstrapResult) -> Self { + impl From<&FactoryWorkerAssociate> for FactoryWorkerAssociate { + fn from(value: &FactoryWorkerAssociate) -> Self { value.clone() } } - impl WorkerBootstrapResult { - pub fn builder() -> builder::WorkerBootstrapResult { - builder::WorkerBootstrapResult::default() + impl FactoryWorkerAssociate { + pub fn builder() -> builder::FactoryWorkerAssociate { + builder::FactoryWorkerAssociate::default() } } #[derive(Clone, Debug, Deserialize, Serialize)] - pub struct WorkerCompleteTask { - pub failed: bool, + pub struct FactoryWorkerCreate { + #[serde(default, skip_serializing_if = "Option::is_none")] + pub job: Option, + pub target: String, + #[serde(default)] + pub wait_for_flush: bool, } - impl From<&WorkerCompleteTask> for WorkerCompleteTask { - fn from(value: &WorkerCompleteTask) -> Self { + impl From<&FactoryWorkerCreate> for FactoryWorkerCreate { + fn from(value: &FactoryWorkerCreate) -> Self { value.clone() } } - impl WorkerCompleteTask { - pub fn builder() -> builder::WorkerCompleteTask { - builder::WorkerCompleteTask::default() + impl FactoryWorkerCreate { + pub fn builder() -> builder::FactoryWorkerCreate { + builder::FactoryWorkerCreate::default() } } #[derive(Clone, Debug, Deserialize, Serialize)] - pub struct WorkerPingResult { - pub poweroff: bool, + pub struct FactoryWorkerResult { #[serde(default, skip_serializing_if = "Option::is_none")] - pub task: Option, + pub worker: Option, } - impl From<&WorkerPingResult> for WorkerPingResult { - fn from(value: &WorkerPingResult) -> Self { + impl From<&FactoryWorkerResult> for FactoryWorkerResult { + fn from(value: &FactoryWorkerResult) -> Self { value.clone() } } - impl WorkerPingResult { - pub fn builder() -> builder::WorkerPingResult { - builder::WorkerPingResult::default() + impl FactoryWorkerResult { + pub fn builder() -> builder::FactoryWorkerResult { + builder::FactoryWorkerResult::default() } } #[derive(Clone, Debug, Deserialize, Serialize)] - pub struct WorkerPingTask { + pub struct Job { + pub cancelled: bool, pub id: String, + pub name: String, pub output_rules: Vec, - pub script: String, + pub owner: String, + pub state: String, + pub tags: std::collections::HashMap, + pub target: String, + pub target_real: String, + pub tasks: Vec, + #[serde(default, skip_serializing_if = "std::collections::HashMap::is_empty")] + pub times: std::collections::HashMap>, } - impl From<&WorkerPingTask> for WorkerPingTask { - fn from(value: &WorkerPingTask) -> Self { + impl From<&Job> for Job { + fn from(value: &Job) -> Self { value.clone() } } - impl WorkerPingTask { - pub fn builder() -> builder::WorkerPingTask { - builder::WorkerPingTask::default() + impl Job { + pub fn builder() -> builder::Job { + builder::Job::default() } } #[derive(Clone, Debug, Deserialize, Serialize)] - pub struct WorkerTask { - pub id: String, + pub struct JobAddInput { + pub chunks: Vec, + pub commit_id: String, pub name: String, - pub owner: String, + pub size: u64, } - impl From<&WorkerTask> for WorkerTask { - fn from(value: &WorkerTask) -> Self { + impl From<&JobAddInput> for JobAddInput { + fn from(value: &JobAddInput) -> Self { value.clone() } } - impl WorkerTask { - pub fn builder() -> builder::WorkerTask { - builder::WorkerTask::default() + impl JobAddInput { + pub fn builder() -> builder::JobAddInput { + builder::JobAddInput::default() } } #[derive(Clone, Debug, Deserialize, Serialize)] - pub struct WorkersResult { - pub workers: Vec, + pub struct JobAddInputResult { + pub complete: bool, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub error: Option, } - impl From<&WorkersResult> for WorkersResult { - fn from(value: &WorkersResult) -> Self { + impl From<&JobAddInputResult> for JobAddInputResult { + fn from(value: &JobAddInputResult) -> Self { value.clone() } } - impl WorkersResult { - pub fn builder() -> builder::WorkersResult { - builder::WorkersResult::default() + impl JobAddInputResult { + pub fn builder() -> builder::JobAddInputResult { + builder::JobAddInputResult::default() } } - pub mod builder { - #[derive(Clone, Debug)] - pub struct Task { - id: Result, - name: Result, - output_rules: Result, String>, - script: Result, - state: Result, - } + #[derive(Clone, Debug, Deserialize, Serialize)] + pub struct JobEvent { + pub payload: String, + pub seq: u32, + pub stream: String, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub task: Option, + pub time: chrono::DateTime, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub time_remote: Option>, + } - impl Default for Task { - fn default() -> Self { - Self { - id: Err("no value supplied for id".to_string()), - name: Err("no value supplied for name".to_string()), - output_rules: Err("no value supplied for output_rules".to_string()), - script: Err("no value supplied for script".to_string()), - state: Err("no value supplied for state".to_string()), - } - } + impl From<&JobEvent> for JobEvent { + fn from(value: &JobEvent) -> Self { + value.clone() } + } - impl Task { - pub fn id(mut self, value: T) -> Self - where - T: std::convert::TryInto, - T::Error: std::fmt::Display, - { - self.id = value - .try_into() - .map_err(|e| format!("error converting supplied value for id: {}", e)); - self - } - pub fn name(mut self, value: T) -> Self - where - T: std::convert::TryInto, - T::Error: std::fmt::Display, - { - self.name = value - .try_into() - .map_err(|e| format!("error converting supplied value for name: {}", e)); - self - } - pub fn output_rules(mut self, value: T) -> Self - where - T: std::convert::TryInto>, - T::Error: std::fmt::Display, - { - self.output_rules = value.try_into().map_err(|e| { - format!("error converting supplied value for output_rules: {}", e) - }); - self - } - pub fn script(mut self, value: T) -> Self - where - T: std::convert::TryInto, - T::Error: std::fmt::Display, - { - self.script = value - .try_into() - .map_err(|e| format!("error converting supplied value for script: {}", e)); - self - } - pub fn state(mut self, value: T) -> Self - where - T: std::convert::TryInto, - T::Error: std::fmt::Display, - { - self.state = value - .try_into() - .map_err(|e| format!("error converting supplied value for state: {}", e)); - self - } + impl JobEvent { + pub fn builder() -> builder::JobEvent { + builder::JobEvent::default() } + } - impl std::convert::TryFrom for super::Task { - type Error = String; - fn try_from(value: Task) -> Result { - Ok(Self { - id: value.id?, - name: value.name?, - output_rules: value.output_rules?, - script: value.script?, - state: value.state?, - }) - } + #[derive(Clone, Debug, Deserialize, Serialize)] + pub struct JobOutput { + pub id: String, + pub path: String, + pub size: u64, + } + + impl From<&JobOutput> for JobOutput { + fn from(value: &JobOutput) -> Self { + value.clone() } + } - impl From for Task { - fn from(value: super::Task) -> Self { - Self { - id: Ok(value.id), - name: Ok(value.name), - output_rules: Ok(value.output_rules), - script: Ok(value.script), - state: Ok(value.state), - } - } + impl JobOutput { + pub fn builder() -> builder::JobOutput { + builder::JobOutput::default() } + } - #[derive(Clone, Debug)] - pub struct TaskEvent { - payload: Result, - seq: Result, - stream: Result, - time: Result, String>, - } + #[derive(Clone, Debug, Deserialize, Serialize)] + pub struct JobOutputPublish { + pub name: String, + pub series: String, + pub version: String, + } - impl Default for TaskEvent { - fn default() -> Self { - Self { - payload: Err("no value supplied for payload".to_string()), - seq: Err("no value supplied for seq".to_string()), - stream: Err("no value supplied for stream".to_string()), - time: Err("no value supplied for time".to_string()), - } - } + impl From<&JobOutputPublish> for JobOutputPublish { + fn from(value: &JobOutputPublish) -> Self { + value.clone() } + } - impl TaskEvent { - pub fn payload(mut self, value: T) -> Self - where - T: std::convert::TryInto, - T::Error: std::fmt::Display, - { - self.payload = value - .try_into() - .map_err(|e| format!("error converting supplied value for payload: {}", e)); - self - } - pub fn seq(mut self, value: T) -> Self - where - T: std::convert::TryInto, - T::Error: std::fmt::Display, - { - self.seq = value - .try_into() - .map_err(|e| format!("error converting supplied value for seq: {}", e)); - self - } - pub fn stream(mut self, value: T) -> Self - where - T: std::convert::TryInto, - T::Error: std::fmt::Display, - { - self.stream = value - .try_into() - .map_err(|e| format!("error converting supplied value for stream: {}", e)); - self - } - pub fn time(mut self, value: T) -> Self - where - T: std::convert::TryInto>, - T::Error: std::fmt::Display, - { - self.time = value - .try_into() - .map_err(|e| format!("error converting supplied value for time: {}", e)); - self - } + impl JobOutputPublish { + pub fn builder() -> builder::JobOutputPublish { + builder::JobOutputPublish::default() } + } - impl std::convert::TryFrom for super::TaskEvent { - type Error = String; - fn try_from(value: TaskEvent) -> Result { - Ok(Self { - payload: value.payload?, - seq: value.seq?, - stream: value.stream?, - time: value.time?, - }) - } - } + #[derive(Clone, Debug, Deserialize, Serialize)] + pub struct JobOutputSignedUrl { + #[serde(default, skip_serializing_if = "Option::is_none")] + pub content_disposition: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub content_type: Option, + pub expiry_seconds: u64, + } - impl From for TaskEvent { - fn from(value: super::TaskEvent) -> Self { - Self { - payload: Ok(value.payload), - seq: Ok(value.seq), - stream: Ok(value.stream), - time: Ok(value.time), - } - } + impl From<&JobOutputSignedUrl> for JobOutputSignedUrl { + fn from(value: &JobOutputSignedUrl) -> Self { + value.clone() } + } - #[derive(Clone, Debug)] - pub struct TaskOutput { - id: Result, - path: Result, - size: Result, + impl JobOutputSignedUrl { + pub fn builder() -> builder::JobOutputSignedUrl { + builder::JobOutputSignedUrl::default() } + } - impl Default for TaskOutput { - fn default() -> Self { - Self { - id: Err("no value supplied for id".to_string()), - path: Err("no value supplied for path".to_string()), - size: Err("no value supplied for size".to_string()), - } - } - } + #[derive(Clone, Debug, Deserialize, Serialize)] + pub struct JobOutputSignedUrlResult { + pub url: String, + } - impl TaskOutput { - pub fn id(mut self, value: T) -> Self - where - T: std::convert::TryInto, - T::Error: std::fmt::Display, - { - self.id = value - .try_into() - .map_err(|e| format!("error converting supplied value for id: {}", e)); - self - } - pub fn path(mut self, value: T) -> Self - where - T: std::convert::TryInto, - T::Error: std::fmt::Display, - { - self.path = value - .try_into() - .map_err(|e| format!("error converting supplied value for path: {}", e)); - self - } - pub fn size(mut self, value: T) -> Self - where - T: std::convert::TryInto, - T::Error: std::fmt::Display, - { - self.size = value - .try_into() - .map_err(|e| format!("error converting supplied value for size: {}", e)); - self - } + impl From<&JobOutputSignedUrlResult> for JobOutputSignedUrlResult { + fn from(value: &JobOutputSignedUrlResult) -> Self { + value.clone() } + } - impl std::convert::TryFrom for super::TaskOutput { - type Error = String; - fn try_from(value: TaskOutput) -> Result { - Ok(Self { - id: value.id?, - path: value.path?, - size: value.size?, - }) - } + impl JobOutputSignedUrlResult { + pub fn builder() -> builder::JobOutputSignedUrlResult { + builder::JobOutputSignedUrlResult::default() } + } - impl From for TaskOutput { - fn from(value: super::TaskOutput) -> Self { - Self { - id: Ok(value.id), - path: Ok(value.path), - size: Ok(value.size), - } - } - } + #[derive(Clone, Debug, Deserialize, Serialize)] + pub struct JobStoreValue { + pub secret: bool, + pub value: String, + } - #[derive(Clone, Debug)] - pub struct TaskSubmit { - name: Result, - output_rules: Result, String>, - script: Result, + impl From<&JobStoreValue> for JobStoreValue { + fn from(value: &JobStoreValue) -> Self { + value.clone() } + } - impl Default for TaskSubmit { - fn default() -> Self { - Self { - name: Err("no value supplied for name".to_string()), - output_rules: Ok(Default::default()), - script: Err("no value supplied for script".to_string()), - } - } + impl JobStoreValue { + pub fn builder() -> builder::JobStoreValue { + builder::JobStoreValue::default() } + } - impl TaskSubmit { - pub fn name(mut self, value: T) -> Self - where - T: std::convert::TryInto, - T::Error: std::fmt::Display, - { - self.name = value - .try_into() - .map_err(|e| format!("error converting supplied value for name: {}", e)); - self - } - pub fn output_rules(mut self, value: T) -> Self - where - T: std::convert::TryInto>, - T::Error: std::fmt::Display, - { - self.output_rules = value.try_into().map_err(|e| { - format!("error converting supplied value for output_rules: {}", e) - }); - self - } - pub fn script(mut self, value: T) -> Self - where - T: std::convert::TryInto, - T::Error: std::fmt::Display, - { - self.script = value - .try_into() - .map_err(|e| format!("error converting supplied value for script: {}", e)); - self - } - } + #[derive(Clone, Debug, Deserialize, Serialize)] + pub struct JobStoreValueInfo { + pub secret: bool, + pub source: String, + pub time_update: chrono::DateTime, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub value: Option, + } - impl std::convert::TryFrom for super::TaskSubmit { - type Error = String; - fn try_from(value: TaskSubmit) -> Result { - Ok(Self { - name: value.name?, - output_rules: value.output_rules?, - script: value.script?, - }) - } + impl From<&JobStoreValueInfo> for JobStoreValueInfo { + fn from(value: &JobStoreValueInfo) -> Self { + value.clone() } + } - impl From for TaskSubmit { - fn from(value: super::TaskSubmit) -> Self { - Self { - name: Ok(value.name), - output_rules: Ok(value.output_rules), - script: Ok(value.script), - } - } + impl JobStoreValueInfo { + pub fn builder() -> builder::JobStoreValueInfo { + builder::JobStoreValueInfo::default() } + } - #[derive(Clone, Debug)] - pub struct TaskSubmitResult { - id: Result, - } + #[derive(Clone, Debug, Deserialize, Serialize)] + pub struct JobSubmit { + #[serde(default, skip_serializing_if = "std::collections::HashMap::is_empty")] + pub depends: std::collections::HashMap, + #[serde(default, skip_serializing_if = "Vec::is_empty")] + pub inputs: Vec, + pub name: String, + pub output_rules: Vec, + #[serde(default, skip_serializing_if = "std::collections::HashMap::is_empty")] + pub tags: std::collections::HashMap, + pub target: String, + pub tasks: Vec, + } - impl Default for TaskSubmitResult { - fn default() -> Self { - Self { - id: Err("no value supplied for id".to_string()), - } - } + impl From<&JobSubmit> for JobSubmit { + fn from(value: &JobSubmit) -> Self { + value.clone() } + } - impl TaskSubmitResult { - pub fn id(mut self, value: T) -> Self - where - T: std::convert::TryInto, - T::Error: std::fmt::Display, - { - self.id = value - .try_into() - .map_err(|e| format!("error converting supplied value for id: {}", e)); - self - } + impl JobSubmit { + pub fn builder() -> builder::JobSubmit { + builder::JobSubmit::default() } + } - impl std::convert::TryFrom for super::TaskSubmitResult { - type Error = String; - fn try_from(value: TaskSubmitResult) -> Result { - Ok(Self { id: value.id? }) - } - } + #[derive(Clone, Debug, Deserialize, Serialize)] + pub struct JobSubmitResult { + pub id: String, + } - impl From for TaskSubmitResult { - fn from(value: super::TaskSubmitResult) -> Self { - Self { id: Ok(value.id) } - } + impl From<&JobSubmitResult> for JobSubmitResult { + fn from(value: &JobSubmitResult) -> Self { + value.clone() } + } - #[derive(Clone, Debug)] - pub struct UploadedChunk { - id: Result, + impl JobSubmitResult { + pub fn builder() -> builder::JobSubmitResult { + builder::JobSubmitResult::default() } + } - impl Default for UploadedChunk { - fn default() -> Self { - Self { - id: Err("no value supplied for id".to_string()), - } - } - } + #[derive(Clone, Debug, Deserialize, Serialize)] + pub struct Quota { + pub max_bytes_per_input: u64, + } - impl UploadedChunk { - pub fn id(mut self, value: T) -> Self - where - T: std::convert::TryInto, - T::Error: std::fmt::Display, - { - self.id = value - .try_into() - .map_err(|e| format!("error converting supplied value for id: {}", e)); - self - } + impl From<&Quota> for Quota { + fn from(value: &Quota) -> Self { + value.clone() } + } - impl std::convert::TryFrom for super::UploadedChunk { - type Error = String; - fn try_from(value: UploadedChunk) -> Result { - Ok(Self { id: value.id? }) - } + impl Quota { + pub fn builder() -> builder::Quota { + builder::Quota::default() } + } - impl From for UploadedChunk { - fn from(value: super::UploadedChunk) -> Self { - Self { id: Ok(value.id) } - } + #[derive(Clone, Debug, Deserialize, Serialize)] + pub struct Target { + pub desc: String, + pub id: String, + pub name: String, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub privilege: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub redirect: Option, + } + + impl From<&Target> for Target { + fn from(value: &Target) -> Self { + value.clone() } + } - #[derive(Clone, Debug)] - pub struct UserCreate { - name: Result, + impl Target { + pub fn builder() -> builder::Target { + builder::Target::default() } + } - impl Default for UserCreate { - fn default() -> Self { - Self { - name: Err("no value supplied for name".to_string()), - } - } + #[derive(Clone, Debug, Deserialize, Serialize)] + pub struct TargetCreate { + pub desc: String, + pub name: String, + } + + impl From<&TargetCreate> for TargetCreate { + fn from(value: &TargetCreate) -> Self { + value.clone() } + } - impl UserCreate { - pub fn name(mut self, value: T) -> Self - where - T: std::convert::TryInto, - T::Error: std::fmt::Display, - { - self.name = value - .try_into() - .map_err(|e| format!("error converting supplied value for name: {}", e)); - self - } + impl TargetCreate { + pub fn builder() -> builder::TargetCreate { + builder::TargetCreate::default() } + } - impl std::convert::TryFrom for super::UserCreate { - type Error = String; - fn try_from(value: UserCreate) -> Result { - Ok(Self { name: value.name? }) - } + #[derive(Clone, Debug, Deserialize, Serialize)] + pub struct TargetCreateResult { + pub id: String, + } + + impl From<&TargetCreateResult> for TargetCreateResult { + fn from(value: &TargetCreateResult) -> Self { + value.clone() } + } - impl From for UserCreate { - fn from(value: super::UserCreate) -> Self { - Self { - name: Ok(value.name), - } - } + impl TargetCreateResult { + pub fn builder() -> builder::TargetCreateResult { + builder::TargetCreateResult::default() } + } - #[derive(Clone, Debug)] - pub struct UserCreateResult { - id: Result, - name: Result, - token: Result, + #[derive(Clone, Debug, Deserialize, Serialize)] + pub struct TargetRedirect { + #[serde(default, skip_serializing_if = "Option::is_none")] + pub redirect: Option, + } + + impl From<&TargetRedirect> for TargetRedirect { + fn from(value: &TargetRedirect) -> Self { + value.clone() } + } - impl Default for UserCreateResult { - fn default() -> Self { - Self { - id: Err("no value supplied for id".to_string()), - name: Err("no value supplied for name".to_string()), - token: Err("no value supplied for token".to_string()), - } - } + impl TargetRedirect { + pub fn builder() -> builder::TargetRedirect { + builder::TargetRedirect::default() } + } - impl UserCreateResult { - pub fn id(mut self, value: T) -> Self - where - T: std::convert::TryInto, - T::Error: std::fmt::Display, - { - self.id = value - .try_into() - .map_err(|e| format!("error converting supplied value for id: {}", e)); - self - } - pub fn name(mut self, value: T) -> Self - where - T: std::convert::TryInto, - T::Error: std::fmt::Display, - { - self.name = value - .try_into() - .map_err(|e| format!("error converting supplied value for name: {}", e)); - self - } - pub fn token(mut self, value: T) -> Self - where - T: std::convert::TryInto, - T::Error: std::fmt::Display, - { - self.token = value - .try_into() - .map_err(|e| format!("error converting supplied value for token: {}", e)); - self - } + #[derive(Clone, Debug, Deserialize, Serialize)] + pub struct TargetRename { + pub new_name: String, + pub signpost_description: String, + } + + impl From<&TargetRename> for TargetRename { + fn from(value: &TargetRename) -> Self { + value.clone() } + } - impl std::convert::TryFrom for super::UserCreateResult { - type Error = String; - fn try_from(value: UserCreateResult) -> Result { - Ok(Self { - id: value.id?, - name: value.name?, - token: value.token?, - }) - } + impl TargetRename { + pub fn builder() -> builder::TargetRename { + builder::TargetRename::default() } + } - impl From for UserCreateResult { - fn from(value: super::UserCreateResult) -> Self { - Self { - id: Ok(value.id), - name: Ok(value.name), - token: Ok(value.token), - } - } + #[derive(Clone, Debug, Deserialize, Serialize)] + pub struct Task { + pub env: std::collections::HashMap, + pub env_clear: bool, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub gid: Option, + pub name: String, + pub script: String, + pub state: String, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub uid: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub workdir: Option, + } + + impl From<&Task> for Task { + fn from(value: &Task) -> Self { + value.clone() } + } - #[derive(Clone, Debug)] - pub struct WhoamiResult { - id: Result, - name: Result, + impl Task { + pub fn builder() -> builder::Task { + builder::Task::default() } + } - impl Default for WhoamiResult { - fn default() -> Self { - Self { - id: Err("no value supplied for id".to_string()), - name: Err("no value supplied for name".to_string()), - } - } + #[derive(Clone, Debug, Deserialize, Serialize)] + pub struct TaskSubmit { + pub env: std::collections::HashMap, + pub env_clear: bool, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub gid: Option, + pub name: String, + pub script: String, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub uid: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub workdir: Option, + } + + impl From<&TaskSubmit> for TaskSubmit { + fn from(value: &TaskSubmit) -> Self { + value.clone() } + } - impl WhoamiResult { - pub fn id(mut self, value: T) -> Self - where - T: std::convert::TryInto, - T::Error: std::fmt::Display, - { - self.id = value - .try_into() - .map_err(|e| format!("error converting supplied value for id: {}", e)); - self - } - pub fn name(mut self, value: T) -> Self - where - T: std::convert::TryInto, - T::Error: std::fmt::Display, - { - self.name = value - .try_into() - .map_err(|e| format!("error converting supplied value for name: {}", e)); - self - } + impl TaskSubmit { + pub fn builder() -> builder::TaskSubmit { + builder::TaskSubmit::default() } + } - impl std::convert::TryFrom for super::WhoamiResult { - type Error = String; - fn try_from(value: WhoamiResult) -> Result { - Ok(Self { - id: value.id?, - name: value.name?, - }) - } + #[derive(Clone, Debug, Deserialize, Serialize)] + pub struct UploadedChunk { + pub id: String, + } + + impl From<&UploadedChunk> for UploadedChunk { + fn from(value: &UploadedChunk) -> Self { + value.clone() } + } - impl From for WhoamiResult { - fn from(value: super::WhoamiResult) -> Self { - Self { - id: Ok(value.id), - name: Ok(value.name), - } - } + impl UploadedChunk { + pub fn builder() -> builder::UploadedChunk { + builder::UploadedChunk::default() + } + } + + #[derive(Clone, Debug, Deserialize, Serialize)] + pub struct User { + pub id: String, + pub name: String, + pub privileges: Vec, + pub time_create: chrono::DateTime, + } + + impl From<&User> for User { + fn from(value: &User) -> Self { + value.clone() + } + } + + impl User { + pub fn builder() -> builder::User { + builder::User::default() + } + } + + #[derive(Clone, Debug, Deserialize, Serialize)] + pub struct UserCreate { + pub name: String, + } + + impl From<&UserCreate> for UserCreate { + fn from(value: &UserCreate) -> Self { + value.clone() + } + } + + impl UserCreate { + pub fn builder() -> builder::UserCreate { + builder::UserCreate::default() + } + } + + #[derive(Clone, Debug, Deserialize, Serialize)] + pub struct UserCreateResult { + pub id: String, + pub name: String, + pub token: String, + } + + impl From<&UserCreateResult> for UserCreateResult { + fn from(value: &UserCreateResult) -> Self { + value.clone() + } + } + + impl UserCreateResult { + pub fn builder() -> builder::UserCreateResult { + builder::UserCreateResult::default() + } + } + + #[derive(Clone, Debug, Deserialize, Serialize)] + pub struct WhoamiResult { + pub id: String, + pub name: String, + } + + impl From<&WhoamiResult> for WhoamiResult { + fn from(value: &WhoamiResult) -> Self { + value.clone() + } + } + + impl WhoamiResult { + pub fn builder() -> builder::WhoamiResult { + builder::WhoamiResult::default() + } + } + + #[derive(Clone, Debug, Deserialize, Serialize)] + pub struct Worker { + pub bootstrap: bool, + pub deleted: bool, + pub factory: String, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub factory_private: Option, + pub id: String, + pub jobs: Vec, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub lastping: Option>, + pub recycle: bool, + pub target: String, + } + + impl From<&Worker> for Worker { + fn from(value: &Worker) -> Self { + value.clone() + } + } + + impl Worker { + pub fn builder() -> builder::Worker { + builder::Worker::default() + } + } + + #[derive(Clone, Debug, Deserialize, Serialize)] + pub struct WorkerAddOutput { + pub chunks: Vec, + pub commit_id: String, + pub path: String, + pub size: u64, + } + + impl From<&WorkerAddOutput> for WorkerAddOutput { + fn from(value: &WorkerAddOutput) -> Self { + value.clone() + } + } + + impl WorkerAddOutput { + pub fn builder() -> builder::WorkerAddOutput { + builder::WorkerAddOutput::default() + } + } + + #[derive(Clone, Debug, Deserialize, Serialize)] + pub struct WorkerAddOutputResult { + pub complete: bool, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub error: Option, + } + + impl From<&WorkerAddOutputResult> for WorkerAddOutputResult { + fn from(value: &WorkerAddOutputResult) -> Self { + value.clone() + } + } + + impl WorkerAddOutputResult { + pub fn builder() -> builder::WorkerAddOutputResult { + builder::WorkerAddOutputResult::default() + } + } + + #[derive(Clone, Debug, Deserialize, Serialize)] + pub struct WorkerAppendJob { + pub payload: String, + pub stream: String, + pub time: chrono::DateTime, + } + + impl From<&WorkerAppendJob> for WorkerAppendJob { + fn from(value: &WorkerAppendJob) -> Self { + value.clone() + } + } + + impl WorkerAppendJob { + pub fn builder() -> builder::WorkerAppendJob { + builder::WorkerAppendJob::default() + } + } + + #[derive(Clone, Debug, Deserialize, Serialize)] + pub struct WorkerAppendJobOrTask { + pub payload: String, + pub stream: String, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub task: Option, + pub time: chrono::DateTime, + } + + impl From<&WorkerAppendJobOrTask> for WorkerAppendJobOrTask { + fn from(value: &WorkerAppendJobOrTask) -> Self { + value.clone() + } + } + + impl WorkerAppendJobOrTask { + pub fn builder() -> builder::WorkerAppendJobOrTask { + builder::WorkerAppendJobOrTask::default() + } + } + + #[derive(Clone, Debug, Deserialize, Serialize)] + pub struct WorkerBootstrap { + pub bootstrap: String, + pub token: String, + } + + impl From<&WorkerBootstrap> for WorkerBootstrap { + fn from(value: &WorkerBootstrap) -> Self { + value.clone() + } + } + + impl WorkerBootstrap { + pub fn builder() -> builder::WorkerBootstrap { + builder::WorkerBootstrap::default() + } + } + + #[derive(Clone, Debug, Deserialize, Serialize)] + pub struct WorkerBootstrapResult { + pub id: String, + } + + impl From<&WorkerBootstrapResult> for WorkerBootstrapResult { + fn from(value: &WorkerBootstrapResult) -> Self { + value.clone() + } + } + + impl WorkerBootstrapResult { + pub fn builder() -> builder::WorkerBootstrapResult { + builder::WorkerBootstrapResult::default() + } + } + + #[derive(Clone, Debug, Deserialize, Serialize)] + pub struct WorkerCompleteJob { + pub failed: bool, + } + + impl From<&WorkerCompleteJob> for WorkerCompleteJob { + fn from(value: &WorkerCompleteJob) -> Self { + value.clone() + } + } + + impl WorkerCompleteJob { + pub fn builder() -> builder::WorkerCompleteJob { + builder::WorkerCompleteJob::default() + } + } + + #[derive(Clone, Debug, Deserialize, Serialize)] + pub struct WorkerCompleteTask { + pub failed: bool, + } + + impl From<&WorkerCompleteTask> for WorkerCompleteTask { + fn from(value: &WorkerCompleteTask) -> Self { + value.clone() + } + } + + impl WorkerCompleteTask { + pub fn builder() -> builder::WorkerCompleteTask { + builder::WorkerCompleteTask::default() + } + } + + #[derive(Clone, Debug, Deserialize, Serialize)] + pub struct WorkerJob { + pub id: String, + pub name: String, + pub owner: String, + pub state: String, + pub tags: std::collections::HashMap, + } + + impl From<&WorkerJob> for WorkerJob { + fn from(value: &WorkerJob) -> Self { + value.clone() + } + } + + impl WorkerJob { + pub fn builder() -> builder::WorkerJob { + builder::WorkerJob::default() + } + } + + #[derive(Clone, Debug, Deserialize, Serialize)] + pub struct WorkerJobQuota { + pub max_bytes_per_output: u64, + } + + impl From<&WorkerJobQuota> for WorkerJobQuota { + fn from(value: &WorkerJobQuota) -> Self { + value.clone() + } + } + + impl WorkerJobQuota { + pub fn builder() -> builder::WorkerJobQuota { + builder::WorkerJobQuota::default() + } + } + + #[derive(Clone, Debug, Deserialize, Serialize)] + pub struct WorkerJobStoreGet { + #[serde(default, skip_serializing_if = "Option::is_none")] + pub value: Option, + } + + impl From<&WorkerJobStoreGet> for WorkerJobStoreGet { + fn from(value: &WorkerJobStoreGet) -> Self { + value.clone() + } + } + + impl WorkerJobStoreGet { + pub fn builder() -> builder::WorkerJobStoreGet { + builder::WorkerJobStoreGet::default() + } + } + + #[derive(Clone, Debug, Deserialize, Serialize)] + pub struct WorkerJobStoreValue { + pub secret: bool, + pub value: String, + } + + impl From<&WorkerJobStoreValue> for WorkerJobStoreValue { + fn from(value: &WorkerJobStoreValue) -> Self { + value.clone() + } + } + + impl WorkerJobStoreValue { + pub fn builder() -> builder::WorkerJobStoreValue { + builder::WorkerJobStoreValue::default() + } + } + + #[derive(Clone, Debug, Deserialize, Serialize)] + pub struct WorkerPingInput { + pub id: String, + pub name: String, + } + + impl From<&WorkerPingInput> for WorkerPingInput { + fn from(value: &WorkerPingInput) -> Self { + value.clone() + } + } + + impl WorkerPingInput { + pub fn builder() -> builder::WorkerPingInput { + builder::WorkerPingInput::default() + } + } + + #[derive(Clone, Debug, Deserialize, Serialize)] + pub struct WorkerPingJob { + pub id: String, + pub inputs: Vec, + pub name: String, + pub output_rules: Vec, + pub tasks: Vec, + } + + impl From<&WorkerPingJob> for WorkerPingJob { + fn from(value: &WorkerPingJob) -> Self { + value.clone() + } + } + + impl WorkerPingJob { + pub fn builder() -> builder::WorkerPingJob { + builder::WorkerPingJob::default() + } + } + + #[derive(Clone, Debug, Deserialize, Serialize)] + pub struct WorkerPingOutputRule { + pub ignore: bool, + pub require_match: bool, + pub rule: String, + pub size_change_ok: bool, + } + + impl From<&WorkerPingOutputRule> for WorkerPingOutputRule { + fn from(value: &WorkerPingOutputRule) -> Self { + value.clone() + } + } + + impl WorkerPingOutputRule { + pub fn builder() -> builder::WorkerPingOutputRule { + builder::WorkerPingOutputRule::default() + } + } + + #[derive(Clone, Debug, Deserialize, Serialize)] + pub struct WorkerPingResult { + #[serde(default, skip_serializing_if = "Option::is_none")] + pub factory_metadata: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub job: Option, + pub poweroff: bool, + } + + impl From<&WorkerPingResult> for WorkerPingResult { + fn from(value: &WorkerPingResult) -> Self { + value.clone() + } + } + + impl WorkerPingResult { + pub fn builder() -> builder::WorkerPingResult { + builder::WorkerPingResult::default() + } + } + + #[derive(Clone, Debug, Deserialize, Serialize)] + pub struct WorkerPingTask { + pub env: std::collections::HashMap, + pub env_clear: bool, + pub gid: u32, + pub id: u32, + pub name: String, + pub script: String, + pub uid: u32, + pub workdir: String, + } + + impl From<&WorkerPingTask> for WorkerPingTask { + fn from(value: &WorkerPingTask) -> Self { + value.clone() + } + } + + impl WorkerPingTask { + pub fn builder() -> builder::WorkerPingTask { + builder::WorkerPingTask::default() + } + } + + #[derive(Clone, Debug, Deserialize, Serialize)] + pub struct WorkersResult { + pub workers: Vec, + } + + impl From<&WorkersResult> for WorkersResult { + fn from(value: &WorkersResult) -> Self { + value.clone() + } + } + + impl WorkersResult { + pub fn builder() -> builder::WorkersResult { + builder::WorkersResult::default() + } + } + + pub mod builder { + #[derive(Clone, Debug)] + pub struct DependSubmit { + copy_outputs: Result, + on_completed: Result, + on_failed: Result, + prior_job: Result, + } + + impl Default for DependSubmit { + fn default() -> Self { + Self { + copy_outputs: Err("no value supplied for copy_outputs".to_string()), + on_completed: Err("no value supplied for on_completed".to_string()), + on_failed: Err("no value supplied for on_failed".to_string()), + prior_job: Err("no value supplied for prior_job".to_string()), + } + } + } + + impl DependSubmit { + pub fn copy_outputs(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.copy_outputs = value.try_into().map_err(|e| { + format!("error converting supplied value for copy_outputs: {}", e) + }); + self + } + pub fn on_completed(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.on_completed = value.try_into().map_err(|e| { + format!("error converting supplied value for on_completed: {}", e) + }); + self + } + pub fn on_failed(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.on_failed = value + .try_into() + .map_err(|e| format!("error converting supplied value for on_failed: {}", e)); + self + } + pub fn prior_job(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.prior_job = value + .try_into() + .map_err(|e| format!("error converting supplied value for prior_job: {}", e)); + self + } + } + + impl std::convert::TryFrom for super::DependSubmit { + type Error = String; + fn try_from(value: DependSubmit) -> Result { + Ok(Self { + copy_outputs: value.copy_outputs?, + on_completed: value.on_completed?, + on_failed: value.on_failed?, + prior_job: value.prior_job?, + }) + } + } + + impl From for DependSubmit { + fn from(value: super::DependSubmit) -> Self { + Self { + copy_outputs: Ok(value.copy_outputs), + on_completed: Ok(value.on_completed), + on_failed: Ok(value.on_failed), + prior_job: Ok(value.prior_job), + } + } + } + + #[derive(Clone, Debug)] + pub struct Error { + error_code: Result, String>, + message: Result, + request_id: Result, + } + + impl Default for Error { + fn default() -> Self { + Self { + error_code: Ok(Default::default()), + message: Err("no value supplied for message".to_string()), + request_id: Err("no value supplied for request_id".to_string()), + } + } + } + + impl Error { + pub fn error_code(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.error_code = value + .try_into() + .map_err(|e| format!("error converting supplied value for error_code: {}", e)); + self + } + pub fn message(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.message = value + .try_into() + .map_err(|e| format!("error converting supplied value for message: {}", e)); + self + } + pub fn request_id(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.request_id = value + .try_into() + .map_err(|e| format!("error converting supplied value for request_id: {}", e)); + self + } + } + + impl std::convert::TryFrom for super::Error { + type Error = String; + fn try_from(value: Error) -> Result { + Ok(Self { + error_code: value.error_code?, + message: value.message?, + request_id: value.request_id?, + }) + } + } + + impl From for Error { + fn from(value: super::Error) -> Self { + Self { + error_code: Ok(value.error_code), + message: Ok(value.message), + request_id: Ok(value.request_id), + } + } + } + + #[derive(Clone, Debug)] + pub struct FactoryAddresses { + cidr: Result, + count: Result, + first: Result, + gateway: Result, String>, + name: Result, + routed: Result, + } + + impl Default for FactoryAddresses { + fn default() -> Self { + Self { + cidr: Err("no value supplied for cidr".to_string()), + count: Err("no value supplied for count".to_string()), + first: Err("no value supplied for first".to_string()), + gateway: Ok(Default::default()), + name: Err("no value supplied for name".to_string()), + routed: Err("no value supplied for routed".to_string()), + } + } + } + + impl FactoryAddresses { + pub fn cidr(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.cidr = value + .try_into() + .map_err(|e| format!("error converting supplied value for cidr: {}", e)); + self + } + pub fn count(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.count = value + .try_into() + .map_err(|e| format!("error converting supplied value for count: {}", e)); + self + } + pub fn first(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.first = value + .try_into() + .map_err(|e| format!("error converting supplied value for first: {}", e)); + self + } + pub fn gateway(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.gateway = value + .try_into() + .map_err(|e| format!("error converting supplied value for gateway: {}", e)); + self + } + pub fn name(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.name = value + .try_into() + .map_err(|e| format!("error converting supplied value for name: {}", e)); + self + } + pub fn routed(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.routed = value + .try_into() + .map_err(|e| format!("error converting supplied value for routed: {}", e)); + self + } + } + + impl std::convert::TryFrom for super::FactoryAddresses { + type Error = String; + fn try_from(value: FactoryAddresses) -> Result { + Ok(Self { + cidr: value.cidr?, + count: value.count?, + first: value.first?, + gateway: value.gateway?, + name: value.name?, + routed: value.routed?, + }) + } + } + + impl From for FactoryAddresses { + fn from(value: super::FactoryAddresses) -> Self { + Self { + cidr: Ok(value.cidr), + count: Ok(value.count), + first: Ok(value.first), + gateway: Ok(value.gateway), + name: Ok(value.name), + routed: Ok(value.routed), + } + } + } + + #[derive(Clone, Debug)] + pub struct FactoryCreate { + name: Result, + } + + impl Default for FactoryCreate { + fn default() -> Self { + Self { + name: Err("no value supplied for name".to_string()), + } + } + } + + impl FactoryCreate { + pub fn name(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.name = value + .try_into() + .map_err(|e| format!("error converting supplied value for name: {}", e)); + self + } + } + + impl std::convert::TryFrom for super::FactoryCreate { + type Error = String; + fn try_from(value: FactoryCreate) -> Result { + Ok(Self { name: value.name? }) + } + } + + impl From for FactoryCreate { + fn from(value: super::FactoryCreate) -> Self { + Self { + name: Ok(value.name), + } + } + } + + #[derive(Clone, Debug)] + pub struct FactoryCreateResult { + id: Result, + name: Result, + token: Result, + } + + impl Default for FactoryCreateResult { + fn default() -> Self { + Self { + id: Err("no value supplied for id".to_string()), + name: Err("no value supplied for name".to_string()), + token: Err("no value supplied for token".to_string()), + } + } + } + + impl FactoryCreateResult { + pub fn id(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.id = value + .try_into() + .map_err(|e| format!("error converting supplied value for id: {}", e)); + self + } + pub fn name(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.name = value + .try_into() + .map_err(|e| format!("error converting supplied value for name: {}", e)); + self + } + pub fn token(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.token = value + .try_into() + .map_err(|e| format!("error converting supplied value for token: {}", e)); + self + } + } + + impl std::convert::TryFrom for super::FactoryCreateResult { + type Error = String; + fn try_from(value: FactoryCreateResult) -> Result { + Ok(Self { + id: value.id?, + name: value.name?, + token: value.token?, + }) + } + } + + impl From for FactoryCreateResult { + fn from(value: super::FactoryCreateResult) -> Self { + Self { + id: Ok(value.id), + name: Ok(value.name), + token: Ok(value.token), + } + } + } + + #[derive(Clone, Debug)] + pub struct FactoryLease { + job: Result, + target: Result, + } + + impl Default for FactoryLease { + fn default() -> Self { + Self { + job: Err("no value supplied for job".to_string()), + target: Err("no value supplied for target".to_string()), + } + } + } + + impl FactoryLease { + pub fn job(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.job = value + .try_into() + .map_err(|e| format!("error converting supplied value for job: {}", e)); + self + } + pub fn target(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.target = value + .try_into() + .map_err(|e| format!("error converting supplied value for target: {}", e)); + self + } + } + + impl std::convert::TryFrom for super::FactoryLease { + type Error = String; + fn try_from(value: FactoryLease) -> Result { + Ok(Self { + job: value.job?, + target: value.target?, + }) + } + } + + impl From for FactoryLease { + fn from(value: super::FactoryLease) -> Self { + Self { + job: Ok(value.job), + target: Ok(value.target), + } + } + } + + #[derive(Clone, Debug)] + pub struct FactoryLeaseResult { + lease: Result, String>, + } + + impl Default for FactoryLeaseResult { + fn default() -> Self { + Self { + lease: Ok(Default::default()), + } + } + } + + impl FactoryLeaseResult { + pub fn lease(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.lease = value + .try_into() + .map_err(|e| format!("error converting supplied value for lease: {}", e)); + self + } + } + + impl std::convert::TryFrom for super::FactoryLeaseResult { + type Error = String; + fn try_from(value: FactoryLeaseResult) -> Result { + Ok(Self { + lease: value.lease?, + }) + } + } + + impl From for FactoryLeaseResult { + fn from(value: super::FactoryLeaseResult) -> Self { + Self { + lease: Ok(value.lease), + } + } + } + + #[derive(Clone, Debug)] + pub struct FactoryPingResult { + ok: Result, + } + + impl Default for FactoryPingResult { + fn default() -> Self { + Self { + ok: Err("no value supplied for ok".to_string()), + } + } + } + + impl FactoryPingResult { + pub fn ok(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.ok = value + .try_into() + .map_err(|e| format!("error converting supplied value for ok: {}", e)); + self + } + } + + impl std::convert::TryFrom for super::FactoryPingResult { + type Error = String; + fn try_from(value: FactoryPingResult) -> Result { + Ok(Self { ok: value.ok? }) + } + } + + impl From for FactoryPingResult { + fn from(value: super::FactoryPingResult) -> Self { + Self { ok: Ok(value.ok) } + } + } + + #[derive(Clone, Debug)] + pub struct FactoryWhatsNext { + supported_targets: Result, String>, + } + + impl Default for FactoryWhatsNext { + fn default() -> Self { + Self { + supported_targets: Err("no value supplied for supported_targets".to_string()), + } + } + } + + impl FactoryWhatsNext { + pub fn supported_targets(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.supported_targets = value.try_into().map_err(|e| { + format!( + "error converting supplied value for supported_targets: {}", + e + ) + }); + self + } + } + + impl std::convert::TryFrom for super::FactoryWhatsNext { + type Error = String; + fn try_from(value: FactoryWhatsNext) -> Result { + Ok(Self { + supported_targets: value.supported_targets?, + }) + } + } + + impl From for FactoryWhatsNext { + fn from(value: super::FactoryWhatsNext) -> Self { + Self { + supported_targets: Ok(value.supported_targets), + } + } + } + + #[derive(Clone, Debug)] + pub struct FactoryWorker { + bootstrap: Result, + id: Result, + online: Result, + private: Result, String>, + recycle: Result, + } + + impl Default for FactoryWorker { + fn default() -> Self { + Self { + bootstrap: Err("no value supplied for bootstrap".to_string()), + id: Err("no value supplied for id".to_string()), + online: Err("no value supplied for online".to_string()), + private: Ok(Default::default()), + recycle: Err("no value supplied for recycle".to_string()), + } + } + } + + impl FactoryWorker { + pub fn bootstrap(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.bootstrap = value + .try_into() + .map_err(|e| format!("error converting supplied value for bootstrap: {}", e)); + self + } + pub fn id(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.id = value + .try_into() + .map_err(|e| format!("error converting supplied value for id: {}", e)); + self + } + pub fn online(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.online = value + .try_into() + .map_err(|e| format!("error converting supplied value for online: {}", e)); + self + } + pub fn private(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.private = value + .try_into() + .map_err(|e| format!("error converting supplied value for private: {}", e)); + self + } + pub fn recycle(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.recycle = value + .try_into() + .map_err(|e| format!("error converting supplied value for recycle: {}", e)); + self + } + } + + impl std::convert::TryFrom for super::FactoryWorker { + type Error = String; + fn try_from(value: FactoryWorker) -> Result { + Ok(Self { + bootstrap: value.bootstrap?, + id: value.id?, + online: value.online?, + private: value.private?, + recycle: value.recycle?, + }) + } + } + + impl From for FactoryWorker { + fn from(value: super::FactoryWorker) -> Self { + Self { + bootstrap: Ok(value.bootstrap), + id: Ok(value.id), + online: Ok(value.online), + private: Ok(value.private), + recycle: Ok(value.recycle), + } + } + } + + #[derive(Clone, Debug)] + pub struct FactoryWorkerAppend { + payload: Result, + stream: Result, + time: Result, String>, + } + + impl Default for FactoryWorkerAppend { + fn default() -> Self { + Self { + payload: Err("no value supplied for payload".to_string()), + stream: Err("no value supplied for stream".to_string()), + time: Err("no value supplied for time".to_string()), + } + } + } + + impl FactoryWorkerAppend { + pub fn payload(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.payload = value + .try_into() + .map_err(|e| format!("error converting supplied value for payload: {}", e)); + self + } + pub fn stream(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.stream = value + .try_into() + .map_err(|e| format!("error converting supplied value for stream: {}", e)); + self + } + pub fn time(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.time = value + .try_into() + .map_err(|e| format!("error converting supplied value for time: {}", e)); + self + } + } + + impl std::convert::TryFrom for super::FactoryWorkerAppend { + type Error = String; + fn try_from(value: FactoryWorkerAppend) -> Result { + Ok(Self { + payload: value.payload?, + stream: value.stream?, + time: value.time?, + }) + } + } + + impl From for FactoryWorkerAppend { + fn from(value: super::FactoryWorkerAppend) -> Self { + Self { + payload: Ok(value.payload), + stream: Ok(value.stream), + time: Ok(value.time), + } + } + } + + #[derive(Clone, Debug)] + pub struct FactoryWorkerAppendResult { + retry: Result, + } + + impl Default for FactoryWorkerAppendResult { + fn default() -> Self { + Self { + retry: Err("no value supplied for retry".to_string()), + } + } + } + + impl FactoryWorkerAppendResult { + pub fn retry(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.retry = value + .try_into() + .map_err(|e| format!("error converting supplied value for retry: {}", e)); + self + } + } + + impl std::convert::TryFrom for super::FactoryWorkerAppendResult { + type Error = String; + fn try_from(value: FactoryWorkerAppendResult) -> Result { + Ok(Self { + retry: value.retry?, + }) + } + } + + impl From for FactoryWorkerAppendResult { + fn from(value: super::FactoryWorkerAppendResult) -> Self { + Self { + retry: Ok(value.retry), + } + } + } + + #[derive(Clone, Debug)] + pub struct FactoryWorkerAssociate { + metadata: Result, String>, + private: Result, + } + + impl Default for FactoryWorkerAssociate { + fn default() -> Self { + Self { + metadata: Ok(Default::default()), + private: Err("no value supplied for private".to_string()), + } + } + } + + impl FactoryWorkerAssociate { + pub fn metadata(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.metadata = value + .try_into() + .map_err(|e| format!("error converting supplied value for metadata: {}", e)); + self + } + pub fn private(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.private = value + .try_into() + .map_err(|e| format!("error converting supplied value for private: {}", e)); + self + } + } + + impl std::convert::TryFrom for super::FactoryWorkerAssociate { + type Error = String; + fn try_from(value: FactoryWorkerAssociate) -> Result { + Ok(Self { + metadata: value.metadata?, + private: value.private?, + }) + } + } + + impl From for FactoryWorkerAssociate { + fn from(value: super::FactoryWorkerAssociate) -> Self { + Self { + metadata: Ok(value.metadata), + private: Ok(value.private), + } + } + } + + #[derive(Clone, Debug)] + pub struct FactoryWorkerCreate { + job: Result, String>, + target: Result, + wait_for_flush: Result, + } + + impl Default for FactoryWorkerCreate { + fn default() -> Self { + Self { + job: Ok(Default::default()), + target: Err("no value supplied for target".to_string()), + wait_for_flush: Ok(Default::default()), + } + } + } + + impl FactoryWorkerCreate { + pub fn job(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.job = value + .try_into() + .map_err(|e| format!("error converting supplied value for job: {}", e)); + self + } + pub fn target(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.target = value + .try_into() + .map_err(|e| format!("error converting supplied value for target: {}", e)); + self + } + pub fn wait_for_flush(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.wait_for_flush = value.try_into().map_err(|e| { + format!("error converting supplied value for wait_for_flush: {}", e) + }); + self + } + } + + impl std::convert::TryFrom for super::FactoryWorkerCreate { + type Error = String; + fn try_from(value: FactoryWorkerCreate) -> Result { + Ok(Self { + job: value.job?, + target: value.target?, + wait_for_flush: value.wait_for_flush?, + }) + } + } + + impl From for FactoryWorkerCreate { + fn from(value: super::FactoryWorkerCreate) -> Self { + Self { + job: Ok(value.job), + target: Ok(value.target), + wait_for_flush: Ok(value.wait_for_flush), + } + } + } + + #[derive(Clone, Debug)] + pub struct FactoryWorkerResult { + worker: Result, String>, + } + + impl Default for FactoryWorkerResult { + fn default() -> Self { + Self { + worker: Ok(Default::default()), + } + } + } + + impl FactoryWorkerResult { + pub fn worker(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.worker = value + .try_into() + .map_err(|e| format!("error converting supplied value for worker: {}", e)); + self + } + } + + impl std::convert::TryFrom for super::FactoryWorkerResult { + type Error = String; + fn try_from(value: FactoryWorkerResult) -> Result { + Ok(Self { + worker: value.worker?, + }) + } + } + + impl From for FactoryWorkerResult { + fn from(value: super::FactoryWorkerResult) -> Self { + Self { + worker: Ok(value.worker), + } + } + } + + #[derive(Clone, Debug)] + pub struct Job { + cancelled: Result, + id: Result, + name: Result, + output_rules: Result, String>, + owner: Result, + state: Result, + tags: Result, String>, + target: Result, + target_real: Result, + tasks: Result, String>, + times: Result< + std::collections::HashMap>, + String, + >, + } + + impl Default for Job { + fn default() -> Self { + Self { + cancelled: Err("no value supplied for cancelled".to_string()), + id: Err("no value supplied for id".to_string()), + name: Err("no value supplied for name".to_string()), + output_rules: Err("no value supplied for output_rules".to_string()), + owner: Err("no value supplied for owner".to_string()), + state: Err("no value supplied for state".to_string()), + tags: Err("no value supplied for tags".to_string()), + target: Err("no value supplied for target".to_string()), + target_real: Err("no value supplied for target_real".to_string()), + tasks: Err("no value supplied for tasks".to_string()), + times: Ok(Default::default()), + } + } + } + + impl Job { + pub fn cancelled(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.cancelled = value + .try_into() + .map_err(|e| format!("error converting supplied value for cancelled: {}", e)); + self + } + pub fn id(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.id = value + .try_into() + .map_err(|e| format!("error converting supplied value for id: {}", e)); + self + } + pub fn name(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.name = value + .try_into() + .map_err(|e| format!("error converting supplied value for name: {}", e)); + self + } + pub fn output_rules(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.output_rules = value.try_into().map_err(|e| { + format!("error converting supplied value for output_rules: {}", e) + }); + self + } + pub fn owner(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.owner = value + .try_into() + .map_err(|e| format!("error converting supplied value for owner: {}", e)); + self + } + pub fn state(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.state = value + .try_into() + .map_err(|e| format!("error converting supplied value for state: {}", e)); + self + } + pub fn tags(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.tags = value + .try_into() + .map_err(|e| format!("error converting supplied value for tags: {}", e)); + self + } + pub fn target(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.target = value + .try_into() + .map_err(|e| format!("error converting supplied value for target: {}", e)); + self + } + pub fn target_real(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.target_real = value + .try_into() + .map_err(|e| format!("error converting supplied value for target_real: {}", e)); + self + } + pub fn tasks(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.tasks = value + .try_into() + .map_err(|e| format!("error converting supplied value for tasks: {}", e)); + self + } + pub fn times(mut self, value: T) -> Self + where + T: std::convert::TryInto< + std::collections::HashMap>, + >, + T::Error: std::fmt::Display, + { + self.times = value + .try_into() + .map_err(|e| format!("error converting supplied value for times: {}", e)); + self + } + } + + impl std::convert::TryFrom for super::Job { + type Error = String; + fn try_from(value: Job) -> Result { + Ok(Self { + cancelled: value.cancelled?, + id: value.id?, + name: value.name?, + output_rules: value.output_rules?, + owner: value.owner?, + state: value.state?, + tags: value.tags?, + target: value.target?, + target_real: value.target_real?, + tasks: value.tasks?, + times: value.times?, + }) + } + } + + impl From for Job { + fn from(value: super::Job) -> Self { + Self { + cancelled: Ok(value.cancelled), + id: Ok(value.id), + name: Ok(value.name), + output_rules: Ok(value.output_rules), + owner: Ok(value.owner), + state: Ok(value.state), + tags: Ok(value.tags), + target: Ok(value.target), + target_real: Ok(value.target_real), + tasks: Ok(value.tasks), + times: Ok(value.times), + } + } + } + + #[derive(Clone, Debug)] + pub struct JobAddInput { + chunks: Result, String>, + commit_id: Result, + name: Result, + size: Result, + } + + impl Default for JobAddInput { + fn default() -> Self { + Self { + chunks: Err("no value supplied for chunks".to_string()), + commit_id: Err("no value supplied for commit_id".to_string()), + name: Err("no value supplied for name".to_string()), + size: Err("no value supplied for size".to_string()), + } + } + } + + impl JobAddInput { + pub fn chunks(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.chunks = value + .try_into() + .map_err(|e| format!("error converting supplied value for chunks: {}", e)); + self + } + pub fn commit_id(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.commit_id = value + .try_into() + .map_err(|e| format!("error converting supplied value for commit_id: {}", e)); + self + } + pub fn name(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.name = value + .try_into() + .map_err(|e| format!("error converting supplied value for name: {}", e)); + self + } + pub fn size(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.size = value + .try_into() + .map_err(|e| format!("error converting supplied value for size: {}", e)); + self + } + } + + impl std::convert::TryFrom for super::JobAddInput { + type Error = String; + fn try_from(value: JobAddInput) -> Result { + Ok(Self { + chunks: value.chunks?, + commit_id: value.commit_id?, + name: value.name?, + size: value.size?, + }) + } + } + + impl From for JobAddInput { + fn from(value: super::JobAddInput) -> Self { + Self { + chunks: Ok(value.chunks), + commit_id: Ok(value.commit_id), + name: Ok(value.name), + size: Ok(value.size), + } + } + } + + #[derive(Clone, Debug)] + pub struct JobAddInputResult { + complete: Result, + error: Result, String>, + } + + impl Default for JobAddInputResult { + fn default() -> Self { + Self { + complete: Err("no value supplied for complete".to_string()), + error: Ok(Default::default()), + } + } + } + + impl JobAddInputResult { + pub fn complete(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.complete = value + .try_into() + .map_err(|e| format!("error converting supplied value for complete: {}", e)); + self + } + pub fn error(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.error = value + .try_into() + .map_err(|e| format!("error converting supplied value for error: {}", e)); + self + } + } + + impl std::convert::TryFrom for super::JobAddInputResult { + type Error = String; + fn try_from(value: JobAddInputResult) -> Result { + Ok(Self { + complete: value.complete?, + error: value.error?, + }) + } + } + + impl From for JobAddInputResult { + fn from(value: super::JobAddInputResult) -> Self { + Self { + complete: Ok(value.complete), + error: Ok(value.error), + } + } + } + + #[derive(Clone, Debug)] + pub struct JobEvent { + payload: Result, + seq: Result, + stream: Result, + task: Result, String>, + time: Result, String>, + time_remote: Result>, String>, + } + + impl Default for JobEvent { + fn default() -> Self { + Self { + payload: Err("no value supplied for payload".to_string()), + seq: Err("no value supplied for seq".to_string()), + stream: Err("no value supplied for stream".to_string()), + task: Ok(Default::default()), + time: Err("no value supplied for time".to_string()), + time_remote: Ok(Default::default()), + } + } + } + + impl JobEvent { + pub fn payload(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.payload = value + .try_into() + .map_err(|e| format!("error converting supplied value for payload: {}", e)); + self + } + pub fn seq(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.seq = value + .try_into() + .map_err(|e| format!("error converting supplied value for seq: {}", e)); + self + } + pub fn stream(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.stream = value + .try_into() + .map_err(|e| format!("error converting supplied value for stream: {}", e)); + self + } + pub fn task(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.task = value + .try_into() + .map_err(|e| format!("error converting supplied value for task: {}", e)); + self + } + pub fn time(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.time = value + .try_into() + .map_err(|e| format!("error converting supplied value for time: {}", e)); + self + } + pub fn time_remote(mut self, value: T) -> Self + where + T: std::convert::TryInto>>, + T::Error: std::fmt::Display, + { + self.time_remote = value + .try_into() + .map_err(|e| format!("error converting supplied value for time_remote: {}", e)); + self + } + } + + impl std::convert::TryFrom for super::JobEvent { + type Error = String; + fn try_from(value: JobEvent) -> Result { + Ok(Self { + payload: value.payload?, + seq: value.seq?, + stream: value.stream?, + task: value.task?, + time: value.time?, + time_remote: value.time_remote?, + }) + } + } + + impl From for JobEvent { + fn from(value: super::JobEvent) -> Self { + Self { + payload: Ok(value.payload), + seq: Ok(value.seq), + stream: Ok(value.stream), + task: Ok(value.task), + time: Ok(value.time), + time_remote: Ok(value.time_remote), + } + } + } + + #[derive(Clone, Debug)] + pub struct JobOutput { + id: Result, + path: Result, + size: Result, + } + + impl Default for JobOutput { + fn default() -> Self { + Self { + id: Err("no value supplied for id".to_string()), + path: Err("no value supplied for path".to_string()), + size: Err("no value supplied for size".to_string()), + } + } + } + + impl JobOutput { + pub fn id(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.id = value + .try_into() + .map_err(|e| format!("error converting supplied value for id: {}", e)); + self + } + pub fn path(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.path = value + .try_into() + .map_err(|e| format!("error converting supplied value for path: {}", e)); + self + } + pub fn size(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.size = value + .try_into() + .map_err(|e| format!("error converting supplied value for size: {}", e)); + self + } + } + + impl std::convert::TryFrom for super::JobOutput { + type Error = String; + fn try_from(value: JobOutput) -> Result { + Ok(Self { + id: value.id?, + path: value.path?, + size: value.size?, + }) + } + } + + impl From for JobOutput { + fn from(value: super::JobOutput) -> Self { + Self { + id: Ok(value.id), + path: Ok(value.path), + size: Ok(value.size), + } + } + } + + #[derive(Clone, Debug)] + pub struct JobOutputPublish { + name: Result, + series: Result, + version: Result, + } + + impl Default for JobOutputPublish { + fn default() -> Self { + Self { + name: Err("no value supplied for name".to_string()), + series: Err("no value supplied for series".to_string()), + version: Err("no value supplied for version".to_string()), + } + } + } + + impl JobOutputPublish { + pub fn name(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.name = value + .try_into() + .map_err(|e| format!("error converting supplied value for name: {}", e)); + self + } + pub fn series(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.series = value + .try_into() + .map_err(|e| format!("error converting supplied value for series: {}", e)); + self + } + pub fn version(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.version = value + .try_into() + .map_err(|e| format!("error converting supplied value for version: {}", e)); + self + } + } + + impl std::convert::TryFrom for super::JobOutputPublish { + type Error = String; + fn try_from(value: JobOutputPublish) -> Result { + Ok(Self { + name: value.name?, + series: value.series?, + version: value.version?, + }) + } + } + + impl From for JobOutputPublish { + fn from(value: super::JobOutputPublish) -> Self { + Self { + name: Ok(value.name), + series: Ok(value.series), + version: Ok(value.version), + } + } + } + + #[derive(Clone, Debug)] + pub struct JobOutputSignedUrl { + content_disposition: Result, String>, + content_type: Result, String>, + expiry_seconds: Result, + } + + impl Default for JobOutputSignedUrl { + fn default() -> Self { + Self { + content_disposition: Ok(Default::default()), + content_type: Ok(Default::default()), + expiry_seconds: Err("no value supplied for expiry_seconds".to_string()), + } + } + } + + impl JobOutputSignedUrl { + pub fn content_disposition(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.content_disposition = value.try_into().map_err(|e| { + format!( + "error converting supplied value for content_disposition: {}", + e + ) + }); + self + } + pub fn content_type(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.content_type = value.try_into().map_err(|e| { + format!("error converting supplied value for content_type: {}", e) + }); + self + } + pub fn expiry_seconds(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.expiry_seconds = value.try_into().map_err(|e| { + format!("error converting supplied value for expiry_seconds: {}", e) + }); + self + } + } + + impl std::convert::TryFrom for super::JobOutputSignedUrl { + type Error = String; + fn try_from(value: JobOutputSignedUrl) -> Result { + Ok(Self { + content_disposition: value.content_disposition?, + content_type: value.content_type?, + expiry_seconds: value.expiry_seconds?, + }) + } + } + + impl From for JobOutputSignedUrl { + fn from(value: super::JobOutputSignedUrl) -> Self { + Self { + content_disposition: Ok(value.content_disposition), + content_type: Ok(value.content_type), + expiry_seconds: Ok(value.expiry_seconds), + } + } + } + + #[derive(Clone, Debug)] + pub struct JobOutputSignedUrlResult { + url: Result, + } + + impl Default for JobOutputSignedUrlResult { + fn default() -> Self { + Self { + url: Err("no value supplied for url".to_string()), + } + } + } + + impl JobOutputSignedUrlResult { + pub fn url(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.url = value + .try_into() + .map_err(|e| format!("error converting supplied value for url: {}", e)); + self + } + } + + impl std::convert::TryFrom for super::JobOutputSignedUrlResult { + type Error = String; + fn try_from(value: JobOutputSignedUrlResult) -> Result { + Ok(Self { url: value.url? }) + } + } + + impl From for JobOutputSignedUrlResult { + fn from(value: super::JobOutputSignedUrlResult) -> Self { + Self { url: Ok(value.url) } + } + } + + #[derive(Clone, Debug)] + pub struct JobStoreValue { + secret: Result, + value: Result, + } + + impl Default for JobStoreValue { + fn default() -> Self { + Self { + secret: Err("no value supplied for secret".to_string()), + value: Err("no value supplied for value".to_string()), + } + } + } + + impl JobStoreValue { + pub fn secret(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.secret = value + .try_into() + .map_err(|e| format!("error converting supplied value for secret: {}", e)); + self + } + pub fn value(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.value = value + .try_into() + .map_err(|e| format!("error converting supplied value for value: {}", e)); + self + } + } + + impl std::convert::TryFrom for super::JobStoreValue { + type Error = String; + fn try_from(value: JobStoreValue) -> Result { + Ok(Self { + secret: value.secret?, + value: value.value?, + }) + } + } + + impl From for JobStoreValue { + fn from(value: super::JobStoreValue) -> Self { + Self { + secret: Ok(value.secret), + value: Ok(value.value), + } + } + } + + #[derive(Clone, Debug)] + pub struct JobStoreValueInfo { + secret: Result, + source: Result, + time_update: Result, String>, + value: Result, String>, + } + + impl Default for JobStoreValueInfo { + fn default() -> Self { + Self { + secret: Err("no value supplied for secret".to_string()), + source: Err("no value supplied for source".to_string()), + time_update: Err("no value supplied for time_update".to_string()), + value: Ok(Default::default()), + } + } + } + + impl JobStoreValueInfo { + pub fn secret(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.secret = value + .try_into() + .map_err(|e| format!("error converting supplied value for secret: {}", e)); + self + } + pub fn source(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.source = value + .try_into() + .map_err(|e| format!("error converting supplied value for source: {}", e)); + self + } + pub fn time_update(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.time_update = value + .try_into() + .map_err(|e| format!("error converting supplied value for time_update: {}", e)); + self + } + pub fn value(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.value = value + .try_into() + .map_err(|e| format!("error converting supplied value for value: {}", e)); + self + } + } + + impl std::convert::TryFrom for super::JobStoreValueInfo { + type Error = String; + fn try_from(value: JobStoreValueInfo) -> Result { + Ok(Self { + secret: value.secret?, + source: value.source?, + time_update: value.time_update?, + value: value.value?, + }) + } + } + + impl From for JobStoreValueInfo { + fn from(value: super::JobStoreValueInfo) -> Self { + Self { + secret: Ok(value.secret), + source: Ok(value.source), + time_update: Ok(value.time_update), + value: Ok(value.value), + } + } + } + + #[derive(Clone, Debug)] + pub struct JobSubmit { + depends: Result, String>, + inputs: Result, String>, + name: Result, + output_rules: Result, String>, + tags: Result, String>, + target: Result, + tasks: Result, String>, + } + + impl Default for JobSubmit { + fn default() -> Self { + Self { + depends: Ok(Default::default()), + inputs: Ok(Default::default()), + name: Err("no value supplied for name".to_string()), + output_rules: Err("no value supplied for output_rules".to_string()), + tags: Ok(Default::default()), + target: Err("no value supplied for target".to_string()), + tasks: Err("no value supplied for tasks".to_string()), + } + } + } + + impl JobSubmit { + pub fn depends(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.depends = value + .try_into() + .map_err(|e| format!("error converting supplied value for depends: {}", e)); + self + } + pub fn inputs(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.inputs = value + .try_into() + .map_err(|e| format!("error converting supplied value for inputs: {}", e)); + self + } + pub fn name(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.name = value + .try_into() + .map_err(|e| format!("error converting supplied value for name: {}", e)); + self + } + pub fn output_rules(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.output_rules = value.try_into().map_err(|e| { + format!("error converting supplied value for output_rules: {}", e) + }); + self + } + pub fn tags(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.tags = value + .try_into() + .map_err(|e| format!("error converting supplied value for tags: {}", e)); + self + } + pub fn target(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.target = value + .try_into() + .map_err(|e| format!("error converting supplied value for target: {}", e)); + self + } + pub fn tasks(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.tasks = value + .try_into() + .map_err(|e| format!("error converting supplied value for tasks: {}", e)); + self + } + } + + impl std::convert::TryFrom for super::JobSubmit { + type Error = String; + fn try_from(value: JobSubmit) -> Result { + Ok(Self { + depends: value.depends?, + inputs: value.inputs?, + name: value.name?, + output_rules: value.output_rules?, + tags: value.tags?, + target: value.target?, + tasks: value.tasks?, + }) + } + } + + impl From for JobSubmit { + fn from(value: super::JobSubmit) -> Self { + Self { + depends: Ok(value.depends), + inputs: Ok(value.inputs), + name: Ok(value.name), + output_rules: Ok(value.output_rules), + tags: Ok(value.tags), + target: Ok(value.target), + tasks: Ok(value.tasks), + } + } + } + + #[derive(Clone, Debug)] + pub struct JobSubmitResult { + id: Result, + } + + impl Default for JobSubmitResult { + fn default() -> Self { + Self { + id: Err("no value supplied for id".to_string()), + } + } + } + + impl JobSubmitResult { + pub fn id(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.id = value + .try_into() + .map_err(|e| format!("error converting supplied value for id: {}", e)); + self + } + } + + impl std::convert::TryFrom for super::JobSubmitResult { + type Error = String; + fn try_from(value: JobSubmitResult) -> Result { + Ok(Self { id: value.id? }) + } + } + + impl From for JobSubmitResult { + fn from(value: super::JobSubmitResult) -> Self { + Self { id: Ok(value.id) } + } + } + + #[derive(Clone, Debug)] + pub struct Quota { + max_bytes_per_input: Result, + } + + impl Default for Quota { + fn default() -> Self { + Self { + max_bytes_per_input: Err( + "no value supplied for max_bytes_per_input".to_string() + ), + } + } + } + + impl Quota { + pub fn max_bytes_per_input(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.max_bytes_per_input = value.try_into().map_err(|e| { + format!( + "error converting supplied value for max_bytes_per_input: {}", + e + ) + }); + self + } + } + + impl std::convert::TryFrom for super::Quota { + type Error = String; + fn try_from(value: Quota) -> Result { + Ok(Self { + max_bytes_per_input: value.max_bytes_per_input?, + }) + } + } + + impl From for Quota { + fn from(value: super::Quota) -> Self { + Self { + max_bytes_per_input: Ok(value.max_bytes_per_input), + } + } + } + + #[derive(Clone, Debug)] + pub struct Target { + desc: Result, + id: Result, + name: Result, + privilege: Result, String>, + redirect: Result, String>, + } + + impl Default for Target { + fn default() -> Self { + Self { + desc: Err("no value supplied for desc".to_string()), + id: Err("no value supplied for id".to_string()), + name: Err("no value supplied for name".to_string()), + privilege: Ok(Default::default()), + redirect: Ok(Default::default()), + } + } + } + + impl Target { + pub fn desc(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.desc = value + .try_into() + .map_err(|e| format!("error converting supplied value for desc: {}", e)); + self + } + pub fn id(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.id = value + .try_into() + .map_err(|e| format!("error converting supplied value for id: {}", e)); + self + } + pub fn name(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.name = value + .try_into() + .map_err(|e| format!("error converting supplied value for name: {}", e)); + self + } + pub fn privilege(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.privilege = value + .try_into() + .map_err(|e| format!("error converting supplied value for privilege: {}", e)); + self + } + pub fn redirect(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.redirect = value + .try_into() + .map_err(|e| format!("error converting supplied value for redirect: {}", e)); + self + } + } + + impl std::convert::TryFrom for super::Target { + type Error = String; + fn try_from(value: Target) -> Result { + Ok(Self { + desc: value.desc?, + id: value.id?, + name: value.name?, + privilege: value.privilege?, + redirect: value.redirect?, + }) + } + } + + impl From for Target { + fn from(value: super::Target) -> Self { + Self { + desc: Ok(value.desc), + id: Ok(value.id), + name: Ok(value.name), + privilege: Ok(value.privilege), + redirect: Ok(value.redirect), + } + } + } + + #[derive(Clone, Debug)] + pub struct TargetCreate { + desc: Result, + name: Result, + } + + impl Default for TargetCreate { + fn default() -> Self { + Self { + desc: Err("no value supplied for desc".to_string()), + name: Err("no value supplied for name".to_string()), + } + } + } + + impl TargetCreate { + pub fn desc(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.desc = value + .try_into() + .map_err(|e| format!("error converting supplied value for desc: {}", e)); + self + } + pub fn name(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.name = value + .try_into() + .map_err(|e| format!("error converting supplied value for name: {}", e)); + self + } + } + + impl std::convert::TryFrom for super::TargetCreate { + type Error = String; + fn try_from(value: TargetCreate) -> Result { + Ok(Self { + desc: value.desc?, + name: value.name?, + }) + } + } + + impl From for TargetCreate { + fn from(value: super::TargetCreate) -> Self { + Self { + desc: Ok(value.desc), + name: Ok(value.name), + } + } + } + + #[derive(Clone, Debug)] + pub struct TargetCreateResult { + id: Result, + } + + impl Default for TargetCreateResult { + fn default() -> Self { + Self { + id: Err("no value supplied for id".to_string()), + } + } + } + + impl TargetCreateResult { + pub fn id(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.id = value + .try_into() + .map_err(|e| format!("error converting supplied value for id: {}", e)); + self + } + } + + impl std::convert::TryFrom for super::TargetCreateResult { + type Error = String; + fn try_from(value: TargetCreateResult) -> Result { + Ok(Self { id: value.id? }) + } + } + + impl From for TargetCreateResult { + fn from(value: super::TargetCreateResult) -> Self { + Self { id: Ok(value.id) } + } + } + + #[derive(Clone, Debug)] + pub struct TargetRedirect { + redirect: Result, String>, + } + + impl Default for TargetRedirect { + fn default() -> Self { + Self { + redirect: Ok(Default::default()), + } + } + } + + impl TargetRedirect { + pub fn redirect(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.redirect = value + .try_into() + .map_err(|e| format!("error converting supplied value for redirect: {}", e)); + self + } + } + + impl std::convert::TryFrom for super::TargetRedirect { + type Error = String; + fn try_from(value: TargetRedirect) -> Result { + Ok(Self { + redirect: value.redirect?, + }) + } + } + + impl From for TargetRedirect { + fn from(value: super::TargetRedirect) -> Self { + Self { + redirect: Ok(value.redirect), + } + } + } + + #[derive(Clone, Debug)] + pub struct TargetRename { + new_name: Result, + signpost_description: Result, + } + + impl Default for TargetRename { + fn default() -> Self { + Self { + new_name: Err("no value supplied for new_name".to_string()), + signpost_description: Err( + "no value supplied for signpost_description".to_string() + ), + } + } + } + + impl TargetRename { + pub fn new_name(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.new_name = value + .try_into() + .map_err(|e| format!("error converting supplied value for new_name: {}", e)); + self + } + pub fn signpost_description(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.signpost_description = value.try_into().map_err(|e| { + format!( + "error converting supplied value for signpost_description: {}", + e + ) + }); + self + } + } + + impl std::convert::TryFrom for super::TargetRename { + type Error = String; + fn try_from(value: TargetRename) -> Result { + Ok(Self { + new_name: value.new_name?, + signpost_description: value.signpost_description?, + }) + } + } + + impl From for TargetRename { + fn from(value: super::TargetRename) -> Self { + Self { + new_name: Ok(value.new_name), + signpost_description: Ok(value.signpost_description), + } + } + } + + #[derive(Clone, Debug)] + pub struct Task { + env: Result, String>, + env_clear: Result, + gid: Result, String>, + name: Result, + script: Result, + state: Result, + uid: Result, String>, + workdir: Result, String>, + } + + impl Default for Task { + fn default() -> Self { + Self { + env: Err("no value supplied for env".to_string()), + env_clear: Err("no value supplied for env_clear".to_string()), + gid: Ok(Default::default()), + name: Err("no value supplied for name".to_string()), + script: Err("no value supplied for script".to_string()), + state: Err("no value supplied for state".to_string()), + uid: Ok(Default::default()), + workdir: Ok(Default::default()), + } + } + } + + impl Task { + pub fn env(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.env = value + .try_into() + .map_err(|e| format!("error converting supplied value for env: {}", e)); + self + } + pub fn env_clear(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.env_clear = value + .try_into() + .map_err(|e| format!("error converting supplied value for env_clear: {}", e)); + self + } + pub fn gid(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.gid = value + .try_into() + .map_err(|e| format!("error converting supplied value for gid: {}", e)); + self + } + pub fn name(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.name = value + .try_into() + .map_err(|e| format!("error converting supplied value for name: {}", e)); + self + } + pub fn script(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.script = value + .try_into() + .map_err(|e| format!("error converting supplied value for script: {}", e)); + self + } + pub fn state(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.state = value + .try_into() + .map_err(|e| format!("error converting supplied value for state: {}", e)); + self + } + pub fn uid(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.uid = value + .try_into() + .map_err(|e| format!("error converting supplied value for uid: {}", e)); + self + } + pub fn workdir(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.workdir = value + .try_into() + .map_err(|e| format!("error converting supplied value for workdir: {}", e)); + self + } + } + + impl std::convert::TryFrom for super::Task { + type Error = String; + fn try_from(value: Task) -> Result { + Ok(Self { + env: value.env?, + env_clear: value.env_clear?, + gid: value.gid?, + name: value.name?, + script: value.script?, + state: value.state?, + uid: value.uid?, + workdir: value.workdir?, + }) + } + } + + impl From for Task { + fn from(value: super::Task) -> Self { + Self { + env: Ok(value.env), + env_clear: Ok(value.env_clear), + gid: Ok(value.gid), + name: Ok(value.name), + script: Ok(value.script), + state: Ok(value.state), + uid: Ok(value.uid), + workdir: Ok(value.workdir), + } + } + } + + #[derive(Clone, Debug)] + pub struct TaskSubmit { + env: Result, String>, + env_clear: Result, + gid: Result, String>, + name: Result, + script: Result, + uid: Result, String>, + workdir: Result, String>, + } + + impl Default for TaskSubmit { + fn default() -> Self { + Self { + env: Err("no value supplied for env".to_string()), + env_clear: Err("no value supplied for env_clear".to_string()), + gid: Ok(Default::default()), + name: Err("no value supplied for name".to_string()), + script: Err("no value supplied for script".to_string()), + uid: Ok(Default::default()), + workdir: Ok(Default::default()), + } + } + } + + impl TaskSubmit { + pub fn env(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.env = value + .try_into() + .map_err(|e| format!("error converting supplied value for env: {}", e)); + self + } + pub fn env_clear(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.env_clear = value + .try_into() + .map_err(|e| format!("error converting supplied value for env_clear: {}", e)); + self + } + pub fn gid(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.gid = value + .try_into() + .map_err(|e| format!("error converting supplied value for gid: {}", e)); + self + } + pub fn name(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.name = value + .try_into() + .map_err(|e| format!("error converting supplied value for name: {}", e)); + self + } + pub fn script(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.script = value + .try_into() + .map_err(|e| format!("error converting supplied value for script: {}", e)); + self + } + pub fn uid(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.uid = value + .try_into() + .map_err(|e| format!("error converting supplied value for uid: {}", e)); + self + } + pub fn workdir(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.workdir = value + .try_into() + .map_err(|e| format!("error converting supplied value for workdir: {}", e)); + self + } + } + + impl std::convert::TryFrom for super::TaskSubmit { + type Error = String; + fn try_from(value: TaskSubmit) -> Result { + Ok(Self { + env: value.env?, + env_clear: value.env_clear?, + gid: value.gid?, + name: value.name?, + script: value.script?, + uid: value.uid?, + workdir: value.workdir?, + }) + } + } + + impl From for TaskSubmit { + fn from(value: super::TaskSubmit) -> Self { + Self { + env: Ok(value.env), + env_clear: Ok(value.env_clear), + gid: Ok(value.gid), + name: Ok(value.name), + script: Ok(value.script), + uid: Ok(value.uid), + workdir: Ok(value.workdir), + } + } + } + + #[derive(Clone, Debug)] + pub struct UploadedChunk { + id: Result, + } + + impl Default for UploadedChunk { + fn default() -> Self { + Self { + id: Err("no value supplied for id".to_string()), + } + } + } + + impl UploadedChunk { + pub fn id(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.id = value + .try_into() + .map_err(|e| format!("error converting supplied value for id: {}", e)); + self + } + } + + impl std::convert::TryFrom for super::UploadedChunk { + type Error = String; + fn try_from(value: UploadedChunk) -> Result { + Ok(Self { id: value.id? }) + } + } + + impl From for UploadedChunk { + fn from(value: super::UploadedChunk) -> Self { + Self { id: Ok(value.id) } + } + } + + #[derive(Clone, Debug)] + pub struct User { + id: Result, + name: Result, + privileges: Result, String>, + time_create: Result, String>, + } + + impl Default for User { + fn default() -> Self { + Self { + id: Err("no value supplied for id".to_string()), + name: Err("no value supplied for name".to_string()), + privileges: Err("no value supplied for privileges".to_string()), + time_create: Err("no value supplied for time_create".to_string()), + } + } + } + + impl User { + pub fn id(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.id = value + .try_into() + .map_err(|e| format!("error converting supplied value for id: {}", e)); + self + } + pub fn name(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.name = value + .try_into() + .map_err(|e| format!("error converting supplied value for name: {}", e)); + self + } + pub fn privileges(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.privileges = value + .try_into() + .map_err(|e| format!("error converting supplied value for privileges: {}", e)); + self + } + pub fn time_create(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.time_create = value + .try_into() + .map_err(|e| format!("error converting supplied value for time_create: {}", e)); + self + } + } + + impl std::convert::TryFrom for super::User { + type Error = String; + fn try_from(value: User) -> Result { + Ok(Self { + id: value.id?, + name: value.name?, + privileges: value.privileges?, + time_create: value.time_create?, + }) + } + } + + impl From for User { + fn from(value: super::User) -> Self { + Self { + id: Ok(value.id), + name: Ok(value.name), + privileges: Ok(value.privileges), + time_create: Ok(value.time_create), + } + } + } + + #[derive(Clone, Debug)] + pub struct UserCreate { + name: Result, + } + + impl Default for UserCreate { + fn default() -> Self { + Self { + name: Err("no value supplied for name".to_string()), + } + } + } + + impl UserCreate { + pub fn name(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.name = value + .try_into() + .map_err(|e| format!("error converting supplied value for name: {}", e)); + self + } + } + + impl std::convert::TryFrom for super::UserCreate { + type Error = String; + fn try_from(value: UserCreate) -> Result { + Ok(Self { name: value.name? }) + } + } + + impl From for UserCreate { + fn from(value: super::UserCreate) -> Self { + Self { + name: Ok(value.name), + } + } + } + + #[derive(Clone, Debug)] + pub struct UserCreateResult { + id: Result, + name: Result, + token: Result, + } + + impl Default for UserCreateResult { + fn default() -> Self { + Self { + id: Err("no value supplied for id".to_string()), + name: Err("no value supplied for name".to_string()), + token: Err("no value supplied for token".to_string()), + } + } + } + + impl UserCreateResult { + pub fn id(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.id = value + .try_into() + .map_err(|e| format!("error converting supplied value for id: {}", e)); + self + } + pub fn name(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.name = value + .try_into() + .map_err(|e| format!("error converting supplied value for name: {}", e)); + self + } + pub fn token(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.token = value + .try_into() + .map_err(|e| format!("error converting supplied value for token: {}", e)); + self + } + } + + impl std::convert::TryFrom for super::UserCreateResult { + type Error = String; + fn try_from(value: UserCreateResult) -> Result { + Ok(Self { + id: value.id?, + name: value.name?, + token: value.token?, + }) + } + } + + impl From for UserCreateResult { + fn from(value: super::UserCreateResult) -> Self { + Self { + id: Ok(value.id), + name: Ok(value.name), + token: Ok(value.token), + } + } + } + + #[derive(Clone, Debug)] + pub struct WhoamiResult { + id: Result, + name: Result, + } + + impl Default for WhoamiResult { + fn default() -> Self { + Self { + id: Err("no value supplied for id".to_string()), + name: Err("no value supplied for name".to_string()), + } + } + } + + impl WhoamiResult { + pub fn id(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.id = value + .try_into() + .map_err(|e| format!("error converting supplied value for id: {}", e)); + self + } + pub fn name(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.name = value + .try_into() + .map_err(|e| format!("error converting supplied value for name: {}", e)); + self + } + } + + impl std::convert::TryFrom for super::WhoamiResult { + type Error = String; + fn try_from(value: WhoamiResult) -> Result { + Ok(Self { + id: value.id?, + name: value.name?, + }) + } + } + + impl From for WhoamiResult { + fn from(value: super::WhoamiResult) -> Self { + Self { + id: Ok(value.id), + name: Ok(value.name), + } + } + } + + #[derive(Clone, Debug)] + pub struct Worker { + bootstrap: Result, + deleted: Result, + factory: Result, + factory_private: Result, String>, + id: Result, + jobs: Result, String>, + lastping: Result>, String>, + recycle: Result, + target: Result, + } + + impl Default for Worker { + fn default() -> Self { + Self { + bootstrap: Err("no value supplied for bootstrap".to_string()), + deleted: Err("no value supplied for deleted".to_string()), + factory: Err("no value supplied for factory".to_string()), + factory_private: Ok(Default::default()), + id: Err("no value supplied for id".to_string()), + jobs: Err("no value supplied for jobs".to_string()), + lastping: Ok(Default::default()), + recycle: Err("no value supplied for recycle".to_string()), + target: Err("no value supplied for target".to_string()), + } + } + } + + impl Worker { + pub fn bootstrap(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.bootstrap = value + .try_into() + .map_err(|e| format!("error converting supplied value for bootstrap: {}", e)); + self + } + pub fn deleted(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.deleted = value + .try_into() + .map_err(|e| format!("error converting supplied value for deleted: {}", e)); + self + } + pub fn factory(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.factory = value + .try_into() + .map_err(|e| format!("error converting supplied value for factory: {}", e)); + self + } + pub fn factory_private(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.factory_private = value.try_into().map_err(|e| { + format!("error converting supplied value for factory_private: {}", e) + }); + self + } + pub fn id(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.id = value + .try_into() + .map_err(|e| format!("error converting supplied value for id: {}", e)); + self + } + pub fn jobs(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.jobs = value + .try_into() + .map_err(|e| format!("error converting supplied value for jobs: {}", e)); + self + } + pub fn lastping(mut self, value: T) -> Self + where + T: std::convert::TryInto>>, + T::Error: std::fmt::Display, + { + self.lastping = value + .try_into() + .map_err(|e| format!("error converting supplied value for lastping: {}", e)); + self + } + pub fn recycle(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.recycle = value + .try_into() + .map_err(|e| format!("error converting supplied value for recycle: {}", e)); + self + } + pub fn target(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.target = value + .try_into() + .map_err(|e| format!("error converting supplied value for target: {}", e)); + self + } + } + + impl std::convert::TryFrom for super::Worker { + type Error = String; + fn try_from(value: Worker) -> Result { + Ok(Self { + bootstrap: value.bootstrap?, + deleted: value.deleted?, + factory: value.factory?, + factory_private: value.factory_private?, + id: value.id?, + jobs: value.jobs?, + lastping: value.lastping?, + recycle: value.recycle?, + target: value.target?, + }) + } + } + + impl From for Worker { + fn from(value: super::Worker) -> Self { + Self { + bootstrap: Ok(value.bootstrap), + deleted: Ok(value.deleted), + factory: Ok(value.factory), + factory_private: Ok(value.factory_private), + id: Ok(value.id), + jobs: Ok(value.jobs), + lastping: Ok(value.lastping), + recycle: Ok(value.recycle), + target: Ok(value.target), + } + } + } + + #[derive(Clone, Debug)] + pub struct WorkerAddOutput { + chunks: Result, String>, + commit_id: Result, + path: Result, + size: Result, + } + + impl Default for WorkerAddOutput { + fn default() -> Self { + Self { + chunks: Err("no value supplied for chunks".to_string()), + commit_id: Err("no value supplied for commit_id".to_string()), + path: Err("no value supplied for path".to_string()), + size: Err("no value supplied for size".to_string()), + } + } + } + + impl WorkerAddOutput { + pub fn chunks(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.chunks = value + .try_into() + .map_err(|e| format!("error converting supplied value for chunks: {}", e)); + self + } + pub fn commit_id(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.commit_id = value + .try_into() + .map_err(|e| format!("error converting supplied value for commit_id: {}", e)); + self + } + pub fn path(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.path = value + .try_into() + .map_err(|e| format!("error converting supplied value for path: {}", e)); + self + } + pub fn size(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.size = value + .try_into() + .map_err(|e| format!("error converting supplied value for size: {}", e)); + self + } + } + + impl std::convert::TryFrom for super::WorkerAddOutput { + type Error = String; + fn try_from(value: WorkerAddOutput) -> Result { + Ok(Self { + chunks: value.chunks?, + commit_id: value.commit_id?, + path: value.path?, + size: value.size?, + }) + } + } + + impl From for WorkerAddOutput { + fn from(value: super::WorkerAddOutput) -> Self { + Self { + chunks: Ok(value.chunks), + commit_id: Ok(value.commit_id), + path: Ok(value.path), + size: Ok(value.size), + } + } + } + + #[derive(Clone, Debug)] + pub struct WorkerAddOutputResult { + complete: Result, + error: Result, String>, + } + + impl Default for WorkerAddOutputResult { + fn default() -> Self { + Self { + complete: Err("no value supplied for complete".to_string()), + error: Ok(Default::default()), + } + } + } + + impl WorkerAddOutputResult { + pub fn complete(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.complete = value + .try_into() + .map_err(|e| format!("error converting supplied value for complete: {}", e)); + self + } + pub fn error(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.error = value + .try_into() + .map_err(|e| format!("error converting supplied value for error: {}", e)); + self + } + } + + impl std::convert::TryFrom for super::WorkerAddOutputResult { + type Error = String; + fn try_from(value: WorkerAddOutputResult) -> Result { + Ok(Self { + complete: value.complete?, + error: value.error?, + }) + } + } + + impl From for WorkerAddOutputResult { + fn from(value: super::WorkerAddOutputResult) -> Self { + Self { + complete: Ok(value.complete), + error: Ok(value.error), + } + } + } + + #[derive(Clone, Debug)] + pub struct WorkerAppendJob { + payload: Result, + stream: Result, + time: Result, String>, + } + + impl Default for WorkerAppendJob { + fn default() -> Self { + Self { + payload: Err("no value supplied for payload".to_string()), + stream: Err("no value supplied for stream".to_string()), + time: Err("no value supplied for time".to_string()), + } + } + } + + impl WorkerAppendJob { + pub fn payload(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.payload = value + .try_into() + .map_err(|e| format!("error converting supplied value for payload: {}", e)); + self + } + pub fn stream(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.stream = value + .try_into() + .map_err(|e| format!("error converting supplied value for stream: {}", e)); + self + } + pub fn time(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.time = value + .try_into() + .map_err(|e| format!("error converting supplied value for time: {}", e)); + self + } + } + + impl std::convert::TryFrom for super::WorkerAppendJob { + type Error = String; + fn try_from(value: WorkerAppendJob) -> Result { + Ok(Self { + payload: value.payload?, + stream: value.stream?, + time: value.time?, + }) + } + } + + impl From for WorkerAppendJob { + fn from(value: super::WorkerAppendJob) -> Self { + Self { + payload: Ok(value.payload), + stream: Ok(value.stream), + time: Ok(value.time), + } + } + } + + #[derive(Clone, Debug)] + pub struct WorkerAppendJobOrTask { + payload: Result, + stream: Result, + task: Result, String>, + time: Result, String>, + } + + impl Default for WorkerAppendJobOrTask { + fn default() -> Self { + Self { + payload: Err("no value supplied for payload".to_string()), + stream: Err("no value supplied for stream".to_string()), + task: Ok(Default::default()), + time: Err("no value supplied for time".to_string()), + } + } + } + + impl WorkerAppendJobOrTask { + pub fn payload(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.payload = value + .try_into() + .map_err(|e| format!("error converting supplied value for payload: {}", e)); + self + } + pub fn stream(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.stream = value + .try_into() + .map_err(|e| format!("error converting supplied value for stream: {}", e)); + self + } + pub fn task(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.task = value + .try_into() + .map_err(|e| format!("error converting supplied value for task: {}", e)); + self + } + pub fn time(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.time = value + .try_into() + .map_err(|e| format!("error converting supplied value for time: {}", e)); + self + } + } + + impl std::convert::TryFrom for super::WorkerAppendJobOrTask { + type Error = String; + fn try_from(value: WorkerAppendJobOrTask) -> Result { + Ok(Self { + payload: value.payload?, + stream: value.stream?, + task: value.task?, + time: value.time?, + }) + } + } + + impl From for WorkerAppendJobOrTask { + fn from(value: super::WorkerAppendJobOrTask) -> Self { + Self { + payload: Ok(value.payload), + stream: Ok(value.stream), + task: Ok(value.task), + time: Ok(value.time), + } + } + } + + #[derive(Clone, Debug)] + pub struct WorkerBootstrap { + bootstrap: Result, + token: Result, + } + + impl Default for WorkerBootstrap { + fn default() -> Self { + Self { + bootstrap: Err("no value supplied for bootstrap".to_string()), + token: Err("no value supplied for token".to_string()), + } + } + } + + impl WorkerBootstrap { + pub fn bootstrap(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.bootstrap = value + .try_into() + .map_err(|e| format!("error converting supplied value for bootstrap: {}", e)); + self + } + pub fn token(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.token = value + .try_into() + .map_err(|e| format!("error converting supplied value for token: {}", e)); + self + } + } + + impl std::convert::TryFrom for super::WorkerBootstrap { + type Error = String; + fn try_from(value: WorkerBootstrap) -> Result { + Ok(Self { + bootstrap: value.bootstrap?, + token: value.token?, + }) + } + } + + impl From for WorkerBootstrap { + fn from(value: super::WorkerBootstrap) -> Self { + Self { + bootstrap: Ok(value.bootstrap), + token: Ok(value.token), + } + } + } + + #[derive(Clone, Debug)] + pub struct WorkerBootstrapResult { + id: Result, + } + + impl Default for WorkerBootstrapResult { + fn default() -> Self { + Self { + id: Err("no value supplied for id".to_string()), + } + } + } + + impl WorkerBootstrapResult { + pub fn id(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.id = value + .try_into() + .map_err(|e| format!("error converting supplied value for id: {}", e)); + self + } + } + + impl std::convert::TryFrom for super::WorkerBootstrapResult { + type Error = String; + fn try_from(value: WorkerBootstrapResult) -> Result { + Ok(Self { id: value.id? }) + } + } + + impl From for WorkerBootstrapResult { + fn from(value: super::WorkerBootstrapResult) -> Self { + Self { id: Ok(value.id) } + } + } + + #[derive(Clone, Debug)] + pub struct WorkerCompleteJob { + failed: Result, + } + + impl Default for WorkerCompleteJob { + fn default() -> Self { + Self { + failed: Err("no value supplied for failed".to_string()), + } + } + } + + impl WorkerCompleteJob { + pub fn failed(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.failed = value + .try_into() + .map_err(|e| format!("error converting supplied value for failed: {}", e)); + self + } + } + + impl std::convert::TryFrom for super::WorkerCompleteJob { + type Error = String; + fn try_from(value: WorkerCompleteJob) -> Result { + Ok(Self { + failed: value.failed?, + }) + } + } + + impl From for WorkerCompleteJob { + fn from(value: super::WorkerCompleteJob) -> Self { + Self { + failed: Ok(value.failed), + } + } + } + + #[derive(Clone, Debug)] + pub struct WorkerCompleteTask { + failed: Result, + } + + impl Default for WorkerCompleteTask { + fn default() -> Self { + Self { + failed: Err("no value supplied for failed".to_string()), + } + } + } + + impl WorkerCompleteTask { + pub fn failed(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.failed = value + .try_into() + .map_err(|e| format!("error converting supplied value for failed: {}", e)); + self + } + } + + impl std::convert::TryFrom for super::WorkerCompleteTask { + type Error = String; + fn try_from(value: WorkerCompleteTask) -> Result { + Ok(Self { + failed: value.failed?, + }) + } + } + + impl From for WorkerCompleteTask { + fn from(value: super::WorkerCompleteTask) -> Self { + Self { + failed: Ok(value.failed), + } + } + } + + #[derive(Clone, Debug)] + pub struct WorkerJob { + id: Result, + name: Result, + owner: Result, + state: Result, + tags: Result, String>, + } + + impl Default for WorkerJob { + fn default() -> Self { + Self { + id: Err("no value supplied for id".to_string()), + name: Err("no value supplied for name".to_string()), + owner: Err("no value supplied for owner".to_string()), + state: Err("no value supplied for state".to_string()), + tags: Err("no value supplied for tags".to_string()), + } + } + } + + impl WorkerJob { + pub fn id(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.id = value + .try_into() + .map_err(|e| format!("error converting supplied value for id: {}", e)); + self + } + pub fn name(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.name = value + .try_into() + .map_err(|e| format!("error converting supplied value for name: {}", e)); + self + } + pub fn owner(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.owner = value + .try_into() + .map_err(|e| format!("error converting supplied value for owner: {}", e)); + self + } + pub fn state(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.state = value + .try_into() + .map_err(|e| format!("error converting supplied value for state: {}", e)); + self + } + pub fn tags(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.tags = value + .try_into() + .map_err(|e| format!("error converting supplied value for tags: {}", e)); + self + } + } + + impl std::convert::TryFrom for super::WorkerJob { + type Error = String; + fn try_from(value: WorkerJob) -> Result { + Ok(Self { + id: value.id?, + name: value.name?, + owner: value.owner?, + state: value.state?, + tags: value.tags?, + }) + } + } + + impl From for WorkerJob { + fn from(value: super::WorkerJob) -> Self { + Self { + id: Ok(value.id), + name: Ok(value.name), + owner: Ok(value.owner), + state: Ok(value.state), + tags: Ok(value.tags), + } + } + } + + #[derive(Clone, Debug)] + pub struct WorkerJobQuota { + max_bytes_per_output: Result, + } + + impl Default for WorkerJobQuota { + fn default() -> Self { + Self { + max_bytes_per_output: Err( + "no value supplied for max_bytes_per_output".to_string() + ), + } + } + } + + impl WorkerJobQuota { + pub fn max_bytes_per_output(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.max_bytes_per_output = value.try_into().map_err(|e| { + format!( + "error converting supplied value for max_bytes_per_output: {}", + e + ) + }); + self + } + } + + impl std::convert::TryFrom for super::WorkerJobQuota { + type Error = String; + fn try_from(value: WorkerJobQuota) -> Result { + Ok(Self { + max_bytes_per_output: value.max_bytes_per_output?, + }) + } + } + + impl From for WorkerJobQuota { + fn from(value: super::WorkerJobQuota) -> Self { + Self { + max_bytes_per_output: Ok(value.max_bytes_per_output), + } + } + } + + #[derive(Clone, Debug)] + pub struct WorkerJobStoreGet { + value: Result, String>, + } + + impl Default for WorkerJobStoreGet { + fn default() -> Self { + Self { + value: Ok(Default::default()), + } + } + } + + impl WorkerJobStoreGet { + pub fn value(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.value = value + .try_into() + .map_err(|e| format!("error converting supplied value for value: {}", e)); + self + } + } + + impl std::convert::TryFrom for super::WorkerJobStoreGet { + type Error = String; + fn try_from(value: WorkerJobStoreGet) -> Result { + Ok(Self { + value: value.value?, + }) + } + } + + impl From for WorkerJobStoreGet { + fn from(value: super::WorkerJobStoreGet) -> Self { + Self { + value: Ok(value.value), + } + } + } + + #[derive(Clone, Debug)] + pub struct WorkerJobStoreValue { + secret: Result, + value: Result, + } + + impl Default for WorkerJobStoreValue { + fn default() -> Self { + Self { + secret: Err("no value supplied for secret".to_string()), + value: Err("no value supplied for value".to_string()), + } + } + } + + impl WorkerJobStoreValue { + pub fn secret(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.secret = value + .try_into() + .map_err(|e| format!("error converting supplied value for secret: {}", e)); + self + } + pub fn value(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.value = value + .try_into() + .map_err(|e| format!("error converting supplied value for value: {}", e)); + self + } + } + + impl std::convert::TryFrom for super::WorkerJobStoreValue { + type Error = String; + fn try_from(value: WorkerJobStoreValue) -> Result { + Ok(Self { + secret: value.secret?, + value: value.value?, + }) + } + } + + impl From for WorkerJobStoreValue { + fn from(value: super::WorkerJobStoreValue) -> Self { + Self { + secret: Ok(value.secret), + value: Ok(value.value), + } + } + } + + #[derive(Clone, Debug)] + pub struct WorkerPingInput { + id: Result, + name: Result, + } + + impl Default for WorkerPingInput { + fn default() -> Self { + Self { + id: Err("no value supplied for id".to_string()), + name: Err("no value supplied for name".to_string()), + } + } + } + + impl WorkerPingInput { + pub fn id(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.id = value + .try_into() + .map_err(|e| format!("error converting supplied value for id: {}", e)); + self + } + pub fn name(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.name = value + .try_into() + .map_err(|e| format!("error converting supplied value for name: {}", e)); + self + } + } + + impl std::convert::TryFrom for super::WorkerPingInput { + type Error = String; + fn try_from(value: WorkerPingInput) -> Result { + Ok(Self { + id: value.id?, + name: value.name?, + }) + } + } + + impl From for WorkerPingInput { + fn from(value: super::WorkerPingInput) -> Self { + Self { + id: Ok(value.id), + name: Ok(value.name), + } + } + } + + #[derive(Clone, Debug)] + pub struct WorkerPingJob { + id: Result, + inputs: Result, String>, + name: Result, + output_rules: Result, String>, + tasks: Result, String>, + } + + impl Default for WorkerPingJob { + fn default() -> Self { + Self { + id: Err("no value supplied for id".to_string()), + inputs: Err("no value supplied for inputs".to_string()), + name: Err("no value supplied for name".to_string()), + output_rules: Err("no value supplied for output_rules".to_string()), + tasks: Err("no value supplied for tasks".to_string()), + } + } + } + + impl WorkerPingJob { + pub fn id(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.id = value + .try_into() + .map_err(|e| format!("error converting supplied value for id: {}", e)); + self + } + pub fn inputs(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.inputs = value + .try_into() + .map_err(|e| format!("error converting supplied value for inputs: {}", e)); + self + } + pub fn name(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.name = value + .try_into() + .map_err(|e| format!("error converting supplied value for name: {}", e)); + self + } + pub fn output_rules(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.output_rules = value.try_into().map_err(|e| { + format!("error converting supplied value for output_rules: {}", e) + }); + self + } + pub fn tasks(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.tasks = value + .try_into() + .map_err(|e| format!("error converting supplied value for tasks: {}", e)); + self + } + } + + impl std::convert::TryFrom for super::WorkerPingJob { + type Error = String; + fn try_from(value: WorkerPingJob) -> Result { + Ok(Self { + id: value.id?, + inputs: value.inputs?, + name: value.name?, + output_rules: value.output_rules?, + tasks: value.tasks?, + }) + } + } + + impl From for WorkerPingJob { + fn from(value: super::WorkerPingJob) -> Self { + Self { + id: Ok(value.id), + inputs: Ok(value.inputs), + name: Ok(value.name), + output_rules: Ok(value.output_rules), + tasks: Ok(value.tasks), + } + } + } + + #[derive(Clone, Debug)] + pub struct WorkerPingOutputRule { + ignore: Result, + require_match: Result, + rule: Result, + size_change_ok: Result, + } + + impl Default for WorkerPingOutputRule { + fn default() -> Self { + Self { + ignore: Err("no value supplied for ignore".to_string()), + require_match: Err("no value supplied for require_match".to_string()), + rule: Err("no value supplied for rule".to_string()), + size_change_ok: Err("no value supplied for size_change_ok".to_string()), + } + } + } + + impl WorkerPingOutputRule { + pub fn ignore(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.ignore = value + .try_into() + .map_err(|e| format!("error converting supplied value for ignore: {}", e)); + self + } + pub fn require_match(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.require_match = value.try_into().map_err(|e| { + format!("error converting supplied value for require_match: {}", e) + }); + self + } + pub fn rule(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.rule = value + .try_into() + .map_err(|e| format!("error converting supplied value for rule: {}", e)); + self + } + pub fn size_change_ok(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.size_change_ok = value.try_into().map_err(|e| { + format!("error converting supplied value for size_change_ok: {}", e) + }); + self + } + } + + impl std::convert::TryFrom for super::WorkerPingOutputRule { + type Error = String; + fn try_from(value: WorkerPingOutputRule) -> Result { + Ok(Self { + ignore: value.ignore?, + require_match: value.require_match?, + rule: value.rule?, + size_change_ok: value.size_change_ok?, + }) + } + } + + impl From for WorkerPingOutputRule { + fn from(value: super::WorkerPingOutputRule) -> Self { + Self { + ignore: Ok(value.ignore), + require_match: Ok(value.require_match), + rule: Ok(value.rule), + size_change_ok: Ok(value.size_change_ok), + } + } + } + + #[derive(Clone, Debug)] + pub struct WorkerPingResult { + factory_metadata: Result, String>, + job: Result, String>, + poweroff: Result, + } + + impl Default for WorkerPingResult { + fn default() -> Self { + Self { + factory_metadata: Ok(Default::default()), + job: Ok(Default::default()), + poweroff: Err("no value supplied for poweroff".to_string()), + } + } + } + + impl WorkerPingResult { + pub fn factory_metadata(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.factory_metadata = value.try_into().map_err(|e| { + format!( + "error converting supplied value for factory_metadata: {}", + e + ) + }); + self + } + pub fn job(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.job = value + .try_into() + .map_err(|e| format!("error converting supplied value for job: {}", e)); + self + } + pub fn poweroff(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.poweroff = value + .try_into() + .map_err(|e| format!("error converting supplied value for poweroff: {}", e)); + self + } + } + + impl std::convert::TryFrom for super::WorkerPingResult { + type Error = String; + fn try_from(value: WorkerPingResult) -> Result { + Ok(Self { + factory_metadata: value.factory_metadata?, + job: value.job?, + poweroff: value.poweroff?, + }) + } + } + + impl From for WorkerPingResult { + fn from(value: super::WorkerPingResult) -> Self { + Self { + factory_metadata: Ok(value.factory_metadata), + job: Ok(value.job), + poweroff: Ok(value.poweroff), + } + } + } + + #[derive(Clone, Debug)] + pub struct WorkerPingTask { + env: Result, String>, + env_clear: Result, + gid: Result, + id: Result, + name: Result, + script: Result, + uid: Result, + workdir: Result, + } + + impl Default for WorkerPingTask { + fn default() -> Self { + Self { + env: Err("no value supplied for env".to_string()), + env_clear: Err("no value supplied for env_clear".to_string()), + gid: Err("no value supplied for gid".to_string()), + id: Err("no value supplied for id".to_string()), + name: Err("no value supplied for name".to_string()), + script: Err("no value supplied for script".to_string()), + uid: Err("no value supplied for uid".to_string()), + workdir: Err("no value supplied for workdir".to_string()), + } + } + } + + impl WorkerPingTask { + pub fn env(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.env = value + .try_into() + .map_err(|e| format!("error converting supplied value for env: {}", e)); + self + } + pub fn env_clear(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.env_clear = value + .try_into() + .map_err(|e| format!("error converting supplied value for env_clear: {}", e)); + self + } + pub fn gid(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.gid = value + .try_into() + .map_err(|e| format!("error converting supplied value for gid: {}", e)); + self + } + pub fn id(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.id = value + .try_into() + .map_err(|e| format!("error converting supplied value for id: {}", e)); + self + } + pub fn name(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.name = value + .try_into() + .map_err(|e| format!("error converting supplied value for name: {}", e)); + self + } + pub fn script(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.script = value + .try_into() + .map_err(|e| format!("error converting supplied value for script: {}", e)); + self + } + pub fn uid(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.uid = value + .try_into() + .map_err(|e| format!("error converting supplied value for uid: {}", e)); + self + } + pub fn workdir(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.workdir = value + .try_into() + .map_err(|e| format!("error converting supplied value for workdir: {}", e)); + self + } + } + + impl std::convert::TryFrom for super::WorkerPingTask { + type Error = String; + fn try_from(value: WorkerPingTask) -> Result { + Ok(Self { + env: value.env?, + env_clear: value.env_clear?, + gid: value.gid?, + id: value.id?, + name: value.name?, + script: value.script?, + uid: value.uid?, + workdir: value.workdir?, + }) + } + } + + impl From for WorkerPingTask { + fn from(value: super::WorkerPingTask) -> Self { + Self { + env: Ok(value.env), + env_clear: Ok(value.env_clear), + gid: Ok(value.gid), + id: Ok(value.id), + name: Ok(value.name), + script: Ok(value.script), + uid: Ok(value.uid), + workdir: Ok(value.workdir), + } + } } #[derive(Clone, Debug)] - pub struct Worker { - deleted: Result, - id: Result, - instance_id: Result, String>, - lastping: Result>, String>, - recycle: Result, - tasks: Result, String>, + pub struct WorkersResult { + workers: Result, String>, + } + + impl Default for WorkersResult { + fn default() -> Self { + Self { + workers: Err("no value supplied for workers".to_string()), + } + } + } + + impl WorkersResult { + pub fn workers(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.workers = value + .try_into() + .map_err(|e| format!("error converting supplied value for workers: {}", e)); + self + } + } + + impl std::convert::TryFrom for super::WorkersResult { + type Error = String; + fn try_from(value: WorkersResult) -> Result { + Ok(Self { + workers: value.workers?, + }) + } + } + + impl From for WorkersResult { + fn from(value: super::WorkersResult) -> Self { + Self { + workers: Ok(value.workers), + } + } + } + } +} + +#[derive(Clone, Debug)] +///Client for Buildomat +/// +///Version: 1.0 +pub struct Client { + pub(crate) baseurl: String, + pub(crate) client: reqwest::Client, +} + +impl Client { + /// Create a new client. + /// + /// `baseurl` is the base URL provided to the internal + /// `reqwest::Client`, and should include a scheme and hostname, + /// as well as port and a path stem if applicable. + pub fn new(baseurl: &str) -> Self { + #[cfg(not(target_arch = "wasm32"))] + let client = { + let dur = std::time::Duration::from_secs(15); + reqwest::ClientBuilder::new() + .connect_timeout(dur) + .timeout(dur) + }; + #[cfg(target_arch = "wasm32")] + let client = reqwest::ClientBuilder::new(); + Self::new_with_client(baseurl, client.build().unwrap()) + } + + /// Construct a new client with an existing `reqwest::Client`, + /// allowing more control over its configuration. + /// + /// `baseurl` is the base URL provided to the internal + /// `reqwest::Client`, and should include a scheme and hostname, + /// as well as port and a path stem if applicable. + pub fn new_with_client(baseurl: &str, client: reqwest::Client) -> Self { + Self { + baseurl: baseurl.to_string(), + client, + } + } + + /// Get the base URL to which requests are made. + pub fn baseurl(&self) -> &String { + &self.baseurl + } + + /// Get the internal `reqwest::Client` used to make requests. + pub fn client(&self) -> &reqwest::Client { + &self.client + } + + /// Get the version of this API. + /// + /// This string is pulled directly from the source OpenAPI + /// document and may be in any format the API selects. + pub fn api_version(&self) -> &'static str { + "1.0" + } +} + +impl Client { + ///Sends a `POST` request to `/0/admin/factory` + /// + ///```ignore + /// let response = client.factory_create() + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn factory_create(&self) -> builder::FactoryCreate { + builder::FactoryCreate::new(self) + } + + ///Sends a `GET` request to `/0/admin/jobs` + /// + ///```ignore + /// let response = client.admin_jobs_get() + /// .active(active) + /// .completed(completed) + /// .send() + /// .await; + /// ``` + pub fn admin_jobs_get(&self) -> builder::AdminJobsGet { + builder::AdminJobsGet::new(self) + } + + ///Sends a `GET` request to `/0/admin/jobs/{job}` + /// + ///```ignore + /// let response = client.admin_job_get() + /// .job(job) + /// .send() + /// .await; + /// ``` + pub fn admin_job_get(&self) -> builder::AdminJobGet { + builder::AdminJobGet::new(self) + } + + ///Sends a `POST` request to `/0/admin/jobs/{job}/archive` + /// + ///```ignore + /// let response = client.admin_job_archive_request() + /// .job(job) + /// .send() + /// .await; + /// ``` + pub fn admin_job_archive_request(&self) -> builder::AdminJobArchiveRequest { + builder::AdminJobArchiveRequest::new(self) + } + + ///Sends a `POST` request to `/0/admin/target` + /// + ///```ignore + /// let response = client.target_create() + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn target_create(&self) -> builder::TargetCreate { + builder::TargetCreate::new(self) + } + + ///Sends a `GET` request to `/0/admin/targets` + /// + ///```ignore + /// let response = client.targets_list() + /// .send() + /// .await; + /// ``` + pub fn targets_list(&self) -> builder::TargetsList { + builder::TargetsList::new(self) + } + + ///Sends a `PUT` request to `/0/admin/targets/{target}/redirect` + /// + ///```ignore + /// let response = client.target_redirect() + /// .target(target) + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn target_redirect(&self) -> builder::TargetRedirect { + builder::TargetRedirect::new(self) + } + + ///Sends a `POST` request to `/0/admin/targets/{target}/rename` + /// + ///```ignore + /// let response = client.target_rename() + /// .target(target) + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn target_rename(&self) -> builder::TargetRename { + builder::TargetRename::new(self) + } + + ///Sends a `DELETE` request to `/0/admin/targets/{target}/require` + /// + ///```ignore + /// let response = client.target_require_no_privilege() + /// .target(target) + /// .send() + /// .await; + /// ``` + pub fn target_require_no_privilege(&self) -> builder::TargetRequireNoPrivilege { + builder::TargetRequireNoPrivilege::new(self) + } + + ///Sends a `PUT` request to `/0/admin/targets/{target}/require/{privilege}` + /// + ///```ignore + /// let response = client.target_require_privilege() + /// .target(target) + /// .privilege(privilege) + /// .send() + /// .await; + /// ``` + pub fn target_require_privilege(&self) -> builder::TargetRequirePrivilege { + builder::TargetRequirePrivilege::new(self) + } + + ///Sends a `POST` request to `/0/admin/worker/{worker}/recycle` + /// + ///```ignore + /// let response = client.worker_recycle() + /// .worker(worker) + /// .send() + /// .await; + /// ``` + pub fn worker_recycle(&self) -> builder::WorkerRecycle { + builder::WorkerRecycle::new(self) + } + + ///Sends a `POST` request to `/0/control/hold` + /// + ///```ignore + /// let response = client.control_hold() + /// .send() + /// .await; + /// ``` + pub fn control_hold(&self) -> builder::ControlHold { + builder::ControlHold::new(self) + } + + ///Sends a `POST` request to `/0/control/resume` + /// + ///```ignore + /// let response = client.control_resume() + /// .send() + /// .await; + /// ``` + pub fn control_resume(&self) -> builder::ControlResume { + builder::ControlResume::new(self) + } + + ///Sends a `POST` request to `/0/factory/lease` + /// + ///```ignore + /// let response = client.factory_lease() + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn factory_lease(&self) -> builder::FactoryLease { + builder::FactoryLease::new(self) + } + + ///Sends a `POST` request to `/0/factory/lease/{job}` + /// + ///```ignore + /// let response = client.factory_lease_renew() + /// .job(job) + /// .send() + /// .await; + /// ``` + pub fn factory_lease_renew(&self) -> builder::FactoryLeaseRenew { + builder::FactoryLeaseRenew::new(self) + } + + ///Sends a `GET` request to `/0/factory/ping` + /// + ///```ignore + /// let response = client.factory_ping() + /// .send() + /// .await; + /// ``` + pub fn factory_ping(&self) -> builder::FactoryPing { + builder::FactoryPing::new(self) + } + + ///Sends a `POST` request to `/0/factory/worker` + /// + ///```ignore + /// let response = client.factory_worker_create() + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn factory_worker_create(&self) -> builder::FactoryWorkerCreate { + builder::FactoryWorkerCreate::new(self) + } + + ///Sends a `GET` request to `/0/factory/worker/{worker}` + /// + ///```ignore + /// let response = client.factory_worker_get() + /// .worker(worker) + /// .send() + /// .await; + /// ``` + pub fn factory_worker_get(&self) -> builder::FactoryWorkerGet { + builder::FactoryWorkerGet::new(self) + } + + ///Sends a `DELETE` request to `/0/factory/worker/{worker}` + /// + ///```ignore + /// let response = client.factory_worker_destroy() + /// .worker(worker) + /// .send() + /// .await; + /// ``` + pub fn factory_worker_destroy(&self) -> builder::FactoryWorkerDestroy { + builder::FactoryWorkerDestroy::new(self) + } + + ///Sends a `PATCH` request to `/0/factory/worker/{worker}` + /// + ///```ignore + /// let response = client.factory_worker_associate() + /// .worker(worker) + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn factory_worker_associate(&self) -> builder::FactoryWorkerAssociate { + builder::FactoryWorkerAssociate::new(self) + } + + ///Sends a `POST` request to `/0/factory/worker/{worker}/append` + /// + ///```ignore + /// let response = client.factory_worker_append() + /// .worker(worker) + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn factory_worker_append(&self) -> builder::FactoryWorkerAppend { + builder::FactoryWorkerAppend::new(self) + } + + ///Sends a `POST` request to `/0/factory/worker/{worker}/flush` + /// + ///```ignore + /// let response = client.factory_worker_flush() + /// .worker(worker) + /// .send() + /// .await; + /// ``` + pub fn factory_worker_flush(&self) -> builder::FactoryWorkerFlush { + builder::FactoryWorkerFlush::new(self) + } + + ///Sends a `GET` request to `/0/factory/workers` + /// + ///```ignore + /// let response = client.factory_workers() + /// .send() + /// .await; + /// ``` + pub fn factory_workers(&self) -> builder::FactoryWorkers { + builder::FactoryWorkers::new(self) + } + + ///Sends a `GET` request to `/0/job/{job}` + /// + ///```ignore + /// let response = client.job_get() + /// .job(job) + /// .send() + /// .await; + /// ``` + pub fn job_get(&self) -> builder::JobGet { + builder::JobGet::new(self) + } + + ///Sends a `GET` request to `/0/jobs` + /// + ///```ignore + /// let response = client.jobs_get() + /// .send() + /// .await; + /// ``` + pub fn jobs_get(&self) -> builder::JobsGet { + builder::JobsGet::new(self) + } + + ///Sends a `POST` request to `/0/jobs` + /// + ///```ignore + /// let response = client.job_submit() + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn job_submit(&self) -> builder::JobSubmit { + builder::JobSubmit::new(self) + } + + ///Sends a `POST` request to `/0/jobs/{job}/cancel` + /// + ///```ignore + /// let response = client.job_cancel() + /// .job(job) + /// .send() + /// .await; + /// ``` + pub fn job_cancel(&self) -> builder::JobCancel { + builder::JobCancel::new(self) + } + + ///Sends a `POST` request to `/0/jobs/{job}/chunk` + /// + ///```ignore + /// let response = client.job_upload_chunk() + /// .job(job) + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn job_upload_chunk(&self) -> builder::JobUploadChunk { + builder::JobUploadChunk::new(self) + } + + ///Sends a `GET` request to `/0/jobs/{job}/events` + /// + ///```ignore + /// let response = client.job_events_get() + /// .job(job) + /// .minseq(minseq) + /// .send() + /// .await; + /// ``` + pub fn job_events_get(&self) -> builder::JobEventsGet { + builder::JobEventsGet::new(self) + } + + ///Sends a `GET` request to `/0/jobs/{job}/outputs` + /// + ///```ignore + /// let response = client.job_outputs_get() + /// .job(job) + /// .send() + /// .await; + /// ``` + pub fn job_outputs_get(&self) -> builder::JobOutputsGet { + builder::JobOutputsGet::new(self) + } + + ///Sends a `GET` request to `/0/jobs/{job}/outputs/{output}` + /// + ///```ignore + /// let response = client.job_output_download() + /// .job(job) + /// .output(output) + /// .send() + /// .await; + /// ``` + pub fn job_output_download(&self) -> builder::JobOutputDownload { + builder::JobOutputDownload::new(self) + } + + ///Sends a `POST` request to `/0/jobs/{job}/outputs/{output}/publish` + /// + ///```ignore + /// let response = client.job_output_publish() + /// .job(job) + /// .output(output) + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn job_output_publish(&self) -> builder::JobOutputPublish { + builder::JobOutputPublish::new(self) + } + + ///Sends a `POST` request to `/0/jobs/{job}/outputs/{output}/sign` + /// + ///```ignore + /// let response = client.job_output_signed_url() + /// .job(job) + /// .output(output) + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn job_output_signed_url(&self) -> builder::JobOutputSignedUrl { + builder::JobOutputSignedUrl::new(self) + } + + ///Sends a `GET` request to `/0/jobs/{job}/store` + /// + ///```ignore + /// let response = client.job_store_get_all() + /// .job(job) + /// .send() + /// .await; + /// ``` + pub fn job_store_get_all(&self) -> builder::JobStoreGetAll { + builder::JobStoreGetAll::new(self) + } + + ///Sends a `PUT` request to `/0/jobs/{job}/store/{name}` + /// + ///```ignore + /// let response = client.job_store_put() + /// .job(job) + /// .name(name) + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn job_store_put(&self) -> builder::JobStorePut { + builder::JobStorePut::new(self) + } + + ///Sends a `GET` request to + /// `/0/public/file/{username}/{series}/{version}/{name}` + /// + ///```ignore + /// let response = client.public_file_download() + /// .username(username) + /// .series(series) + /// .version(version) + /// .name(name) + /// .send() + /// .await; + /// ``` + pub fn public_file_download(&self) -> builder::PublicFileDownload { + builder::PublicFileDownload::new(self) + } + + ///Sends a `GET` request to `/0/quota` + /// + ///```ignore + /// let response = client.quota() + /// .send() + /// .await; + /// ``` + pub fn quota(&self) -> builder::Quota { + builder::Quota::new(self) + } + + ///Sends a `GET` request to `/0/users` + /// + ///```ignore + /// let response = client.users_list() + /// .name(name) + /// .send() + /// .await; + /// ``` + pub fn users_list(&self) -> builder::UsersList { + builder::UsersList::new(self) + } + + ///Sends a `POST` request to `/0/users` + /// + ///```ignore + /// let response = client.user_create() + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn user_create(&self) -> builder::UserCreate { + builder::UserCreate::new(self) + } + + ///Sends a `GET` request to `/0/users/{user}` + /// + ///```ignore + /// let response = client.user_get() + /// .user(user) + /// .send() + /// .await; + /// ``` + pub fn user_get(&self) -> builder::UserGet { + builder::UserGet::new(self) + } + + ///Sends a `PUT` request to `/0/users/{user}/privilege/{privilege}` + /// + ///```ignore + /// let response = client.user_privilege_grant() + /// .user(user) + /// .privilege(privilege) + /// .send() + /// .await; + /// ``` + pub fn user_privilege_grant(&self) -> builder::UserPrivilegeGrant { + builder::UserPrivilegeGrant::new(self) + } + + ///Sends a `DELETE` request to `/0/users/{user}/privilege/{privilege}` + /// + ///```ignore + /// let response = client.user_privilege_revoke() + /// .user(user) + /// .privilege(privilege) + /// .send() + /// .await; + /// ``` + pub fn user_privilege_revoke(&self) -> builder::UserPrivilegeRevoke { + builder::UserPrivilegeRevoke::new(self) + } + + ///Sends a `GET` request to `/0/whoami` + /// + ///```ignore + /// let response = client.whoami() + /// .send() + /// .await; + /// ``` + pub fn whoami(&self) -> builder::Whoami { + builder::Whoami::new(self) + } + + ///Sends a `POST` request to `/0/worker/bootstrap` + /// + ///```ignore + /// let response = client.worker_bootstrap() + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn worker_bootstrap(&self) -> builder::WorkerBootstrap { + builder::WorkerBootstrap::new(self) + } + + ///Sends a `POST` request to `/0/worker/job/{job}/chunk` + /// + ///```ignore + /// let response = client.worker_job_upload_chunk() + /// .job(job) + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn worker_job_upload_chunk(&self) -> builder::WorkerJobUploadChunk { + builder::WorkerJobUploadChunk::new(self) + } + + ///Sends a `POST` request to `/0/worker/job/{job}/complete` + /// + ///```ignore + /// let response = client.worker_job_complete() + /// .job(job) + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn worker_job_complete(&self) -> builder::WorkerJobComplete { + builder::WorkerJobComplete::new(self) + } + + ///Sends a `GET` request to `/0/worker/job/{job}/inputs/{input}` + /// + ///```ignore + /// let response = client.worker_job_input_download() + /// .job(job) + /// .input(input) + /// .send() + /// .await; + /// ``` + pub fn worker_job_input_download(&self) -> builder::WorkerJobInputDownload { + builder::WorkerJobInputDownload::new(self) + } + + ///Sends a `GET` request to `/0/worker/job/{job}/quota` + /// + ///```ignore + /// let response = client.worker_job_quota() + /// .job(job) + /// .send() + /// .await; + /// ``` + pub fn worker_job_quota(&self) -> builder::WorkerJobQuota { + builder::WorkerJobQuota::new(self) + } + + ///Sends a `GET` request to `/0/worker/job/{job}/store/{name}` + /// + ///```ignore + /// let response = client.worker_job_store_get() + /// .job(job) + /// .name(name) + /// .send() + /// .await; + /// ``` + pub fn worker_job_store_get(&self) -> builder::WorkerJobStoreGet { + builder::WorkerJobStoreGet::new(self) + } + + ///Sends a `PUT` request to `/0/worker/job/{job}/store/{name}` + /// + ///```ignore + /// let response = client.worker_job_store_put() + /// .job(job) + /// .name(name) + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn worker_job_store_put(&self) -> builder::WorkerJobStorePut { + builder::WorkerJobStorePut::new(self) + } + + ///Sends a `POST` request to `/0/worker/job/{job}/task/{task}/append` + /// + ///```ignore + /// let response = client.worker_task_append() + /// .job(job) + /// .task(task) + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn worker_task_append(&self) -> builder::WorkerTaskAppend { + builder::WorkerTaskAppend::new(self) + } + + ///Sends a `POST` request to `/0/worker/job/{job}/task/{task}/complete` + /// + ///```ignore + /// let response = client.worker_task_complete() + /// .job(job) + /// .task(task) + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn worker_task_complete(&self) -> builder::WorkerTaskComplete { + builder::WorkerTaskComplete::new(self) + } + + ///Sends a `GET` request to `/0/worker/ping` + /// + ///```ignore + /// let response = client.worker_ping() + /// .send() + /// .await; + /// ``` + pub fn worker_ping(&self) -> builder::WorkerPing { + builder::WorkerPing::new(self) + } + + ///Sends a `GET` request to `/0/workers` + /// + ///```ignore + /// let response = client.workers_list() + /// .active(active) + /// .send() + /// .await; + /// ``` + pub fn workers_list(&self) -> builder::WorkersList { + builder::WorkersList::new(self) + } + + ///Sends a `POST` request to `/0/workers/recycle` + /// + ///```ignore + /// let response = client.workers_recycle() + /// .send() + /// .await; + /// ``` + pub fn workers_recycle(&self) -> builder::WorkersRecycle { + builder::WorkersRecycle::new(self) + } + + ///Sends a `POST` request to `/1/jobs/{job}/input` + /// + ///```ignore + /// let response = client.job_add_input() + /// .job(job) + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn job_add_input(&self) -> builder::JobAddInput { + builder::JobAddInput::new(self) + } + + ///Sends a `POST` request to `/1/worker/job/{job}/append` + /// + ///```ignore + /// let response = client.worker_job_append() + /// .job(job) + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn worker_job_append(&self) -> builder::WorkerJobAppend { + builder::WorkerJobAppend::new(self) + } + + ///Sends a `POST` request to `/1/worker/job/{job}/output` + /// + ///```ignore + /// let response = client.worker_job_add_output() + /// .job(job) + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn worker_job_add_output(&self) -> builder::WorkerJobAddOutput { + builder::WorkerJobAddOutput::new(self) + } +} + +pub mod builder { + use super::types; + #[allow(unused_imports)] + use super::{ + encode_path, ByteStream, Error, HeaderMap, HeaderValue, RequestBuilderExt, ResponseValue, + }; + ///Builder for [`Client::factory_create`] + /// + ///[`Client::factory_create`]: super::Client::factory_create + #[derive(Debug, Clone)] + pub struct FactoryCreate<'a> { + client: &'a super::Client, + body: Result, + } + + impl<'a> FactoryCreate<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + body: Ok(types::builder::FactoryCreate::default()), + } + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.body = value + .try_into() + .map(From::from) + .map_err(|_| "conversion to `FactoryCreate` for body failed".to_string()); + self + } + + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::FactoryCreate) -> types::builder::FactoryCreate, + { + self.body = self.body.map(f); + self + } + + ///Sends a `POST` request to `/0/admin/factory` + pub async fn send( + self, + ) -> Result, Error> { + let Self { client, body } = self; + let body = body + .and_then(std::convert::TryInto::::try_into) + .map_err(Error::InvalidRequest)?; + let url = format!("{}/0/admin/factory", client.baseurl,); + let request = client + .client + .post(url) + .header( + reqwest::header::ACCEPT, + reqwest::header::HeaderValue::from_static("application/json"), + ) + .json(&body) + .build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 201u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::admin_jobs_get`] + /// + ///[`Client::admin_jobs_get`]: super::Client::admin_jobs_get + #[derive(Debug, Clone)] + pub struct AdminJobsGet<'a> { + client: &'a super::Client, + active: Result, String>, + completed: Result, String>, + } + + impl<'a> AdminJobsGet<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + active: Ok(None), + completed: Ok(None), + } + } + + pub fn active(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.active = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `bool` for active failed".to_string()); + self + } + + pub fn completed(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.completed = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `u64` for completed failed".to_string()); + self + } + + ///Sends a `GET` request to `/0/admin/jobs` + pub async fn send(self) -> Result>, Error> { + let Self { + client, + active, + completed, + } = self; + let active = active.map_err(Error::InvalidRequest)?; + let completed = completed.map_err(Error::InvalidRequest)?; + let url = format!("{}/0/admin/jobs", client.baseurl,); + let mut query = Vec::with_capacity(2usize); + if let Some(v) = &active { + query.push(("active", v.to_string())); + } + if let Some(v) = &completed { + query.push(("completed", v.to_string())); + } + let request = client + .client + .get(url) + .header( + reqwest::header::ACCEPT, + reqwest::header::HeaderValue::from_static("application/json"), + ) + .query(&query) + .build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::admin_job_get`] + /// + ///[`Client::admin_job_get`]: super::Client::admin_job_get + #[derive(Debug, Clone)] + pub struct AdminJobGet<'a> { + client: &'a super::Client, + job: Result, + } + + impl<'a> AdminJobGet<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + job: Err("job was not initialized".to_string()), + } + } + + pub fn job(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.job = value + .try_into() + .map_err(|_| "conversion to `String` for job failed".to_string()); + self + } + + ///Sends a `GET` request to `/0/admin/jobs/{job}` + pub async fn send(self) -> Result, Error> { + let Self { client, job } = self; + let job = job.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/0/admin/jobs/{}", + client.baseurl, + encode_path(&job.to_string()), + ); + let request = client + .client + .get(url) + .header( + reqwest::header::ACCEPT, + reqwest::header::HeaderValue::from_static("application/json"), + ) + .build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::admin_job_archive_request`] + /// + ///[`Client::admin_job_archive_request`]: super::Client::admin_job_archive_request + #[derive(Debug, Clone)] + pub struct AdminJobArchiveRequest<'a> { + client: &'a super::Client, + job: Result, + } + + impl<'a> AdminJobArchiveRequest<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + job: Err("job was not initialized".to_string()), + } + } + + pub fn job(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.job = value + .try_into() + .map_err(|_| "conversion to `String` for job failed".to_string()); + self + } + + ///Sends a `POST` request to `/0/admin/jobs/{job}/archive` + pub async fn send(self) -> Result, Error> { + let Self { client, job } = self; + let job = job.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/0/admin/jobs/{}/archive", + client.baseurl, + encode_path(&job.to_string()), + ); + let request = client + .client + .post(url) + .header( + reqwest::header::ACCEPT, + reqwest::header::HeaderValue::from_static("application/json"), + ) + .build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::target_create`] + /// + ///[`Client::target_create`]: super::Client::target_create + #[derive(Debug, Clone)] + pub struct TargetCreate<'a> { + client: &'a super::Client, + body: Result, + } + + impl<'a> TargetCreate<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + body: Ok(types::builder::TargetCreate::default()), + } + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.body = value + .try_into() + .map(From::from) + .map_err(|_| "conversion to `TargetCreate` for body failed".to_string()); + self + } + + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::TargetCreate) -> types::builder::TargetCreate, + { + self.body = self.body.map(f); + self + } + + ///Sends a `POST` request to `/0/admin/target` + pub async fn send( + self, + ) -> Result, Error> { + let Self { client, body } = self; + let body = body + .and_then(std::convert::TryInto::::try_into) + .map_err(Error::InvalidRequest)?; + let url = format!("{}/0/admin/target", client.baseurl,); + let request = client + .client + .post(url) + .header( + reqwest::header::ACCEPT, + reqwest::header::HeaderValue::from_static("application/json"), + ) + .json(&body) + .build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 201u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::targets_list`] + /// + ///[`Client::targets_list`]: super::Client::targets_list + #[derive(Debug, Clone)] + pub struct TargetsList<'a> { + client: &'a super::Client, + } + + impl<'a> TargetsList<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { client: client } + } + + ///Sends a `GET` request to `/0/admin/targets` + pub async fn send(self) -> Result>, Error> { + let Self { client } = self; + let url = format!("{}/0/admin/targets", client.baseurl,); + let request = client + .client + .get(url) + .header( + reqwest::header::ACCEPT, + reqwest::header::HeaderValue::from_static("application/json"), + ) + .build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::target_redirect`] + /// + ///[`Client::target_redirect`]: super::Client::target_redirect + #[derive(Debug, Clone)] + pub struct TargetRedirect<'a> { + client: &'a super::Client, + target: Result, + body: Result, + } + + impl<'a> TargetRedirect<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + target: Err("target was not initialized".to_string()), + body: Ok(types::builder::TargetRedirect::default()), + } + } + + pub fn target(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.target = value + .try_into() + .map_err(|_| "conversion to `String` for target failed".to_string()); + self + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.body = value + .try_into() + .map(From::from) + .map_err(|_| "conversion to `TargetRedirect` for body failed".to_string()); + self + } + + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::TargetRedirect) -> types::builder::TargetRedirect, + { + self.body = self.body.map(f); + self + } + + ///Sends a `PUT` request to `/0/admin/targets/{target}/redirect` + pub async fn send(self) -> Result, Error> { + let Self { + client, + target, + body, + } = self; + let target = target.map_err(Error::InvalidRequest)?; + let body = body + .and_then(std::convert::TryInto::::try_into) + .map_err(Error::InvalidRequest)?; + let url = format!( + "{}/0/admin/targets/{}/redirect", + client.baseurl, + encode_path(&target.to_string()), + ); + let request = client + .client + .put(url) + .header( + reqwest::header::ACCEPT, + reqwest::header::HeaderValue::from_static("application/json"), + ) + .json(&body) + .build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::target_rename`] + /// + ///[`Client::target_rename`]: super::Client::target_rename + #[derive(Debug, Clone)] + pub struct TargetRename<'a> { + client: &'a super::Client, + target: Result, + body: Result, + } + + impl<'a> TargetRename<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + target: Err("target was not initialized".to_string()), + body: Ok(types::builder::TargetRename::default()), + } + } + + pub fn target(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.target = value + .try_into() + .map_err(|_| "conversion to `String` for target failed".to_string()); + self + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.body = value + .try_into() + .map(From::from) + .map_err(|_| "conversion to `TargetRename` for body failed".to_string()); + self + } + + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::TargetRename) -> types::builder::TargetRename, + { + self.body = self.body.map(f); + self + } + + ///Sends a `POST` request to `/0/admin/targets/{target}/rename` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + target, + body, + } = self; + let target = target.map_err(Error::InvalidRequest)?; + let body = body + .and_then(std::convert::TryInto::::try_into) + .map_err(Error::InvalidRequest)?; + let url = format!( + "{}/0/admin/targets/{}/rename", + client.baseurl, + encode_path(&target.to_string()), + ); + let request = client + .client + .post(url) + .header( + reqwest::header::ACCEPT, + reqwest::header::HeaderValue::from_static("application/json"), + ) + .json(&body) + .build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 201u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::target_require_no_privilege`] + /// + ///[`Client::target_require_no_privilege`]: super::Client::target_require_no_privilege + #[derive(Debug, Clone)] + pub struct TargetRequireNoPrivilege<'a> { + client: &'a super::Client, + target: Result, + } + + impl<'a> TargetRequireNoPrivilege<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + target: Err("target was not initialized".to_string()), + } + } + + pub fn target(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.target = value + .try_into() + .map_err(|_| "conversion to `String` for target failed".to_string()); + self + } + + ///Sends a `DELETE` request to `/0/admin/targets/{target}/require` + pub async fn send(self) -> Result, Error> { + let Self { client, target } = self; + let target = target.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/0/admin/targets/{}/require", + client.baseurl, + encode_path(&target.to_string()), + ); + let request = client + .client + .delete(url) + .header( + reqwest::header::ACCEPT, + reqwest::header::HeaderValue::from_static("application/json"), + ) + .build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::target_require_privilege`] + /// + ///[`Client::target_require_privilege`]: super::Client::target_require_privilege + #[derive(Debug, Clone)] + pub struct TargetRequirePrivilege<'a> { + client: &'a super::Client, + target: Result, + privilege: Result, + } + + impl<'a> TargetRequirePrivilege<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + target: Err("target was not initialized".to_string()), + privilege: Err("privilege was not initialized".to_string()), + } + } + + pub fn target(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.target = value + .try_into() + .map_err(|_| "conversion to `String` for target failed".to_string()); + self + } + + pub fn privilege(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.privilege = value + .try_into() + .map_err(|_| "conversion to `String` for privilege failed".to_string()); + self + } + + ///Sends a `PUT` request to + /// `/0/admin/targets/{target}/require/{privilege}` + pub async fn send(self) -> Result, Error> { + let Self { + client, + target, + privilege, + } = self; + let target = target.map_err(Error::InvalidRequest)?; + let privilege = privilege.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/0/admin/targets/{}/require/{}", + client.baseurl, + encode_path(&target.to_string()), + encode_path(&privilege.to_string()), + ); + let request = client + .client + .put(url) + .header( + reqwest::header::ACCEPT, + reqwest::header::HeaderValue::from_static("application/json"), + ) + .build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::worker_recycle`] + /// + ///[`Client::worker_recycle`]: super::Client::worker_recycle + #[derive(Debug, Clone)] + pub struct WorkerRecycle<'a> { + client: &'a super::Client, + worker: Result, + } + + impl<'a> WorkerRecycle<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + worker: Err("worker was not initialized".to_string()), + } + } + + pub fn worker(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.worker = value + .try_into() + .map_err(|_| "conversion to `String` for worker failed".to_string()); + self + } + + ///Sends a `POST` request to `/0/admin/worker/{worker}/recycle` + pub async fn send(self) -> Result, Error> { + let Self { client, worker } = self; + let worker = worker.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/0/admin/worker/{}/recycle", + client.baseurl, + encode_path(&worker.to_string()), + ); + let request = client + .client + .post(url) + .header( + reqwest::header::ACCEPT, + reqwest::header::HeaderValue::from_static("application/json"), + ) + .build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::control_hold`] + /// + ///[`Client::control_hold`]: super::Client::control_hold + #[derive(Debug, Clone)] + pub struct ControlHold<'a> { + client: &'a super::Client, + } + + impl<'a> ControlHold<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { client: client } + } + + ///Sends a `POST` request to `/0/control/hold` + pub async fn send(self) -> Result, Error> { + let Self { client } = self; + let url = format!("{}/0/control/hold", client.baseurl,); + let request = client + .client + .post(url) + .header( + reqwest::header::ACCEPT, + reqwest::header::HeaderValue::from_static("application/json"), + ) + .build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::control_resume`] + /// + ///[`Client::control_resume`]: super::Client::control_resume + #[derive(Debug, Clone)] + pub struct ControlResume<'a> { + client: &'a super::Client, + } + + impl<'a> ControlResume<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { client: client } + } + + ///Sends a `POST` request to `/0/control/resume` + pub async fn send(self) -> Result, Error> { + let Self { client } = self; + let url = format!("{}/0/control/resume", client.baseurl,); + let request = client + .client + .post(url) + .header( + reqwest::header::ACCEPT, + reqwest::header::HeaderValue::from_static("application/json"), + ) + .build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::factory_lease`] + /// + ///[`Client::factory_lease`]: super::Client::factory_lease + #[derive(Debug, Clone)] + pub struct FactoryLease<'a> { + client: &'a super::Client, + body: Result, + } + + impl<'a> FactoryLease<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + body: Ok(types::builder::FactoryWhatsNext::default()), + } + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.body = value + .try_into() + .map(From::from) + .map_err(|_| "conversion to `FactoryWhatsNext` for body failed".to_string()); + self + } + + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce( + types::builder::FactoryWhatsNext, + ) -> types::builder::FactoryWhatsNext, + { + self.body = self.body.map(f); + self + } + + ///Sends a `POST` request to `/0/factory/lease` + pub async fn send( + self, + ) -> Result, Error> { + let Self { client, body } = self; + let body = body + .and_then(std::convert::TryInto::::try_into) + .map_err(Error::InvalidRequest)?; + let url = format!("{}/0/factory/lease", client.baseurl,); + let request = client + .client + .post(url) + .header( + reqwest::header::ACCEPT, + reqwest::header::HeaderValue::from_static("application/json"), + ) + .json(&body) + .build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::factory_lease_renew`] + /// + ///[`Client::factory_lease_renew`]: super::Client::factory_lease_renew + #[derive(Debug, Clone)] + pub struct FactoryLeaseRenew<'a> { + client: &'a super::Client, + job: Result, + } + + impl<'a> FactoryLeaseRenew<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + job: Err("job was not initialized".to_string()), + } + } + + pub fn job(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.job = value + .try_into() + .map_err(|_| "conversion to `String` for job failed".to_string()); + self + } + + ///Sends a `POST` request to `/0/factory/lease/{job}` + pub async fn send(self) -> Result, Error> { + let Self { client, job } = self; + let job = job.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/0/factory/lease/{}", + client.baseurl, + encode_path(&job.to_string()), + ); + let request = client + .client + .post(url) + .header( + reqwest::header::ACCEPT, + reqwest::header::HeaderValue::from_static("application/json"), + ) + .build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::factory_ping`] + /// + ///[`Client::factory_ping`]: super::Client::factory_ping + #[derive(Debug, Clone)] + pub struct FactoryPing<'a> { + client: &'a super::Client, + } + + impl<'a> FactoryPing<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { client: client } + } + + ///Sends a `GET` request to `/0/factory/ping` + pub async fn send( + self, + ) -> Result, Error> { + let Self { client } = self; + let url = format!("{}/0/factory/ping", client.baseurl,); + let request = client + .client + .get(url) + .header( + reqwest::header::ACCEPT, + reqwest::header::HeaderValue::from_static("application/json"), + ) + .build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::factory_worker_create`] + /// + ///[`Client::factory_worker_create`]: super::Client::factory_worker_create + #[derive(Debug, Clone)] + pub struct FactoryWorkerCreate<'a> { + client: &'a super::Client, + body: Result, + } + + impl<'a> FactoryWorkerCreate<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + body: Ok(types::builder::FactoryWorkerCreate::default()), + } + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.body = value + .try_into() + .map(From::from) + .map_err(|_| "conversion to `FactoryWorkerCreate` for body failed".to_string()); + self + } + + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce( + types::builder::FactoryWorkerCreate, + ) -> types::builder::FactoryWorkerCreate, + { + self.body = self.body.map(f); + self + } + + ///Sends a `POST` request to `/0/factory/worker` + pub async fn send( + self, + ) -> Result, Error> { + let Self { client, body } = self; + let body = body + .and_then(std::convert::TryInto::::try_into) + .map_err(Error::InvalidRequest)?; + let url = format!("{}/0/factory/worker", client.baseurl,); + let request = client + .client + .post(url) + .header( + reqwest::header::ACCEPT, + reqwest::header::HeaderValue::from_static("application/json"), + ) + .json(&body) + .build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 201u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::factory_worker_get`] + /// + ///[`Client::factory_worker_get`]: super::Client::factory_worker_get + #[derive(Debug, Clone)] + pub struct FactoryWorkerGet<'a> { + client: &'a super::Client, + worker: Result, + } + + impl<'a> FactoryWorkerGet<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + worker: Err("worker was not initialized".to_string()), + } + } + + pub fn worker(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.worker = value + .try_into() + .map_err(|_| "conversion to `String` for worker failed".to_string()); + self + } + + ///Sends a `GET` request to `/0/factory/worker/{worker}` + pub async fn send( + self, + ) -> Result, Error> { + let Self { client, worker } = self; + let worker = worker.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/0/factory/worker/{}", + client.baseurl, + encode_path(&worker.to_string()), + ); + let request = client + .client + .get(url) + .header( + reqwest::header::ACCEPT, + reqwest::header::HeaderValue::from_static("application/json"), + ) + .build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::factory_worker_destroy`] + /// + ///[`Client::factory_worker_destroy`]: super::Client::factory_worker_destroy + #[derive(Debug, Clone)] + pub struct FactoryWorkerDestroy<'a> { + client: &'a super::Client, + worker: Result, + } + + impl<'a> FactoryWorkerDestroy<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + worker: Err("worker was not initialized".to_string()), + } + } + + pub fn worker(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.worker = value + .try_into() + .map_err(|_| "conversion to `String` for worker failed".to_string()); + self + } + + ///Sends a `DELETE` request to `/0/factory/worker/{worker}` + pub async fn send(self) -> Result, Error> { + let Self { client, worker } = self; + let worker = worker.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/0/factory/worker/{}", + client.baseurl, + encode_path(&worker.to_string()), + ); + let request = client + .client + .delete(url) + .header( + reqwest::header::ACCEPT, + reqwest::header::HeaderValue::from_static("application/json"), + ) + .build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::factory_worker_associate`] + /// + ///[`Client::factory_worker_associate`]: super::Client::factory_worker_associate + #[derive(Debug, Clone)] + pub struct FactoryWorkerAssociate<'a> { + client: &'a super::Client, + worker: Result, + body: Result, + } + + impl<'a> FactoryWorkerAssociate<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + worker: Err("worker was not initialized".to_string()), + body: Ok(types::builder::FactoryWorkerAssociate::default()), + } + } + + pub fn worker(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.worker = value + .try_into() + .map_err(|_| "conversion to `String` for worker failed".to_string()); + self + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.body = value + .try_into() + .map(From::from) + .map_err(|_| "conversion to `FactoryWorkerAssociate` for body failed".to_string()); + self + } + + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce( + types::builder::FactoryWorkerAssociate, + ) -> types::builder::FactoryWorkerAssociate, + { + self.body = self.body.map(f); + self + } + + ///Sends a `PATCH` request to `/0/factory/worker/{worker}` + pub async fn send(self) -> Result, Error> { + let Self { + client, + worker, + body, + } = self; + let worker = worker.map_err(Error::InvalidRequest)?; + let body = body + .and_then(std::convert::TryInto::::try_into) + .map_err(Error::InvalidRequest)?; + let url = format!( + "{}/0/factory/worker/{}", + client.baseurl, + encode_path(&worker.to_string()), + ); + let request = client + .client + .patch(url) + .header( + reqwest::header::ACCEPT, + reqwest::header::HeaderValue::from_static("application/json"), + ) + .json(&body) + .build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::factory_worker_append`] + /// + ///[`Client::factory_worker_append`]: super::Client::factory_worker_append + #[derive(Debug, Clone)] + pub struct FactoryWorkerAppend<'a> { + client: &'a super::Client, + worker: Result, + body: Result, + } + + impl<'a> FactoryWorkerAppend<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + worker: Err("worker was not initialized".to_string()), + body: Ok(types::builder::FactoryWorkerAppend::default()), + } + } + + pub fn worker(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.worker = value + .try_into() + .map_err(|_| "conversion to `String` for worker failed".to_string()); + self + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.body = value + .try_into() + .map(From::from) + .map_err(|_| "conversion to `FactoryWorkerAppend` for body failed".to_string()); + self + } + + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce( + types::builder::FactoryWorkerAppend, + ) -> types::builder::FactoryWorkerAppend, + { + self.body = self.body.map(f); + self + } + + ///Sends a `POST` request to `/0/factory/worker/{worker}/append` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + worker, + body, + } = self; + let worker = worker.map_err(Error::InvalidRequest)?; + let body = body + .and_then(std::convert::TryInto::::try_into) + .map_err(Error::InvalidRequest)?; + let url = format!( + "{}/0/factory/worker/{}/append", + client.baseurl, + encode_path(&worker.to_string()), + ); + let request = client + .client + .post(url) + .header( + reqwest::header::ACCEPT, + reqwest::header::HeaderValue::from_static("application/json"), + ) + .json(&body) + .build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::factory_worker_flush`] + /// + ///[`Client::factory_worker_flush`]: super::Client::factory_worker_flush + #[derive(Debug, Clone)] + pub struct FactoryWorkerFlush<'a> { + client: &'a super::Client, + worker: Result, + } + + impl<'a> FactoryWorkerFlush<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + worker: Err("worker was not initialized".to_string()), + } } - impl Default for Worker { - fn default() -> Self { - Self { - deleted: Err("no value supplied for deleted".to_string()), - id: Err("no value supplied for id".to_string()), - instance_id: Ok(Default::default()), - lastping: Ok(Default::default()), - recycle: Err("no value supplied for recycle".to_string()), - tasks: Err("no value supplied for tasks".to_string()), - } + pub fn worker(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.worker = value + .try_into() + .map_err(|_| "conversion to `String` for worker failed".to_string()); + self + } + + ///Sends a `POST` request to `/0/factory/worker/{worker}/flush` + pub async fn send(self) -> Result, Error> { + let Self { client, worker } = self; + let worker = worker.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/0/factory/worker/{}/flush", + client.baseurl, + encode_path(&worker.to_string()), + ); + let request = client + .client + .post(url) + .header( + reqwest::header::ACCEPT, + reqwest::header::HeaderValue::from_static("application/json"), + ) + .build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), } } + } - impl Worker { - pub fn deleted(mut self, value: T) -> Self - where - T: std::convert::TryInto, - T::Error: std::fmt::Display, - { - self.deleted = value - .try_into() - .map_err(|e| format!("error converting supplied value for deleted: {}", e)); - self + ///Builder for [`Client::factory_workers`] + /// + ///[`Client::factory_workers`]: super::Client::factory_workers + #[derive(Debug, Clone)] + pub struct FactoryWorkers<'a> { + client: &'a super::Client, + } + + impl<'a> FactoryWorkers<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { client: client } + } + + ///Sends a `GET` request to `/0/factory/workers` + pub async fn send( + self, + ) -> Result>, Error> { + let Self { client } = self; + let url = format!("{}/0/factory/workers", client.baseurl,); + let request = client + .client + .get(url) + .header( + reqwest::header::ACCEPT, + reqwest::header::HeaderValue::from_static("application/json"), + ) + .build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), } - pub fn id(mut self, value: T) -> Self - where - T: std::convert::TryInto, - T::Error: std::fmt::Display, - { - self.id = value - .try_into() - .map_err(|e| format!("error converting supplied value for id: {}", e)); - self + } + } + + ///Builder for [`Client::job_get`] + /// + ///[`Client::job_get`]: super::Client::job_get + #[derive(Debug, Clone)] + pub struct JobGet<'a> { + client: &'a super::Client, + job: Result, + } + + impl<'a> JobGet<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + job: Err("job was not initialized".to_string()), } - pub fn instance_id(mut self, value: T) -> Self - where - T: std::convert::TryInto>, - T::Error: std::fmt::Display, - { - self.instance_id = value - .try_into() - .map_err(|e| format!("error converting supplied value for instance_id: {}", e)); - self + } + + pub fn job(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.job = value + .try_into() + .map_err(|_| "conversion to `String` for job failed".to_string()); + self + } + + ///Sends a `GET` request to `/0/job/{job}` + pub async fn send(self) -> Result, Error> { + let Self { client, job } = self; + let job = job.map_err(Error::InvalidRequest)?; + let url = format!("{}/0/job/{}", client.baseurl, encode_path(&job.to_string()),); + let request = client + .client + .get(url) + .header( + reqwest::header::ACCEPT, + reqwest::header::HeaderValue::from_static("application/json"), + ) + .build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), } - pub fn lastping(mut self, value: T) -> Self - where - T: std::convert::TryInto>>, - T::Error: std::fmt::Display, - { - self.lastping = value - .try_into() - .map_err(|e| format!("error converting supplied value for lastping: {}", e)); - self + } + } + + ///Builder for [`Client::jobs_get`] + /// + ///[`Client::jobs_get`]: super::Client::jobs_get + #[derive(Debug, Clone)] + pub struct JobsGet<'a> { + client: &'a super::Client, + } + + impl<'a> JobsGet<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { client: client } + } + + ///Sends a `GET` request to `/0/jobs` + pub async fn send(self) -> Result>, Error> { + let Self { client } = self; + let url = format!("{}/0/jobs", client.baseurl,); + let request = client + .client + .get(url) + .header( + reqwest::header::ACCEPT, + reqwest::header::HeaderValue::from_static("application/json"), + ) + .build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), } - pub fn recycle(mut self, value: T) -> Self - where - T: std::convert::TryInto, - T::Error: std::fmt::Display, - { - self.recycle = value - .try_into() - .map_err(|e| format!("error converting supplied value for recycle: {}", e)); - self + } + } + + ///Builder for [`Client::job_submit`] + /// + ///[`Client::job_submit`]: super::Client::job_submit + #[derive(Debug, Clone)] + pub struct JobSubmit<'a> { + client: &'a super::Client, + body: Result, + } + + impl<'a> JobSubmit<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + body: Ok(types::builder::JobSubmit::default()), } - pub fn tasks(mut self, value: T) -> Self - where - T: std::convert::TryInto>, - T::Error: std::fmt::Display, - { - self.tasks = value - .try_into() - .map_err(|e| format!("error converting supplied value for tasks: {}", e)); - self + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.body = value + .try_into() + .map(From::from) + .map_err(|_| "conversion to `JobSubmit` for body failed".to_string()); + self + } + + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::JobSubmit) -> types::builder::JobSubmit, + { + self.body = self.body.map(f); + self + } + + ///Sends a `POST` request to `/0/jobs` + pub async fn send( + self, + ) -> Result, Error> { + let Self { client, body } = self; + let body = body + .and_then(std::convert::TryInto::::try_into) + .map_err(Error::InvalidRequest)?; + let url = format!("{}/0/jobs", client.baseurl,); + let request = client + .client + .post(url) + .header( + reqwest::header::ACCEPT, + reqwest::header::HeaderValue::from_static("application/json"), + ) + .json(&body) + .build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 201u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), } } + } - impl std::convert::TryFrom for super::Worker { - type Error = String; - fn try_from(value: Worker) -> Result { - Ok(Self { - deleted: value.deleted?, - id: value.id?, - instance_id: value.instance_id?, - lastping: value.lastping?, - recycle: value.recycle?, - tasks: value.tasks?, - }) + ///Builder for [`Client::job_cancel`] + /// + ///[`Client::job_cancel`]: super::Client::job_cancel + #[derive(Debug, Clone)] + pub struct JobCancel<'a> { + client: &'a super::Client, + job: Result, + } + + impl<'a> JobCancel<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + job: Err("job was not initialized".to_string()), } } - impl From for Worker { - fn from(value: super::Worker) -> Self { - Self { - deleted: Ok(value.deleted), - id: Ok(value.id), - instance_id: Ok(value.instance_id), - lastping: Ok(value.lastping), - recycle: Ok(value.recycle), - tasks: Ok(value.tasks), - } + pub fn job(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.job = value + .try_into() + .map_err(|_| "conversion to `String` for job failed".to_string()); + self + } + + ///Sends a `POST` request to `/0/jobs/{job}/cancel` + pub async fn send(self) -> Result, Error> { + let Self { client, job } = self; + let job = job.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/0/jobs/{}/cancel", + client.baseurl, + encode_path(&job.to_string()), + ); + let request = client + .client + .post(url) + .header( + reqwest::header::ACCEPT, + reqwest::header::HeaderValue::from_static("application/json"), + ) + .build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), } } + } - #[derive(Clone, Debug)] - pub struct WorkerAddOutput { - chunks: Result, String>, - path: Result, - size: Result, - } + ///Builder for [`Client::job_upload_chunk`] + /// + ///[`Client::job_upload_chunk`]: super::Client::job_upload_chunk + #[derive(Debug)] + pub struct JobUploadChunk<'a> { + client: &'a super::Client, + job: Result, + body: Result, + } - impl Default for WorkerAddOutput { - fn default() -> Self { - Self { - chunks: Err("no value supplied for chunks".to_string()), - path: Err("no value supplied for path".to_string()), - size: Err("no value supplied for size".to_string()), - } + impl<'a> JobUploadChunk<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + job: Err("job was not initialized".to_string()), + body: Err("body was not initialized".to_string()), } } - impl WorkerAddOutput { - pub fn chunks(mut self, value: T) -> Self - where - T: std::convert::TryInto>, - T::Error: std::fmt::Display, - { - self.chunks = value - .try_into() - .map_err(|e| format!("error converting supplied value for chunks: {}", e)); - self - } - pub fn path(mut self, value: T) -> Self - where - T: std::convert::TryInto, - T::Error: std::fmt::Display, - { - self.path = value - .try_into() - .map_err(|e| format!("error converting supplied value for path: {}", e)); - self - } - pub fn size(mut self, value: T) -> Self - where - T: std::convert::TryInto, - T::Error: std::fmt::Display, - { - self.size = value - .try_into() - .map_err(|e| format!("error converting supplied value for size: {}", e)); - self - } + pub fn job(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.job = value + .try_into() + .map_err(|_| "conversion to `String` for job failed".to_string()); + self } - impl std::convert::TryFrom for super::WorkerAddOutput { - type Error = String; - fn try_from(value: WorkerAddOutput) -> Result { - Ok(Self { - chunks: value.chunks?, - path: value.path?, - size: value.size?, - }) - } + pub fn body(mut self, value: B) -> Self + where + B: std::convert::TryInto, + { + self.body = value + .try_into() + .map_err(|_| "conversion to `reqwest::Body` for body failed".to_string()); + self } - impl From for WorkerAddOutput { - fn from(value: super::WorkerAddOutput) -> Self { - Self { - chunks: Ok(value.chunks), - path: Ok(value.path), - size: Ok(value.size), - } + ///Sends a `POST` request to `/0/jobs/{job}/chunk` + pub async fn send( + self, + ) -> Result, Error> { + let Self { client, job, body } = self; + let job = job.map_err(Error::InvalidRequest)?; + let body = body.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/0/jobs/{}/chunk", + client.baseurl, + encode_path(&job.to_string()), + ); + let request = client + .client + .post(url) + .header( + reqwest::header::ACCEPT, + reqwest::header::HeaderValue::from_static("application/json"), + ) + .header( + reqwest::header::CONTENT_TYPE, + reqwest::header::HeaderValue::from_static("application/octet-stream"), + ) + .body(body) + .build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 201u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), } } + } - #[derive(Clone, Debug)] - pub struct WorkerAppendTask { - payload: Result, - stream: Result, - time: Result, String>, - } + ///Builder for [`Client::job_events_get`] + /// + ///[`Client::job_events_get`]: super::Client::job_events_get + #[derive(Debug, Clone)] + pub struct JobEventsGet<'a> { + client: &'a super::Client, + job: Result, + minseq: Result, String>, + } - impl Default for WorkerAppendTask { - fn default() -> Self { - Self { - payload: Err("no value supplied for payload".to_string()), - stream: Err("no value supplied for stream".to_string()), - time: Err("no value supplied for time".to_string()), - } + impl<'a> JobEventsGet<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + job: Err("job was not initialized".to_string()), + minseq: Ok(None), } } - impl WorkerAppendTask { - pub fn payload(mut self, value: T) -> Self - where - T: std::convert::TryInto, - T::Error: std::fmt::Display, - { - self.payload = value - .try_into() - .map_err(|e| format!("error converting supplied value for payload: {}", e)); - self - } - pub fn stream(mut self, value: T) -> Self - where - T: std::convert::TryInto, - T::Error: std::fmt::Display, - { - self.stream = value - .try_into() - .map_err(|e| format!("error converting supplied value for stream: {}", e)); - self - } - pub fn time(mut self, value: T) -> Self - where - T: std::convert::TryInto>, - T::Error: std::fmt::Display, - { - self.time = value - .try_into() - .map_err(|e| format!("error converting supplied value for time: {}", e)); - self - } + pub fn job(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.job = value + .try_into() + .map_err(|_| "conversion to `String` for job failed".to_string()); + self } - impl std::convert::TryFrom for super::WorkerAppendTask { - type Error = String; - fn try_from(value: WorkerAppendTask) -> Result { - Ok(Self { - payload: value.payload?, - stream: value.stream?, - time: value.time?, - }) - } + pub fn minseq(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.minseq = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `u32` for minseq failed".to_string()); + self } - impl From for WorkerAppendTask { - fn from(value: super::WorkerAppendTask) -> Self { - Self { - payload: Ok(value.payload), - stream: Ok(value.stream), - time: Ok(value.time), - } + ///Sends a `GET` request to `/0/jobs/{job}/events` + pub async fn send( + self, + ) -> Result>, Error> { + let Self { + client, + job, + minseq, + } = self; + let job = job.map_err(Error::InvalidRequest)?; + let minseq = minseq.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/0/jobs/{}/events", + client.baseurl, + encode_path(&job.to_string()), + ); + let mut query = Vec::with_capacity(1usize); + if let Some(v) = &minseq { + query.push(("minseq", v.to_string())); + } + let request = client + .client + .get(url) + .header( + reqwest::header::ACCEPT, + reqwest::header::HeaderValue::from_static("application/json"), + ) + .query(&query) + .build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), } } + } - #[derive(Clone, Debug)] - pub struct WorkerBootstrap { - bootstrap: Result, - token: Result, - } + ///Builder for [`Client::job_outputs_get`] + /// + ///[`Client::job_outputs_get`]: super::Client::job_outputs_get + #[derive(Debug, Clone)] + pub struct JobOutputsGet<'a> { + client: &'a super::Client, + job: Result, + } - impl Default for WorkerBootstrap { - fn default() -> Self { - Self { - bootstrap: Err("no value supplied for bootstrap".to_string()), - token: Err("no value supplied for token".to_string()), - } + impl<'a> JobOutputsGet<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + job: Err("job was not initialized".to_string()), } } - impl WorkerBootstrap { - pub fn bootstrap(mut self, value: T) -> Self - where - T: std::convert::TryInto, - T::Error: std::fmt::Display, - { - self.bootstrap = value - .try_into() - .map_err(|e| format!("error converting supplied value for bootstrap: {}", e)); - self - } - pub fn token(mut self, value: T) -> Self - where - T: std::convert::TryInto, - T::Error: std::fmt::Display, - { - self.token = value - .try_into() - .map_err(|e| format!("error converting supplied value for token: {}", e)); - self - } + pub fn job(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.job = value + .try_into() + .map_err(|_| "conversion to `String` for job failed".to_string()); + self } - impl std::convert::TryFrom for super::WorkerBootstrap { - type Error = String; - fn try_from(value: WorkerBootstrap) -> Result { - Ok(Self { - bootstrap: value.bootstrap?, - token: value.token?, - }) + ///Sends a `GET` request to `/0/jobs/{job}/outputs` + pub async fn send( + self, + ) -> Result>, Error> { + let Self { client, job } = self; + let job = job.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/0/jobs/{}/outputs", + client.baseurl, + encode_path(&job.to_string()), + ); + let request = client + .client + .get(url) + .header( + reqwest::header::ACCEPT, + reqwest::header::HeaderValue::from_static("application/json"), + ) + .build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), } } + } - impl From for WorkerBootstrap { - fn from(value: super::WorkerBootstrap) -> Self { - Self { - bootstrap: Ok(value.bootstrap), - token: Ok(value.token), - } + ///Builder for [`Client::job_output_download`] + /// + ///[`Client::job_output_download`]: super::Client::job_output_download + #[derive(Debug, Clone)] + pub struct JobOutputDownload<'a> { + client: &'a super::Client, + job: Result, + output: Result, + } + + impl<'a> JobOutputDownload<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + job: Err("job was not initialized".to_string()), + output: Err("output was not initialized".to_string()), } } - #[derive(Clone, Debug)] - pub struct WorkerBootstrapResult { - id: Result, + pub fn job(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.job = value + .try_into() + .map_err(|_| "conversion to `String` for job failed".to_string()); + self } - impl Default for WorkerBootstrapResult { - fn default() -> Self { - Self { - id: Err("no value supplied for id".to_string()), - } - } + pub fn output(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.output = value + .try_into() + .map_err(|_| "conversion to `String` for output failed".to_string()); + self } - impl WorkerBootstrapResult { - pub fn id(mut self, value: T) -> Self - where - T: std::convert::TryInto, - T::Error: std::fmt::Display, - { - self.id = value - .try_into() - .map_err(|e| format!("error converting supplied value for id: {}", e)); - self + ///Sends a `GET` request to `/0/jobs/{job}/outputs/{output}` + pub async fn send(self) -> Result, Error> { + let Self { + client, + job, + output, + } = self; + let job = job.map_err(Error::InvalidRequest)?; + let output = output.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/0/jobs/{}/outputs/{}", + client.baseurl, + encode_path(&job.to_string()), + encode_path(&output.to_string()), + ); + let request = client.client.get(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200..=299 => Ok(ResponseValue::stream(response)), + _ => Err(Error::ErrorResponse(ResponseValue::stream(response))), } } + } - impl std::convert::TryFrom for super::WorkerBootstrapResult { - type Error = String; - fn try_from(value: WorkerBootstrapResult) -> Result { - Ok(Self { id: value.id? }) + ///Builder for [`Client::job_output_publish`] + /// + ///[`Client::job_output_publish`]: super::Client::job_output_publish + #[derive(Debug, Clone)] + pub struct JobOutputPublish<'a> { + client: &'a super::Client, + job: Result, + output: Result, + body: Result, + } + + impl<'a> JobOutputPublish<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + job: Err("job was not initialized".to_string()), + output: Err("output was not initialized".to_string()), + body: Ok(types::builder::JobOutputPublish::default()), } } - impl From for WorkerBootstrapResult { - fn from(value: super::WorkerBootstrapResult) -> Self { - Self { id: Ok(value.id) } - } + pub fn job(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.job = value + .try_into() + .map_err(|_| "conversion to `String` for job failed".to_string()); + self } - #[derive(Clone, Debug)] - pub struct WorkerCompleteTask { - failed: Result, + pub fn output(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.output = value + .try_into() + .map_err(|_| "conversion to `String` for output failed".to_string()); + self } - impl Default for WorkerCompleteTask { - fn default() -> Self { - Self { - failed: Err("no value supplied for failed".to_string()), - } - } + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.body = value + .try_into() + .map(From::from) + .map_err(|_| "conversion to `JobOutputPublish` for body failed".to_string()); + self } - impl WorkerCompleteTask { - pub fn failed(mut self, value: T) -> Self - where - T: std::convert::TryInto, - T::Error: std::fmt::Display, - { - self.failed = value - .try_into() - .map_err(|e| format!("error converting supplied value for failed: {}", e)); - self - } + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce( + types::builder::JobOutputPublish, + ) -> types::builder::JobOutputPublish, + { + self.body = self.body.map(f); + self } - impl std::convert::TryFrom for super::WorkerCompleteTask { - type Error = String; - fn try_from(value: WorkerCompleteTask) -> Result { - Ok(Self { - failed: value.failed?, - }) + ///Sends a `POST` request to `/0/jobs/{job}/outputs/{output}/publish` + pub async fn send(self) -> Result, Error> { + let Self { + client, + job, + output, + body, + } = self; + let job = job.map_err(Error::InvalidRequest)?; + let output = output.map_err(Error::InvalidRequest)?; + let body = body + .and_then(std::convert::TryInto::::try_into) + .map_err(Error::InvalidRequest)?; + let url = format!( + "{}/0/jobs/{}/outputs/{}/publish", + client.baseurl, + encode_path(&job.to_string()), + encode_path(&output.to_string()), + ); + let request = client + .client + .post(url) + .header( + reqwest::header::ACCEPT, + reqwest::header::HeaderValue::from_static("application/json"), + ) + .json(&body) + .build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), } } + } - impl From for WorkerCompleteTask { - fn from(value: super::WorkerCompleteTask) -> Self { - Self { - failed: Ok(value.failed), - } + ///Builder for [`Client::job_output_signed_url`] + /// + ///[`Client::job_output_signed_url`]: super::Client::job_output_signed_url + #[derive(Debug, Clone)] + pub struct JobOutputSignedUrl<'a> { + client: &'a super::Client, + job: Result, + output: Result, + body: Result, + } + + impl<'a> JobOutputSignedUrl<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + job: Err("job was not initialized".to_string()), + output: Err("output was not initialized".to_string()), + body: Ok(types::builder::JobOutputSignedUrl::default()), } } - #[derive(Clone, Debug)] - pub struct WorkerPingResult { - poweroff: Result, - task: Result, String>, + pub fn job(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.job = value + .try_into() + .map_err(|_| "conversion to `String` for job failed".to_string()); + self } - impl Default for WorkerPingResult { - fn default() -> Self { - Self { - poweroff: Err("no value supplied for poweroff".to_string()), - task: Ok(Default::default()), - } - } + pub fn output(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.output = value + .try_into() + .map_err(|_| "conversion to `String` for output failed".to_string()); + self } - impl WorkerPingResult { - pub fn poweroff(mut self, value: T) -> Self - where - T: std::convert::TryInto, - T::Error: std::fmt::Display, - { - self.poweroff = value - .try_into() - .map_err(|e| format!("error converting supplied value for poweroff: {}", e)); - self - } - pub fn task(mut self, value: T) -> Self - where - T: std::convert::TryInto>, - T::Error: std::fmt::Display, - { - self.task = value - .try_into() - .map_err(|e| format!("error converting supplied value for task: {}", e)); - self - } + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.body = value + .try_into() + .map(From::from) + .map_err(|_| "conversion to `JobOutputSignedUrl` for body failed".to_string()); + self + } + + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce( + types::builder::JobOutputSignedUrl, + ) -> types::builder::JobOutputSignedUrl, + { + self.body = self.body.map(f); + self } - impl std::convert::TryFrom for super::WorkerPingResult { - type Error = String; - fn try_from(value: WorkerPingResult) -> Result { - Ok(Self { - poweroff: value.poweroff?, - task: value.task?, - }) + ///Sends a `POST` request to `/0/jobs/{job}/outputs/{output}/sign` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + job, + output, + body, + } = self; + let job = job.map_err(Error::InvalidRequest)?; + let output = output.map_err(Error::InvalidRequest)?; + let body = body + .and_then(std::convert::TryInto::::try_into) + .map_err(Error::InvalidRequest)?; + let url = format!( + "{}/0/jobs/{}/outputs/{}/sign", + client.baseurl, + encode_path(&job.to_string()), + encode_path(&output.to_string()), + ); + let request = client + .client + .post(url) + .header( + reqwest::header::ACCEPT, + reqwest::header::HeaderValue::from_static("application/json"), + ) + .json(&body) + .build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), } } + } - impl From for WorkerPingResult { - fn from(value: super::WorkerPingResult) -> Self { - Self { - poweroff: Ok(value.poweroff), - task: Ok(value.task), - } + ///Builder for [`Client::job_store_get_all`] + /// + ///[`Client::job_store_get_all`]: super::Client::job_store_get_all + #[derive(Debug, Clone)] + pub struct JobStoreGetAll<'a> { + client: &'a super::Client, + job: Result, + } + + impl<'a> JobStoreGetAll<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + job: Err("job was not initialized".to_string()), } } - #[derive(Clone, Debug)] - pub struct WorkerPingTask { - id: Result, - output_rules: Result, String>, - script: Result, + pub fn job(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.job = value + .try_into() + .map_err(|_| "conversion to `String` for job failed".to_string()); + self } - impl Default for WorkerPingTask { - fn default() -> Self { - Self { - id: Err("no value supplied for id".to_string()), - output_rules: Err("no value supplied for output_rules".to_string()), - script: Err("no value supplied for script".to_string()), - } + ///Sends a `GET` request to `/0/jobs/{job}/store` + pub async fn send( + self, + ) -> Result< + ResponseValue>, + Error, + > { + let Self { client, job } = self; + let job = job.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/0/jobs/{}/store", + client.baseurl, + encode_path(&job.to_string()), + ); + let request = client + .client + .get(url) + .header( + reqwest::header::ACCEPT, + reqwest::header::HeaderValue::from_static("application/json"), + ) + .build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), } } + } - impl WorkerPingTask { - pub fn id(mut self, value: T) -> Self - where - T: std::convert::TryInto, - T::Error: std::fmt::Display, - { - self.id = value - .try_into() - .map_err(|e| format!("error converting supplied value for id: {}", e)); - self - } - pub fn output_rules(mut self, value: T) -> Self - where - T: std::convert::TryInto>, - T::Error: std::fmt::Display, - { - self.output_rules = value.try_into().map_err(|e| { - format!("error converting supplied value for output_rules: {}", e) - }); - self - } - pub fn script(mut self, value: T) -> Self - where - T: std::convert::TryInto, - T::Error: std::fmt::Display, - { - self.script = value - .try_into() - .map_err(|e| format!("error converting supplied value for script: {}", e)); - self - } - } + ///Builder for [`Client::job_store_put`] + /// + ///[`Client::job_store_put`]: super::Client::job_store_put + #[derive(Debug, Clone)] + pub struct JobStorePut<'a> { + client: &'a super::Client, + job: Result, + name: Result, + body: Result, + } - impl std::convert::TryFrom for super::WorkerPingTask { - type Error = String; - fn try_from(value: WorkerPingTask) -> Result { - Ok(Self { - id: value.id?, - output_rules: value.output_rules?, - script: value.script?, - }) + impl<'a> JobStorePut<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + job: Err("job was not initialized".to_string()), + name: Err("name was not initialized".to_string()), + body: Ok(types::builder::JobStoreValue::default()), } } - impl From for WorkerPingTask { - fn from(value: super::WorkerPingTask) -> Self { - Self { - id: Ok(value.id), - output_rules: Ok(value.output_rules), - script: Ok(value.script), - } - } + pub fn job(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.job = value + .try_into() + .map_err(|_| "conversion to `String` for job failed".to_string()); + self } - #[derive(Clone, Debug)] - pub struct WorkerTask { - id: Result, - name: Result, - owner: Result, + pub fn name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.name = value + .try_into() + .map_err(|_| "conversion to `String` for name failed".to_string()); + self } - impl Default for WorkerTask { - fn default() -> Self { - Self { - id: Err("no value supplied for id".to_string()), - name: Err("no value supplied for name".to_string()), - owner: Err("no value supplied for owner".to_string()), - } - } + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.body = value + .try_into() + .map(From::from) + .map_err(|_| "conversion to `JobStoreValue` for body failed".to_string()); + self } - impl WorkerTask { - pub fn id(mut self, value: T) -> Self - where - T: std::convert::TryInto, - T::Error: std::fmt::Display, - { - self.id = value - .try_into() - .map_err(|e| format!("error converting supplied value for id: {}", e)); - self - } - pub fn name(mut self, value: T) -> Self - where - T: std::convert::TryInto, - T::Error: std::fmt::Display, - { - self.name = value - .try_into() - .map_err(|e| format!("error converting supplied value for name: {}", e)); - self - } - pub fn owner(mut self, value: T) -> Self - where - T: std::convert::TryInto, - T::Error: std::fmt::Display, - { - self.owner = value - .try_into() - .map_err(|e| format!("error converting supplied value for owner: {}", e)); - self - } + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::JobStoreValue) -> types::builder::JobStoreValue, + { + self.body = self.body.map(f); + self } - impl std::convert::TryFrom for super::WorkerTask { - type Error = String; - fn try_from(value: WorkerTask) -> Result { - Ok(Self { - id: value.id?, - name: value.name?, - owner: value.owner?, - }) + ///Sends a `PUT` request to `/0/jobs/{job}/store/{name}` + pub async fn send(self) -> Result, Error> { + let Self { + client, + job, + name, + body, + } = self; + let job = job.map_err(Error::InvalidRequest)?; + let name = name.map_err(Error::InvalidRequest)?; + let body = body + .and_then(std::convert::TryInto::::try_into) + .map_err(Error::InvalidRequest)?; + let url = format!( + "{}/0/jobs/{}/store/{}", + client.baseurl, + encode_path(&job.to_string()), + encode_path(&name.to_string()), + ); + let request = client + .client + .put(url) + .header( + reqwest::header::ACCEPT, + reqwest::header::HeaderValue::from_static("application/json"), + ) + .json(&body) + .build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), } } + } - impl From for WorkerTask { - fn from(value: super::WorkerTask) -> Self { - Self { - id: Ok(value.id), - name: Ok(value.name), - owner: Ok(value.owner), - } + ///Builder for [`Client::public_file_download`] + /// + ///[`Client::public_file_download`]: super::Client::public_file_download + #[derive(Debug, Clone)] + pub struct PublicFileDownload<'a> { + client: &'a super::Client, + username: Result, + series: Result, + version: Result, + name: Result, + } + + impl<'a> PublicFileDownload<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + username: Err("username was not initialized".to_string()), + series: Err("series was not initialized".to_string()), + version: Err("version was not initialized".to_string()), + name: Err("name was not initialized".to_string()), } } - #[derive(Clone, Debug)] - pub struct WorkersResult { - workers: Result, String>, + pub fn username(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.username = value + .try_into() + .map_err(|_| "conversion to `String` for username failed".to_string()); + self } - - impl Default for WorkersResult { - fn default() -> Self { - Self { - workers: Err("no value supplied for workers".to_string()), - } - } + + pub fn series(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.series = value + .try_into() + .map_err(|_| "conversion to `String` for series failed".to_string()); + self } - impl WorkersResult { - pub fn workers(mut self, value: T) -> Self - where - T: std::convert::TryInto>, - T::Error: std::fmt::Display, - { - self.workers = value - .try_into() - .map_err(|e| format!("error converting supplied value for workers: {}", e)); - self - } + pub fn version(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.version = value + .try_into() + .map_err(|_| "conversion to `String` for version failed".to_string()); + self } - impl std::convert::TryFrom for super::WorkersResult { - type Error = String; - fn try_from(value: WorkersResult) -> Result { - Ok(Self { - workers: value.workers?, - }) - } + pub fn name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.name = value + .try_into() + .map_err(|_| "conversion to `String` for name failed".to_string()); + self } - impl From for WorkersResult { - fn from(value: super::WorkersResult) -> Self { - Self { - workers: Ok(value.workers), - } + ///Sends a `GET` request to + /// `/0/public/file/{username}/{series}/{version}/{name}` + pub async fn send(self) -> Result, Error> { + let Self { + client, + username, + series, + version, + name, + } = self; + let username = username.map_err(Error::InvalidRequest)?; + let series = series.map_err(Error::InvalidRequest)?; + let version = version.map_err(Error::InvalidRequest)?; + let name = name.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/0/public/file/{}/{}/{}/{}", + client.baseurl, + encode_path(&username.to_string()), + encode_path(&series.to_string()), + encode_path(&version.to_string()), + encode_path(&name.to_string()), + ); + let request = client.client.get(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200..=299 => Ok(ResponseValue::stream(response)), + _ => Err(Error::ErrorResponse(ResponseValue::stream(response))), } } } -} - -#[derive(Clone, Debug)] -///Client for Buildomat -/// -///Version: 1.0 -pub struct Client { - pub(crate) baseurl: String, - pub(crate) client: reqwest::Client, -} -impl Client { - /// Create a new client. + ///Builder for [`Client::quota`] /// - /// `baseurl` is the base URL provided to the internal - /// `reqwest::Client`, and should include a scheme and hostname, - /// as well as port and a path stem if applicable. - pub fn new(baseurl: &str) -> Self { - #[cfg(not(target_arch = "wasm32"))] - let client = { - let dur = std::time::Duration::from_secs(15); - reqwest::ClientBuilder::new() - .connect_timeout(dur) - .timeout(dur) - }; - #[cfg(target_arch = "wasm32")] - let client = reqwest::ClientBuilder::new(); - Self::new_with_client(baseurl, client.build().unwrap()) + ///[`Client::quota`]: super::Client::quota + #[derive(Debug, Clone)] + pub struct Quota<'a> { + client: &'a super::Client, } - /// Construct a new client with an existing `reqwest::Client`, - /// allowing more control over its configuration. - /// - /// `baseurl` is the base URL provided to the internal - /// `reqwest::Client`, and should include a scheme and hostname, - /// as well as port and a path stem if applicable. - pub fn new_with_client(baseurl: &str, client: reqwest::Client) -> Self { - Self { - baseurl: baseurl.to_string(), - client, + impl<'a> Quota<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { client: client } } - } - - /// Get the base URL to which requests are made. - pub fn baseurl(&self) -> &String { - &self.baseurl - } - /// Get the internal `reqwest::Client` used to make requests. - pub fn client(&self) -> &reqwest::Client { - &self.client + ///Sends a `GET` request to `/0/quota` + pub async fn send(self) -> Result, Error> { + let Self { client } = self; + let url = format!("{}/0/quota", client.baseurl,); + let request = client + .client + .get(url) + .header( + reqwest::header::ACCEPT, + reqwest::header::HeaderValue::from_static("application/json"), + ) + .build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } } - /// Get the version of this API. + ///Builder for [`Client::users_list`] /// - /// This string is pulled directly from the source OpenAPI - /// document and may be in any format the API selects. - pub fn api_version(&self) -> &'static str { - "1.0" + ///[`Client::users_list`]: super::Client::users_list + #[derive(Debug, Clone)] + pub struct UsersList<'a> { + client: &'a super::Client, + name: Result, String>, } -} -impl Client { - ///Sends a `POST` request to `/v1/control/hold` - /// - ///```ignore - /// let response = client.control_hold() - /// .send() - /// .await; - /// ``` - pub fn control_hold(&self) -> builder::ControlHold { - builder::ControlHold::new(self) - } + impl<'a> UsersList<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + name: Ok(None), + } + } - ///Sends a `POST` request to `/v1/control/resume` - /// - ///```ignore - /// let response = client.control_resume() - /// .send() - /// .await; - /// ``` - pub fn control_resume(&self) -> builder::ControlResume { - builder::ControlResume::new(self) - } + pub fn name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.name = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `String` for name failed".to_string()); + self + } - ///Sends a `GET` request to `/v1/task/{task}` - /// - ///```ignore - /// let response = client.task_get() - /// .task(task) - /// .send() - /// .await; - /// ``` - pub fn task_get(&self) -> builder::TaskGet { - builder::TaskGet::new(self) + ///Sends a `GET` request to `/0/users` + pub async fn send(self) -> Result>, Error> { + let Self { client, name } = self; + let name = name.map_err(Error::InvalidRequest)?; + let url = format!("{}/0/users", client.baseurl,); + let mut query = Vec::with_capacity(1usize); + if let Some(v) = &name { + query.push(("name", v.to_string())); + } + let request = client + .client + .get(url) + .header( + reqwest::header::ACCEPT, + reqwest::header::HeaderValue::from_static("application/json"), + ) + .query(&query) + .build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } } - ///Sends a `GET` request to `/v1/tasks` + ///Builder for [`Client::user_create`] /// - ///```ignore - /// let response = client.tasks_get() - /// .send() - /// .await; - /// ``` - pub fn tasks_get(&self) -> builder::TasksGet { - builder::TasksGet::new(self) + ///[`Client::user_create`]: super::Client::user_create + #[derive(Debug, Clone)] + pub struct UserCreate<'a> { + client: &'a super::Client, + body: Result, } - ///Sends a `POST` request to `/v1/tasks` - /// - ///```ignore - /// let response = client.task_submit() - /// .body(body) - /// .send() - /// .await; - /// ``` - pub fn task_submit(&self) -> builder::TaskSubmit { - builder::TaskSubmit::new(self) - } + impl<'a> UserCreate<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + body: Ok(types::builder::UserCreate::default()), + } + } - ///Sends a `GET` request to `/v1/tasks/{task}/events` - /// - ///```ignore - /// let response = client.task_events_get() - /// .task(task) - /// .minseq(minseq) - /// .send() - /// .await; - /// ``` - pub fn task_events_get(&self) -> builder::TaskEventsGet { - builder::TaskEventsGet::new(self) - } + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.body = value + .try_into() + .map(From::from) + .map_err(|_| "conversion to `UserCreate` for body failed".to_string()); + self + } - ///Sends a `GET` request to `/v1/tasks/{task}/outputs` - /// - ///```ignore - /// let response = client.task_outputs_get() - /// .task(task) - /// .send() - /// .await; - /// ``` - pub fn task_outputs_get(&self) -> builder::TaskOutputsGet { - builder::TaskOutputsGet::new(self) - } + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::UserCreate) -> types::builder::UserCreate, + { + self.body = self.body.map(f); + self + } - ///Sends a `GET` request to `/v1/tasks/{task}/outputs/{output}` - /// - ///```ignore - /// let response = client.task_output_download() - /// .task(task) - /// .output(output) - /// .send() - /// .await; - /// ``` - pub fn task_output_download(&self) -> builder::TaskOutputDownload { - builder::TaskOutputDownload::new(self) + ///Sends a `POST` request to `/0/users` + pub async fn send( + self, + ) -> Result, Error> { + let Self { client, body } = self; + let body = body + .and_then(std::convert::TryInto::::try_into) + .map_err(Error::InvalidRequest)?; + let url = format!("{}/0/users", client.baseurl,); + let request = client + .client + .post(url) + .header( + reqwest::header::ACCEPT, + reqwest::header::HeaderValue::from_static("application/json"), + ) + .json(&body) + .build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 201u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } } - ///Sends a `POST` request to `/v1/users` + ///Builder for [`Client::user_get`] /// - ///```ignore - /// let response = client.user_create() - /// .body(body) - /// .send() - /// .await; - /// ``` - pub fn user_create(&self) -> builder::UserCreate { - builder::UserCreate::new(self) + ///[`Client::user_get`]: super::Client::user_get + #[derive(Debug, Clone)] + pub struct UserGet<'a> { + client: &'a super::Client, + user: Result, } - ///Sends a `GET` request to `/v1/whoami` - /// - ///```ignore - /// let response = client.whoami() - /// .send() - /// .await; - /// ``` - pub fn whoami(&self) -> builder::Whoami { - builder::Whoami::new(self) - } + impl<'a> UserGet<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + user: Err("user was not initialized".to_string()), + } + } - ///Sends a `PUT` request to `/v1/whoami/name` - /// - ///```ignore - /// let response = client.whoami_put_name() - /// .body(body) - /// .send() - /// .await; - /// ``` - pub fn whoami_put_name(&self) -> builder::WhoamiPutName { - builder::WhoamiPutName::new(self) - } + pub fn user(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.user = value + .try_into() + .map_err(|_| "conversion to `String` for user failed".to_string()); + self + } - ///Sends a `POST` request to `/v1/worker/bootstrap` - /// - ///```ignore - /// let response = client.worker_bootstrap() - /// .body(body) - /// .send() - /// .await; - /// ``` - pub fn worker_bootstrap(&self) -> builder::WorkerBootstrap { - builder::WorkerBootstrap::new(self) + ///Sends a `GET` request to `/0/users/{user}` + pub async fn send(self) -> Result, Error> { + let Self { client, user } = self; + let user = user.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/0/users/{}", + client.baseurl, + encode_path(&user.to_string()), + ); + let request = client + .client + .get(url) + .header( + reqwest::header::ACCEPT, + reqwest::header::HeaderValue::from_static("application/json"), + ) + .build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } } - ///Sends a `GET` request to `/v1/worker/ping` + ///Builder for [`Client::user_privilege_grant`] /// - ///```ignore - /// let response = client.worker_ping() - /// .send() - /// .await; - /// ``` - pub fn worker_ping(&self) -> builder::WorkerPing { - builder::WorkerPing::new(self) + ///[`Client::user_privilege_grant`]: super::Client::user_privilege_grant + #[derive(Debug, Clone)] + pub struct UserPrivilegeGrant<'a> { + client: &'a super::Client, + user: Result, + privilege: Result, } - ///Sends a `POST` request to `/v1/worker/task/{task}/append` - /// - ///```ignore - /// let response = client.worker_task_append() - /// .task(task) - /// .body(body) - /// .send() - /// .await; - /// ``` - pub fn worker_task_append(&self) -> builder::WorkerTaskAppend { - builder::WorkerTaskAppend::new(self) - } + impl<'a> UserPrivilegeGrant<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + user: Err("user was not initialized".to_string()), + privilege: Err("privilege was not initialized".to_string()), + } + } - ///Sends a `POST` request to `/v1/worker/task/{task}/chunk` - /// - ///```ignore - /// let response = client.worker_task_upload_chunk() - /// .task(task) - /// .body(body) - /// .send() - /// .await; - /// ``` - pub fn worker_task_upload_chunk(&self) -> builder::WorkerTaskUploadChunk { - builder::WorkerTaskUploadChunk::new(self) - } + pub fn user(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.user = value + .try_into() + .map_err(|_| "conversion to `String` for user failed".to_string()); + self + } - ///Sends a `POST` request to `/v1/worker/task/{task}/complete` - /// - ///```ignore - /// let response = client.worker_task_complete() - /// .task(task) - /// .body(body) - /// .send() - /// .await; - /// ``` - pub fn worker_task_complete(&self) -> builder::WorkerTaskComplete { - builder::WorkerTaskComplete::new(self) - } + pub fn privilege(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.privilege = value + .try_into() + .map_err(|_| "conversion to `String` for privilege failed".to_string()); + self + } - ///Sends a `POST` request to `/v1/worker/task/{task}/output` - /// - ///```ignore - /// let response = client.worker_task_add_output() - /// .task(task) - /// .body(body) - /// .send() - /// .await; - /// ``` - pub fn worker_task_add_output(&self) -> builder::WorkerTaskAddOutput { - builder::WorkerTaskAddOutput::new(self) + ///Sends a `PUT` request to `/0/users/{user}/privilege/{privilege}` + pub async fn send(self) -> Result, Error> { + let Self { + client, + user, + privilege, + } = self; + let user = user.map_err(Error::InvalidRequest)?; + let privilege = privilege.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/0/users/{}/privilege/{}", + client.baseurl, + encode_path(&user.to_string()), + encode_path(&privilege.to_string()), + ); + let request = client + .client + .put(url) + .header( + reqwest::header::ACCEPT, + reqwest::header::HeaderValue::from_static("application/json"), + ) + .build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } } - ///Sends a `GET` request to `/v1/workers` + ///Builder for [`Client::user_privilege_revoke`] /// - ///```ignore - /// let response = client.workers_list() - /// .send() - /// .await; - /// ``` - pub fn workers_list(&self) -> builder::WorkersList { - builder::WorkersList::new(self) + ///[`Client::user_privilege_revoke`]: super::Client::user_privilege_revoke + #[derive(Debug, Clone)] + pub struct UserPrivilegeRevoke<'a> { + client: &'a super::Client, + user: Result, + privilege: Result, } - ///Sends a `POST` request to `/v1/workers/recycle` - /// - ///```ignore - /// let response = client.workers_recycle() - /// .send() - /// .await; - /// ``` - pub fn workers_recycle(&self) -> builder::WorkersRecycle { - builder::WorkersRecycle::new(self) + impl<'a> UserPrivilegeRevoke<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + user: Err("user was not initialized".to_string()), + privilege: Err("privilege was not initialized".to_string()), + } + } + + pub fn user(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.user = value + .try_into() + .map_err(|_| "conversion to `String` for user failed".to_string()); + self + } + + pub fn privilege(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.privilege = value + .try_into() + .map_err(|_| "conversion to `String` for privilege failed".to_string()); + self + } + + ///Sends a `DELETE` request to `/0/users/{user}/privilege/{privilege}` + pub async fn send(self) -> Result, Error> { + let Self { + client, + user, + privilege, + } = self; + let user = user.map_err(Error::InvalidRequest)?; + let privilege = privilege.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/0/users/{}/privilege/{}", + client.baseurl, + encode_path(&user.to_string()), + encode_path(&privilege.to_string()), + ); + let request = client + .client + .delete(url) + .header( + reqwest::header::ACCEPT, + reqwest::header::HeaderValue::from_static("application/json"), + ) + .build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } } -} -pub mod builder { - use super::types; - #[allow(unused_imports)] - use super::{ - encode_path, ByteStream, Error, HeaderMap, HeaderValue, RequestBuilderExt, ResponseValue, - }; - ///Builder for [`Client::control_hold`] + ///Builder for [`Client::whoami`] /// - ///[`Client::control_hold`]: super::Client::control_hold + ///[`Client::whoami`]: super::Client::whoami #[derive(Debug, Clone)] - pub struct ControlHold<'a> { + pub struct Whoami<'a> { client: &'a super::Client, } - impl<'a> ControlHold<'a> { + impl<'a> Whoami<'a> { pub fn new(client: &'a super::Client) -> Self { Self { client: client } } - ///Sends a `POST` request to `/v1/control/hold` - pub async fn send(self) -> Result, Error<()>> { + ///Sends a `GET` request to `/0/whoami` + pub async fn send(self) -> Result, Error> { let Self { client } = self; - let url = format!("{}/v1/control/hold", client.baseurl,); + let url = format!("{}/0/whoami", client.baseurl,); let request = client .client - .post(url) + .get(url) .header( reqwest::header::ACCEPT, reqwest::header::HeaderValue::from_static("application/json"), @@ -1899,168 +9095,227 @@ pub mod builder { let response = result?; match response.status().as_u16() { 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), _ => Err(Error::UnexpectedResponse(response)), } } } - ///Builder for [`Client::control_resume`] + ///Builder for [`Client::worker_bootstrap`] /// - ///[`Client::control_resume`]: super::Client::control_resume + ///[`Client::worker_bootstrap`]: super::Client::worker_bootstrap #[derive(Debug, Clone)] - pub struct ControlResume<'a> { + pub struct WorkerBootstrap<'a> { client: &'a super::Client, + body: Result, } - impl<'a> ControlResume<'a> { + impl<'a> WorkerBootstrap<'a> { pub fn new(client: &'a super::Client) -> Self { - Self { client: client } + Self { + client: client, + body: Ok(types::builder::WorkerBootstrap::default()), + } + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.body = value + .try_into() + .map(From::from) + .map_err(|_| "conversion to `WorkerBootstrap` for body failed".to_string()); + self + } + + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::WorkerBootstrap) -> types::builder::WorkerBootstrap, + { + self.body = self.body.map(f); + self } - ///Sends a `POST` request to `/v1/control/resume` - pub async fn send(self) -> Result, Error<()>> { - let Self { client } = self; - let url = format!("{}/v1/control/resume", client.baseurl,); - let request = client.client.post(url).build()?; + ///Sends a `POST` request to `/0/worker/bootstrap` + pub async fn send( + self, + ) -> Result, Error> { + let Self { client, body } = self; + let body = body + .and_then(std::convert::TryInto::::try_into) + .map_err(Error::InvalidRequest)?; + let url = format!("{}/0/worker/bootstrap", client.baseurl,); + let request = client + .client + .post(url) + .header( + reqwest::header::ACCEPT, + reqwest::header::HeaderValue::from_static("application/json"), + ) + .json(&body) + .build()?; let result = client.client.execute(request).await; let response = result?; match response.status().as_u16() { - 200u16 => Ok(ResponseValue::empty(response)), + 201u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), _ => Err(Error::UnexpectedResponse(response)), } } } - ///Builder for [`Client::task_get`] + ///Builder for [`Client::worker_job_upload_chunk`] /// - ///[`Client::task_get`]: super::Client::task_get - #[derive(Debug, Clone)] - pub struct TaskGet<'a> { + ///[`Client::worker_job_upload_chunk`]: super::Client::worker_job_upload_chunk + #[derive(Debug)] + pub struct WorkerJobUploadChunk<'a> { client: &'a super::Client, - task: Result, + job: Result, + body: Result, } - impl<'a> TaskGet<'a> { + impl<'a> WorkerJobUploadChunk<'a> { pub fn new(client: &'a super::Client) -> Self { Self { client: client, - task: Err("task was not initialized".to_string()), + job: Err("job was not initialized".to_string()), + body: Err("body was not initialized".to_string()), } } - pub fn task(mut self, value: V) -> Self + pub fn job(mut self, value: V) -> Self where V: std::convert::TryInto, { - self.task = value + self.job = value .try_into() - .map_err(|_| "conversion to `String` for task failed".to_string()); + .map_err(|_| "conversion to `String` for job failed".to_string()); self } - ///Sends a `GET` request to `/v1/task/{task}` - pub async fn send(self) -> Result, Error<()>> { - let Self { client, task } = self; - let task = task.map_err(Error::InvalidRequest)?; + pub fn body(mut self, value: B) -> Self + where + B: std::convert::TryInto, + { + self.body = value + .try_into() + .map_err(|_| "conversion to `reqwest::Body` for body failed".to_string()); + self + } + + ///Sends a `POST` request to `/0/worker/job/{job}/chunk` + pub async fn send( + self, + ) -> Result, Error> { + let Self { client, job, body } = self; + let job = job.map_err(Error::InvalidRequest)?; + let body = body.map_err(Error::InvalidRequest)?; let url = format!( - "{}/v1/task/{}", + "{}/0/worker/job/{}/chunk", client.baseurl, - encode_path(&task.to_string()), + encode_path(&job.to_string()), ); let request = client .client - .get(url) + .post(url) .header( reqwest::header::ACCEPT, reqwest::header::HeaderValue::from_static("application/json"), ) - .build()?; - let result = client.client.execute(request).await; - let response = result?; - match response.status().as_u16() { - 200u16 => ResponseValue::from_response(response).await, - _ => Err(Error::UnexpectedResponse(response)), - } - } - } - - ///Builder for [`Client::tasks_get`] - /// - ///[`Client::tasks_get`]: super::Client::tasks_get - #[derive(Debug, Clone)] - pub struct TasksGet<'a> { - client: &'a super::Client, - } - - impl<'a> TasksGet<'a> { - pub fn new(client: &'a super::Client) -> Self { - Self { client: client } - } - - ///Sends a `GET` request to `/v1/tasks` - pub async fn send(self) -> Result>, Error<()>> { - let Self { client } = self; - let url = format!("{}/v1/tasks", client.baseurl,); - let request = client - .client - .get(url) .header( - reqwest::header::ACCEPT, - reqwest::header::HeaderValue::from_static("application/json"), + reqwest::header::CONTENT_TYPE, + reqwest::header::HeaderValue::from_static("application/octet-stream"), ) + .body(body) .build()?; let result = client.client.execute(request).await; let response = result?; match response.status().as_u16() { - 200u16 => ResponseValue::from_response(response).await, + 201u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), _ => Err(Error::UnexpectedResponse(response)), } } } - ///Builder for [`Client::task_submit`] + ///Builder for [`Client::worker_job_complete`] /// - ///[`Client::task_submit`]: super::Client::task_submit + ///[`Client::worker_job_complete`]: super::Client::worker_job_complete #[derive(Debug, Clone)] - pub struct TaskSubmit<'a> { + pub struct WorkerJobComplete<'a> { client: &'a super::Client, - body: Result, + job: Result, + body: Result, } - impl<'a> TaskSubmit<'a> { + impl<'a> WorkerJobComplete<'a> { pub fn new(client: &'a super::Client) -> Self { Self { client: client, - body: Ok(types::builder::TaskSubmit::default()), + job: Err("job was not initialized".to_string()), + body: Ok(types::builder::WorkerCompleteJob::default()), } } + pub fn job(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.job = value + .try_into() + .map_err(|_| "conversion to `String` for job failed".to_string()); + self + } + pub fn body(mut self, value: V) -> Self where - V: std::convert::TryInto, + V: std::convert::TryInto, { self.body = value .try_into() .map(From::from) - .map_err(|_| "conversion to `TaskSubmit` for body failed".to_string()); + .map_err(|_| "conversion to `WorkerCompleteJob` for body failed".to_string()); self } pub fn body_map(mut self, f: F) -> Self where - F: std::ops::FnOnce(types::builder::TaskSubmit) -> types::builder::TaskSubmit, + F: std::ops::FnOnce( + types::builder::WorkerCompleteJob, + ) -> types::builder::WorkerCompleteJob, { self.body = self.body.map(f); self } - ///Sends a `POST` request to `/v1/tasks` - pub async fn send(self) -> Result, Error<()>> { - let Self { client, body } = self; + ///Sends a `POST` request to `/0/worker/job/{job}/complete` + pub async fn send(self) -> Result, Error> { + let Self { client, job, body } = self; + let job = job.map_err(Error::InvalidRequest)?; let body = body - .and_then(std::convert::TryInto::::try_into) + .and_then(std::convert::TryInto::::try_into) .map_err(Error::InvalidRequest)?; - let url = format!("{}/v1/tasks", client.baseurl,); + let url = format!( + "{}/0/worker/job/{}/complete", + client.baseurl, + encode_path(&job.to_string()), + ); let request = client .client .post(url) @@ -2073,123 +9328,115 @@ pub mod builder { let result = client.client.execute(request).await; let response = result?; match response.status().as_u16() { - 201u16 => ResponseValue::from_response(response).await, + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), _ => Err(Error::UnexpectedResponse(response)), } } } - ///Builder for [`Client::task_events_get`] + ///Builder for [`Client::worker_job_input_download`] /// - ///[`Client::task_events_get`]: super::Client::task_events_get + ///[`Client::worker_job_input_download`]: super::Client::worker_job_input_download #[derive(Debug, Clone)] - pub struct TaskEventsGet<'a> { + pub struct WorkerJobInputDownload<'a> { client: &'a super::Client, - task: Result, - minseq: Result, String>, + job: Result, + input: Result, } - impl<'a> TaskEventsGet<'a> { + impl<'a> WorkerJobInputDownload<'a> { pub fn new(client: &'a super::Client) -> Self { Self { client: client, - task: Err("task was not initialized".to_string()), - minseq: Ok(None), + job: Err("job was not initialized".to_string()), + input: Err("input was not initialized".to_string()), } } - pub fn task(mut self, value: V) -> Self + pub fn job(mut self, value: V) -> Self where V: std::convert::TryInto, { - self.task = value + self.job = value .try_into() - .map_err(|_| "conversion to `String` for task failed".to_string()); + .map_err(|_| "conversion to `String` for job failed".to_string()); self } - pub fn minseq(mut self, value: V) -> Self + pub fn input(mut self, value: V) -> Self where - V: std::convert::TryInto, + V: std::convert::TryInto, { - self.minseq = value + self.input = value .try_into() - .map(Some) - .map_err(|_| "conversion to `u32` for minseq failed".to_string()); + .map_err(|_| "conversion to `String` for input failed".to_string()); self } - ///Sends a `GET` request to `/v1/tasks/{task}/events` - pub async fn send(self) -> Result>, Error<()>> { - let Self { - client, - task, - minseq, - } = self; - let task = task.map_err(Error::InvalidRequest)?; - let minseq = minseq.map_err(Error::InvalidRequest)?; + ///Sends a `GET` request to `/0/worker/job/{job}/inputs/{input}` + pub async fn send(self) -> Result, Error> { + let Self { client, job, input } = self; + let job = job.map_err(Error::InvalidRequest)?; + let input = input.map_err(Error::InvalidRequest)?; let url = format!( - "{}/v1/tasks/{}/events", + "{}/0/worker/job/{}/inputs/{}", client.baseurl, - encode_path(&task.to_string()), + encode_path(&job.to_string()), + encode_path(&input.to_string()), ); - let mut query = Vec::with_capacity(1usize); - if let Some(v) = &minseq { - query.push(("minseq", v.to_string())); - } - let request = client - .client - .get(url) - .header( - reqwest::header::ACCEPT, - reqwest::header::HeaderValue::from_static("application/json"), - ) - .query(&query) - .build()?; + let request = client.client.get(url).build()?; let result = client.client.execute(request).await; let response = result?; match response.status().as_u16() { - 200u16 => ResponseValue::from_response(response).await, - _ => Err(Error::UnexpectedResponse(response)), + 200..=299 => Ok(ResponseValue::stream(response)), + _ => Err(Error::ErrorResponse(ResponseValue::stream(response))), } } } - ///Builder for [`Client::task_outputs_get`] + ///Builder for [`Client::worker_job_quota`] /// - ///[`Client::task_outputs_get`]: super::Client::task_outputs_get + ///[`Client::worker_job_quota`]: super::Client::worker_job_quota #[derive(Debug, Clone)] - pub struct TaskOutputsGet<'a> { + pub struct WorkerJobQuota<'a> { client: &'a super::Client, - task: Result, + job: Result, } - impl<'a> TaskOutputsGet<'a> { + impl<'a> WorkerJobQuota<'a> { pub fn new(client: &'a super::Client) -> Self { Self { client: client, - task: Err("task was not initialized".to_string()), + job: Err("job was not initialized".to_string()), } } - pub fn task(mut self, value: V) -> Self + pub fn job(mut self, value: V) -> Self where V: std::convert::TryInto, { - self.task = value + self.job = value .try_into() - .map_err(|_| "conversion to `String` for task failed".to_string()); + .map_err(|_| "conversion to `String` for job failed".to_string()); self } - ///Sends a `GET` request to `/v1/tasks/{task}/outputs` - pub async fn send(self) -> Result>, Error<()>> { - let Self { client, task } = self; - let task = task.map_err(Error::InvalidRequest)?; + ///Sends a `GET` request to `/0/worker/job/{job}/quota` + pub async fn send( + self, + ) -> Result, Error> { + let Self { client, job } = self; + let job = job.map_err(Error::InvalidRequest)?; let url = format!( - "{}/v1/tasks/{}/outputs", + "{}/0/worker/job/{}/quota", client.baseurl, - encode_path(&task.to_string()), + encode_path(&job.to_string()), ); let request = client .client @@ -2203,121 +9450,176 @@ pub mod builder { let response = result?; match response.status().as_u16() { 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), _ => Err(Error::UnexpectedResponse(response)), } } } - ///Builder for [`Client::task_output_download`] + ///Builder for [`Client::worker_job_store_get`] /// - ///[`Client::task_output_download`]: super::Client::task_output_download + ///[`Client::worker_job_store_get`]: super::Client::worker_job_store_get #[derive(Debug, Clone)] - pub struct TaskOutputDownload<'a> { + pub struct WorkerJobStoreGet<'a> { client: &'a super::Client, - task: Result, - output: Result, + job: Result, + name: Result, } - impl<'a> TaskOutputDownload<'a> { + impl<'a> WorkerJobStoreGet<'a> { pub fn new(client: &'a super::Client) -> Self { Self { client: client, - task: Err("task was not initialized".to_string()), - output: Err("output was not initialized".to_string()), + job: Err("job was not initialized".to_string()), + name: Err("name was not initialized".to_string()), } } - pub fn task(mut self, value: V) -> Self + pub fn job(mut self, value: V) -> Self where V: std::convert::TryInto, { - self.task = value + self.job = value .try_into() - .map_err(|_| "conversion to `String` for task failed".to_string()); + .map_err(|_| "conversion to `String` for job failed".to_string()); self } - pub fn output(mut self, value: V) -> Self + pub fn name(mut self, value: V) -> Self where V: std::convert::TryInto, { - self.output = value + self.name = value .try_into() - .map_err(|_| "conversion to `String` for output failed".to_string()); + .map_err(|_| "conversion to `String` for name failed".to_string()); self } - ///Sends a `GET` request to `/v1/tasks/{task}/outputs/{output}` - pub async fn send(self) -> Result, Error<()>> { - let Self { - client, - task, - output, - } = self; - let task = task.map_err(Error::InvalidRequest)?; - let output = output.map_err(Error::InvalidRequest)?; + ///Sends a `GET` request to `/0/worker/job/{job}/store/{name}` + pub async fn send( + self, + ) -> Result, Error> { + let Self { client, job, name } = self; + let job = job.map_err(Error::InvalidRequest)?; + let name = name.map_err(Error::InvalidRequest)?; let url = format!( - "{}/v1/tasks/{}/outputs/{}", + "{}/0/worker/job/{}/store/{}", client.baseurl, - encode_path(&task.to_string()), - encode_path(&output.to_string()), + encode_path(&job.to_string()), + encode_path(&name.to_string()), ); - let request = client.client.get(url).build()?; + let request = client + .client + .get(url) + .header( + reqwest::header::ACCEPT, + reqwest::header::HeaderValue::from_static("application/json"), + ) + .build()?; let result = client.client.execute(request).await; let response = result?; match response.status().as_u16() { - 200..=299 => Ok(ResponseValue::stream(response)), + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), _ => Err(Error::UnexpectedResponse(response)), } } } - ///Builder for [`Client::user_create`] + ///Builder for [`Client::worker_job_store_put`] /// - ///[`Client::user_create`]: super::Client::user_create + ///[`Client::worker_job_store_put`]: super::Client::worker_job_store_put #[derive(Debug, Clone)] - pub struct UserCreate<'a> { + pub struct WorkerJobStorePut<'a> { client: &'a super::Client, - body: Result, + job: Result, + name: Result, + body: Result, } - impl<'a> UserCreate<'a> { + impl<'a> WorkerJobStorePut<'a> { pub fn new(client: &'a super::Client) -> Self { Self { client: client, - body: Ok(types::builder::UserCreate::default()), + job: Err("job was not initialized".to_string()), + name: Err("name was not initialized".to_string()), + body: Ok(types::builder::WorkerJobStoreValue::default()), } } + pub fn job(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.job = value + .try_into() + .map_err(|_| "conversion to `String` for job failed".to_string()); + self + } + + pub fn name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.name = value + .try_into() + .map_err(|_| "conversion to `String` for name failed".to_string()); + self + } + pub fn body(mut self, value: V) -> Self where - V: std::convert::TryInto, + V: std::convert::TryInto, { self.body = value .try_into() .map(From::from) - .map_err(|_| "conversion to `UserCreate` for body failed".to_string()); + .map_err(|_| "conversion to `WorkerJobStoreValue` for body failed".to_string()); self } pub fn body_map(mut self, f: F) -> Self where - F: std::ops::FnOnce(types::builder::UserCreate) -> types::builder::UserCreate, + F: std::ops::FnOnce( + types::builder::WorkerJobStoreValue, + ) -> types::builder::WorkerJobStoreValue, { self.body = self.body.map(f); self } - ///Sends a `POST` request to `/v1/users` - pub async fn send(self) -> Result, Error<()>> { - let Self { client, body } = self; + ///Sends a `PUT` request to `/0/worker/job/{job}/store/{name}` + pub async fn send(self) -> Result, Error> { + let Self { + client, + job, + name, + body, + } = self; + let job = job.map_err(Error::InvalidRequest)?; + let name = name.map_err(Error::InvalidRequest)?; let body = body - .and_then(std::convert::TryInto::::try_into) + .and_then(std::convert::TryInto::::try_into) .map_err(Error::InvalidRequest)?; - let url = format!("{}/v1/users", client.baseurl,); + let url = format!( + "{}/0/worker/job/{}/store/{}", + client.baseurl, + encode_path(&job.to_string()), + encode_path(&name.to_string()), + ); let request = client .client - .post(url) + .put(url) .header( reqwest::header::ACCEPT, reqwest::header::HeaderValue::from_static("application/json"), @@ -2327,140 +9629,202 @@ pub mod builder { let result = client.client.execute(request).await; let response = result?; match response.status().as_u16() { - 201u16 => ResponseValue::from_response(response).await, + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), _ => Err(Error::UnexpectedResponse(response)), } } } - ///Builder for [`Client::whoami`] + ///Builder for [`Client::worker_task_append`] /// - ///[`Client::whoami`]: super::Client::whoami + ///[`Client::worker_task_append`]: super::Client::worker_task_append #[derive(Debug, Clone)] - pub struct Whoami<'a> { + pub struct WorkerTaskAppend<'a> { client: &'a super::Client, + job: Result, + task: Result, + body: Result, } - impl<'a> Whoami<'a> { + impl<'a> WorkerTaskAppend<'a> { pub fn new(client: &'a super::Client) -> Self { - Self { client: client } - } - - ///Sends a `GET` request to `/v1/whoami` - pub async fn send(self) -> Result, Error<()>> { - let Self { client } = self; - let url = format!("{}/v1/whoami", client.baseurl,); - let request = client - .client - .get(url) - .header( - reqwest::header::ACCEPT, - reqwest::header::HeaderValue::from_static("application/json"), - ) - .build()?; - let result = client.client.execute(request).await; - let response = result?; - match response.status().as_u16() { - 200u16 => ResponseValue::from_response(response).await, - _ => Err(Error::UnexpectedResponse(response)), + Self { + client: client, + job: Err("job was not initialized".to_string()), + task: Err("task was not initialized".to_string()), + body: Ok(types::builder::WorkerAppendJob::default()), } } - } - ///Builder for [`Client::whoami_put_name`] - /// - ///[`Client::whoami_put_name`]: super::Client::whoami_put_name - #[derive(Debug)] - pub struct WhoamiPutName<'a> { - client: &'a super::Client, - body: Result, - } + pub fn job(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.job = value + .try_into() + .map_err(|_| "conversion to `String` for job failed".to_string()); + self + } - impl<'a> WhoamiPutName<'a> { - pub fn new(client: &'a super::Client) -> Self { - Self { - client: client, - body: Err("body was not initialized".to_string()), - } + pub fn task(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.task = value + .try_into() + .map_err(|_| "conversion to `u32` for task failed".to_string()); + self } pub fn body(mut self, value: V) -> Self where - V: std::convert::TryInto, + V: std::convert::TryInto, { self.body = value .try_into() - .map_err(|_| "conversion to `String` for body failed".to_string()) - .map(|v| v.into()); + .map(From::from) + .map_err(|_| "conversion to `WorkerAppendJob` for body failed".to_string()); self } - ///Sends a `PUT` request to `/v1/whoami/name` - pub async fn send(self) -> Result, Error<()>> { - let Self { client, body } = self; - let body = body.map_err(Error::InvalidRequest)?; - let url = format!("{}/v1/whoami/name", client.baseurl,); + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::WorkerAppendJob) -> types::builder::WorkerAppendJob, + { + self.body = self.body.map(f); + self + } + + ///Sends a `POST` request to `/0/worker/job/{job}/task/{task}/append` + pub async fn send(self) -> Result, Error> { + let Self { + client, + job, + task, + body, + } = self; + let job = job.map_err(Error::InvalidRequest)?; + let task = task.map_err(Error::InvalidRequest)?; + let body = body + .and_then(std::convert::TryInto::::try_into) + .map_err(Error::InvalidRequest)?; + let url = format!( + "{}/0/worker/job/{}/task/{}/append", + client.baseurl, + encode_path(&job.to_string()), + encode_path(&task.to_string()), + ); let request = client .client - .put(url) + .post(url) .header( - reqwest::header::CONTENT_TYPE, - reqwest::header::HeaderValue::from_static("text/plain"), + reqwest::header::ACCEPT, + reqwest::header::HeaderValue::from_static("application/json"), ) - .body(body) + .json(&body) .build()?; let result = client.client.execute(request).await; let response = result?; match response.status().as_u16() { - 200u16 => Ok(ResponseValue::empty(response)), + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), _ => Err(Error::UnexpectedResponse(response)), } } } - ///Builder for [`Client::worker_bootstrap`] + ///Builder for [`Client::worker_task_complete`] /// - ///[`Client::worker_bootstrap`]: super::Client::worker_bootstrap + ///[`Client::worker_task_complete`]: super::Client::worker_task_complete #[derive(Debug, Clone)] - pub struct WorkerBootstrap<'a> { + pub struct WorkerTaskComplete<'a> { client: &'a super::Client, - body: Result, + job: Result, + task: Result, + body: Result, } - impl<'a> WorkerBootstrap<'a> { + impl<'a> WorkerTaskComplete<'a> { pub fn new(client: &'a super::Client) -> Self { Self { client: client, - body: Ok(types::builder::WorkerBootstrap::default()), + job: Err("job was not initialized".to_string()), + task: Err("task was not initialized".to_string()), + body: Ok(types::builder::WorkerCompleteTask::default()), } } + pub fn job(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.job = value + .try_into() + .map_err(|_| "conversion to `String` for job failed".to_string()); + self + } + + pub fn task(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.task = value + .try_into() + .map_err(|_| "conversion to `u32` for task failed".to_string()); + self + } + pub fn body(mut self, value: V) -> Self where - V: std::convert::TryInto, + V: std::convert::TryInto, { self.body = value .try_into() .map(From::from) - .map_err(|_| "conversion to `WorkerBootstrap` for body failed".to_string()); + .map_err(|_| "conversion to `WorkerCompleteTask` for body failed".to_string()); self } pub fn body_map(mut self, f: F) -> Self where - F: std::ops::FnOnce(types::builder::WorkerBootstrap) -> types::builder::WorkerBootstrap, + F: std::ops::FnOnce( + types::builder::WorkerCompleteTask, + ) -> types::builder::WorkerCompleteTask, { self.body = self.body.map(f); self } - ///Sends a `POST` request to `/v1/worker/bootstrap` - pub async fn send(self) -> Result, Error<()>> { - let Self { client, body } = self; + ///Sends a `POST` request to `/0/worker/job/{job}/task/{task}/complete` + pub async fn send(self) -> Result, Error> { + let Self { + client, + job, + task, + body, + } = self; + let job = job.map_err(Error::InvalidRequest)?; + let task = task.map_err(Error::InvalidRequest)?; let body = body - .and_then(std::convert::TryInto::::try_into) + .and_then(std::convert::TryInto::::try_into) .map_err(Error::InvalidRequest)?; - let url = format!("{}/v1/worker/bootstrap", client.baseurl,); + let url = format!( + "{}/0/worker/job/{}/task/{}/complete", + client.baseurl, + encode_path(&job.to_string()), + encode_path(&task.to_string()), + ); let request = client .client .post(url) @@ -2473,7 +9837,13 @@ pub mod builder { let result = client.client.execute(request).await; let response = result?; match response.status().as_u16() { - 201u16 => ResponseValue::from_response(response).await, + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), _ => Err(Error::UnexpectedResponse(response)), } } @@ -2492,10 +9862,12 @@ pub mod builder { Self { client: client } } - ///Sends a `GET` request to `/v1/worker/ping` - pub async fn send(self) -> Result, Error<()>> { + ///Sends a `GET` request to `/0/worker/ping` + pub async fn send( + self, + ) -> Result, Error> { let Self { client } = self; - let url = format!("{}/v1/worker/ping", client.baseurl,); + let url = format!("{}/0/worker/ping", client.baseurl,); let request = client .client .get(url) @@ -2508,131 +9880,181 @@ pub mod builder { let response = result?; match response.status().as_u16() { 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), _ => Err(Error::UnexpectedResponse(response)), } } } - ///Builder for [`Client::worker_task_append`] + ///Builder for [`Client::workers_list`] /// - ///[`Client::worker_task_append`]: super::Client::worker_task_append + ///[`Client::workers_list`]: super::Client::workers_list #[derive(Debug, Clone)] - pub struct WorkerTaskAppend<'a> { + pub struct WorkersList<'a> { client: &'a super::Client, - task: Result, - body: Result, + active: Result, String>, } - impl<'a> WorkerTaskAppend<'a> { + impl<'a> WorkersList<'a> { pub fn new(client: &'a super::Client) -> Self { Self { client: client, - task: Err("task was not initialized".to_string()), - body: Ok(types::builder::WorkerAppendTask::default()), + active: Ok(None), } } - pub fn task(mut self, value: V) -> Self + pub fn active(mut self, value: V) -> Self where - V: std::convert::TryInto, + V: std::convert::TryInto, { - self.task = value + self.active = value .try_into() - .map_err(|_| "conversion to `String` for task failed".to_string()); + .map(Some) + .map_err(|_| "conversion to `bool` for active failed".to_string()); self } - pub fn body(mut self, value: V) -> Self - where - V: std::convert::TryInto, - { - self.body = value - .try_into() - .map(From::from) - .map_err(|_| "conversion to `WorkerAppendTask` for body failed".to_string()); - self + ///Sends a `GET` request to `/0/workers` + pub async fn send( + self, + ) -> Result, Error> { + let Self { client, active } = self; + let active = active.map_err(Error::InvalidRequest)?; + let url = format!("{}/0/workers", client.baseurl,); + let mut query = Vec::with_capacity(1usize); + if let Some(v) = &active { + query.push(("active", v.to_string())); + } + let request = client + .client + .get(url) + .header( + reqwest::header::ACCEPT, + reqwest::header::HeaderValue::from_static("application/json"), + ) + .query(&query) + .build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } } + } - pub fn body_map(mut self, f: F) -> Self - where - F: std::ops::FnOnce( - types::builder::WorkerAppendTask, - ) -> types::builder::WorkerAppendTask, - { - self.body = self.body.map(f); - self + ///Builder for [`Client::workers_recycle`] + /// + ///[`Client::workers_recycle`]: super::Client::workers_recycle + #[derive(Debug, Clone)] + pub struct WorkersRecycle<'a> { + client: &'a super::Client, + } + + impl<'a> WorkersRecycle<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { client: client } } - ///Sends a `POST` request to `/v1/worker/task/{task}/append` - pub async fn send(self) -> Result, Error<()>> { - let Self { client, task, body } = self; - let task = task.map_err(Error::InvalidRequest)?; - let body = body - .and_then(std::convert::TryInto::::try_into) - .map_err(Error::InvalidRequest)?; - let url = format!( - "{}/v1/worker/task/{}/append", - client.baseurl, - encode_path(&task.to_string()), - ); - let request = client.client.post(url).json(&body).build()?; + ///Sends a `POST` request to `/0/workers/recycle` + pub async fn send(self) -> Result, Error> { + let Self { client } = self; + let url = format!("{}/0/workers/recycle", client.baseurl,); + let request = client + .client + .post(url) + .header( + reqwest::header::ACCEPT, + reqwest::header::HeaderValue::from_static("application/json"), + ) + .build()?; let result = client.client.execute(request).await; let response = result?; match response.status().as_u16() { - 201u16 => Ok(ResponseValue::empty(response)), + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), _ => Err(Error::UnexpectedResponse(response)), } } } - ///Builder for [`Client::worker_task_upload_chunk`] + ///Builder for [`Client::job_add_input`] /// - ///[`Client::worker_task_upload_chunk`]: super::Client::worker_task_upload_chunk - #[derive(Debug)] - pub struct WorkerTaskUploadChunk<'a> { + ///[`Client::job_add_input`]: super::Client::job_add_input + #[derive(Debug, Clone)] + pub struct JobAddInput<'a> { client: &'a super::Client, - task: Result, - body: Result, + job: Result, + body: Result, } - impl<'a> WorkerTaskUploadChunk<'a> { + impl<'a> JobAddInput<'a> { pub fn new(client: &'a super::Client) -> Self { Self { client: client, - task: Err("task was not initialized".to_string()), - body: Err("body was not initialized".to_string()), + job: Err("job was not initialized".to_string()), + body: Ok(types::builder::JobAddInput::default()), } } - pub fn task(mut self, value: V) -> Self + pub fn job(mut self, value: V) -> Self where V: std::convert::TryInto, { - self.task = value + self.job = value .try_into() - .map_err(|_| "conversion to `String` for task failed".to_string()); + .map_err(|_| "conversion to `String` for job failed".to_string()); self } - pub fn body(mut self, value: B) -> Self + pub fn body(mut self, value: V) -> Self where - B: std::convert::TryInto, + V: std::convert::TryInto, { self.body = value .try_into() - .map_err(|_| "conversion to `reqwest::Body` for body failed".to_string()); + .map(From::from) + .map_err(|_| "conversion to `JobAddInput` for body failed".to_string()); self } - ///Sends a `POST` request to `/v1/worker/task/{task}/chunk` - pub async fn send(self) -> Result, Error<()>> { - let Self { client, task, body } = self; - let task = task.map_err(Error::InvalidRequest)?; - let body = body.map_err(Error::InvalidRequest)?; + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::JobAddInput) -> types::builder::JobAddInput, + { + self.body = self.body.map(f); + self + } + + ///Sends a `POST` request to `/1/jobs/{job}/input` + pub async fn send( + self, + ) -> Result, Error> { + let Self { client, job, body } = self; + let job = job.map_err(Error::InvalidRequest)?; + let body = body + .and_then(std::convert::TryInto::::try_into) + .map_err(Error::InvalidRequest)?; let url = format!( - "{}/v1/worker/task/{}/chunk", + "{}/1/jobs/{}/input", client.baseurl, - encode_path(&task.to_string()), + encode_path(&job.to_string()), ); let request = client .client @@ -2641,119 +10063,122 @@ pub mod builder { reqwest::header::ACCEPT, reqwest::header::HeaderValue::from_static("application/json"), ) - .header( - reqwest::header::CONTENT_TYPE, - reqwest::header::HeaderValue::from_static("application/octet-stream"), - ) - .body(body) + .json(&body) .build()?; let result = client.client.execute(request).await; let response = result?; match response.status().as_u16() { - 201u16 => ResponseValue::from_response(response).await, + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), _ => Err(Error::UnexpectedResponse(response)), } } } - ///Builder for [`Client::worker_task_complete`] + ///Builder for [`Client::worker_job_append`] /// - ///[`Client::worker_task_complete`]: super::Client::worker_task_complete + ///[`Client::worker_job_append`]: super::Client::worker_job_append #[derive(Debug, Clone)] - pub struct WorkerTaskComplete<'a> { + pub struct WorkerJobAppend<'a> { client: &'a super::Client, - task: Result, - body: Result, + job: Result, + body: Result, String>, } - impl<'a> WorkerTaskComplete<'a> { + impl<'a> WorkerJobAppend<'a> { pub fn new(client: &'a super::Client) -> Self { Self { client: client, - task: Err("task was not initialized".to_string()), - body: Ok(types::builder::WorkerCompleteTask::default()), + job: Err("job was not initialized".to_string()), + body: Err("body was not initialized".to_string()), } } - pub fn task(mut self, value: V) -> Self + pub fn job(mut self, value: V) -> Self where V: std::convert::TryInto, { - self.task = value + self.job = value .try_into() - .map_err(|_| "conversion to `String` for task failed".to_string()); + .map_err(|_| "conversion to `String` for job failed".to_string()); self } pub fn body(mut self, value: V) -> Self where - V: std::convert::TryInto, - { - self.body = value - .try_into() - .map(From::from) - .map_err(|_| "conversion to `WorkerCompleteTask` for body failed".to_string()); - self - } - - pub fn body_map(mut self, f: F) -> Self - where - F: std::ops::FnOnce( - types::builder::WorkerCompleteTask, - ) -> types::builder::WorkerCompleteTask, + V: std::convert::TryInto>, { - self.body = self.body.map(f); + self.body = value.try_into().map_err(|_| { + "conversion to `Vec < WorkerAppendJobOrTask >` for body failed".to_string() + }); self } - ///Sends a `POST` request to `/v1/worker/task/{task}/complete` - pub async fn send(self) -> Result, Error<()>> { - let Self { client, task, body } = self; - let task = task.map_err(Error::InvalidRequest)?; - let body = body - .and_then(std::convert::TryInto::::try_into) - .map_err(Error::InvalidRequest)?; + ///Sends a `POST` request to `/1/worker/job/{job}/append` + pub async fn send(self) -> Result, Error> { + let Self { client, job, body } = self; + let job = job.map_err(Error::InvalidRequest)?; + let body = body.map_err(Error::InvalidRequest)?; let url = format!( - "{}/v1/worker/task/{}/complete", + "{}/1/worker/job/{}/append", client.baseurl, - encode_path(&task.to_string()), + encode_path(&job.to_string()), ); - let request = client.client.post(url).json(&body).build()?; + let request = client + .client + .post(url) + .header( + reqwest::header::ACCEPT, + reqwest::header::HeaderValue::from_static("application/json"), + ) + .json(&body) + .build()?; let result = client.client.execute(request).await; let response = result?; match response.status().as_u16() { - 200u16 => Ok(ResponseValue::empty(response)), + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), _ => Err(Error::UnexpectedResponse(response)), } } } - ///Builder for [`Client::worker_task_add_output`] + ///Builder for [`Client::worker_job_add_output`] /// - ///[`Client::worker_task_add_output`]: super::Client::worker_task_add_output + ///[`Client::worker_job_add_output`]: super::Client::worker_job_add_output #[derive(Debug, Clone)] - pub struct WorkerTaskAddOutput<'a> { + pub struct WorkerJobAddOutput<'a> { client: &'a super::Client, - task: Result, + job: Result, body: Result, } - impl<'a> WorkerTaskAddOutput<'a> { + impl<'a> WorkerJobAddOutput<'a> { pub fn new(client: &'a super::Client) -> Self { Self { client: client, - task: Err("task was not initialized".to_string()), + job: Err("job was not initialized".to_string()), body: Ok(types::builder::WorkerAddOutput::default()), } } - pub fn task(mut self, value: V) -> Self + pub fn job(mut self, value: V) -> Self where V: std::convert::TryInto, { - self.task = value + self.job = value .try_into() - .map_err(|_| "conversion to `String` for task failed".to_string()); + .map_err(|_| "conversion to `String` for job failed".to_string()); self } @@ -2776,84 +10201,39 @@ pub mod builder { self } - ///Sends a `POST` request to `/v1/worker/task/{task}/output` - pub async fn send(self) -> Result, Error<()>> { - let Self { client, task, body } = self; - let task = task.map_err(Error::InvalidRequest)?; + ///Sends a `POST` request to `/1/worker/job/{job}/output` + pub async fn send( + self, + ) -> Result, Error> { + let Self { client, job, body } = self; + let job = job.map_err(Error::InvalidRequest)?; let body = body .and_then(std::convert::TryInto::::try_into) .map_err(Error::InvalidRequest)?; let url = format!( - "{}/v1/worker/task/{}/output", + "{}/1/worker/job/{}/output", client.baseurl, - encode_path(&task.to_string()), + encode_path(&job.to_string()), ); - let request = client.client.post(url).json(&body).build()?; - let result = client.client.execute(request).await; - let response = result?; - match response.status().as_u16() { - 201u16 => Ok(ResponseValue::empty(response)), - _ => Err(Error::UnexpectedResponse(response)), - } - } - } - - ///Builder for [`Client::workers_list`] - /// - ///[`Client::workers_list`]: super::Client::workers_list - #[derive(Debug, Clone)] - pub struct WorkersList<'a> { - client: &'a super::Client, - } - - impl<'a> WorkersList<'a> { - pub fn new(client: &'a super::Client) -> Self { - Self { client: client } - } - - ///Sends a `GET` request to `/v1/workers` - pub async fn send(self) -> Result, Error<()>> { - let Self { client } = self; - let url = format!("{}/v1/workers", client.baseurl,); let request = client .client - .get(url) + .post(url) .header( reqwest::header::ACCEPT, reqwest::header::HeaderValue::from_static("application/json"), ) + .json(&body) .build()?; let result = client.client.execute(request).await; let response = result?; match response.status().as_u16() { 200u16 => ResponseValue::from_response(response).await, - _ => Err(Error::UnexpectedResponse(response)), - } - } - } - - ///Builder for [`Client::workers_recycle`] - /// - ///[`Client::workers_recycle`]: super::Client::workers_recycle - #[derive(Debug, Clone)] - pub struct WorkersRecycle<'a> { - client: &'a super::Client, - } - - impl<'a> WorkersRecycle<'a> { - pub fn new(client: &'a super::Client) -> Self { - Self { client: client } - } - - ///Sends a `POST` request to `/v1/workers/recycle` - pub async fn send(self) -> Result, Error<()>> { - let Self { client } = self; - let url = format!("{}/v1/workers/recycle", client.baseurl,); - let request = client.client.post(url).build()?; - let result = client.client.execute(request).await; - let response = result?; - match response.status().as_u16() { - 200u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), _ => Err(Error::UnexpectedResponse(response)), } } diff --git a/progenitor-impl/tests/output/buildomat-builder.out b/progenitor-impl/tests/output/buildomat-builder.out index 077f8489..472e53b1 100644 --- a/progenitor-impl/tests/output/buildomat-builder.out +++ b/progenitor-impl/tests/output/buildomat-builder.out @@ -8,1888 +8,9084 @@ pub mod types { #[allow(unused_imports)] use std::convert::TryFrom; #[derive(Clone, Debug, Deserialize, JsonSchema, Serialize)] - pub struct Task { - pub id: String, - pub name: String, - pub output_rules: Vec, - pub script: String, - pub state: String, + pub struct DependSubmit { + pub copy_outputs: bool, + pub on_completed: bool, + pub on_failed: bool, + pub prior_job: String, } - impl From<&Task> for Task { - fn from(value: &Task) -> Self { + impl From<&DependSubmit> for DependSubmit { + fn from(value: &DependSubmit) -> Self { value.clone() } } - impl Task { - pub fn builder() -> builder::Task { - builder::Task::default() + impl DependSubmit { + pub fn builder() -> builder::DependSubmit { + builder::DependSubmit::default() } } + ///Error information from a response. #[derive(Clone, Debug, Deserialize, JsonSchema, Serialize)] - pub struct TaskEvent { - pub payload: String, - pub seq: u32, - pub stream: String, - pub time: chrono::DateTime, + pub struct Error { + #[serde(default, skip_serializing_if = "Option::is_none")] + pub error_code: Option, + pub message: String, + pub request_id: String, } - impl From<&TaskEvent> for TaskEvent { - fn from(value: &TaskEvent) -> Self { + impl From<&Error> for Error { + fn from(value: &Error) -> Self { value.clone() } } - impl TaskEvent { - pub fn builder() -> builder::TaskEvent { - builder::TaskEvent::default() + impl Error { + pub fn builder() -> builder::Error { + builder::Error::default() } } #[derive(Clone, Debug, Deserialize, JsonSchema, Serialize)] - pub struct TaskOutput { - pub id: String, - pub path: String, - pub size: u64, + pub struct FactoryAddresses { + pub cidr: String, + pub count: u32, + pub first: String, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub gateway: Option, + pub name: String, + pub routed: bool, } - impl From<&TaskOutput> for TaskOutput { - fn from(value: &TaskOutput) -> Self { + impl From<&FactoryAddresses> for FactoryAddresses { + fn from(value: &FactoryAddresses) -> Self { value.clone() } } - impl TaskOutput { - pub fn builder() -> builder::TaskOutput { - builder::TaskOutput::default() + impl FactoryAddresses { + pub fn builder() -> builder::FactoryAddresses { + builder::FactoryAddresses::default() } } #[derive(Clone, Debug, Deserialize, JsonSchema, Serialize)] - pub struct TaskSubmit { + pub struct FactoryCreate { pub name: String, - #[serde(default, skip_serializing_if = "Vec::is_empty")] - pub output_rules: Vec, - pub script: String, } - impl From<&TaskSubmit> for TaskSubmit { - fn from(value: &TaskSubmit) -> Self { + impl From<&FactoryCreate> for FactoryCreate { + fn from(value: &FactoryCreate) -> Self { value.clone() } } - impl TaskSubmit { - pub fn builder() -> builder::TaskSubmit { - builder::TaskSubmit::default() + impl FactoryCreate { + pub fn builder() -> builder::FactoryCreate { + builder::FactoryCreate::default() } } #[derive(Clone, Debug, Deserialize, JsonSchema, Serialize)] - pub struct TaskSubmitResult { + pub struct FactoryCreateResult { pub id: String, + pub name: String, + pub token: String, } - impl From<&TaskSubmitResult> for TaskSubmitResult { - fn from(value: &TaskSubmitResult) -> Self { + impl From<&FactoryCreateResult> for FactoryCreateResult { + fn from(value: &FactoryCreateResult) -> Self { value.clone() } } - impl TaskSubmitResult { - pub fn builder() -> builder::TaskSubmitResult { - builder::TaskSubmitResult::default() + impl FactoryCreateResult { + pub fn builder() -> builder::FactoryCreateResult { + builder::FactoryCreateResult::default() } } #[derive(Clone, Debug, Deserialize, JsonSchema, Serialize)] - pub struct UploadedChunk { - pub id: String, + pub struct FactoryLease { + pub job: String, + pub target: String, } - impl From<&UploadedChunk> for UploadedChunk { - fn from(value: &UploadedChunk) -> Self { + impl From<&FactoryLease> for FactoryLease { + fn from(value: &FactoryLease) -> Self { value.clone() } } - impl UploadedChunk { - pub fn builder() -> builder::UploadedChunk { - builder::UploadedChunk::default() + impl FactoryLease { + pub fn builder() -> builder::FactoryLease { + builder::FactoryLease::default() } } #[derive(Clone, Debug, Deserialize, JsonSchema, Serialize)] - pub struct UserCreate { - pub name: String, + pub struct FactoryLeaseResult { + #[serde(default, skip_serializing_if = "Option::is_none")] + pub lease: Option, } - impl From<&UserCreate> for UserCreate { - fn from(value: &UserCreate) -> Self { + impl From<&FactoryLeaseResult> for FactoryLeaseResult { + fn from(value: &FactoryLeaseResult) -> Self { value.clone() } } - impl UserCreate { - pub fn builder() -> builder::UserCreate { - builder::UserCreate::default() + impl FactoryLeaseResult { + pub fn builder() -> builder::FactoryLeaseResult { + builder::FactoryLeaseResult::default() } } #[derive(Clone, Debug, Deserialize, JsonSchema, Serialize)] - pub struct UserCreateResult { - pub id: String, - pub name: String, - pub token: String, + #[serde(tag = "v")] + pub enum FactoryMetadata { + #[serde(rename = "1")] + _1 { + #[serde(default, skip_serializing_if = "Vec::is_empty")] + addresses: Vec, + }, } - impl From<&UserCreateResult> for UserCreateResult { - fn from(value: &UserCreateResult) -> Self { + impl From<&FactoryMetadata> for FactoryMetadata { + fn from(value: &FactoryMetadata) -> Self { value.clone() } } - impl UserCreateResult { - pub fn builder() -> builder::UserCreateResult { - builder::UserCreateResult::default() - } - } - #[derive(Clone, Debug, Deserialize, JsonSchema, Serialize)] - pub struct WhoamiResult { - pub id: String, - pub name: String, + pub struct FactoryPingResult { + pub ok: bool, } - impl From<&WhoamiResult> for WhoamiResult { - fn from(value: &WhoamiResult) -> Self { + impl From<&FactoryPingResult> for FactoryPingResult { + fn from(value: &FactoryPingResult) -> Self { value.clone() } } - impl WhoamiResult { - pub fn builder() -> builder::WhoamiResult { - builder::WhoamiResult::default() + impl FactoryPingResult { + pub fn builder() -> builder::FactoryPingResult { + builder::FactoryPingResult::default() } } #[derive(Clone, Debug, Deserialize, JsonSchema, Serialize)] - pub struct Worker { - pub deleted: bool, - pub id: String, - #[serde(default, skip_serializing_if = "Option::is_none")] - pub instance_id: Option, - #[serde(default, skip_serializing_if = "Option::is_none")] - pub lastping: Option>, - pub recycle: bool, - pub tasks: Vec, + pub struct FactoryWhatsNext { + pub supported_targets: Vec, } - impl From<&Worker> for Worker { - fn from(value: &Worker) -> Self { + impl From<&FactoryWhatsNext> for FactoryWhatsNext { + fn from(value: &FactoryWhatsNext) -> Self { value.clone() } } - impl Worker { - pub fn builder() -> builder::Worker { - builder::Worker::default() + impl FactoryWhatsNext { + pub fn builder() -> builder::FactoryWhatsNext { + builder::FactoryWhatsNext::default() } } #[derive(Clone, Debug, Deserialize, JsonSchema, Serialize)] - pub struct WorkerAddOutput { - pub chunks: Vec, - pub path: String, - pub size: i64, + pub struct FactoryWorker { + pub bootstrap: String, + pub id: String, + pub online: bool, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub private: Option, + pub recycle: bool, } - impl From<&WorkerAddOutput> for WorkerAddOutput { - fn from(value: &WorkerAddOutput) -> Self { + impl From<&FactoryWorker> for FactoryWorker { + fn from(value: &FactoryWorker) -> Self { value.clone() } } - impl WorkerAddOutput { - pub fn builder() -> builder::WorkerAddOutput { - builder::WorkerAddOutput::default() + impl FactoryWorker { + pub fn builder() -> builder::FactoryWorker { + builder::FactoryWorker::default() } } #[derive(Clone, Debug, Deserialize, JsonSchema, Serialize)] - pub struct WorkerAppendTask { + pub struct FactoryWorkerAppend { pub payload: String, pub stream: String, pub time: chrono::DateTime, } - impl From<&WorkerAppendTask> for WorkerAppendTask { - fn from(value: &WorkerAppendTask) -> Self { + impl From<&FactoryWorkerAppend> for FactoryWorkerAppend { + fn from(value: &FactoryWorkerAppend) -> Self { value.clone() } } - impl WorkerAppendTask { - pub fn builder() -> builder::WorkerAppendTask { - builder::WorkerAppendTask::default() + impl FactoryWorkerAppend { + pub fn builder() -> builder::FactoryWorkerAppend { + builder::FactoryWorkerAppend::default() } } #[derive(Clone, Debug, Deserialize, JsonSchema, Serialize)] - pub struct WorkerBootstrap { - pub bootstrap: String, - pub token: String, + pub struct FactoryWorkerAppendResult { + pub retry: bool, } - impl From<&WorkerBootstrap> for WorkerBootstrap { - fn from(value: &WorkerBootstrap) -> Self { + impl From<&FactoryWorkerAppendResult> for FactoryWorkerAppendResult { + fn from(value: &FactoryWorkerAppendResult) -> Self { value.clone() } } - impl WorkerBootstrap { - pub fn builder() -> builder::WorkerBootstrap { - builder::WorkerBootstrap::default() + impl FactoryWorkerAppendResult { + pub fn builder() -> builder::FactoryWorkerAppendResult { + builder::FactoryWorkerAppendResult::default() } } #[derive(Clone, Debug, Deserialize, JsonSchema, Serialize)] - pub struct WorkerBootstrapResult { - pub id: String, + pub struct FactoryWorkerAssociate { + #[serde(default, skip_serializing_if = "Option::is_none")] + pub metadata: Option, + pub private: String, } - impl From<&WorkerBootstrapResult> for WorkerBootstrapResult { - fn from(value: &WorkerBootstrapResult) -> Self { + impl From<&FactoryWorkerAssociate> for FactoryWorkerAssociate { + fn from(value: &FactoryWorkerAssociate) -> Self { value.clone() } } - impl WorkerBootstrapResult { - pub fn builder() -> builder::WorkerBootstrapResult { - builder::WorkerBootstrapResult::default() + impl FactoryWorkerAssociate { + pub fn builder() -> builder::FactoryWorkerAssociate { + builder::FactoryWorkerAssociate::default() } } #[derive(Clone, Debug, Deserialize, JsonSchema, Serialize)] - pub struct WorkerCompleteTask { - pub failed: bool, + pub struct FactoryWorkerCreate { + #[serde(default, skip_serializing_if = "Option::is_none")] + pub job: Option, + pub target: String, + #[serde(default)] + pub wait_for_flush: bool, } - impl From<&WorkerCompleteTask> for WorkerCompleteTask { - fn from(value: &WorkerCompleteTask) -> Self { + impl From<&FactoryWorkerCreate> for FactoryWorkerCreate { + fn from(value: &FactoryWorkerCreate) -> Self { value.clone() } } - impl WorkerCompleteTask { - pub fn builder() -> builder::WorkerCompleteTask { - builder::WorkerCompleteTask::default() + impl FactoryWorkerCreate { + pub fn builder() -> builder::FactoryWorkerCreate { + builder::FactoryWorkerCreate::default() } } #[derive(Clone, Debug, Deserialize, JsonSchema, Serialize)] - pub struct WorkerPingResult { - pub poweroff: bool, + pub struct FactoryWorkerResult { #[serde(default, skip_serializing_if = "Option::is_none")] - pub task: Option, + pub worker: Option, } - impl From<&WorkerPingResult> for WorkerPingResult { - fn from(value: &WorkerPingResult) -> Self { + impl From<&FactoryWorkerResult> for FactoryWorkerResult { + fn from(value: &FactoryWorkerResult) -> Self { value.clone() } } - impl WorkerPingResult { - pub fn builder() -> builder::WorkerPingResult { - builder::WorkerPingResult::default() + impl FactoryWorkerResult { + pub fn builder() -> builder::FactoryWorkerResult { + builder::FactoryWorkerResult::default() } } #[derive(Clone, Debug, Deserialize, JsonSchema, Serialize)] - pub struct WorkerPingTask { + pub struct Job { + pub cancelled: bool, pub id: String, + pub name: String, pub output_rules: Vec, - pub script: String, + pub owner: String, + pub state: String, + pub tags: std::collections::HashMap, + pub target: String, + pub target_real: String, + pub tasks: Vec, + #[serde(default, skip_serializing_if = "std::collections::HashMap::is_empty")] + pub times: std::collections::HashMap>, } - impl From<&WorkerPingTask> for WorkerPingTask { - fn from(value: &WorkerPingTask) -> Self { + impl From<&Job> for Job { + fn from(value: &Job) -> Self { value.clone() } } - impl WorkerPingTask { - pub fn builder() -> builder::WorkerPingTask { - builder::WorkerPingTask::default() + impl Job { + pub fn builder() -> builder::Job { + builder::Job::default() } } #[derive(Clone, Debug, Deserialize, JsonSchema, Serialize)] - pub struct WorkerTask { - pub id: String, + pub struct JobAddInput { + pub chunks: Vec, + pub commit_id: String, pub name: String, - pub owner: String, + pub size: u64, } - impl From<&WorkerTask> for WorkerTask { - fn from(value: &WorkerTask) -> Self { + impl From<&JobAddInput> for JobAddInput { + fn from(value: &JobAddInput) -> Self { value.clone() } } - impl WorkerTask { - pub fn builder() -> builder::WorkerTask { - builder::WorkerTask::default() + impl JobAddInput { + pub fn builder() -> builder::JobAddInput { + builder::JobAddInput::default() } } #[derive(Clone, Debug, Deserialize, JsonSchema, Serialize)] - pub struct WorkersResult { - pub workers: Vec, + pub struct JobAddInputResult { + pub complete: bool, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub error: Option, } - impl From<&WorkersResult> for WorkersResult { - fn from(value: &WorkersResult) -> Self { + impl From<&JobAddInputResult> for JobAddInputResult { + fn from(value: &JobAddInputResult) -> Self { value.clone() } } - impl WorkersResult { - pub fn builder() -> builder::WorkersResult { - builder::WorkersResult::default() + impl JobAddInputResult { + pub fn builder() -> builder::JobAddInputResult { + builder::JobAddInputResult::default() } } - pub mod builder { - #[derive(Clone, Debug)] - pub struct Task { - id: Result, - name: Result, - output_rules: Result, String>, - script: Result, - state: Result, - } + #[derive(Clone, Debug, Deserialize, JsonSchema, Serialize)] + pub struct JobEvent { + pub payload: String, + pub seq: u32, + pub stream: String, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub task: Option, + pub time: chrono::DateTime, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub time_remote: Option>, + } - impl Default for Task { - fn default() -> Self { - Self { - id: Err("no value supplied for id".to_string()), - name: Err("no value supplied for name".to_string()), - output_rules: Err("no value supplied for output_rules".to_string()), - script: Err("no value supplied for script".to_string()), - state: Err("no value supplied for state".to_string()), - } - } + impl From<&JobEvent> for JobEvent { + fn from(value: &JobEvent) -> Self { + value.clone() } + } - impl Task { - pub fn id(mut self, value: T) -> Self - where - T: std::convert::TryInto, - T::Error: std::fmt::Display, - { - self.id = value - .try_into() - .map_err(|e| format!("error converting supplied value for id: {}", e)); - self - } - pub fn name(mut self, value: T) -> Self - where - T: std::convert::TryInto, - T::Error: std::fmt::Display, - { - self.name = value - .try_into() - .map_err(|e| format!("error converting supplied value for name: {}", e)); - self - } - pub fn output_rules(mut self, value: T) -> Self - where - T: std::convert::TryInto>, - T::Error: std::fmt::Display, - { - self.output_rules = value.try_into().map_err(|e| { - format!("error converting supplied value for output_rules: {}", e) - }); - self - } - pub fn script(mut self, value: T) -> Self - where - T: std::convert::TryInto, - T::Error: std::fmt::Display, - { - self.script = value - .try_into() - .map_err(|e| format!("error converting supplied value for script: {}", e)); - self - } - pub fn state(mut self, value: T) -> Self - where - T: std::convert::TryInto, - T::Error: std::fmt::Display, - { - self.state = value - .try_into() - .map_err(|e| format!("error converting supplied value for state: {}", e)); - self - } + impl JobEvent { + pub fn builder() -> builder::JobEvent { + builder::JobEvent::default() } + } - impl std::convert::TryFrom for super::Task { - type Error = String; - fn try_from(value: Task) -> Result { - Ok(Self { - id: value.id?, - name: value.name?, - output_rules: value.output_rules?, - script: value.script?, - state: value.state?, - }) - } + #[derive(Clone, Debug, Deserialize, JsonSchema, Serialize)] + pub struct JobOutput { + pub id: String, + pub path: String, + pub size: u64, + } + + impl From<&JobOutput> for JobOutput { + fn from(value: &JobOutput) -> Self { + value.clone() } + } - impl From for Task { - fn from(value: super::Task) -> Self { - Self { - id: Ok(value.id), - name: Ok(value.name), - output_rules: Ok(value.output_rules), - script: Ok(value.script), - state: Ok(value.state), - } - } + impl JobOutput { + pub fn builder() -> builder::JobOutput { + builder::JobOutput::default() } + } - #[derive(Clone, Debug)] - pub struct TaskEvent { - payload: Result, - seq: Result, - stream: Result, - time: Result, String>, - } + #[derive(Clone, Debug, Deserialize, JsonSchema, Serialize)] + pub struct JobOutputPublish { + pub name: String, + pub series: String, + pub version: String, + } - impl Default for TaskEvent { - fn default() -> Self { - Self { - payload: Err("no value supplied for payload".to_string()), - seq: Err("no value supplied for seq".to_string()), - stream: Err("no value supplied for stream".to_string()), - time: Err("no value supplied for time".to_string()), - } - } + impl From<&JobOutputPublish> for JobOutputPublish { + fn from(value: &JobOutputPublish) -> Self { + value.clone() } + } - impl TaskEvent { - pub fn payload(mut self, value: T) -> Self - where - T: std::convert::TryInto, - T::Error: std::fmt::Display, - { - self.payload = value - .try_into() - .map_err(|e| format!("error converting supplied value for payload: {}", e)); - self - } - pub fn seq(mut self, value: T) -> Self - where - T: std::convert::TryInto, - T::Error: std::fmt::Display, - { - self.seq = value - .try_into() - .map_err(|e| format!("error converting supplied value for seq: {}", e)); - self - } - pub fn stream(mut self, value: T) -> Self - where - T: std::convert::TryInto, - T::Error: std::fmt::Display, - { - self.stream = value - .try_into() - .map_err(|e| format!("error converting supplied value for stream: {}", e)); - self - } - pub fn time(mut self, value: T) -> Self - where - T: std::convert::TryInto>, - T::Error: std::fmt::Display, - { - self.time = value - .try_into() - .map_err(|e| format!("error converting supplied value for time: {}", e)); - self - } + impl JobOutputPublish { + pub fn builder() -> builder::JobOutputPublish { + builder::JobOutputPublish::default() } + } - impl std::convert::TryFrom for super::TaskEvent { - type Error = String; - fn try_from(value: TaskEvent) -> Result { - Ok(Self { - payload: value.payload?, - seq: value.seq?, - stream: value.stream?, - time: value.time?, - }) - } - } + #[derive(Clone, Debug, Deserialize, JsonSchema, Serialize)] + pub struct JobOutputSignedUrl { + #[serde(default, skip_serializing_if = "Option::is_none")] + pub content_disposition: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub content_type: Option, + pub expiry_seconds: u64, + } - impl From for TaskEvent { - fn from(value: super::TaskEvent) -> Self { - Self { - payload: Ok(value.payload), - seq: Ok(value.seq), - stream: Ok(value.stream), - time: Ok(value.time), - } - } + impl From<&JobOutputSignedUrl> for JobOutputSignedUrl { + fn from(value: &JobOutputSignedUrl) -> Self { + value.clone() } + } - #[derive(Clone, Debug)] - pub struct TaskOutput { - id: Result, - path: Result, - size: Result, + impl JobOutputSignedUrl { + pub fn builder() -> builder::JobOutputSignedUrl { + builder::JobOutputSignedUrl::default() } + } - impl Default for TaskOutput { - fn default() -> Self { - Self { - id: Err("no value supplied for id".to_string()), - path: Err("no value supplied for path".to_string()), - size: Err("no value supplied for size".to_string()), - } - } - } + #[derive(Clone, Debug, Deserialize, JsonSchema, Serialize)] + pub struct JobOutputSignedUrlResult { + pub url: String, + } - impl TaskOutput { - pub fn id(mut self, value: T) -> Self - where - T: std::convert::TryInto, - T::Error: std::fmt::Display, - { - self.id = value - .try_into() - .map_err(|e| format!("error converting supplied value for id: {}", e)); - self - } - pub fn path(mut self, value: T) -> Self - where - T: std::convert::TryInto, - T::Error: std::fmt::Display, - { - self.path = value - .try_into() - .map_err(|e| format!("error converting supplied value for path: {}", e)); - self - } - pub fn size(mut self, value: T) -> Self - where - T: std::convert::TryInto, - T::Error: std::fmt::Display, - { - self.size = value - .try_into() - .map_err(|e| format!("error converting supplied value for size: {}", e)); - self - } + impl From<&JobOutputSignedUrlResult> for JobOutputSignedUrlResult { + fn from(value: &JobOutputSignedUrlResult) -> Self { + value.clone() } + } - impl std::convert::TryFrom for super::TaskOutput { - type Error = String; - fn try_from(value: TaskOutput) -> Result { - Ok(Self { - id: value.id?, - path: value.path?, - size: value.size?, - }) - } + impl JobOutputSignedUrlResult { + pub fn builder() -> builder::JobOutputSignedUrlResult { + builder::JobOutputSignedUrlResult::default() } + } - impl From for TaskOutput { - fn from(value: super::TaskOutput) -> Self { - Self { - id: Ok(value.id), - path: Ok(value.path), - size: Ok(value.size), - } - } - } + #[derive(Clone, Debug, Deserialize, JsonSchema, Serialize)] + pub struct JobStoreValue { + pub secret: bool, + pub value: String, + } - #[derive(Clone, Debug)] - pub struct TaskSubmit { - name: Result, - output_rules: Result, String>, - script: Result, + impl From<&JobStoreValue> for JobStoreValue { + fn from(value: &JobStoreValue) -> Self { + value.clone() } + } - impl Default for TaskSubmit { - fn default() -> Self { - Self { - name: Err("no value supplied for name".to_string()), - output_rules: Ok(Default::default()), - script: Err("no value supplied for script".to_string()), - } - } + impl JobStoreValue { + pub fn builder() -> builder::JobStoreValue { + builder::JobStoreValue::default() } + } - impl TaskSubmit { - pub fn name(mut self, value: T) -> Self - where - T: std::convert::TryInto, - T::Error: std::fmt::Display, - { - self.name = value - .try_into() - .map_err(|e| format!("error converting supplied value for name: {}", e)); - self - } - pub fn output_rules(mut self, value: T) -> Self - where - T: std::convert::TryInto>, - T::Error: std::fmt::Display, - { - self.output_rules = value.try_into().map_err(|e| { - format!("error converting supplied value for output_rules: {}", e) - }); - self - } - pub fn script(mut self, value: T) -> Self - where - T: std::convert::TryInto, - T::Error: std::fmt::Display, - { - self.script = value - .try_into() - .map_err(|e| format!("error converting supplied value for script: {}", e)); - self - } - } + #[derive(Clone, Debug, Deserialize, JsonSchema, Serialize)] + pub struct JobStoreValueInfo { + pub secret: bool, + pub source: String, + pub time_update: chrono::DateTime, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub value: Option, + } - impl std::convert::TryFrom for super::TaskSubmit { - type Error = String; - fn try_from(value: TaskSubmit) -> Result { - Ok(Self { - name: value.name?, - output_rules: value.output_rules?, - script: value.script?, - }) - } + impl From<&JobStoreValueInfo> for JobStoreValueInfo { + fn from(value: &JobStoreValueInfo) -> Self { + value.clone() } + } - impl From for TaskSubmit { - fn from(value: super::TaskSubmit) -> Self { - Self { - name: Ok(value.name), - output_rules: Ok(value.output_rules), - script: Ok(value.script), - } - } + impl JobStoreValueInfo { + pub fn builder() -> builder::JobStoreValueInfo { + builder::JobStoreValueInfo::default() } + } - #[derive(Clone, Debug)] - pub struct TaskSubmitResult { - id: Result, - } + #[derive(Clone, Debug, Deserialize, JsonSchema, Serialize)] + pub struct JobSubmit { + #[serde(default, skip_serializing_if = "std::collections::HashMap::is_empty")] + pub depends: std::collections::HashMap, + #[serde(default, skip_serializing_if = "Vec::is_empty")] + pub inputs: Vec, + pub name: String, + pub output_rules: Vec, + #[serde(default, skip_serializing_if = "std::collections::HashMap::is_empty")] + pub tags: std::collections::HashMap, + pub target: String, + pub tasks: Vec, + } - impl Default for TaskSubmitResult { - fn default() -> Self { - Self { - id: Err("no value supplied for id".to_string()), - } - } + impl From<&JobSubmit> for JobSubmit { + fn from(value: &JobSubmit) -> Self { + value.clone() } + } - impl TaskSubmitResult { - pub fn id(mut self, value: T) -> Self - where - T: std::convert::TryInto, - T::Error: std::fmt::Display, - { - self.id = value - .try_into() - .map_err(|e| format!("error converting supplied value for id: {}", e)); - self - } + impl JobSubmit { + pub fn builder() -> builder::JobSubmit { + builder::JobSubmit::default() } + } - impl std::convert::TryFrom for super::TaskSubmitResult { - type Error = String; - fn try_from(value: TaskSubmitResult) -> Result { - Ok(Self { id: value.id? }) - } - } + #[derive(Clone, Debug, Deserialize, JsonSchema, Serialize)] + pub struct JobSubmitResult { + pub id: String, + } - impl From for TaskSubmitResult { - fn from(value: super::TaskSubmitResult) -> Self { - Self { id: Ok(value.id) } - } + impl From<&JobSubmitResult> for JobSubmitResult { + fn from(value: &JobSubmitResult) -> Self { + value.clone() } + } - #[derive(Clone, Debug)] - pub struct UploadedChunk { - id: Result, + impl JobSubmitResult { + pub fn builder() -> builder::JobSubmitResult { + builder::JobSubmitResult::default() } + } - impl Default for UploadedChunk { - fn default() -> Self { - Self { - id: Err("no value supplied for id".to_string()), - } - } - } + #[derive(Clone, Debug, Deserialize, JsonSchema, Serialize)] + pub struct Quota { + pub max_bytes_per_input: u64, + } - impl UploadedChunk { - pub fn id(mut self, value: T) -> Self - where - T: std::convert::TryInto, - T::Error: std::fmt::Display, - { - self.id = value - .try_into() - .map_err(|e| format!("error converting supplied value for id: {}", e)); - self - } + impl From<&Quota> for Quota { + fn from(value: &Quota) -> Self { + value.clone() } + } - impl std::convert::TryFrom for super::UploadedChunk { - type Error = String; - fn try_from(value: UploadedChunk) -> Result { - Ok(Self { id: value.id? }) - } + impl Quota { + pub fn builder() -> builder::Quota { + builder::Quota::default() } + } - impl From for UploadedChunk { - fn from(value: super::UploadedChunk) -> Self { - Self { id: Ok(value.id) } - } + #[derive(Clone, Debug, Deserialize, JsonSchema, Serialize)] + pub struct Target { + pub desc: String, + pub id: String, + pub name: String, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub privilege: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub redirect: Option, + } + + impl From<&Target> for Target { + fn from(value: &Target) -> Self { + value.clone() } + } - #[derive(Clone, Debug)] - pub struct UserCreate { - name: Result, + impl Target { + pub fn builder() -> builder::Target { + builder::Target::default() } + } - impl Default for UserCreate { - fn default() -> Self { - Self { - name: Err("no value supplied for name".to_string()), - } - } + #[derive(Clone, Debug, Deserialize, JsonSchema, Serialize)] + pub struct TargetCreate { + pub desc: String, + pub name: String, + } + + impl From<&TargetCreate> for TargetCreate { + fn from(value: &TargetCreate) -> Self { + value.clone() } + } - impl UserCreate { - pub fn name(mut self, value: T) -> Self - where - T: std::convert::TryInto, - T::Error: std::fmt::Display, - { - self.name = value - .try_into() - .map_err(|e| format!("error converting supplied value for name: {}", e)); - self - } + impl TargetCreate { + pub fn builder() -> builder::TargetCreate { + builder::TargetCreate::default() } + } - impl std::convert::TryFrom for super::UserCreate { - type Error = String; - fn try_from(value: UserCreate) -> Result { - Ok(Self { name: value.name? }) - } + #[derive(Clone, Debug, Deserialize, JsonSchema, Serialize)] + pub struct TargetCreateResult { + pub id: String, + } + + impl From<&TargetCreateResult> for TargetCreateResult { + fn from(value: &TargetCreateResult) -> Self { + value.clone() } + } - impl From for UserCreate { - fn from(value: super::UserCreate) -> Self { - Self { - name: Ok(value.name), - } - } + impl TargetCreateResult { + pub fn builder() -> builder::TargetCreateResult { + builder::TargetCreateResult::default() } + } - #[derive(Clone, Debug)] - pub struct UserCreateResult { - id: Result, - name: Result, - token: Result, + #[derive(Clone, Debug, Deserialize, JsonSchema, Serialize)] + pub struct TargetRedirect { + #[serde(default, skip_serializing_if = "Option::is_none")] + pub redirect: Option, + } + + impl From<&TargetRedirect> for TargetRedirect { + fn from(value: &TargetRedirect) -> Self { + value.clone() } + } - impl Default for UserCreateResult { - fn default() -> Self { - Self { - id: Err("no value supplied for id".to_string()), - name: Err("no value supplied for name".to_string()), - token: Err("no value supplied for token".to_string()), - } - } + impl TargetRedirect { + pub fn builder() -> builder::TargetRedirect { + builder::TargetRedirect::default() } + } - impl UserCreateResult { - pub fn id(mut self, value: T) -> Self - where - T: std::convert::TryInto, - T::Error: std::fmt::Display, - { - self.id = value - .try_into() - .map_err(|e| format!("error converting supplied value for id: {}", e)); - self - } - pub fn name(mut self, value: T) -> Self - where - T: std::convert::TryInto, - T::Error: std::fmt::Display, - { - self.name = value - .try_into() - .map_err(|e| format!("error converting supplied value for name: {}", e)); - self - } - pub fn token(mut self, value: T) -> Self - where - T: std::convert::TryInto, - T::Error: std::fmt::Display, - { - self.token = value - .try_into() - .map_err(|e| format!("error converting supplied value for token: {}", e)); - self - } + #[derive(Clone, Debug, Deserialize, JsonSchema, Serialize)] + pub struct TargetRename { + pub new_name: String, + pub signpost_description: String, + } + + impl From<&TargetRename> for TargetRename { + fn from(value: &TargetRename) -> Self { + value.clone() } + } - impl std::convert::TryFrom for super::UserCreateResult { - type Error = String; - fn try_from(value: UserCreateResult) -> Result { - Ok(Self { - id: value.id?, - name: value.name?, - token: value.token?, - }) - } + impl TargetRename { + pub fn builder() -> builder::TargetRename { + builder::TargetRename::default() } + } - impl From for UserCreateResult { - fn from(value: super::UserCreateResult) -> Self { - Self { - id: Ok(value.id), - name: Ok(value.name), - token: Ok(value.token), - } - } + #[derive(Clone, Debug, Deserialize, JsonSchema, Serialize)] + pub struct Task { + pub env: std::collections::HashMap, + pub env_clear: bool, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub gid: Option, + pub name: String, + pub script: String, + pub state: String, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub uid: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub workdir: Option, + } + + impl From<&Task> for Task { + fn from(value: &Task) -> Self { + value.clone() } + } - #[derive(Clone, Debug)] - pub struct WhoamiResult { - id: Result, - name: Result, + impl Task { + pub fn builder() -> builder::Task { + builder::Task::default() } + } - impl Default for WhoamiResult { - fn default() -> Self { - Self { - id: Err("no value supplied for id".to_string()), - name: Err("no value supplied for name".to_string()), - } - } + #[derive(Clone, Debug, Deserialize, JsonSchema, Serialize)] + pub struct TaskSubmit { + pub env: std::collections::HashMap, + pub env_clear: bool, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub gid: Option, + pub name: String, + pub script: String, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub uid: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub workdir: Option, + } + + impl From<&TaskSubmit> for TaskSubmit { + fn from(value: &TaskSubmit) -> Self { + value.clone() } + } - impl WhoamiResult { - pub fn id(mut self, value: T) -> Self - where - T: std::convert::TryInto, - T::Error: std::fmt::Display, - { - self.id = value - .try_into() - .map_err(|e| format!("error converting supplied value for id: {}", e)); - self - } - pub fn name(mut self, value: T) -> Self - where - T: std::convert::TryInto, - T::Error: std::fmt::Display, - { - self.name = value - .try_into() - .map_err(|e| format!("error converting supplied value for name: {}", e)); - self - } + impl TaskSubmit { + pub fn builder() -> builder::TaskSubmit { + builder::TaskSubmit::default() } + } - impl std::convert::TryFrom for super::WhoamiResult { - type Error = String; - fn try_from(value: WhoamiResult) -> Result { - Ok(Self { - id: value.id?, - name: value.name?, - }) - } + #[derive(Clone, Debug, Deserialize, JsonSchema, Serialize)] + pub struct UploadedChunk { + pub id: String, + } + + impl From<&UploadedChunk> for UploadedChunk { + fn from(value: &UploadedChunk) -> Self { + value.clone() } + } - impl From for WhoamiResult { - fn from(value: super::WhoamiResult) -> Self { - Self { - id: Ok(value.id), - name: Ok(value.name), - } - } + impl UploadedChunk { + pub fn builder() -> builder::UploadedChunk { + builder::UploadedChunk::default() + } + } + + #[derive(Clone, Debug, Deserialize, JsonSchema, Serialize)] + pub struct User { + pub id: String, + pub name: String, + pub privileges: Vec, + pub time_create: chrono::DateTime, + } + + impl From<&User> for User { + fn from(value: &User) -> Self { + value.clone() + } + } + + impl User { + pub fn builder() -> builder::User { + builder::User::default() + } + } + + #[derive(Clone, Debug, Deserialize, JsonSchema, Serialize)] + pub struct UserCreate { + pub name: String, + } + + impl From<&UserCreate> for UserCreate { + fn from(value: &UserCreate) -> Self { + value.clone() + } + } + + impl UserCreate { + pub fn builder() -> builder::UserCreate { + builder::UserCreate::default() + } + } + + #[derive(Clone, Debug, Deserialize, JsonSchema, Serialize)] + pub struct UserCreateResult { + pub id: String, + pub name: String, + pub token: String, + } + + impl From<&UserCreateResult> for UserCreateResult { + fn from(value: &UserCreateResult) -> Self { + value.clone() + } + } + + impl UserCreateResult { + pub fn builder() -> builder::UserCreateResult { + builder::UserCreateResult::default() + } + } + + #[derive(Clone, Debug, Deserialize, JsonSchema, Serialize)] + pub struct WhoamiResult { + pub id: String, + pub name: String, + } + + impl From<&WhoamiResult> for WhoamiResult { + fn from(value: &WhoamiResult) -> Self { + value.clone() + } + } + + impl WhoamiResult { + pub fn builder() -> builder::WhoamiResult { + builder::WhoamiResult::default() + } + } + + #[derive(Clone, Debug, Deserialize, JsonSchema, Serialize)] + pub struct Worker { + pub bootstrap: bool, + pub deleted: bool, + pub factory: String, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub factory_private: Option, + pub id: String, + pub jobs: Vec, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub lastping: Option>, + pub recycle: bool, + pub target: String, + } + + impl From<&Worker> for Worker { + fn from(value: &Worker) -> Self { + value.clone() + } + } + + impl Worker { + pub fn builder() -> builder::Worker { + builder::Worker::default() + } + } + + #[derive(Clone, Debug, Deserialize, JsonSchema, Serialize)] + pub struct WorkerAddOutput { + pub chunks: Vec, + pub commit_id: String, + pub path: String, + pub size: u64, + } + + impl From<&WorkerAddOutput> for WorkerAddOutput { + fn from(value: &WorkerAddOutput) -> Self { + value.clone() + } + } + + impl WorkerAddOutput { + pub fn builder() -> builder::WorkerAddOutput { + builder::WorkerAddOutput::default() + } + } + + #[derive(Clone, Debug, Deserialize, JsonSchema, Serialize)] + pub struct WorkerAddOutputResult { + pub complete: bool, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub error: Option, + } + + impl From<&WorkerAddOutputResult> for WorkerAddOutputResult { + fn from(value: &WorkerAddOutputResult) -> Self { + value.clone() + } + } + + impl WorkerAddOutputResult { + pub fn builder() -> builder::WorkerAddOutputResult { + builder::WorkerAddOutputResult::default() + } + } + + #[derive(Clone, Debug, Deserialize, JsonSchema, Serialize)] + pub struct WorkerAppendJob { + pub payload: String, + pub stream: String, + pub time: chrono::DateTime, + } + + impl From<&WorkerAppendJob> for WorkerAppendJob { + fn from(value: &WorkerAppendJob) -> Self { + value.clone() + } + } + + impl WorkerAppendJob { + pub fn builder() -> builder::WorkerAppendJob { + builder::WorkerAppendJob::default() + } + } + + #[derive(Clone, Debug, Deserialize, JsonSchema, Serialize)] + pub struct WorkerAppendJobOrTask { + pub payload: String, + pub stream: String, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub task: Option, + pub time: chrono::DateTime, + } + + impl From<&WorkerAppendJobOrTask> for WorkerAppendJobOrTask { + fn from(value: &WorkerAppendJobOrTask) -> Self { + value.clone() + } + } + + impl WorkerAppendJobOrTask { + pub fn builder() -> builder::WorkerAppendJobOrTask { + builder::WorkerAppendJobOrTask::default() + } + } + + #[derive(Clone, Debug, Deserialize, JsonSchema, Serialize)] + pub struct WorkerBootstrap { + pub bootstrap: String, + pub token: String, + } + + impl From<&WorkerBootstrap> for WorkerBootstrap { + fn from(value: &WorkerBootstrap) -> Self { + value.clone() + } + } + + impl WorkerBootstrap { + pub fn builder() -> builder::WorkerBootstrap { + builder::WorkerBootstrap::default() + } + } + + #[derive(Clone, Debug, Deserialize, JsonSchema, Serialize)] + pub struct WorkerBootstrapResult { + pub id: String, + } + + impl From<&WorkerBootstrapResult> for WorkerBootstrapResult { + fn from(value: &WorkerBootstrapResult) -> Self { + value.clone() + } + } + + impl WorkerBootstrapResult { + pub fn builder() -> builder::WorkerBootstrapResult { + builder::WorkerBootstrapResult::default() + } + } + + #[derive(Clone, Debug, Deserialize, JsonSchema, Serialize)] + pub struct WorkerCompleteJob { + pub failed: bool, + } + + impl From<&WorkerCompleteJob> for WorkerCompleteJob { + fn from(value: &WorkerCompleteJob) -> Self { + value.clone() + } + } + + impl WorkerCompleteJob { + pub fn builder() -> builder::WorkerCompleteJob { + builder::WorkerCompleteJob::default() + } + } + + #[derive(Clone, Debug, Deserialize, JsonSchema, Serialize)] + pub struct WorkerCompleteTask { + pub failed: bool, + } + + impl From<&WorkerCompleteTask> for WorkerCompleteTask { + fn from(value: &WorkerCompleteTask) -> Self { + value.clone() + } + } + + impl WorkerCompleteTask { + pub fn builder() -> builder::WorkerCompleteTask { + builder::WorkerCompleteTask::default() + } + } + + #[derive(Clone, Debug, Deserialize, JsonSchema, Serialize)] + pub struct WorkerJob { + pub id: String, + pub name: String, + pub owner: String, + pub state: String, + pub tags: std::collections::HashMap, + } + + impl From<&WorkerJob> for WorkerJob { + fn from(value: &WorkerJob) -> Self { + value.clone() + } + } + + impl WorkerJob { + pub fn builder() -> builder::WorkerJob { + builder::WorkerJob::default() + } + } + + #[derive(Clone, Debug, Deserialize, JsonSchema, Serialize)] + pub struct WorkerJobQuota { + pub max_bytes_per_output: u64, + } + + impl From<&WorkerJobQuota> for WorkerJobQuota { + fn from(value: &WorkerJobQuota) -> Self { + value.clone() + } + } + + impl WorkerJobQuota { + pub fn builder() -> builder::WorkerJobQuota { + builder::WorkerJobQuota::default() + } + } + + #[derive(Clone, Debug, Deserialize, JsonSchema, Serialize)] + pub struct WorkerJobStoreGet { + #[serde(default, skip_serializing_if = "Option::is_none")] + pub value: Option, + } + + impl From<&WorkerJobStoreGet> for WorkerJobStoreGet { + fn from(value: &WorkerJobStoreGet) -> Self { + value.clone() + } + } + + impl WorkerJobStoreGet { + pub fn builder() -> builder::WorkerJobStoreGet { + builder::WorkerJobStoreGet::default() + } + } + + #[derive(Clone, Debug, Deserialize, JsonSchema, Serialize)] + pub struct WorkerJobStoreValue { + pub secret: bool, + pub value: String, + } + + impl From<&WorkerJobStoreValue> for WorkerJobStoreValue { + fn from(value: &WorkerJobStoreValue) -> Self { + value.clone() + } + } + + impl WorkerJobStoreValue { + pub fn builder() -> builder::WorkerJobStoreValue { + builder::WorkerJobStoreValue::default() + } + } + + #[derive(Clone, Debug, Deserialize, JsonSchema, Serialize)] + pub struct WorkerPingInput { + pub id: String, + pub name: String, + } + + impl From<&WorkerPingInput> for WorkerPingInput { + fn from(value: &WorkerPingInput) -> Self { + value.clone() + } + } + + impl WorkerPingInput { + pub fn builder() -> builder::WorkerPingInput { + builder::WorkerPingInput::default() + } + } + + #[derive(Clone, Debug, Deserialize, JsonSchema, Serialize)] + pub struct WorkerPingJob { + pub id: String, + pub inputs: Vec, + pub name: String, + pub output_rules: Vec, + pub tasks: Vec, + } + + impl From<&WorkerPingJob> for WorkerPingJob { + fn from(value: &WorkerPingJob) -> Self { + value.clone() + } + } + + impl WorkerPingJob { + pub fn builder() -> builder::WorkerPingJob { + builder::WorkerPingJob::default() + } + } + + #[derive(Clone, Debug, Deserialize, JsonSchema, Serialize)] + pub struct WorkerPingOutputRule { + pub ignore: bool, + pub require_match: bool, + pub rule: String, + pub size_change_ok: bool, + } + + impl From<&WorkerPingOutputRule> for WorkerPingOutputRule { + fn from(value: &WorkerPingOutputRule) -> Self { + value.clone() + } + } + + impl WorkerPingOutputRule { + pub fn builder() -> builder::WorkerPingOutputRule { + builder::WorkerPingOutputRule::default() + } + } + + #[derive(Clone, Debug, Deserialize, JsonSchema, Serialize)] + pub struct WorkerPingResult { + #[serde(default, skip_serializing_if = "Option::is_none")] + pub factory_metadata: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub job: Option, + pub poweroff: bool, + } + + impl From<&WorkerPingResult> for WorkerPingResult { + fn from(value: &WorkerPingResult) -> Self { + value.clone() + } + } + + impl WorkerPingResult { + pub fn builder() -> builder::WorkerPingResult { + builder::WorkerPingResult::default() + } + } + + #[derive(Clone, Debug, Deserialize, JsonSchema, Serialize)] + pub struct WorkerPingTask { + pub env: std::collections::HashMap, + pub env_clear: bool, + pub gid: u32, + pub id: u32, + pub name: String, + pub script: String, + pub uid: u32, + pub workdir: String, + } + + impl From<&WorkerPingTask> for WorkerPingTask { + fn from(value: &WorkerPingTask) -> Self { + value.clone() + } + } + + impl WorkerPingTask { + pub fn builder() -> builder::WorkerPingTask { + builder::WorkerPingTask::default() + } + } + + #[derive(Clone, Debug, Deserialize, JsonSchema, Serialize)] + pub struct WorkersResult { + pub workers: Vec, + } + + impl From<&WorkersResult> for WorkersResult { + fn from(value: &WorkersResult) -> Self { + value.clone() + } + } + + impl WorkersResult { + pub fn builder() -> builder::WorkersResult { + builder::WorkersResult::default() + } + } + + pub mod builder { + #[derive(Clone, Debug)] + pub struct DependSubmit { + copy_outputs: Result, + on_completed: Result, + on_failed: Result, + prior_job: Result, + } + + impl Default for DependSubmit { + fn default() -> Self { + Self { + copy_outputs: Err("no value supplied for copy_outputs".to_string()), + on_completed: Err("no value supplied for on_completed".to_string()), + on_failed: Err("no value supplied for on_failed".to_string()), + prior_job: Err("no value supplied for prior_job".to_string()), + } + } + } + + impl DependSubmit { + pub fn copy_outputs(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.copy_outputs = value.try_into().map_err(|e| { + format!("error converting supplied value for copy_outputs: {}", e) + }); + self + } + pub fn on_completed(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.on_completed = value.try_into().map_err(|e| { + format!("error converting supplied value for on_completed: {}", e) + }); + self + } + pub fn on_failed(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.on_failed = value + .try_into() + .map_err(|e| format!("error converting supplied value for on_failed: {}", e)); + self + } + pub fn prior_job(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.prior_job = value + .try_into() + .map_err(|e| format!("error converting supplied value for prior_job: {}", e)); + self + } + } + + impl std::convert::TryFrom for super::DependSubmit { + type Error = String; + fn try_from(value: DependSubmit) -> Result { + Ok(Self { + copy_outputs: value.copy_outputs?, + on_completed: value.on_completed?, + on_failed: value.on_failed?, + prior_job: value.prior_job?, + }) + } + } + + impl From for DependSubmit { + fn from(value: super::DependSubmit) -> Self { + Self { + copy_outputs: Ok(value.copy_outputs), + on_completed: Ok(value.on_completed), + on_failed: Ok(value.on_failed), + prior_job: Ok(value.prior_job), + } + } + } + + #[derive(Clone, Debug)] + pub struct Error { + error_code: Result, String>, + message: Result, + request_id: Result, + } + + impl Default for Error { + fn default() -> Self { + Self { + error_code: Ok(Default::default()), + message: Err("no value supplied for message".to_string()), + request_id: Err("no value supplied for request_id".to_string()), + } + } + } + + impl Error { + pub fn error_code(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.error_code = value + .try_into() + .map_err(|e| format!("error converting supplied value for error_code: {}", e)); + self + } + pub fn message(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.message = value + .try_into() + .map_err(|e| format!("error converting supplied value for message: {}", e)); + self + } + pub fn request_id(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.request_id = value + .try_into() + .map_err(|e| format!("error converting supplied value for request_id: {}", e)); + self + } + } + + impl std::convert::TryFrom for super::Error { + type Error = String; + fn try_from(value: Error) -> Result { + Ok(Self { + error_code: value.error_code?, + message: value.message?, + request_id: value.request_id?, + }) + } + } + + impl From for Error { + fn from(value: super::Error) -> Self { + Self { + error_code: Ok(value.error_code), + message: Ok(value.message), + request_id: Ok(value.request_id), + } + } + } + + #[derive(Clone, Debug)] + pub struct FactoryAddresses { + cidr: Result, + count: Result, + first: Result, + gateway: Result, String>, + name: Result, + routed: Result, + } + + impl Default for FactoryAddresses { + fn default() -> Self { + Self { + cidr: Err("no value supplied for cidr".to_string()), + count: Err("no value supplied for count".to_string()), + first: Err("no value supplied for first".to_string()), + gateway: Ok(Default::default()), + name: Err("no value supplied for name".to_string()), + routed: Err("no value supplied for routed".to_string()), + } + } + } + + impl FactoryAddresses { + pub fn cidr(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.cidr = value + .try_into() + .map_err(|e| format!("error converting supplied value for cidr: {}", e)); + self + } + pub fn count(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.count = value + .try_into() + .map_err(|e| format!("error converting supplied value for count: {}", e)); + self + } + pub fn first(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.first = value + .try_into() + .map_err(|e| format!("error converting supplied value for first: {}", e)); + self + } + pub fn gateway(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.gateway = value + .try_into() + .map_err(|e| format!("error converting supplied value for gateway: {}", e)); + self + } + pub fn name(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.name = value + .try_into() + .map_err(|e| format!("error converting supplied value for name: {}", e)); + self + } + pub fn routed(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.routed = value + .try_into() + .map_err(|e| format!("error converting supplied value for routed: {}", e)); + self + } + } + + impl std::convert::TryFrom for super::FactoryAddresses { + type Error = String; + fn try_from(value: FactoryAddresses) -> Result { + Ok(Self { + cidr: value.cidr?, + count: value.count?, + first: value.first?, + gateway: value.gateway?, + name: value.name?, + routed: value.routed?, + }) + } + } + + impl From for FactoryAddresses { + fn from(value: super::FactoryAddresses) -> Self { + Self { + cidr: Ok(value.cidr), + count: Ok(value.count), + first: Ok(value.first), + gateway: Ok(value.gateway), + name: Ok(value.name), + routed: Ok(value.routed), + } + } + } + + #[derive(Clone, Debug)] + pub struct FactoryCreate { + name: Result, + } + + impl Default for FactoryCreate { + fn default() -> Self { + Self { + name: Err("no value supplied for name".to_string()), + } + } + } + + impl FactoryCreate { + pub fn name(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.name = value + .try_into() + .map_err(|e| format!("error converting supplied value for name: {}", e)); + self + } + } + + impl std::convert::TryFrom for super::FactoryCreate { + type Error = String; + fn try_from(value: FactoryCreate) -> Result { + Ok(Self { name: value.name? }) + } + } + + impl From for FactoryCreate { + fn from(value: super::FactoryCreate) -> Self { + Self { + name: Ok(value.name), + } + } + } + + #[derive(Clone, Debug)] + pub struct FactoryCreateResult { + id: Result, + name: Result, + token: Result, + } + + impl Default for FactoryCreateResult { + fn default() -> Self { + Self { + id: Err("no value supplied for id".to_string()), + name: Err("no value supplied for name".to_string()), + token: Err("no value supplied for token".to_string()), + } + } + } + + impl FactoryCreateResult { + pub fn id(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.id = value + .try_into() + .map_err(|e| format!("error converting supplied value for id: {}", e)); + self + } + pub fn name(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.name = value + .try_into() + .map_err(|e| format!("error converting supplied value for name: {}", e)); + self + } + pub fn token(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.token = value + .try_into() + .map_err(|e| format!("error converting supplied value for token: {}", e)); + self + } + } + + impl std::convert::TryFrom for super::FactoryCreateResult { + type Error = String; + fn try_from(value: FactoryCreateResult) -> Result { + Ok(Self { + id: value.id?, + name: value.name?, + token: value.token?, + }) + } + } + + impl From for FactoryCreateResult { + fn from(value: super::FactoryCreateResult) -> Self { + Self { + id: Ok(value.id), + name: Ok(value.name), + token: Ok(value.token), + } + } + } + + #[derive(Clone, Debug)] + pub struct FactoryLease { + job: Result, + target: Result, + } + + impl Default for FactoryLease { + fn default() -> Self { + Self { + job: Err("no value supplied for job".to_string()), + target: Err("no value supplied for target".to_string()), + } + } + } + + impl FactoryLease { + pub fn job(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.job = value + .try_into() + .map_err(|e| format!("error converting supplied value for job: {}", e)); + self + } + pub fn target(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.target = value + .try_into() + .map_err(|e| format!("error converting supplied value for target: {}", e)); + self + } + } + + impl std::convert::TryFrom for super::FactoryLease { + type Error = String; + fn try_from(value: FactoryLease) -> Result { + Ok(Self { + job: value.job?, + target: value.target?, + }) + } + } + + impl From for FactoryLease { + fn from(value: super::FactoryLease) -> Self { + Self { + job: Ok(value.job), + target: Ok(value.target), + } + } + } + + #[derive(Clone, Debug)] + pub struct FactoryLeaseResult { + lease: Result, String>, + } + + impl Default for FactoryLeaseResult { + fn default() -> Self { + Self { + lease: Ok(Default::default()), + } + } + } + + impl FactoryLeaseResult { + pub fn lease(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.lease = value + .try_into() + .map_err(|e| format!("error converting supplied value for lease: {}", e)); + self + } + } + + impl std::convert::TryFrom for super::FactoryLeaseResult { + type Error = String; + fn try_from(value: FactoryLeaseResult) -> Result { + Ok(Self { + lease: value.lease?, + }) + } + } + + impl From for FactoryLeaseResult { + fn from(value: super::FactoryLeaseResult) -> Self { + Self { + lease: Ok(value.lease), + } + } + } + + #[derive(Clone, Debug)] + pub struct FactoryPingResult { + ok: Result, + } + + impl Default for FactoryPingResult { + fn default() -> Self { + Self { + ok: Err("no value supplied for ok".to_string()), + } + } + } + + impl FactoryPingResult { + pub fn ok(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.ok = value + .try_into() + .map_err(|e| format!("error converting supplied value for ok: {}", e)); + self + } + } + + impl std::convert::TryFrom for super::FactoryPingResult { + type Error = String; + fn try_from(value: FactoryPingResult) -> Result { + Ok(Self { ok: value.ok? }) + } + } + + impl From for FactoryPingResult { + fn from(value: super::FactoryPingResult) -> Self { + Self { ok: Ok(value.ok) } + } + } + + #[derive(Clone, Debug)] + pub struct FactoryWhatsNext { + supported_targets: Result, String>, + } + + impl Default for FactoryWhatsNext { + fn default() -> Self { + Self { + supported_targets: Err("no value supplied for supported_targets".to_string()), + } + } + } + + impl FactoryWhatsNext { + pub fn supported_targets(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.supported_targets = value.try_into().map_err(|e| { + format!( + "error converting supplied value for supported_targets: {}", + e + ) + }); + self + } + } + + impl std::convert::TryFrom for super::FactoryWhatsNext { + type Error = String; + fn try_from(value: FactoryWhatsNext) -> Result { + Ok(Self { + supported_targets: value.supported_targets?, + }) + } + } + + impl From for FactoryWhatsNext { + fn from(value: super::FactoryWhatsNext) -> Self { + Self { + supported_targets: Ok(value.supported_targets), + } + } + } + + #[derive(Clone, Debug)] + pub struct FactoryWorker { + bootstrap: Result, + id: Result, + online: Result, + private: Result, String>, + recycle: Result, + } + + impl Default for FactoryWorker { + fn default() -> Self { + Self { + bootstrap: Err("no value supplied for bootstrap".to_string()), + id: Err("no value supplied for id".to_string()), + online: Err("no value supplied for online".to_string()), + private: Ok(Default::default()), + recycle: Err("no value supplied for recycle".to_string()), + } + } + } + + impl FactoryWorker { + pub fn bootstrap(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.bootstrap = value + .try_into() + .map_err(|e| format!("error converting supplied value for bootstrap: {}", e)); + self + } + pub fn id(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.id = value + .try_into() + .map_err(|e| format!("error converting supplied value for id: {}", e)); + self + } + pub fn online(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.online = value + .try_into() + .map_err(|e| format!("error converting supplied value for online: {}", e)); + self + } + pub fn private(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.private = value + .try_into() + .map_err(|e| format!("error converting supplied value for private: {}", e)); + self + } + pub fn recycle(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.recycle = value + .try_into() + .map_err(|e| format!("error converting supplied value for recycle: {}", e)); + self + } + } + + impl std::convert::TryFrom for super::FactoryWorker { + type Error = String; + fn try_from(value: FactoryWorker) -> Result { + Ok(Self { + bootstrap: value.bootstrap?, + id: value.id?, + online: value.online?, + private: value.private?, + recycle: value.recycle?, + }) + } + } + + impl From for FactoryWorker { + fn from(value: super::FactoryWorker) -> Self { + Self { + bootstrap: Ok(value.bootstrap), + id: Ok(value.id), + online: Ok(value.online), + private: Ok(value.private), + recycle: Ok(value.recycle), + } + } + } + + #[derive(Clone, Debug)] + pub struct FactoryWorkerAppend { + payload: Result, + stream: Result, + time: Result, String>, + } + + impl Default for FactoryWorkerAppend { + fn default() -> Self { + Self { + payload: Err("no value supplied for payload".to_string()), + stream: Err("no value supplied for stream".to_string()), + time: Err("no value supplied for time".to_string()), + } + } + } + + impl FactoryWorkerAppend { + pub fn payload(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.payload = value + .try_into() + .map_err(|e| format!("error converting supplied value for payload: {}", e)); + self + } + pub fn stream(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.stream = value + .try_into() + .map_err(|e| format!("error converting supplied value for stream: {}", e)); + self + } + pub fn time(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.time = value + .try_into() + .map_err(|e| format!("error converting supplied value for time: {}", e)); + self + } + } + + impl std::convert::TryFrom for super::FactoryWorkerAppend { + type Error = String; + fn try_from(value: FactoryWorkerAppend) -> Result { + Ok(Self { + payload: value.payload?, + stream: value.stream?, + time: value.time?, + }) + } + } + + impl From for FactoryWorkerAppend { + fn from(value: super::FactoryWorkerAppend) -> Self { + Self { + payload: Ok(value.payload), + stream: Ok(value.stream), + time: Ok(value.time), + } + } + } + + #[derive(Clone, Debug)] + pub struct FactoryWorkerAppendResult { + retry: Result, + } + + impl Default for FactoryWorkerAppendResult { + fn default() -> Self { + Self { + retry: Err("no value supplied for retry".to_string()), + } + } + } + + impl FactoryWorkerAppendResult { + pub fn retry(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.retry = value + .try_into() + .map_err(|e| format!("error converting supplied value for retry: {}", e)); + self + } + } + + impl std::convert::TryFrom for super::FactoryWorkerAppendResult { + type Error = String; + fn try_from(value: FactoryWorkerAppendResult) -> Result { + Ok(Self { + retry: value.retry?, + }) + } + } + + impl From for FactoryWorkerAppendResult { + fn from(value: super::FactoryWorkerAppendResult) -> Self { + Self { + retry: Ok(value.retry), + } + } + } + + #[derive(Clone, Debug)] + pub struct FactoryWorkerAssociate { + metadata: Result, String>, + private: Result, + } + + impl Default for FactoryWorkerAssociate { + fn default() -> Self { + Self { + metadata: Ok(Default::default()), + private: Err("no value supplied for private".to_string()), + } + } + } + + impl FactoryWorkerAssociate { + pub fn metadata(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.metadata = value + .try_into() + .map_err(|e| format!("error converting supplied value for metadata: {}", e)); + self + } + pub fn private(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.private = value + .try_into() + .map_err(|e| format!("error converting supplied value for private: {}", e)); + self + } + } + + impl std::convert::TryFrom for super::FactoryWorkerAssociate { + type Error = String; + fn try_from(value: FactoryWorkerAssociate) -> Result { + Ok(Self { + metadata: value.metadata?, + private: value.private?, + }) + } + } + + impl From for FactoryWorkerAssociate { + fn from(value: super::FactoryWorkerAssociate) -> Self { + Self { + metadata: Ok(value.metadata), + private: Ok(value.private), + } + } + } + + #[derive(Clone, Debug)] + pub struct FactoryWorkerCreate { + job: Result, String>, + target: Result, + wait_for_flush: Result, + } + + impl Default for FactoryWorkerCreate { + fn default() -> Self { + Self { + job: Ok(Default::default()), + target: Err("no value supplied for target".to_string()), + wait_for_flush: Ok(Default::default()), + } + } + } + + impl FactoryWorkerCreate { + pub fn job(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.job = value + .try_into() + .map_err(|e| format!("error converting supplied value for job: {}", e)); + self + } + pub fn target(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.target = value + .try_into() + .map_err(|e| format!("error converting supplied value for target: {}", e)); + self + } + pub fn wait_for_flush(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.wait_for_flush = value.try_into().map_err(|e| { + format!("error converting supplied value for wait_for_flush: {}", e) + }); + self + } + } + + impl std::convert::TryFrom for super::FactoryWorkerCreate { + type Error = String; + fn try_from(value: FactoryWorkerCreate) -> Result { + Ok(Self { + job: value.job?, + target: value.target?, + wait_for_flush: value.wait_for_flush?, + }) + } + } + + impl From for FactoryWorkerCreate { + fn from(value: super::FactoryWorkerCreate) -> Self { + Self { + job: Ok(value.job), + target: Ok(value.target), + wait_for_flush: Ok(value.wait_for_flush), + } + } + } + + #[derive(Clone, Debug)] + pub struct FactoryWorkerResult { + worker: Result, String>, + } + + impl Default for FactoryWorkerResult { + fn default() -> Self { + Self { + worker: Ok(Default::default()), + } + } + } + + impl FactoryWorkerResult { + pub fn worker(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.worker = value + .try_into() + .map_err(|e| format!("error converting supplied value for worker: {}", e)); + self + } + } + + impl std::convert::TryFrom for super::FactoryWorkerResult { + type Error = String; + fn try_from(value: FactoryWorkerResult) -> Result { + Ok(Self { + worker: value.worker?, + }) + } + } + + impl From for FactoryWorkerResult { + fn from(value: super::FactoryWorkerResult) -> Self { + Self { + worker: Ok(value.worker), + } + } + } + + #[derive(Clone, Debug)] + pub struct Job { + cancelled: Result, + id: Result, + name: Result, + output_rules: Result, String>, + owner: Result, + state: Result, + tags: Result, String>, + target: Result, + target_real: Result, + tasks: Result, String>, + times: Result< + std::collections::HashMap>, + String, + >, + } + + impl Default for Job { + fn default() -> Self { + Self { + cancelled: Err("no value supplied for cancelled".to_string()), + id: Err("no value supplied for id".to_string()), + name: Err("no value supplied for name".to_string()), + output_rules: Err("no value supplied for output_rules".to_string()), + owner: Err("no value supplied for owner".to_string()), + state: Err("no value supplied for state".to_string()), + tags: Err("no value supplied for tags".to_string()), + target: Err("no value supplied for target".to_string()), + target_real: Err("no value supplied for target_real".to_string()), + tasks: Err("no value supplied for tasks".to_string()), + times: Ok(Default::default()), + } + } + } + + impl Job { + pub fn cancelled(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.cancelled = value + .try_into() + .map_err(|e| format!("error converting supplied value for cancelled: {}", e)); + self + } + pub fn id(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.id = value + .try_into() + .map_err(|e| format!("error converting supplied value for id: {}", e)); + self + } + pub fn name(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.name = value + .try_into() + .map_err(|e| format!("error converting supplied value for name: {}", e)); + self + } + pub fn output_rules(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.output_rules = value.try_into().map_err(|e| { + format!("error converting supplied value for output_rules: {}", e) + }); + self + } + pub fn owner(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.owner = value + .try_into() + .map_err(|e| format!("error converting supplied value for owner: {}", e)); + self + } + pub fn state(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.state = value + .try_into() + .map_err(|e| format!("error converting supplied value for state: {}", e)); + self + } + pub fn tags(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.tags = value + .try_into() + .map_err(|e| format!("error converting supplied value for tags: {}", e)); + self + } + pub fn target(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.target = value + .try_into() + .map_err(|e| format!("error converting supplied value for target: {}", e)); + self + } + pub fn target_real(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.target_real = value + .try_into() + .map_err(|e| format!("error converting supplied value for target_real: {}", e)); + self + } + pub fn tasks(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.tasks = value + .try_into() + .map_err(|e| format!("error converting supplied value for tasks: {}", e)); + self + } + pub fn times(mut self, value: T) -> Self + where + T: std::convert::TryInto< + std::collections::HashMap>, + >, + T::Error: std::fmt::Display, + { + self.times = value + .try_into() + .map_err(|e| format!("error converting supplied value for times: {}", e)); + self + } + } + + impl std::convert::TryFrom for super::Job { + type Error = String; + fn try_from(value: Job) -> Result { + Ok(Self { + cancelled: value.cancelled?, + id: value.id?, + name: value.name?, + output_rules: value.output_rules?, + owner: value.owner?, + state: value.state?, + tags: value.tags?, + target: value.target?, + target_real: value.target_real?, + tasks: value.tasks?, + times: value.times?, + }) + } + } + + impl From for Job { + fn from(value: super::Job) -> Self { + Self { + cancelled: Ok(value.cancelled), + id: Ok(value.id), + name: Ok(value.name), + output_rules: Ok(value.output_rules), + owner: Ok(value.owner), + state: Ok(value.state), + tags: Ok(value.tags), + target: Ok(value.target), + target_real: Ok(value.target_real), + tasks: Ok(value.tasks), + times: Ok(value.times), + } + } + } + + #[derive(Clone, Debug)] + pub struct JobAddInput { + chunks: Result, String>, + commit_id: Result, + name: Result, + size: Result, + } + + impl Default for JobAddInput { + fn default() -> Self { + Self { + chunks: Err("no value supplied for chunks".to_string()), + commit_id: Err("no value supplied for commit_id".to_string()), + name: Err("no value supplied for name".to_string()), + size: Err("no value supplied for size".to_string()), + } + } + } + + impl JobAddInput { + pub fn chunks(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.chunks = value + .try_into() + .map_err(|e| format!("error converting supplied value for chunks: {}", e)); + self + } + pub fn commit_id(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.commit_id = value + .try_into() + .map_err(|e| format!("error converting supplied value for commit_id: {}", e)); + self + } + pub fn name(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.name = value + .try_into() + .map_err(|e| format!("error converting supplied value for name: {}", e)); + self + } + pub fn size(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.size = value + .try_into() + .map_err(|e| format!("error converting supplied value for size: {}", e)); + self + } + } + + impl std::convert::TryFrom for super::JobAddInput { + type Error = String; + fn try_from(value: JobAddInput) -> Result { + Ok(Self { + chunks: value.chunks?, + commit_id: value.commit_id?, + name: value.name?, + size: value.size?, + }) + } + } + + impl From for JobAddInput { + fn from(value: super::JobAddInput) -> Self { + Self { + chunks: Ok(value.chunks), + commit_id: Ok(value.commit_id), + name: Ok(value.name), + size: Ok(value.size), + } + } + } + + #[derive(Clone, Debug)] + pub struct JobAddInputResult { + complete: Result, + error: Result, String>, + } + + impl Default for JobAddInputResult { + fn default() -> Self { + Self { + complete: Err("no value supplied for complete".to_string()), + error: Ok(Default::default()), + } + } + } + + impl JobAddInputResult { + pub fn complete(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.complete = value + .try_into() + .map_err(|e| format!("error converting supplied value for complete: {}", e)); + self + } + pub fn error(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.error = value + .try_into() + .map_err(|e| format!("error converting supplied value for error: {}", e)); + self + } + } + + impl std::convert::TryFrom for super::JobAddInputResult { + type Error = String; + fn try_from(value: JobAddInputResult) -> Result { + Ok(Self { + complete: value.complete?, + error: value.error?, + }) + } + } + + impl From for JobAddInputResult { + fn from(value: super::JobAddInputResult) -> Self { + Self { + complete: Ok(value.complete), + error: Ok(value.error), + } + } + } + + #[derive(Clone, Debug)] + pub struct JobEvent { + payload: Result, + seq: Result, + stream: Result, + task: Result, String>, + time: Result, String>, + time_remote: Result>, String>, + } + + impl Default for JobEvent { + fn default() -> Self { + Self { + payload: Err("no value supplied for payload".to_string()), + seq: Err("no value supplied for seq".to_string()), + stream: Err("no value supplied for stream".to_string()), + task: Ok(Default::default()), + time: Err("no value supplied for time".to_string()), + time_remote: Ok(Default::default()), + } + } + } + + impl JobEvent { + pub fn payload(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.payload = value + .try_into() + .map_err(|e| format!("error converting supplied value for payload: {}", e)); + self + } + pub fn seq(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.seq = value + .try_into() + .map_err(|e| format!("error converting supplied value for seq: {}", e)); + self + } + pub fn stream(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.stream = value + .try_into() + .map_err(|e| format!("error converting supplied value for stream: {}", e)); + self + } + pub fn task(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.task = value + .try_into() + .map_err(|e| format!("error converting supplied value for task: {}", e)); + self + } + pub fn time(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.time = value + .try_into() + .map_err(|e| format!("error converting supplied value for time: {}", e)); + self + } + pub fn time_remote(mut self, value: T) -> Self + where + T: std::convert::TryInto>>, + T::Error: std::fmt::Display, + { + self.time_remote = value + .try_into() + .map_err(|e| format!("error converting supplied value for time_remote: {}", e)); + self + } + } + + impl std::convert::TryFrom for super::JobEvent { + type Error = String; + fn try_from(value: JobEvent) -> Result { + Ok(Self { + payload: value.payload?, + seq: value.seq?, + stream: value.stream?, + task: value.task?, + time: value.time?, + time_remote: value.time_remote?, + }) + } + } + + impl From for JobEvent { + fn from(value: super::JobEvent) -> Self { + Self { + payload: Ok(value.payload), + seq: Ok(value.seq), + stream: Ok(value.stream), + task: Ok(value.task), + time: Ok(value.time), + time_remote: Ok(value.time_remote), + } + } + } + + #[derive(Clone, Debug)] + pub struct JobOutput { + id: Result, + path: Result, + size: Result, + } + + impl Default for JobOutput { + fn default() -> Self { + Self { + id: Err("no value supplied for id".to_string()), + path: Err("no value supplied for path".to_string()), + size: Err("no value supplied for size".to_string()), + } + } + } + + impl JobOutput { + pub fn id(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.id = value + .try_into() + .map_err(|e| format!("error converting supplied value for id: {}", e)); + self + } + pub fn path(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.path = value + .try_into() + .map_err(|e| format!("error converting supplied value for path: {}", e)); + self + } + pub fn size(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.size = value + .try_into() + .map_err(|e| format!("error converting supplied value for size: {}", e)); + self + } + } + + impl std::convert::TryFrom for super::JobOutput { + type Error = String; + fn try_from(value: JobOutput) -> Result { + Ok(Self { + id: value.id?, + path: value.path?, + size: value.size?, + }) + } + } + + impl From for JobOutput { + fn from(value: super::JobOutput) -> Self { + Self { + id: Ok(value.id), + path: Ok(value.path), + size: Ok(value.size), + } + } + } + + #[derive(Clone, Debug)] + pub struct JobOutputPublish { + name: Result, + series: Result, + version: Result, + } + + impl Default for JobOutputPublish { + fn default() -> Self { + Self { + name: Err("no value supplied for name".to_string()), + series: Err("no value supplied for series".to_string()), + version: Err("no value supplied for version".to_string()), + } + } + } + + impl JobOutputPublish { + pub fn name(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.name = value + .try_into() + .map_err(|e| format!("error converting supplied value for name: {}", e)); + self + } + pub fn series(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.series = value + .try_into() + .map_err(|e| format!("error converting supplied value for series: {}", e)); + self + } + pub fn version(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.version = value + .try_into() + .map_err(|e| format!("error converting supplied value for version: {}", e)); + self + } + } + + impl std::convert::TryFrom for super::JobOutputPublish { + type Error = String; + fn try_from(value: JobOutputPublish) -> Result { + Ok(Self { + name: value.name?, + series: value.series?, + version: value.version?, + }) + } + } + + impl From for JobOutputPublish { + fn from(value: super::JobOutputPublish) -> Self { + Self { + name: Ok(value.name), + series: Ok(value.series), + version: Ok(value.version), + } + } + } + + #[derive(Clone, Debug)] + pub struct JobOutputSignedUrl { + content_disposition: Result, String>, + content_type: Result, String>, + expiry_seconds: Result, + } + + impl Default for JobOutputSignedUrl { + fn default() -> Self { + Self { + content_disposition: Ok(Default::default()), + content_type: Ok(Default::default()), + expiry_seconds: Err("no value supplied for expiry_seconds".to_string()), + } + } + } + + impl JobOutputSignedUrl { + pub fn content_disposition(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.content_disposition = value.try_into().map_err(|e| { + format!( + "error converting supplied value for content_disposition: {}", + e + ) + }); + self + } + pub fn content_type(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.content_type = value.try_into().map_err(|e| { + format!("error converting supplied value for content_type: {}", e) + }); + self + } + pub fn expiry_seconds(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.expiry_seconds = value.try_into().map_err(|e| { + format!("error converting supplied value for expiry_seconds: {}", e) + }); + self + } + } + + impl std::convert::TryFrom for super::JobOutputSignedUrl { + type Error = String; + fn try_from(value: JobOutputSignedUrl) -> Result { + Ok(Self { + content_disposition: value.content_disposition?, + content_type: value.content_type?, + expiry_seconds: value.expiry_seconds?, + }) + } + } + + impl From for JobOutputSignedUrl { + fn from(value: super::JobOutputSignedUrl) -> Self { + Self { + content_disposition: Ok(value.content_disposition), + content_type: Ok(value.content_type), + expiry_seconds: Ok(value.expiry_seconds), + } + } + } + + #[derive(Clone, Debug)] + pub struct JobOutputSignedUrlResult { + url: Result, + } + + impl Default for JobOutputSignedUrlResult { + fn default() -> Self { + Self { + url: Err("no value supplied for url".to_string()), + } + } + } + + impl JobOutputSignedUrlResult { + pub fn url(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.url = value + .try_into() + .map_err(|e| format!("error converting supplied value for url: {}", e)); + self + } + } + + impl std::convert::TryFrom for super::JobOutputSignedUrlResult { + type Error = String; + fn try_from(value: JobOutputSignedUrlResult) -> Result { + Ok(Self { url: value.url? }) + } + } + + impl From for JobOutputSignedUrlResult { + fn from(value: super::JobOutputSignedUrlResult) -> Self { + Self { url: Ok(value.url) } + } + } + + #[derive(Clone, Debug)] + pub struct JobStoreValue { + secret: Result, + value: Result, + } + + impl Default for JobStoreValue { + fn default() -> Self { + Self { + secret: Err("no value supplied for secret".to_string()), + value: Err("no value supplied for value".to_string()), + } + } + } + + impl JobStoreValue { + pub fn secret(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.secret = value + .try_into() + .map_err(|e| format!("error converting supplied value for secret: {}", e)); + self + } + pub fn value(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.value = value + .try_into() + .map_err(|e| format!("error converting supplied value for value: {}", e)); + self + } + } + + impl std::convert::TryFrom for super::JobStoreValue { + type Error = String; + fn try_from(value: JobStoreValue) -> Result { + Ok(Self { + secret: value.secret?, + value: value.value?, + }) + } + } + + impl From for JobStoreValue { + fn from(value: super::JobStoreValue) -> Self { + Self { + secret: Ok(value.secret), + value: Ok(value.value), + } + } + } + + #[derive(Clone, Debug)] + pub struct JobStoreValueInfo { + secret: Result, + source: Result, + time_update: Result, String>, + value: Result, String>, + } + + impl Default for JobStoreValueInfo { + fn default() -> Self { + Self { + secret: Err("no value supplied for secret".to_string()), + source: Err("no value supplied for source".to_string()), + time_update: Err("no value supplied for time_update".to_string()), + value: Ok(Default::default()), + } + } + } + + impl JobStoreValueInfo { + pub fn secret(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.secret = value + .try_into() + .map_err(|e| format!("error converting supplied value for secret: {}", e)); + self + } + pub fn source(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.source = value + .try_into() + .map_err(|e| format!("error converting supplied value for source: {}", e)); + self + } + pub fn time_update(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.time_update = value + .try_into() + .map_err(|e| format!("error converting supplied value for time_update: {}", e)); + self + } + pub fn value(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.value = value + .try_into() + .map_err(|e| format!("error converting supplied value for value: {}", e)); + self + } + } + + impl std::convert::TryFrom for super::JobStoreValueInfo { + type Error = String; + fn try_from(value: JobStoreValueInfo) -> Result { + Ok(Self { + secret: value.secret?, + source: value.source?, + time_update: value.time_update?, + value: value.value?, + }) + } + } + + impl From for JobStoreValueInfo { + fn from(value: super::JobStoreValueInfo) -> Self { + Self { + secret: Ok(value.secret), + source: Ok(value.source), + time_update: Ok(value.time_update), + value: Ok(value.value), + } + } + } + + #[derive(Clone, Debug)] + pub struct JobSubmit { + depends: Result, String>, + inputs: Result, String>, + name: Result, + output_rules: Result, String>, + tags: Result, String>, + target: Result, + tasks: Result, String>, + } + + impl Default for JobSubmit { + fn default() -> Self { + Self { + depends: Ok(Default::default()), + inputs: Ok(Default::default()), + name: Err("no value supplied for name".to_string()), + output_rules: Err("no value supplied for output_rules".to_string()), + tags: Ok(Default::default()), + target: Err("no value supplied for target".to_string()), + tasks: Err("no value supplied for tasks".to_string()), + } + } + } + + impl JobSubmit { + pub fn depends(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.depends = value + .try_into() + .map_err(|e| format!("error converting supplied value for depends: {}", e)); + self + } + pub fn inputs(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.inputs = value + .try_into() + .map_err(|e| format!("error converting supplied value for inputs: {}", e)); + self + } + pub fn name(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.name = value + .try_into() + .map_err(|e| format!("error converting supplied value for name: {}", e)); + self + } + pub fn output_rules(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.output_rules = value.try_into().map_err(|e| { + format!("error converting supplied value for output_rules: {}", e) + }); + self + } + pub fn tags(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.tags = value + .try_into() + .map_err(|e| format!("error converting supplied value for tags: {}", e)); + self + } + pub fn target(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.target = value + .try_into() + .map_err(|e| format!("error converting supplied value for target: {}", e)); + self + } + pub fn tasks(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.tasks = value + .try_into() + .map_err(|e| format!("error converting supplied value for tasks: {}", e)); + self + } + } + + impl std::convert::TryFrom for super::JobSubmit { + type Error = String; + fn try_from(value: JobSubmit) -> Result { + Ok(Self { + depends: value.depends?, + inputs: value.inputs?, + name: value.name?, + output_rules: value.output_rules?, + tags: value.tags?, + target: value.target?, + tasks: value.tasks?, + }) + } + } + + impl From for JobSubmit { + fn from(value: super::JobSubmit) -> Self { + Self { + depends: Ok(value.depends), + inputs: Ok(value.inputs), + name: Ok(value.name), + output_rules: Ok(value.output_rules), + tags: Ok(value.tags), + target: Ok(value.target), + tasks: Ok(value.tasks), + } + } + } + + #[derive(Clone, Debug)] + pub struct JobSubmitResult { + id: Result, + } + + impl Default for JobSubmitResult { + fn default() -> Self { + Self { + id: Err("no value supplied for id".to_string()), + } + } + } + + impl JobSubmitResult { + pub fn id(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.id = value + .try_into() + .map_err(|e| format!("error converting supplied value for id: {}", e)); + self + } + } + + impl std::convert::TryFrom for super::JobSubmitResult { + type Error = String; + fn try_from(value: JobSubmitResult) -> Result { + Ok(Self { id: value.id? }) + } + } + + impl From for JobSubmitResult { + fn from(value: super::JobSubmitResult) -> Self { + Self { id: Ok(value.id) } + } + } + + #[derive(Clone, Debug)] + pub struct Quota { + max_bytes_per_input: Result, + } + + impl Default for Quota { + fn default() -> Self { + Self { + max_bytes_per_input: Err( + "no value supplied for max_bytes_per_input".to_string() + ), + } + } + } + + impl Quota { + pub fn max_bytes_per_input(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.max_bytes_per_input = value.try_into().map_err(|e| { + format!( + "error converting supplied value for max_bytes_per_input: {}", + e + ) + }); + self + } + } + + impl std::convert::TryFrom for super::Quota { + type Error = String; + fn try_from(value: Quota) -> Result { + Ok(Self { + max_bytes_per_input: value.max_bytes_per_input?, + }) + } + } + + impl From for Quota { + fn from(value: super::Quota) -> Self { + Self { + max_bytes_per_input: Ok(value.max_bytes_per_input), + } + } + } + + #[derive(Clone, Debug)] + pub struct Target { + desc: Result, + id: Result, + name: Result, + privilege: Result, String>, + redirect: Result, String>, + } + + impl Default for Target { + fn default() -> Self { + Self { + desc: Err("no value supplied for desc".to_string()), + id: Err("no value supplied for id".to_string()), + name: Err("no value supplied for name".to_string()), + privilege: Ok(Default::default()), + redirect: Ok(Default::default()), + } + } + } + + impl Target { + pub fn desc(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.desc = value + .try_into() + .map_err(|e| format!("error converting supplied value for desc: {}", e)); + self + } + pub fn id(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.id = value + .try_into() + .map_err(|e| format!("error converting supplied value for id: {}", e)); + self + } + pub fn name(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.name = value + .try_into() + .map_err(|e| format!("error converting supplied value for name: {}", e)); + self + } + pub fn privilege(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.privilege = value + .try_into() + .map_err(|e| format!("error converting supplied value for privilege: {}", e)); + self + } + pub fn redirect(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.redirect = value + .try_into() + .map_err(|e| format!("error converting supplied value for redirect: {}", e)); + self + } + } + + impl std::convert::TryFrom for super::Target { + type Error = String; + fn try_from(value: Target) -> Result { + Ok(Self { + desc: value.desc?, + id: value.id?, + name: value.name?, + privilege: value.privilege?, + redirect: value.redirect?, + }) + } + } + + impl From for Target { + fn from(value: super::Target) -> Self { + Self { + desc: Ok(value.desc), + id: Ok(value.id), + name: Ok(value.name), + privilege: Ok(value.privilege), + redirect: Ok(value.redirect), + } + } + } + + #[derive(Clone, Debug)] + pub struct TargetCreate { + desc: Result, + name: Result, + } + + impl Default for TargetCreate { + fn default() -> Self { + Self { + desc: Err("no value supplied for desc".to_string()), + name: Err("no value supplied for name".to_string()), + } + } + } + + impl TargetCreate { + pub fn desc(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.desc = value + .try_into() + .map_err(|e| format!("error converting supplied value for desc: {}", e)); + self + } + pub fn name(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.name = value + .try_into() + .map_err(|e| format!("error converting supplied value for name: {}", e)); + self + } + } + + impl std::convert::TryFrom for super::TargetCreate { + type Error = String; + fn try_from(value: TargetCreate) -> Result { + Ok(Self { + desc: value.desc?, + name: value.name?, + }) + } + } + + impl From for TargetCreate { + fn from(value: super::TargetCreate) -> Self { + Self { + desc: Ok(value.desc), + name: Ok(value.name), + } + } + } + + #[derive(Clone, Debug)] + pub struct TargetCreateResult { + id: Result, + } + + impl Default for TargetCreateResult { + fn default() -> Self { + Self { + id: Err("no value supplied for id".to_string()), + } + } + } + + impl TargetCreateResult { + pub fn id(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.id = value + .try_into() + .map_err(|e| format!("error converting supplied value for id: {}", e)); + self + } + } + + impl std::convert::TryFrom for super::TargetCreateResult { + type Error = String; + fn try_from(value: TargetCreateResult) -> Result { + Ok(Self { id: value.id? }) + } + } + + impl From for TargetCreateResult { + fn from(value: super::TargetCreateResult) -> Self { + Self { id: Ok(value.id) } + } + } + + #[derive(Clone, Debug)] + pub struct TargetRedirect { + redirect: Result, String>, + } + + impl Default for TargetRedirect { + fn default() -> Self { + Self { + redirect: Ok(Default::default()), + } + } + } + + impl TargetRedirect { + pub fn redirect(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.redirect = value + .try_into() + .map_err(|e| format!("error converting supplied value for redirect: {}", e)); + self + } + } + + impl std::convert::TryFrom for super::TargetRedirect { + type Error = String; + fn try_from(value: TargetRedirect) -> Result { + Ok(Self { + redirect: value.redirect?, + }) + } + } + + impl From for TargetRedirect { + fn from(value: super::TargetRedirect) -> Self { + Self { + redirect: Ok(value.redirect), + } + } + } + + #[derive(Clone, Debug)] + pub struct TargetRename { + new_name: Result, + signpost_description: Result, + } + + impl Default for TargetRename { + fn default() -> Self { + Self { + new_name: Err("no value supplied for new_name".to_string()), + signpost_description: Err( + "no value supplied for signpost_description".to_string() + ), + } + } + } + + impl TargetRename { + pub fn new_name(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.new_name = value + .try_into() + .map_err(|e| format!("error converting supplied value for new_name: {}", e)); + self + } + pub fn signpost_description(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.signpost_description = value.try_into().map_err(|e| { + format!( + "error converting supplied value for signpost_description: {}", + e + ) + }); + self + } + } + + impl std::convert::TryFrom for super::TargetRename { + type Error = String; + fn try_from(value: TargetRename) -> Result { + Ok(Self { + new_name: value.new_name?, + signpost_description: value.signpost_description?, + }) + } + } + + impl From for TargetRename { + fn from(value: super::TargetRename) -> Self { + Self { + new_name: Ok(value.new_name), + signpost_description: Ok(value.signpost_description), + } + } + } + + #[derive(Clone, Debug)] + pub struct Task { + env: Result, String>, + env_clear: Result, + gid: Result, String>, + name: Result, + script: Result, + state: Result, + uid: Result, String>, + workdir: Result, String>, + } + + impl Default for Task { + fn default() -> Self { + Self { + env: Err("no value supplied for env".to_string()), + env_clear: Err("no value supplied for env_clear".to_string()), + gid: Ok(Default::default()), + name: Err("no value supplied for name".to_string()), + script: Err("no value supplied for script".to_string()), + state: Err("no value supplied for state".to_string()), + uid: Ok(Default::default()), + workdir: Ok(Default::default()), + } + } + } + + impl Task { + pub fn env(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.env = value + .try_into() + .map_err(|e| format!("error converting supplied value for env: {}", e)); + self + } + pub fn env_clear(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.env_clear = value + .try_into() + .map_err(|e| format!("error converting supplied value for env_clear: {}", e)); + self + } + pub fn gid(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.gid = value + .try_into() + .map_err(|e| format!("error converting supplied value for gid: {}", e)); + self + } + pub fn name(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.name = value + .try_into() + .map_err(|e| format!("error converting supplied value for name: {}", e)); + self + } + pub fn script(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.script = value + .try_into() + .map_err(|e| format!("error converting supplied value for script: {}", e)); + self + } + pub fn state(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.state = value + .try_into() + .map_err(|e| format!("error converting supplied value for state: {}", e)); + self + } + pub fn uid(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.uid = value + .try_into() + .map_err(|e| format!("error converting supplied value for uid: {}", e)); + self + } + pub fn workdir(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.workdir = value + .try_into() + .map_err(|e| format!("error converting supplied value for workdir: {}", e)); + self + } + } + + impl std::convert::TryFrom for super::Task { + type Error = String; + fn try_from(value: Task) -> Result { + Ok(Self { + env: value.env?, + env_clear: value.env_clear?, + gid: value.gid?, + name: value.name?, + script: value.script?, + state: value.state?, + uid: value.uid?, + workdir: value.workdir?, + }) + } + } + + impl From for Task { + fn from(value: super::Task) -> Self { + Self { + env: Ok(value.env), + env_clear: Ok(value.env_clear), + gid: Ok(value.gid), + name: Ok(value.name), + script: Ok(value.script), + state: Ok(value.state), + uid: Ok(value.uid), + workdir: Ok(value.workdir), + } + } + } + + #[derive(Clone, Debug)] + pub struct TaskSubmit { + env: Result, String>, + env_clear: Result, + gid: Result, String>, + name: Result, + script: Result, + uid: Result, String>, + workdir: Result, String>, + } + + impl Default for TaskSubmit { + fn default() -> Self { + Self { + env: Err("no value supplied for env".to_string()), + env_clear: Err("no value supplied for env_clear".to_string()), + gid: Ok(Default::default()), + name: Err("no value supplied for name".to_string()), + script: Err("no value supplied for script".to_string()), + uid: Ok(Default::default()), + workdir: Ok(Default::default()), + } + } + } + + impl TaskSubmit { + pub fn env(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.env = value + .try_into() + .map_err(|e| format!("error converting supplied value for env: {}", e)); + self + } + pub fn env_clear(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.env_clear = value + .try_into() + .map_err(|e| format!("error converting supplied value for env_clear: {}", e)); + self + } + pub fn gid(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.gid = value + .try_into() + .map_err(|e| format!("error converting supplied value for gid: {}", e)); + self + } + pub fn name(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.name = value + .try_into() + .map_err(|e| format!("error converting supplied value for name: {}", e)); + self + } + pub fn script(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.script = value + .try_into() + .map_err(|e| format!("error converting supplied value for script: {}", e)); + self + } + pub fn uid(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.uid = value + .try_into() + .map_err(|e| format!("error converting supplied value for uid: {}", e)); + self + } + pub fn workdir(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.workdir = value + .try_into() + .map_err(|e| format!("error converting supplied value for workdir: {}", e)); + self + } + } + + impl std::convert::TryFrom for super::TaskSubmit { + type Error = String; + fn try_from(value: TaskSubmit) -> Result { + Ok(Self { + env: value.env?, + env_clear: value.env_clear?, + gid: value.gid?, + name: value.name?, + script: value.script?, + uid: value.uid?, + workdir: value.workdir?, + }) + } + } + + impl From for TaskSubmit { + fn from(value: super::TaskSubmit) -> Self { + Self { + env: Ok(value.env), + env_clear: Ok(value.env_clear), + gid: Ok(value.gid), + name: Ok(value.name), + script: Ok(value.script), + uid: Ok(value.uid), + workdir: Ok(value.workdir), + } + } + } + + #[derive(Clone, Debug)] + pub struct UploadedChunk { + id: Result, + } + + impl Default for UploadedChunk { + fn default() -> Self { + Self { + id: Err("no value supplied for id".to_string()), + } + } + } + + impl UploadedChunk { + pub fn id(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.id = value + .try_into() + .map_err(|e| format!("error converting supplied value for id: {}", e)); + self + } + } + + impl std::convert::TryFrom for super::UploadedChunk { + type Error = String; + fn try_from(value: UploadedChunk) -> Result { + Ok(Self { id: value.id? }) + } + } + + impl From for UploadedChunk { + fn from(value: super::UploadedChunk) -> Self { + Self { id: Ok(value.id) } + } + } + + #[derive(Clone, Debug)] + pub struct User { + id: Result, + name: Result, + privileges: Result, String>, + time_create: Result, String>, + } + + impl Default for User { + fn default() -> Self { + Self { + id: Err("no value supplied for id".to_string()), + name: Err("no value supplied for name".to_string()), + privileges: Err("no value supplied for privileges".to_string()), + time_create: Err("no value supplied for time_create".to_string()), + } + } + } + + impl User { + pub fn id(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.id = value + .try_into() + .map_err(|e| format!("error converting supplied value for id: {}", e)); + self + } + pub fn name(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.name = value + .try_into() + .map_err(|e| format!("error converting supplied value for name: {}", e)); + self + } + pub fn privileges(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.privileges = value + .try_into() + .map_err(|e| format!("error converting supplied value for privileges: {}", e)); + self + } + pub fn time_create(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.time_create = value + .try_into() + .map_err(|e| format!("error converting supplied value for time_create: {}", e)); + self + } + } + + impl std::convert::TryFrom for super::User { + type Error = String; + fn try_from(value: User) -> Result { + Ok(Self { + id: value.id?, + name: value.name?, + privileges: value.privileges?, + time_create: value.time_create?, + }) + } + } + + impl From for User { + fn from(value: super::User) -> Self { + Self { + id: Ok(value.id), + name: Ok(value.name), + privileges: Ok(value.privileges), + time_create: Ok(value.time_create), + } + } + } + + #[derive(Clone, Debug)] + pub struct UserCreate { + name: Result, + } + + impl Default for UserCreate { + fn default() -> Self { + Self { + name: Err("no value supplied for name".to_string()), + } + } + } + + impl UserCreate { + pub fn name(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.name = value + .try_into() + .map_err(|e| format!("error converting supplied value for name: {}", e)); + self + } + } + + impl std::convert::TryFrom for super::UserCreate { + type Error = String; + fn try_from(value: UserCreate) -> Result { + Ok(Self { name: value.name? }) + } + } + + impl From for UserCreate { + fn from(value: super::UserCreate) -> Self { + Self { + name: Ok(value.name), + } + } + } + + #[derive(Clone, Debug)] + pub struct UserCreateResult { + id: Result, + name: Result, + token: Result, + } + + impl Default for UserCreateResult { + fn default() -> Self { + Self { + id: Err("no value supplied for id".to_string()), + name: Err("no value supplied for name".to_string()), + token: Err("no value supplied for token".to_string()), + } + } + } + + impl UserCreateResult { + pub fn id(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.id = value + .try_into() + .map_err(|e| format!("error converting supplied value for id: {}", e)); + self + } + pub fn name(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.name = value + .try_into() + .map_err(|e| format!("error converting supplied value for name: {}", e)); + self + } + pub fn token(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.token = value + .try_into() + .map_err(|e| format!("error converting supplied value for token: {}", e)); + self + } + } + + impl std::convert::TryFrom for super::UserCreateResult { + type Error = String; + fn try_from(value: UserCreateResult) -> Result { + Ok(Self { + id: value.id?, + name: value.name?, + token: value.token?, + }) + } + } + + impl From for UserCreateResult { + fn from(value: super::UserCreateResult) -> Self { + Self { + id: Ok(value.id), + name: Ok(value.name), + token: Ok(value.token), + } + } + } + + #[derive(Clone, Debug)] + pub struct WhoamiResult { + id: Result, + name: Result, + } + + impl Default for WhoamiResult { + fn default() -> Self { + Self { + id: Err("no value supplied for id".to_string()), + name: Err("no value supplied for name".to_string()), + } + } + } + + impl WhoamiResult { + pub fn id(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.id = value + .try_into() + .map_err(|e| format!("error converting supplied value for id: {}", e)); + self + } + pub fn name(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.name = value + .try_into() + .map_err(|e| format!("error converting supplied value for name: {}", e)); + self + } + } + + impl std::convert::TryFrom for super::WhoamiResult { + type Error = String; + fn try_from(value: WhoamiResult) -> Result { + Ok(Self { + id: value.id?, + name: value.name?, + }) + } + } + + impl From for WhoamiResult { + fn from(value: super::WhoamiResult) -> Self { + Self { + id: Ok(value.id), + name: Ok(value.name), + } + } + } + + #[derive(Clone, Debug)] + pub struct Worker { + bootstrap: Result, + deleted: Result, + factory: Result, + factory_private: Result, String>, + id: Result, + jobs: Result, String>, + lastping: Result>, String>, + recycle: Result, + target: Result, + } + + impl Default for Worker { + fn default() -> Self { + Self { + bootstrap: Err("no value supplied for bootstrap".to_string()), + deleted: Err("no value supplied for deleted".to_string()), + factory: Err("no value supplied for factory".to_string()), + factory_private: Ok(Default::default()), + id: Err("no value supplied for id".to_string()), + jobs: Err("no value supplied for jobs".to_string()), + lastping: Ok(Default::default()), + recycle: Err("no value supplied for recycle".to_string()), + target: Err("no value supplied for target".to_string()), + } + } + } + + impl Worker { + pub fn bootstrap(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.bootstrap = value + .try_into() + .map_err(|e| format!("error converting supplied value for bootstrap: {}", e)); + self + } + pub fn deleted(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.deleted = value + .try_into() + .map_err(|e| format!("error converting supplied value for deleted: {}", e)); + self + } + pub fn factory(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.factory = value + .try_into() + .map_err(|e| format!("error converting supplied value for factory: {}", e)); + self + } + pub fn factory_private(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.factory_private = value.try_into().map_err(|e| { + format!("error converting supplied value for factory_private: {}", e) + }); + self + } + pub fn id(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.id = value + .try_into() + .map_err(|e| format!("error converting supplied value for id: {}", e)); + self + } + pub fn jobs(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.jobs = value + .try_into() + .map_err(|e| format!("error converting supplied value for jobs: {}", e)); + self + } + pub fn lastping(mut self, value: T) -> Self + where + T: std::convert::TryInto>>, + T::Error: std::fmt::Display, + { + self.lastping = value + .try_into() + .map_err(|e| format!("error converting supplied value for lastping: {}", e)); + self + } + pub fn recycle(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.recycle = value + .try_into() + .map_err(|e| format!("error converting supplied value for recycle: {}", e)); + self + } + pub fn target(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.target = value + .try_into() + .map_err(|e| format!("error converting supplied value for target: {}", e)); + self + } + } + + impl std::convert::TryFrom for super::Worker { + type Error = String; + fn try_from(value: Worker) -> Result { + Ok(Self { + bootstrap: value.bootstrap?, + deleted: value.deleted?, + factory: value.factory?, + factory_private: value.factory_private?, + id: value.id?, + jobs: value.jobs?, + lastping: value.lastping?, + recycle: value.recycle?, + target: value.target?, + }) + } + } + + impl From for Worker { + fn from(value: super::Worker) -> Self { + Self { + bootstrap: Ok(value.bootstrap), + deleted: Ok(value.deleted), + factory: Ok(value.factory), + factory_private: Ok(value.factory_private), + id: Ok(value.id), + jobs: Ok(value.jobs), + lastping: Ok(value.lastping), + recycle: Ok(value.recycle), + target: Ok(value.target), + } + } + } + + #[derive(Clone, Debug)] + pub struct WorkerAddOutput { + chunks: Result, String>, + commit_id: Result, + path: Result, + size: Result, + } + + impl Default for WorkerAddOutput { + fn default() -> Self { + Self { + chunks: Err("no value supplied for chunks".to_string()), + commit_id: Err("no value supplied for commit_id".to_string()), + path: Err("no value supplied for path".to_string()), + size: Err("no value supplied for size".to_string()), + } + } + } + + impl WorkerAddOutput { + pub fn chunks(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.chunks = value + .try_into() + .map_err(|e| format!("error converting supplied value for chunks: {}", e)); + self + } + pub fn commit_id(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.commit_id = value + .try_into() + .map_err(|e| format!("error converting supplied value for commit_id: {}", e)); + self + } + pub fn path(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.path = value + .try_into() + .map_err(|e| format!("error converting supplied value for path: {}", e)); + self + } + pub fn size(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.size = value + .try_into() + .map_err(|e| format!("error converting supplied value for size: {}", e)); + self + } + } + + impl std::convert::TryFrom for super::WorkerAddOutput { + type Error = String; + fn try_from(value: WorkerAddOutput) -> Result { + Ok(Self { + chunks: value.chunks?, + commit_id: value.commit_id?, + path: value.path?, + size: value.size?, + }) + } + } + + impl From for WorkerAddOutput { + fn from(value: super::WorkerAddOutput) -> Self { + Self { + chunks: Ok(value.chunks), + commit_id: Ok(value.commit_id), + path: Ok(value.path), + size: Ok(value.size), + } + } + } + + #[derive(Clone, Debug)] + pub struct WorkerAddOutputResult { + complete: Result, + error: Result, String>, + } + + impl Default for WorkerAddOutputResult { + fn default() -> Self { + Self { + complete: Err("no value supplied for complete".to_string()), + error: Ok(Default::default()), + } + } + } + + impl WorkerAddOutputResult { + pub fn complete(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.complete = value + .try_into() + .map_err(|e| format!("error converting supplied value for complete: {}", e)); + self + } + pub fn error(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.error = value + .try_into() + .map_err(|e| format!("error converting supplied value for error: {}", e)); + self + } + } + + impl std::convert::TryFrom for super::WorkerAddOutputResult { + type Error = String; + fn try_from(value: WorkerAddOutputResult) -> Result { + Ok(Self { + complete: value.complete?, + error: value.error?, + }) + } + } + + impl From for WorkerAddOutputResult { + fn from(value: super::WorkerAddOutputResult) -> Self { + Self { + complete: Ok(value.complete), + error: Ok(value.error), + } + } + } + + #[derive(Clone, Debug)] + pub struct WorkerAppendJob { + payload: Result, + stream: Result, + time: Result, String>, + } + + impl Default for WorkerAppendJob { + fn default() -> Self { + Self { + payload: Err("no value supplied for payload".to_string()), + stream: Err("no value supplied for stream".to_string()), + time: Err("no value supplied for time".to_string()), + } + } + } + + impl WorkerAppendJob { + pub fn payload(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.payload = value + .try_into() + .map_err(|e| format!("error converting supplied value for payload: {}", e)); + self + } + pub fn stream(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.stream = value + .try_into() + .map_err(|e| format!("error converting supplied value for stream: {}", e)); + self + } + pub fn time(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.time = value + .try_into() + .map_err(|e| format!("error converting supplied value for time: {}", e)); + self + } + } + + impl std::convert::TryFrom for super::WorkerAppendJob { + type Error = String; + fn try_from(value: WorkerAppendJob) -> Result { + Ok(Self { + payload: value.payload?, + stream: value.stream?, + time: value.time?, + }) + } + } + + impl From for WorkerAppendJob { + fn from(value: super::WorkerAppendJob) -> Self { + Self { + payload: Ok(value.payload), + stream: Ok(value.stream), + time: Ok(value.time), + } + } + } + + #[derive(Clone, Debug)] + pub struct WorkerAppendJobOrTask { + payload: Result, + stream: Result, + task: Result, String>, + time: Result, String>, + } + + impl Default for WorkerAppendJobOrTask { + fn default() -> Self { + Self { + payload: Err("no value supplied for payload".to_string()), + stream: Err("no value supplied for stream".to_string()), + task: Ok(Default::default()), + time: Err("no value supplied for time".to_string()), + } + } + } + + impl WorkerAppendJobOrTask { + pub fn payload(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.payload = value + .try_into() + .map_err(|e| format!("error converting supplied value for payload: {}", e)); + self + } + pub fn stream(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.stream = value + .try_into() + .map_err(|e| format!("error converting supplied value for stream: {}", e)); + self + } + pub fn task(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.task = value + .try_into() + .map_err(|e| format!("error converting supplied value for task: {}", e)); + self + } + pub fn time(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.time = value + .try_into() + .map_err(|e| format!("error converting supplied value for time: {}", e)); + self + } + } + + impl std::convert::TryFrom for super::WorkerAppendJobOrTask { + type Error = String; + fn try_from(value: WorkerAppendJobOrTask) -> Result { + Ok(Self { + payload: value.payload?, + stream: value.stream?, + task: value.task?, + time: value.time?, + }) + } + } + + impl From for WorkerAppendJobOrTask { + fn from(value: super::WorkerAppendJobOrTask) -> Self { + Self { + payload: Ok(value.payload), + stream: Ok(value.stream), + task: Ok(value.task), + time: Ok(value.time), + } + } + } + + #[derive(Clone, Debug)] + pub struct WorkerBootstrap { + bootstrap: Result, + token: Result, + } + + impl Default for WorkerBootstrap { + fn default() -> Self { + Self { + bootstrap: Err("no value supplied for bootstrap".to_string()), + token: Err("no value supplied for token".to_string()), + } + } + } + + impl WorkerBootstrap { + pub fn bootstrap(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.bootstrap = value + .try_into() + .map_err(|e| format!("error converting supplied value for bootstrap: {}", e)); + self + } + pub fn token(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.token = value + .try_into() + .map_err(|e| format!("error converting supplied value for token: {}", e)); + self + } + } + + impl std::convert::TryFrom for super::WorkerBootstrap { + type Error = String; + fn try_from(value: WorkerBootstrap) -> Result { + Ok(Self { + bootstrap: value.bootstrap?, + token: value.token?, + }) + } + } + + impl From for WorkerBootstrap { + fn from(value: super::WorkerBootstrap) -> Self { + Self { + bootstrap: Ok(value.bootstrap), + token: Ok(value.token), + } + } + } + + #[derive(Clone, Debug)] + pub struct WorkerBootstrapResult { + id: Result, + } + + impl Default for WorkerBootstrapResult { + fn default() -> Self { + Self { + id: Err("no value supplied for id".to_string()), + } + } + } + + impl WorkerBootstrapResult { + pub fn id(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.id = value + .try_into() + .map_err(|e| format!("error converting supplied value for id: {}", e)); + self + } + } + + impl std::convert::TryFrom for super::WorkerBootstrapResult { + type Error = String; + fn try_from(value: WorkerBootstrapResult) -> Result { + Ok(Self { id: value.id? }) + } + } + + impl From for WorkerBootstrapResult { + fn from(value: super::WorkerBootstrapResult) -> Self { + Self { id: Ok(value.id) } + } + } + + #[derive(Clone, Debug)] + pub struct WorkerCompleteJob { + failed: Result, + } + + impl Default for WorkerCompleteJob { + fn default() -> Self { + Self { + failed: Err("no value supplied for failed".to_string()), + } + } + } + + impl WorkerCompleteJob { + pub fn failed(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.failed = value + .try_into() + .map_err(|e| format!("error converting supplied value for failed: {}", e)); + self + } + } + + impl std::convert::TryFrom for super::WorkerCompleteJob { + type Error = String; + fn try_from(value: WorkerCompleteJob) -> Result { + Ok(Self { + failed: value.failed?, + }) + } + } + + impl From for WorkerCompleteJob { + fn from(value: super::WorkerCompleteJob) -> Self { + Self { + failed: Ok(value.failed), + } + } + } + + #[derive(Clone, Debug)] + pub struct WorkerCompleteTask { + failed: Result, + } + + impl Default for WorkerCompleteTask { + fn default() -> Self { + Self { + failed: Err("no value supplied for failed".to_string()), + } + } + } + + impl WorkerCompleteTask { + pub fn failed(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.failed = value + .try_into() + .map_err(|e| format!("error converting supplied value for failed: {}", e)); + self + } + } + + impl std::convert::TryFrom for super::WorkerCompleteTask { + type Error = String; + fn try_from(value: WorkerCompleteTask) -> Result { + Ok(Self { + failed: value.failed?, + }) + } + } + + impl From for WorkerCompleteTask { + fn from(value: super::WorkerCompleteTask) -> Self { + Self { + failed: Ok(value.failed), + } + } + } + + #[derive(Clone, Debug)] + pub struct WorkerJob { + id: Result, + name: Result, + owner: Result, + state: Result, + tags: Result, String>, + } + + impl Default for WorkerJob { + fn default() -> Self { + Self { + id: Err("no value supplied for id".to_string()), + name: Err("no value supplied for name".to_string()), + owner: Err("no value supplied for owner".to_string()), + state: Err("no value supplied for state".to_string()), + tags: Err("no value supplied for tags".to_string()), + } + } + } + + impl WorkerJob { + pub fn id(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.id = value + .try_into() + .map_err(|e| format!("error converting supplied value for id: {}", e)); + self + } + pub fn name(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.name = value + .try_into() + .map_err(|e| format!("error converting supplied value for name: {}", e)); + self + } + pub fn owner(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.owner = value + .try_into() + .map_err(|e| format!("error converting supplied value for owner: {}", e)); + self + } + pub fn state(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.state = value + .try_into() + .map_err(|e| format!("error converting supplied value for state: {}", e)); + self + } + pub fn tags(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.tags = value + .try_into() + .map_err(|e| format!("error converting supplied value for tags: {}", e)); + self + } + } + + impl std::convert::TryFrom for super::WorkerJob { + type Error = String; + fn try_from(value: WorkerJob) -> Result { + Ok(Self { + id: value.id?, + name: value.name?, + owner: value.owner?, + state: value.state?, + tags: value.tags?, + }) + } + } + + impl From for WorkerJob { + fn from(value: super::WorkerJob) -> Self { + Self { + id: Ok(value.id), + name: Ok(value.name), + owner: Ok(value.owner), + state: Ok(value.state), + tags: Ok(value.tags), + } + } + } + + #[derive(Clone, Debug)] + pub struct WorkerJobQuota { + max_bytes_per_output: Result, + } + + impl Default for WorkerJobQuota { + fn default() -> Self { + Self { + max_bytes_per_output: Err( + "no value supplied for max_bytes_per_output".to_string() + ), + } + } + } + + impl WorkerJobQuota { + pub fn max_bytes_per_output(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.max_bytes_per_output = value.try_into().map_err(|e| { + format!( + "error converting supplied value for max_bytes_per_output: {}", + e + ) + }); + self + } + } + + impl std::convert::TryFrom for super::WorkerJobQuota { + type Error = String; + fn try_from(value: WorkerJobQuota) -> Result { + Ok(Self { + max_bytes_per_output: value.max_bytes_per_output?, + }) + } + } + + impl From for WorkerJobQuota { + fn from(value: super::WorkerJobQuota) -> Self { + Self { + max_bytes_per_output: Ok(value.max_bytes_per_output), + } + } + } + + #[derive(Clone, Debug)] + pub struct WorkerJobStoreGet { + value: Result, String>, + } + + impl Default for WorkerJobStoreGet { + fn default() -> Self { + Self { + value: Ok(Default::default()), + } + } + } + + impl WorkerJobStoreGet { + pub fn value(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.value = value + .try_into() + .map_err(|e| format!("error converting supplied value for value: {}", e)); + self + } + } + + impl std::convert::TryFrom for super::WorkerJobStoreGet { + type Error = String; + fn try_from(value: WorkerJobStoreGet) -> Result { + Ok(Self { + value: value.value?, + }) + } + } + + impl From for WorkerJobStoreGet { + fn from(value: super::WorkerJobStoreGet) -> Self { + Self { + value: Ok(value.value), + } + } + } + + #[derive(Clone, Debug)] + pub struct WorkerJobStoreValue { + secret: Result, + value: Result, + } + + impl Default for WorkerJobStoreValue { + fn default() -> Self { + Self { + secret: Err("no value supplied for secret".to_string()), + value: Err("no value supplied for value".to_string()), + } + } + } + + impl WorkerJobStoreValue { + pub fn secret(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.secret = value + .try_into() + .map_err(|e| format!("error converting supplied value for secret: {}", e)); + self + } + pub fn value(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.value = value + .try_into() + .map_err(|e| format!("error converting supplied value for value: {}", e)); + self + } + } + + impl std::convert::TryFrom for super::WorkerJobStoreValue { + type Error = String; + fn try_from(value: WorkerJobStoreValue) -> Result { + Ok(Self { + secret: value.secret?, + value: value.value?, + }) + } + } + + impl From for WorkerJobStoreValue { + fn from(value: super::WorkerJobStoreValue) -> Self { + Self { + secret: Ok(value.secret), + value: Ok(value.value), + } + } + } + + #[derive(Clone, Debug)] + pub struct WorkerPingInput { + id: Result, + name: Result, + } + + impl Default for WorkerPingInput { + fn default() -> Self { + Self { + id: Err("no value supplied for id".to_string()), + name: Err("no value supplied for name".to_string()), + } + } + } + + impl WorkerPingInput { + pub fn id(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.id = value + .try_into() + .map_err(|e| format!("error converting supplied value for id: {}", e)); + self + } + pub fn name(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.name = value + .try_into() + .map_err(|e| format!("error converting supplied value for name: {}", e)); + self + } + } + + impl std::convert::TryFrom for super::WorkerPingInput { + type Error = String; + fn try_from(value: WorkerPingInput) -> Result { + Ok(Self { + id: value.id?, + name: value.name?, + }) + } + } + + impl From for WorkerPingInput { + fn from(value: super::WorkerPingInput) -> Self { + Self { + id: Ok(value.id), + name: Ok(value.name), + } + } + } + + #[derive(Clone, Debug)] + pub struct WorkerPingJob { + id: Result, + inputs: Result, String>, + name: Result, + output_rules: Result, String>, + tasks: Result, String>, + } + + impl Default for WorkerPingJob { + fn default() -> Self { + Self { + id: Err("no value supplied for id".to_string()), + inputs: Err("no value supplied for inputs".to_string()), + name: Err("no value supplied for name".to_string()), + output_rules: Err("no value supplied for output_rules".to_string()), + tasks: Err("no value supplied for tasks".to_string()), + } + } + } + + impl WorkerPingJob { + pub fn id(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.id = value + .try_into() + .map_err(|e| format!("error converting supplied value for id: {}", e)); + self + } + pub fn inputs(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.inputs = value + .try_into() + .map_err(|e| format!("error converting supplied value for inputs: {}", e)); + self + } + pub fn name(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.name = value + .try_into() + .map_err(|e| format!("error converting supplied value for name: {}", e)); + self + } + pub fn output_rules(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.output_rules = value.try_into().map_err(|e| { + format!("error converting supplied value for output_rules: {}", e) + }); + self + } + pub fn tasks(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.tasks = value + .try_into() + .map_err(|e| format!("error converting supplied value for tasks: {}", e)); + self + } + } + + impl std::convert::TryFrom for super::WorkerPingJob { + type Error = String; + fn try_from(value: WorkerPingJob) -> Result { + Ok(Self { + id: value.id?, + inputs: value.inputs?, + name: value.name?, + output_rules: value.output_rules?, + tasks: value.tasks?, + }) + } + } + + impl From for WorkerPingJob { + fn from(value: super::WorkerPingJob) -> Self { + Self { + id: Ok(value.id), + inputs: Ok(value.inputs), + name: Ok(value.name), + output_rules: Ok(value.output_rules), + tasks: Ok(value.tasks), + } + } + } + + #[derive(Clone, Debug)] + pub struct WorkerPingOutputRule { + ignore: Result, + require_match: Result, + rule: Result, + size_change_ok: Result, + } + + impl Default for WorkerPingOutputRule { + fn default() -> Self { + Self { + ignore: Err("no value supplied for ignore".to_string()), + require_match: Err("no value supplied for require_match".to_string()), + rule: Err("no value supplied for rule".to_string()), + size_change_ok: Err("no value supplied for size_change_ok".to_string()), + } + } + } + + impl WorkerPingOutputRule { + pub fn ignore(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.ignore = value + .try_into() + .map_err(|e| format!("error converting supplied value for ignore: {}", e)); + self + } + pub fn require_match(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.require_match = value.try_into().map_err(|e| { + format!("error converting supplied value for require_match: {}", e) + }); + self + } + pub fn rule(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.rule = value + .try_into() + .map_err(|e| format!("error converting supplied value for rule: {}", e)); + self + } + pub fn size_change_ok(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.size_change_ok = value.try_into().map_err(|e| { + format!("error converting supplied value for size_change_ok: {}", e) + }); + self + } + } + + impl std::convert::TryFrom for super::WorkerPingOutputRule { + type Error = String; + fn try_from(value: WorkerPingOutputRule) -> Result { + Ok(Self { + ignore: value.ignore?, + require_match: value.require_match?, + rule: value.rule?, + size_change_ok: value.size_change_ok?, + }) + } + } + + impl From for WorkerPingOutputRule { + fn from(value: super::WorkerPingOutputRule) -> Self { + Self { + ignore: Ok(value.ignore), + require_match: Ok(value.require_match), + rule: Ok(value.rule), + size_change_ok: Ok(value.size_change_ok), + } + } + } + + #[derive(Clone, Debug)] + pub struct WorkerPingResult { + factory_metadata: Result, String>, + job: Result, String>, + poweroff: Result, + } + + impl Default for WorkerPingResult { + fn default() -> Self { + Self { + factory_metadata: Ok(Default::default()), + job: Ok(Default::default()), + poweroff: Err("no value supplied for poweroff".to_string()), + } + } + } + + impl WorkerPingResult { + pub fn factory_metadata(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.factory_metadata = value.try_into().map_err(|e| { + format!( + "error converting supplied value for factory_metadata: {}", + e + ) + }); + self + } + pub fn job(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.job = value + .try_into() + .map_err(|e| format!("error converting supplied value for job: {}", e)); + self + } + pub fn poweroff(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.poweroff = value + .try_into() + .map_err(|e| format!("error converting supplied value for poweroff: {}", e)); + self + } + } + + impl std::convert::TryFrom for super::WorkerPingResult { + type Error = String; + fn try_from(value: WorkerPingResult) -> Result { + Ok(Self { + factory_metadata: value.factory_metadata?, + job: value.job?, + poweroff: value.poweroff?, + }) + } + } + + impl From for WorkerPingResult { + fn from(value: super::WorkerPingResult) -> Self { + Self { + factory_metadata: Ok(value.factory_metadata), + job: Ok(value.job), + poweroff: Ok(value.poweroff), + } + } + } + + #[derive(Clone, Debug)] + pub struct WorkerPingTask { + env: Result, String>, + env_clear: Result, + gid: Result, + id: Result, + name: Result, + script: Result, + uid: Result, + workdir: Result, + } + + impl Default for WorkerPingTask { + fn default() -> Self { + Self { + env: Err("no value supplied for env".to_string()), + env_clear: Err("no value supplied for env_clear".to_string()), + gid: Err("no value supplied for gid".to_string()), + id: Err("no value supplied for id".to_string()), + name: Err("no value supplied for name".to_string()), + script: Err("no value supplied for script".to_string()), + uid: Err("no value supplied for uid".to_string()), + workdir: Err("no value supplied for workdir".to_string()), + } + } + } + + impl WorkerPingTask { + pub fn env(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.env = value + .try_into() + .map_err(|e| format!("error converting supplied value for env: {}", e)); + self + } + pub fn env_clear(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.env_clear = value + .try_into() + .map_err(|e| format!("error converting supplied value for env_clear: {}", e)); + self + } + pub fn gid(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.gid = value + .try_into() + .map_err(|e| format!("error converting supplied value for gid: {}", e)); + self + } + pub fn id(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.id = value + .try_into() + .map_err(|e| format!("error converting supplied value for id: {}", e)); + self + } + pub fn name(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.name = value + .try_into() + .map_err(|e| format!("error converting supplied value for name: {}", e)); + self + } + pub fn script(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.script = value + .try_into() + .map_err(|e| format!("error converting supplied value for script: {}", e)); + self + } + pub fn uid(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.uid = value + .try_into() + .map_err(|e| format!("error converting supplied value for uid: {}", e)); + self + } + pub fn workdir(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.workdir = value + .try_into() + .map_err(|e| format!("error converting supplied value for workdir: {}", e)); + self + } + } + + impl std::convert::TryFrom for super::WorkerPingTask { + type Error = String; + fn try_from(value: WorkerPingTask) -> Result { + Ok(Self { + env: value.env?, + env_clear: value.env_clear?, + gid: value.gid?, + id: value.id?, + name: value.name?, + script: value.script?, + uid: value.uid?, + workdir: value.workdir?, + }) + } + } + + impl From for WorkerPingTask { + fn from(value: super::WorkerPingTask) -> Self { + Self { + env: Ok(value.env), + env_clear: Ok(value.env_clear), + gid: Ok(value.gid), + id: Ok(value.id), + name: Ok(value.name), + script: Ok(value.script), + uid: Ok(value.uid), + workdir: Ok(value.workdir), + } + } } #[derive(Clone, Debug)] - pub struct Worker { - deleted: Result, - id: Result, - instance_id: Result, String>, - lastping: Result>, String>, - recycle: Result, - tasks: Result, String>, + pub struct WorkersResult { + workers: Result, String>, + } + + impl Default for WorkersResult { + fn default() -> Self { + Self { + workers: Err("no value supplied for workers".to_string()), + } + } + } + + impl WorkersResult { + pub fn workers(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.workers = value + .try_into() + .map_err(|e| format!("error converting supplied value for workers: {}", e)); + self + } + } + + impl std::convert::TryFrom for super::WorkersResult { + type Error = String; + fn try_from(value: WorkersResult) -> Result { + Ok(Self { + workers: value.workers?, + }) + } + } + + impl From for WorkersResult { + fn from(value: super::WorkersResult) -> Self { + Self { + workers: Ok(value.workers), + } + } + } + } +} + +#[derive(Clone, Debug)] +///Client for Buildomat +/// +///Version: 1.0 +pub struct Client { + pub(crate) baseurl: String, + pub(crate) client: reqwest::Client, +} + +impl Client { + /// Create a new client. + /// + /// `baseurl` is the base URL provided to the internal + /// `reqwest::Client`, and should include a scheme and hostname, + /// as well as port and a path stem if applicable. + pub fn new(baseurl: &str) -> Self { + #[cfg(not(target_arch = "wasm32"))] + let client = { + let dur = std::time::Duration::from_secs(15); + reqwest::ClientBuilder::new() + .connect_timeout(dur) + .timeout(dur) + }; + #[cfg(target_arch = "wasm32")] + let client = reqwest::ClientBuilder::new(); + Self::new_with_client(baseurl, client.build().unwrap()) + } + + /// Construct a new client with an existing `reqwest::Client`, + /// allowing more control over its configuration. + /// + /// `baseurl` is the base URL provided to the internal + /// `reqwest::Client`, and should include a scheme and hostname, + /// as well as port and a path stem if applicable. + pub fn new_with_client(baseurl: &str, client: reqwest::Client) -> Self { + Self { + baseurl: baseurl.to_string(), + client, + } + } + + /// Get the base URL to which requests are made. + pub fn baseurl(&self) -> &String { + &self.baseurl + } + + /// Get the internal `reqwest::Client` used to make requests. + pub fn client(&self) -> &reqwest::Client { + &self.client + } + + /// Get the version of this API. + /// + /// This string is pulled directly from the source OpenAPI + /// document and may be in any format the API selects. + pub fn api_version(&self) -> &'static str { + "1.0" + } +} + +impl Client { + ///Sends a `POST` request to `/0/admin/factory` + /// + ///```ignore + /// let response = client.factory_create() + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn factory_create(&self) -> builder::FactoryCreate { + builder::FactoryCreate::new(self) + } + + ///Sends a `GET` request to `/0/admin/jobs` + /// + ///```ignore + /// let response = client.admin_jobs_get() + /// .active(active) + /// .completed(completed) + /// .send() + /// .await; + /// ``` + pub fn admin_jobs_get(&self) -> builder::AdminJobsGet { + builder::AdminJobsGet::new(self) + } + + ///Sends a `GET` request to `/0/admin/jobs/{job}` + /// + ///```ignore + /// let response = client.admin_job_get() + /// .job(job) + /// .send() + /// .await; + /// ``` + pub fn admin_job_get(&self) -> builder::AdminJobGet { + builder::AdminJobGet::new(self) + } + + ///Sends a `POST` request to `/0/admin/jobs/{job}/archive` + /// + ///```ignore + /// let response = client.admin_job_archive_request() + /// .job(job) + /// .send() + /// .await; + /// ``` + pub fn admin_job_archive_request(&self) -> builder::AdminJobArchiveRequest { + builder::AdminJobArchiveRequest::new(self) + } + + ///Sends a `POST` request to `/0/admin/target` + /// + ///```ignore + /// let response = client.target_create() + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn target_create(&self) -> builder::TargetCreate { + builder::TargetCreate::new(self) + } + + ///Sends a `GET` request to `/0/admin/targets` + /// + ///```ignore + /// let response = client.targets_list() + /// .send() + /// .await; + /// ``` + pub fn targets_list(&self) -> builder::TargetsList { + builder::TargetsList::new(self) + } + + ///Sends a `PUT` request to `/0/admin/targets/{target}/redirect` + /// + ///```ignore + /// let response = client.target_redirect() + /// .target(target) + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn target_redirect(&self) -> builder::TargetRedirect { + builder::TargetRedirect::new(self) + } + + ///Sends a `POST` request to `/0/admin/targets/{target}/rename` + /// + ///```ignore + /// let response = client.target_rename() + /// .target(target) + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn target_rename(&self) -> builder::TargetRename { + builder::TargetRename::new(self) + } + + ///Sends a `DELETE` request to `/0/admin/targets/{target}/require` + /// + ///```ignore + /// let response = client.target_require_no_privilege() + /// .target(target) + /// .send() + /// .await; + /// ``` + pub fn target_require_no_privilege(&self) -> builder::TargetRequireNoPrivilege { + builder::TargetRequireNoPrivilege::new(self) + } + + ///Sends a `PUT` request to `/0/admin/targets/{target}/require/{privilege}` + /// + ///```ignore + /// let response = client.target_require_privilege() + /// .target(target) + /// .privilege(privilege) + /// .send() + /// .await; + /// ``` + pub fn target_require_privilege(&self) -> builder::TargetRequirePrivilege { + builder::TargetRequirePrivilege::new(self) + } + + ///Sends a `POST` request to `/0/admin/worker/{worker}/recycle` + /// + ///```ignore + /// let response = client.worker_recycle() + /// .worker(worker) + /// .send() + /// .await; + /// ``` + pub fn worker_recycle(&self) -> builder::WorkerRecycle { + builder::WorkerRecycle::new(self) + } + + ///Sends a `POST` request to `/0/control/hold` + /// + ///```ignore + /// let response = client.control_hold() + /// .send() + /// .await; + /// ``` + pub fn control_hold(&self) -> builder::ControlHold { + builder::ControlHold::new(self) + } + + ///Sends a `POST` request to `/0/control/resume` + /// + ///```ignore + /// let response = client.control_resume() + /// .send() + /// .await; + /// ``` + pub fn control_resume(&self) -> builder::ControlResume { + builder::ControlResume::new(self) + } + + ///Sends a `POST` request to `/0/factory/lease` + /// + ///```ignore + /// let response = client.factory_lease() + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn factory_lease(&self) -> builder::FactoryLease { + builder::FactoryLease::new(self) + } + + ///Sends a `POST` request to `/0/factory/lease/{job}` + /// + ///```ignore + /// let response = client.factory_lease_renew() + /// .job(job) + /// .send() + /// .await; + /// ``` + pub fn factory_lease_renew(&self) -> builder::FactoryLeaseRenew { + builder::FactoryLeaseRenew::new(self) + } + + ///Sends a `GET` request to `/0/factory/ping` + /// + ///```ignore + /// let response = client.factory_ping() + /// .send() + /// .await; + /// ``` + pub fn factory_ping(&self) -> builder::FactoryPing { + builder::FactoryPing::new(self) + } + + ///Sends a `POST` request to `/0/factory/worker` + /// + ///```ignore + /// let response = client.factory_worker_create() + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn factory_worker_create(&self) -> builder::FactoryWorkerCreate { + builder::FactoryWorkerCreate::new(self) + } + + ///Sends a `GET` request to `/0/factory/worker/{worker}` + /// + ///```ignore + /// let response = client.factory_worker_get() + /// .worker(worker) + /// .send() + /// .await; + /// ``` + pub fn factory_worker_get(&self) -> builder::FactoryWorkerGet { + builder::FactoryWorkerGet::new(self) + } + + ///Sends a `DELETE` request to `/0/factory/worker/{worker}` + /// + ///```ignore + /// let response = client.factory_worker_destroy() + /// .worker(worker) + /// .send() + /// .await; + /// ``` + pub fn factory_worker_destroy(&self) -> builder::FactoryWorkerDestroy { + builder::FactoryWorkerDestroy::new(self) + } + + ///Sends a `PATCH` request to `/0/factory/worker/{worker}` + /// + ///```ignore + /// let response = client.factory_worker_associate() + /// .worker(worker) + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn factory_worker_associate(&self) -> builder::FactoryWorkerAssociate { + builder::FactoryWorkerAssociate::new(self) + } + + ///Sends a `POST` request to `/0/factory/worker/{worker}/append` + /// + ///```ignore + /// let response = client.factory_worker_append() + /// .worker(worker) + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn factory_worker_append(&self) -> builder::FactoryWorkerAppend { + builder::FactoryWorkerAppend::new(self) + } + + ///Sends a `POST` request to `/0/factory/worker/{worker}/flush` + /// + ///```ignore + /// let response = client.factory_worker_flush() + /// .worker(worker) + /// .send() + /// .await; + /// ``` + pub fn factory_worker_flush(&self) -> builder::FactoryWorkerFlush { + builder::FactoryWorkerFlush::new(self) + } + + ///Sends a `GET` request to `/0/factory/workers` + /// + ///```ignore + /// let response = client.factory_workers() + /// .send() + /// .await; + /// ``` + pub fn factory_workers(&self) -> builder::FactoryWorkers { + builder::FactoryWorkers::new(self) + } + + ///Sends a `GET` request to `/0/job/{job}` + /// + ///```ignore + /// let response = client.job_get() + /// .job(job) + /// .send() + /// .await; + /// ``` + pub fn job_get(&self) -> builder::JobGet { + builder::JobGet::new(self) + } + + ///Sends a `GET` request to `/0/jobs` + /// + ///```ignore + /// let response = client.jobs_get() + /// .send() + /// .await; + /// ``` + pub fn jobs_get(&self) -> builder::JobsGet { + builder::JobsGet::new(self) + } + + ///Sends a `POST` request to `/0/jobs` + /// + ///```ignore + /// let response = client.job_submit() + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn job_submit(&self) -> builder::JobSubmit { + builder::JobSubmit::new(self) + } + + ///Sends a `POST` request to `/0/jobs/{job}/cancel` + /// + ///```ignore + /// let response = client.job_cancel() + /// .job(job) + /// .send() + /// .await; + /// ``` + pub fn job_cancel(&self) -> builder::JobCancel { + builder::JobCancel::new(self) + } + + ///Sends a `POST` request to `/0/jobs/{job}/chunk` + /// + ///```ignore + /// let response = client.job_upload_chunk() + /// .job(job) + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn job_upload_chunk(&self) -> builder::JobUploadChunk { + builder::JobUploadChunk::new(self) + } + + ///Sends a `GET` request to `/0/jobs/{job}/events` + /// + ///```ignore + /// let response = client.job_events_get() + /// .job(job) + /// .minseq(minseq) + /// .send() + /// .await; + /// ``` + pub fn job_events_get(&self) -> builder::JobEventsGet { + builder::JobEventsGet::new(self) + } + + ///Sends a `GET` request to `/0/jobs/{job}/outputs` + /// + ///```ignore + /// let response = client.job_outputs_get() + /// .job(job) + /// .send() + /// .await; + /// ``` + pub fn job_outputs_get(&self) -> builder::JobOutputsGet { + builder::JobOutputsGet::new(self) + } + + ///Sends a `GET` request to `/0/jobs/{job}/outputs/{output}` + /// + ///```ignore + /// let response = client.job_output_download() + /// .job(job) + /// .output(output) + /// .send() + /// .await; + /// ``` + pub fn job_output_download(&self) -> builder::JobOutputDownload { + builder::JobOutputDownload::new(self) + } + + ///Sends a `POST` request to `/0/jobs/{job}/outputs/{output}/publish` + /// + ///```ignore + /// let response = client.job_output_publish() + /// .job(job) + /// .output(output) + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn job_output_publish(&self) -> builder::JobOutputPublish { + builder::JobOutputPublish::new(self) + } + + ///Sends a `POST` request to `/0/jobs/{job}/outputs/{output}/sign` + /// + ///```ignore + /// let response = client.job_output_signed_url() + /// .job(job) + /// .output(output) + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn job_output_signed_url(&self) -> builder::JobOutputSignedUrl { + builder::JobOutputSignedUrl::new(self) + } + + ///Sends a `GET` request to `/0/jobs/{job}/store` + /// + ///```ignore + /// let response = client.job_store_get_all() + /// .job(job) + /// .send() + /// .await; + /// ``` + pub fn job_store_get_all(&self) -> builder::JobStoreGetAll { + builder::JobStoreGetAll::new(self) + } + + ///Sends a `PUT` request to `/0/jobs/{job}/store/{name}` + /// + ///```ignore + /// let response = client.job_store_put() + /// .job(job) + /// .name(name) + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn job_store_put(&self) -> builder::JobStorePut { + builder::JobStorePut::new(self) + } + + ///Sends a `GET` request to + /// `/0/public/file/{username}/{series}/{version}/{name}` + /// + ///```ignore + /// let response = client.public_file_download() + /// .username(username) + /// .series(series) + /// .version(version) + /// .name(name) + /// .send() + /// .await; + /// ``` + pub fn public_file_download(&self) -> builder::PublicFileDownload { + builder::PublicFileDownload::new(self) + } + + ///Sends a `GET` request to `/0/quota` + /// + ///```ignore + /// let response = client.quota() + /// .send() + /// .await; + /// ``` + pub fn quota(&self) -> builder::Quota { + builder::Quota::new(self) + } + + ///Sends a `GET` request to `/0/users` + /// + ///```ignore + /// let response = client.users_list() + /// .name(name) + /// .send() + /// .await; + /// ``` + pub fn users_list(&self) -> builder::UsersList { + builder::UsersList::new(self) + } + + ///Sends a `POST` request to `/0/users` + /// + ///```ignore + /// let response = client.user_create() + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn user_create(&self) -> builder::UserCreate { + builder::UserCreate::new(self) + } + + ///Sends a `GET` request to `/0/users/{user}` + /// + ///```ignore + /// let response = client.user_get() + /// .user(user) + /// .send() + /// .await; + /// ``` + pub fn user_get(&self) -> builder::UserGet { + builder::UserGet::new(self) + } + + ///Sends a `PUT` request to `/0/users/{user}/privilege/{privilege}` + /// + ///```ignore + /// let response = client.user_privilege_grant() + /// .user(user) + /// .privilege(privilege) + /// .send() + /// .await; + /// ``` + pub fn user_privilege_grant(&self) -> builder::UserPrivilegeGrant { + builder::UserPrivilegeGrant::new(self) + } + + ///Sends a `DELETE` request to `/0/users/{user}/privilege/{privilege}` + /// + ///```ignore + /// let response = client.user_privilege_revoke() + /// .user(user) + /// .privilege(privilege) + /// .send() + /// .await; + /// ``` + pub fn user_privilege_revoke(&self) -> builder::UserPrivilegeRevoke { + builder::UserPrivilegeRevoke::new(self) + } + + ///Sends a `GET` request to `/0/whoami` + /// + ///```ignore + /// let response = client.whoami() + /// .send() + /// .await; + /// ``` + pub fn whoami(&self) -> builder::Whoami { + builder::Whoami::new(self) + } + + ///Sends a `POST` request to `/0/worker/bootstrap` + /// + ///```ignore + /// let response = client.worker_bootstrap() + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn worker_bootstrap(&self) -> builder::WorkerBootstrap { + builder::WorkerBootstrap::new(self) + } + + ///Sends a `POST` request to `/0/worker/job/{job}/chunk` + /// + ///```ignore + /// let response = client.worker_job_upload_chunk() + /// .job(job) + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn worker_job_upload_chunk(&self) -> builder::WorkerJobUploadChunk { + builder::WorkerJobUploadChunk::new(self) + } + + ///Sends a `POST` request to `/0/worker/job/{job}/complete` + /// + ///```ignore + /// let response = client.worker_job_complete() + /// .job(job) + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn worker_job_complete(&self) -> builder::WorkerJobComplete { + builder::WorkerJobComplete::new(self) + } + + ///Sends a `GET` request to `/0/worker/job/{job}/inputs/{input}` + /// + ///```ignore + /// let response = client.worker_job_input_download() + /// .job(job) + /// .input(input) + /// .send() + /// .await; + /// ``` + pub fn worker_job_input_download(&self) -> builder::WorkerJobInputDownload { + builder::WorkerJobInputDownload::new(self) + } + + ///Sends a `GET` request to `/0/worker/job/{job}/quota` + /// + ///```ignore + /// let response = client.worker_job_quota() + /// .job(job) + /// .send() + /// .await; + /// ``` + pub fn worker_job_quota(&self) -> builder::WorkerJobQuota { + builder::WorkerJobQuota::new(self) + } + + ///Sends a `GET` request to `/0/worker/job/{job}/store/{name}` + /// + ///```ignore + /// let response = client.worker_job_store_get() + /// .job(job) + /// .name(name) + /// .send() + /// .await; + /// ``` + pub fn worker_job_store_get(&self) -> builder::WorkerJobStoreGet { + builder::WorkerJobStoreGet::new(self) + } + + ///Sends a `PUT` request to `/0/worker/job/{job}/store/{name}` + /// + ///```ignore + /// let response = client.worker_job_store_put() + /// .job(job) + /// .name(name) + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn worker_job_store_put(&self) -> builder::WorkerJobStorePut { + builder::WorkerJobStorePut::new(self) + } + + ///Sends a `POST` request to `/0/worker/job/{job}/task/{task}/append` + /// + ///```ignore + /// let response = client.worker_task_append() + /// .job(job) + /// .task(task) + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn worker_task_append(&self) -> builder::WorkerTaskAppend { + builder::WorkerTaskAppend::new(self) + } + + ///Sends a `POST` request to `/0/worker/job/{job}/task/{task}/complete` + /// + ///```ignore + /// let response = client.worker_task_complete() + /// .job(job) + /// .task(task) + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn worker_task_complete(&self) -> builder::WorkerTaskComplete { + builder::WorkerTaskComplete::new(self) + } + + ///Sends a `GET` request to `/0/worker/ping` + /// + ///```ignore + /// let response = client.worker_ping() + /// .send() + /// .await; + /// ``` + pub fn worker_ping(&self) -> builder::WorkerPing { + builder::WorkerPing::new(self) + } + + ///Sends a `GET` request to `/0/workers` + /// + ///```ignore + /// let response = client.workers_list() + /// .active(active) + /// .send() + /// .await; + /// ``` + pub fn workers_list(&self) -> builder::WorkersList { + builder::WorkersList::new(self) + } + + ///Sends a `POST` request to `/0/workers/recycle` + /// + ///```ignore + /// let response = client.workers_recycle() + /// .send() + /// .await; + /// ``` + pub fn workers_recycle(&self) -> builder::WorkersRecycle { + builder::WorkersRecycle::new(self) + } + + ///Sends a `POST` request to `/1/jobs/{job}/input` + /// + ///```ignore + /// let response = client.job_add_input() + /// .job(job) + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn job_add_input(&self) -> builder::JobAddInput { + builder::JobAddInput::new(self) + } + + ///Sends a `POST` request to `/1/worker/job/{job}/append` + /// + ///```ignore + /// let response = client.worker_job_append() + /// .job(job) + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn worker_job_append(&self) -> builder::WorkerJobAppend { + builder::WorkerJobAppend::new(self) + } + + ///Sends a `POST` request to `/1/worker/job/{job}/output` + /// + ///```ignore + /// let response = client.worker_job_add_output() + /// .job(job) + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn worker_job_add_output(&self) -> builder::WorkerJobAddOutput { + builder::WorkerJobAddOutput::new(self) + } +} + +pub mod builder { + use super::types; + #[allow(unused_imports)] + use super::{ + encode_path, ByteStream, Error, HeaderMap, HeaderValue, RequestBuilderExt, ResponseValue, + }; + ///Builder for [`Client::factory_create`] + /// + ///[`Client::factory_create`]: super::Client::factory_create + #[derive(Debug, Clone)] + pub struct FactoryCreate<'a> { + client: &'a super::Client, + body: Result, + } + + impl<'a> FactoryCreate<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + body: Ok(types::builder::FactoryCreate::default()), + } + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.body = value + .try_into() + .map(From::from) + .map_err(|_| "conversion to `FactoryCreate` for body failed".to_string()); + self + } + + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::FactoryCreate) -> types::builder::FactoryCreate, + { + self.body = self.body.map(f); + self + } + + ///Sends a `POST` request to `/0/admin/factory` + pub async fn send( + self, + ) -> Result, Error> { + let Self { client, body } = self; + let body = body + .and_then(std::convert::TryInto::::try_into) + .map_err(Error::InvalidRequest)?; + let url = format!("{}/0/admin/factory", client.baseurl,); + let request = client + .client + .post(url) + .header( + reqwest::header::ACCEPT, + reqwest::header::HeaderValue::from_static("application/json"), + ) + .json(&body) + .build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 201u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::admin_jobs_get`] + /// + ///[`Client::admin_jobs_get`]: super::Client::admin_jobs_get + #[derive(Debug, Clone)] + pub struct AdminJobsGet<'a> { + client: &'a super::Client, + active: Result, String>, + completed: Result, String>, + } + + impl<'a> AdminJobsGet<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + active: Ok(None), + completed: Ok(None), + } + } + + pub fn active(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.active = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `bool` for active failed".to_string()); + self + } + + pub fn completed(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.completed = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `u64` for completed failed".to_string()); + self + } + + ///Sends a `GET` request to `/0/admin/jobs` + pub async fn send(self) -> Result>, Error> { + let Self { + client, + active, + completed, + } = self; + let active = active.map_err(Error::InvalidRequest)?; + let completed = completed.map_err(Error::InvalidRequest)?; + let url = format!("{}/0/admin/jobs", client.baseurl,); + let mut query = Vec::with_capacity(2usize); + if let Some(v) = &active { + query.push(("active", v.to_string())); + } + if let Some(v) = &completed { + query.push(("completed", v.to_string())); + } + let request = client + .client + .get(url) + .header( + reqwest::header::ACCEPT, + reqwest::header::HeaderValue::from_static("application/json"), + ) + .query(&query) + .build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::admin_job_get`] + /// + ///[`Client::admin_job_get`]: super::Client::admin_job_get + #[derive(Debug, Clone)] + pub struct AdminJobGet<'a> { + client: &'a super::Client, + job: Result, + } + + impl<'a> AdminJobGet<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + job: Err("job was not initialized".to_string()), + } + } + + pub fn job(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.job = value + .try_into() + .map_err(|_| "conversion to `String` for job failed".to_string()); + self + } + + ///Sends a `GET` request to `/0/admin/jobs/{job}` + pub async fn send(self) -> Result, Error> { + let Self { client, job } = self; + let job = job.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/0/admin/jobs/{}", + client.baseurl, + encode_path(&job.to_string()), + ); + let request = client + .client + .get(url) + .header( + reqwest::header::ACCEPT, + reqwest::header::HeaderValue::from_static("application/json"), + ) + .build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::admin_job_archive_request`] + /// + ///[`Client::admin_job_archive_request`]: super::Client::admin_job_archive_request + #[derive(Debug, Clone)] + pub struct AdminJobArchiveRequest<'a> { + client: &'a super::Client, + job: Result, + } + + impl<'a> AdminJobArchiveRequest<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + job: Err("job was not initialized".to_string()), + } + } + + pub fn job(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.job = value + .try_into() + .map_err(|_| "conversion to `String` for job failed".to_string()); + self + } + + ///Sends a `POST` request to `/0/admin/jobs/{job}/archive` + pub async fn send(self) -> Result, Error> { + let Self { client, job } = self; + let job = job.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/0/admin/jobs/{}/archive", + client.baseurl, + encode_path(&job.to_string()), + ); + let request = client + .client + .post(url) + .header( + reqwest::header::ACCEPT, + reqwest::header::HeaderValue::from_static("application/json"), + ) + .build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::target_create`] + /// + ///[`Client::target_create`]: super::Client::target_create + #[derive(Debug, Clone)] + pub struct TargetCreate<'a> { + client: &'a super::Client, + body: Result, + } + + impl<'a> TargetCreate<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + body: Ok(types::builder::TargetCreate::default()), + } + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.body = value + .try_into() + .map(From::from) + .map_err(|_| "conversion to `TargetCreate` for body failed".to_string()); + self + } + + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::TargetCreate) -> types::builder::TargetCreate, + { + self.body = self.body.map(f); + self + } + + ///Sends a `POST` request to `/0/admin/target` + pub async fn send( + self, + ) -> Result, Error> { + let Self { client, body } = self; + let body = body + .and_then(std::convert::TryInto::::try_into) + .map_err(Error::InvalidRequest)?; + let url = format!("{}/0/admin/target", client.baseurl,); + let request = client + .client + .post(url) + .header( + reqwest::header::ACCEPT, + reqwest::header::HeaderValue::from_static("application/json"), + ) + .json(&body) + .build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 201u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::targets_list`] + /// + ///[`Client::targets_list`]: super::Client::targets_list + #[derive(Debug, Clone)] + pub struct TargetsList<'a> { + client: &'a super::Client, + } + + impl<'a> TargetsList<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { client: client } + } + + ///Sends a `GET` request to `/0/admin/targets` + pub async fn send(self) -> Result>, Error> { + let Self { client } = self; + let url = format!("{}/0/admin/targets", client.baseurl,); + let request = client + .client + .get(url) + .header( + reqwest::header::ACCEPT, + reqwest::header::HeaderValue::from_static("application/json"), + ) + .build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::target_redirect`] + /// + ///[`Client::target_redirect`]: super::Client::target_redirect + #[derive(Debug, Clone)] + pub struct TargetRedirect<'a> { + client: &'a super::Client, + target: Result, + body: Result, + } + + impl<'a> TargetRedirect<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + target: Err("target was not initialized".to_string()), + body: Ok(types::builder::TargetRedirect::default()), + } + } + + pub fn target(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.target = value + .try_into() + .map_err(|_| "conversion to `String` for target failed".to_string()); + self + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.body = value + .try_into() + .map(From::from) + .map_err(|_| "conversion to `TargetRedirect` for body failed".to_string()); + self + } + + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::TargetRedirect) -> types::builder::TargetRedirect, + { + self.body = self.body.map(f); + self + } + + ///Sends a `PUT` request to `/0/admin/targets/{target}/redirect` + pub async fn send(self) -> Result, Error> { + let Self { + client, + target, + body, + } = self; + let target = target.map_err(Error::InvalidRequest)?; + let body = body + .and_then(std::convert::TryInto::::try_into) + .map_err(Error::InvalidRequest)?; + let url = format!( + "{}/0/admin/targets/{}/redirect", + client.baseurl, + encode_path(&target.to_string()), + ); + let request = client + .client + .put(url) + .header( + reqwest::header::ACCEPT, + reqwest::header::HeaderValue::from_static("application/json"), + ) + .json(&body) + .build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::target_rename`] + /// + ///[`Client::target_rename`]: super::Client::target_rename + #[derive(Debug, Clone)] + pub struct TargetRename<'a> { + client: &'a super::Client, + target: Result, + body: Result, + } + + impl<'a> TargetRename<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + target: Err("target was not initialized".to_string()), + body: Ok(types::builder::TargetRename::default()), + } + } + + pub fn target(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.target = value + .try_into() + .map_err(|_| "conversion to `String` for target failed".to_string()); + self + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.body = value + .try_into() + .map(From::from) + .map_err(|_| "conversion to `TargetRename` for body failed".to_string()); + self + } + + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::TargetRename) -> types::builder::TargetRename, + { + self.body = self.body.map(f); + self + } + + ///Sends a `POST` request to `/0/admin/targets/{target}/rename` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + target, + body, + } = self; + let target = target.map_err(Error::InvalidRequest)?; + let body = body + .and_then(std::convert::TryInto::::try_into) + .map_err(Error::InvalidRequest)?; + let url = format!( + "{}/0/admin/targets/{}/rename", + client.baseurl, + encode_path(&target.to_string()), + ); + let request = client + .client + .post(url) + .header( + reqwest::header::ACCEPT, + reqwest::header::HeaderValue::from_static("application/json"), + ) + .json(&body) + .build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 201u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::target_require_no_privilege`] + /// + ///[`Client::target_require_no_privilege`]: super::Client::target_require_no_privilege + #[derive(Debug, Clone)] + pub struct TargetRequireNoPrivilege<'a> { + client: &'a super::Client, + target: Result, + } + + impl<'a> TargetRequireNoPrivilege<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + target: Err("target was not initialized".to_string()), + } + } + + pub fn target(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.target = value + .try_into() + .map_err(|_| "conversion to `String` for target failed".to_string()); + self + } + + ///Sends a `DELETE` request to `/0/admin/targets/{target}/require` + pub async fn send(self) -> Result, Error> { + let Self { client, target } = self; + let target = target.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/0/admin/targets/{}/require", + client.baseurl, + encode_path(&target.to_string()), + ); + let request = client + .client + .delete(url) + .header( + reqwest::header::ACCEPT, + reqwest::header::HeaderValue::from_static("application/json"), + ) + .build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::target_require_privilege`] + /// + ///[`Client::target_require_privilege`]: super::Client::target_require_privilege + #[derive(Debug, Clone)] + pub struct TargetRequirePrivilege<'a> { + client: &'a super::Client, + target: Result, + privilege: Result, + } + + impl<'a> TargetRequirePrivilege<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + target: Err("target was not initialized".to_string()), + privilege: Err("privilege was not initialized".to_string()), + } + } + + pub fn target(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.target = value + .try_into() + .map_err(|_| "conversion to `String` for target failed".to_string()); + self + } + + pub fn privilege(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.privilege = value + .try_into() + .map_err(|_| "conversion to `String` for privilege failed".to_string()); + self + } + + ///Sends a `PUT` request to + /// `/0/admin/targets/{target}/require/{privilege}` + pub async fn send(self) -> Result, Error> { + let Self { + client, + target, + privilege, + } = self; + let target = target.map_err(Error::InvalidRequest)?; + let privilege = privilege.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/0/admin/targets/{}/require/{}", + client.baseurl, + encode_path(&target.to_string()), + encode_path(&privilege.to_string()), + ); + let request = client + .client + .put(url) + .header( + reqwest::header::ACCEPT, + reqwest::header::HeaderValue::from_static("application/json"), + ) + .build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::worker_recycle`] + /// + ///[`Client::worker_recycle`]: super::Client::worker_recycle + #[derive(Debug, Clone)] + pub struct WorkerRecycle<'a> { + client: &'a super::Client, + worker: Result, + } + + impl<'a> WorkerRecycle<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + worker: Err("worker was not initialized".to_string()), + } + } + + pub fn worker(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.worker = value + .try_into() + .map_err(|_| "conversion to `String` for worker failed".to_string()); + self + } + + ///Sends a `POST` request to `/0/admin/worker/{worker}/recycle` + pub async fn send(self) -> Result, Error> { + let Self { client, worker } = self; + let worker = worker.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/0/admin/worker/{}/recycle", + client.baseurl, + encode_path(&worker.to_string()), + ); + let request = client + .client + .post(url) + .header( + reqwest::header::ACCEPT, + reqwest::header::HeaderValue::from_static("application/json"), + ) + .build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::control_hold`] + /// + ///[`Client::control_hold`]: super::Client::control_hold + #[derive(Debug, Clone)] + pub struct ControlHold<'a> { + client: &'a super::Client, + } + + impl<'a> ControlHold<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { client: client } + } + + ///Sends a `POST` request to `/0/control/hold` + pub async fn send(self) -> Result, Error> { + let Self { client } = self; + let url = format!("{}/0/control/hold", client.baseurl,); + let request = client + .client + .post(url) + .header( + reqwest::header::ACCEPT, + reqwest::header::HeaderValue::from_static("application/json"), + ) + .build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::control_resume`] + /// + ///[`Client::control_resume`]: super::Client::control_resume + #[derive(Debug, Clone)] + pub struct ControlResume<'a> { + client: &'a super::Client, + } + + impl<'a> ControlResume<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { client: client } + } + + ///Sends a `POST` request to `/0/control/resume` + pub async fn send(self) -> Result, Error> { + let Self { client } = self; + let url = format!("{}/0/control/resume", client.baseurl,); + let request = client + .client + .post(url) + .header( + reqwest::header::ACCEPT, + reqwest::header::HeaderValue::from_static("application/json"), + ) + .build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::factory_lease`] + /// + ///[`Client::factory_lease`]: super::Client::factory_lease + #[derive(Debug, Clone)] + pub struct FactoryLease<'a> { + client: &'a super::Client, + body: Result, + } + + impl<'a> FactoryLease<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + body: Ok(types::builder::FactoryWhatsNext::default()), + } + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.body = value + .try_into() + .map(From::from) + .map_err(|_| "conversion to `FactoryWhatsNext` for body failed".to_string()); + self + } + + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce( + types::builder::FactoryWhatsNext, + ) -> types::builder::FactoryWhatsNext, + { + self.body = self.body.map(f); + self + } + + ///Sends a `POST` request to `/0/factory/lease` + pub async fn send( + self, + ) -> Result, Error> { + let Self { client, body } = self; + let body = body + .and_then(std::convert::TryInto::::try_into) + .map_err(Error::InvalidRequest)?; + let url = format!("{}/0/factory/lease", client.baseurl,); + let request = client + .client + .post(url) + .header( + reqwest::header::ACCEPT, + reqwest::header::HeaderValue::from_static("application/json"), + ) + .json(&body) + .build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::factory_lease_renew`] + /// + ///[`Client::factory_lease_renew`]: super::Client::factory_lease_renew + #[derive(Debug, Clone)] + pub struct FactoryLeaseRenew<'a> { + client: &'a super::Client, + job: Result, + } + + impl<'a> FactoryLeaseRenew<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + job: Err("job was not initialized".to_string()), + } + } + + pub fn job(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.job = value + .try_into() + .map_err(|_| "conversion to `String` for job failed".to_string()); + self + } + + ///Sends a `POST` request to `/0/factory/lease/{job}` + pub async fn send(self) -> Result, Error> { + let Self { client, job } = self; + let job = job.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/0/factory/lease/{}", + client.baseurl, + encode_path(&job.to_string()), + ); + let request = client + .client + .post(url) + .header( + reqwest::header::ACCEPT, + reqwest::header::HeaderValue::from_static("application/json"), + ) + .build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::factory_ping`] + /// + ///[`Client::factory_ping`]: super::Client::factory_ping + #[derive(Debug, Clone)] + pub struct FactoryPing<'a> { + client: &'a super::Client, + } + + impl<'a> FactoryPing<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { client: client } + } + + ///Sends a `GET` request to `/0/factory/ping` + pub async fn send( + self, + ) -> Result, Error> { + let Self { client } = self; + let url = format!("{}/0/factory/ping", client.baseurl,); + let request = client + .client + .get(url) + .header( + reqwest::header::ACCEPT, + reqwest::header::HeaderValue::from_static("application/json"), + ) + .build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::factory_worker_create`] + /// + ///[`Client::factory_worker_create`]: super::Client::factory_worker_create + #[derive(Debug, Clone)] + pub struct FactoryWorkerCreate<'a> { + client: &'a super::Client, + body: Result, + } + + impl<'a> FactoryWorkerCreate<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + body: Ok(types::builder::FactoryWorkerCreate::default()), + } + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.body = value + .try_into() + .map(From::from) + .map_err(|_| "conversion to `FactoryWorkerCreate` for body failed".to_string()); + self + } + + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce( + types::builder::FactoryWorkerCreate, + ) -> types::builder::FactoryWorkerCreate, + { + self.body = self.body.map(f); + self + } + + ///Sends a `POST` request to `/0/factory/worker` + pub async fn send( + self, + ) -> Result, Error> { + let Self { client, body } = self; + let body = body + .and_then(std::convert::TryInto::::try_into) + .map_err(Error::InvalidRequest)?; + let url = format!("{}/0/factory/worker", client.baseurl,); + let request = client + .client + .post(url) + .header( + reqwest::header::ACCEPT, + reqwest::header::HeaderValue::from_static("application/json"), + ) + .json(&body) + .build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 201u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::factory_worker_get`] + /// + ///[`Client::factory_worker_get`]: super::Client::factory_worker_get + #[derive(Debug, Clone)] + pub struct FactoryWorkerGet<'a> { + client: &'a super::Client, + worker: Result, + } + + impl<'a> FactoryWorkerGet<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + worker: Err("worker was not initialized".to_string()), + } + } + + pub fn worker(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.worker = value + .try_into() + .map_err(|_| "conversion to `String` for worker failed".to_string()); + self + } + + ///Sends a `GET` request to `/0/factory/worker/{worker}` + pub async fn send( + self, + ) -> Result, Error> { + let Self { client, worker } = self; + let worker = worker.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/0/factory/worker/{}", + client.baseurl, + encode_path(&worker.to_string()), + ); + let request = client + .client + .get(url) + .header( + reqwest::header::ACCEPT, + reqwest::header::HeaderValue::from_static("application/json"), + ) + .build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::factory_worker_destroy`] + /// + ///[`Client::factory_worker_destroy`]: super::Client::factory_worker_destroy + #[derive(Debug, Clone)] + pub struct FactoryWorkerDestroy<'a> { + client: &'a super::Client, + worker: Result, + } + + impl<'a> FactoryWorkerDestroy<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + worker: Err("worker was not initialized".to_string()), + } + } + + pub fn worker(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.worker = value + .try_into() + .map_err(|_| "conversion to `String` for worker failed".to_string()); + self + } + + ///Sends a `DELETE` request to `/0/factory/worker/{worker}` + pub async fn send(self) -> Result, Error> { + let Self { client, worker } = self; + let worker = worker.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/0/factory/worker/{}", + client.baseurl, + encode_path(&worker.to_string()), + ); + let request = client + .client + .delete(url) + .header( + reqwest::header::ACCEPT, + reqwest::header::HeaderValue::from_static("application/json"), + ) + .build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::factory_worker_associate`] + /// + ///[`Client::factory_worker_associate`]: super::Client::factory_worker_associate + #[derive(Debug, Clone)] + pub struct FactoryWorkerAssociate<'a> { + client: &'a super::Client, + worker: Result, + body: Result, + } + + impl<'a> FactoryWorkerAssociate<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + worker: Err("worker was not initialized".to_string()), + body: Ok(types::builder::FactoryWorkerAssociate::default()), + } + } + + pub fn worker(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.worker = value + .try_into() + .map_err(|_| "conversion to `String` for worker failed".to_string()); + self + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.body = value + .try_into() + .map(From::from) + .map_err(|_| "conversion to `FactoryWorkerAssociate` for body failed".to_string()); + self + } + + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce( + types::builder::FactoryWorkerAssociate, + ) -> types::builder::FactoryWorkerAssociate, + { + self.body = self.body.map(f); + self + } + + ///Sends a `PATCH` request to `/0/factory/worker/{worker}` + pub async fn send(self) -> Result, Error> { + let Self { + client, + worker, + body, + } = self; + let worker = worker.map_err(Error::InvalidRequest)?; + let body = body + .and_then(std::convert::TryInto::::try_into) + .map_err(Error::InvalidRequest)?; + let url = format!( + "{}/0/factory/worker/{}", + client.baseurl, + encode_path(&worker.to_string()), + ); + let request = client + .client + .patch(url) + .header( + reqwest::header::ACCEPT, + reqwest::header::HeaderValue::from_static("application/json"), + ) + .json(&body) + .build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::factory_worker_append`] + /// + ///[`Client::factory_worker_append`]: super::Client::factory_worker_append + #[derive(Debug, Clone)] + pub struct FactoryWorkerAppend<'a> { + client: &'a super::Client, + worker: Result, + body: Result, + } + + impl<'a> FactoryWorkerAppend<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + worker: Err("worker was not initialized".to_string()), + body: Ok(types::builder::FactoryWorkerAppend::default()), + } + } + + pub fn worker(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.worker = value + .try_into() + .map_err(|_| "conversion to `String` for worker failed".to_string()); + self + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.body = value + .try_into() + .map(From::from) + .map_err(|_| "conversion to `FactoryWorkerAppend` for body failed".to_string()); + self + } + + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce( + types::builder::FactoryWorkerAppend, + ) -> types::builder::FactoryWorkerAppend, + { + self.body = self.body.map(f); + self + } + + ///Sends a `POST` request to `/0/factory/worker/{worker}/append` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + worker, + body, + } = self; + let worker = worker.map_err(Error::InvalidRequest)?; + let body = body + .and_then(std::convert::TryInto::::try_into) + .map_err(Error::InvalidRequest)?; + let url = format!( + "{}/0/factory/worker/{}/append", + client.baseurl, + encode_path(&worker.to_string()), + ); + let request = client + .client + .post(url) + .header( + reqwest::header::ACCEPT, + reqwest::header::HeaderValue::from_static("application/json"), + ) + .json(&body) + .build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::factory_worker_flush`] + /// + ///[`Client::factory_worker_flush`]: super::Client::factory_worker_flush + #[derive(Debug, Clone)] + pub struct FactoryWorkerFlush<'a> { + client: &'a super::Client, + worker: Result, + } + + impl<'a> FactoryWorkerFlush<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + worker: Err("worker was not initialized".to_string()), + } } - impl Default for Worker { - fn default() -> Self { - Self { - deleted: Err("no value supplied for deleted".to_string()), - id: Err("no value supplied for id".to_string()), - instance_id: Ok(Default::default()), - lastping: Ok(Default::default()), - recycle: Err("no value supplied for recycle".to_string()), - tasks: Err("no value supplied for tasks".to_string()), - } + pub fn worker(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.worker = value + .try_into() + .map_err(|_| "conversion to `String` for worker failed".to_string()); + self + } + + ///Sends a `POST` request to `/0/factory/worker/{worker}/flush` + pub async fn send(self) -> Result, Error> { + let Self { client, worker } = self; + let worker = worker.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/0/factory/worker/{}/flush", + client.baseurl, + encode_path(&worker.to_string()), + ); + let request = client + .client + .post(url) + .header( + reqwest::header::ACCEPT, + reqwest::header::HeaderValue::from_static("application/json"), + ) + .build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), } } + } - impl Worker { - pub fn deleted(mut self, value: T) -> Self - where - T: std::convert::TryInto, - T::Error: std::fmt::Display, - { - self.deleted = value - .try_into() - .map_err(|e| format!("error converting supplied value for deleted: {}", e)); - self + ///Builder for [`Client::factory_workers`] + /// + ///[`Client::factory_workers`]: super::Client::factory_workers + #[derive(Debug, Clone)] + pub struct FactoryWorkers<'a> { + client: &'a super::Client, + } + + impl<'a> FactoryWorkers<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { client: client } + } + + ///Sends a `GET` request to `/0/factory/workers` + pub async fn send( + self, + ) -> Result>, Error> { + let Self { client } = self; + let url = format!("{}/0/factory/workers", client.baseurl,); + let request = client + .client + .get(url) + .header( + reqwest::header::ACCEPT, + reqwest::header::HeaderValue::from_static("application/json"), + ) + .build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), } - pub fn id(mut self, value: T) -> Self - where - T: std::convert::TryInto, - T::Error: std::fmt::Display, - { - self.id = value - .try_into() - .map_err(|e| format!("error converting supplied value for id: {}", e)); - self + } + } + + ///Builder for [`Client::job_get`] + /// + ///[`Client::job_get`]: super::Client::job_get + #[derive(Debug, Clone)] + pub struct JobGet<'a> { + client: &'a super::Client, + job: Result, + } + + impl<'a> JobGet<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + job: Err("job was not initialized".to_string()), } - pub fn instance_id(mut self, value: T) -> Self - where - T: std::convert::TryInto>, - T::Error: std::fmt::Display, - { - self.instance_id = value - .try_into() - .map_err(|e| format!("error converting supplied value for instance_id: {}", e)); - self + } + + pub fn job(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.job = value + .try_into() + .map_err(|_| "conversion to `String` for job failed".to_string()); + self + } + + ///Sends a `GET` request to `/0/job/{job}` + pub async fn send(self) -> Result, Error> { + let Self { client, job } = self; + let job = job.map_err(Error::InvalidRequest)?; + let url = format!("{}/0/job/{}", client.baseurl, encode_path(&job.to_string()),); + let request = client + .client + .get(url) + .header( + reqwest::header::ACCEPT, + reqwest::header::HeaderValue::from_static("application/json"), + ) + .build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), } - pub fn lastping(mut self, value: T) -> Self - where - T: std::convert::TryInto>>, - T::Error: std::fmt::Display, - { - self.lastping = value - .try_into() - .map_err(|e| format!("error converting supplied value for lastping: {}", e)); - self + } + } + + ///Builder for [`Client::jobs_get`] + /// + ///[`Client::jobs_get`]: super::Client::jobs_get + #[derive(Debug, Clone)] + pub struct JobsGet<'a> { + client: &'a super::Client, + } + + impl<'a> JobsGet<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { client: client } + } + + ///Sends a `GET` request to `/0/jobs` + pub async fn send(self) -> Result>, Error> { + let Self { client } = self; + let url = format!("{}/0/jobs", client.baseurl,); + let request = client + .client + .get(url) + .header( + reqwest::header::ACCEPT, + reqwest::header::HeaderValue::from_static("application/json"), + ) + .build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), } - pub fn recycle(mut self, value: T) -> Self - where - T: std::convert::TryInto, - T::Error: std::fmt::Display, - { - self.recycle = value - .try_into() - .map_err(|e| format!("error converting supplied value for recycle: {}", e)); - self + } + } + + ///Builder for [`Client::job_submit`] + /// + ///[`Client::job_submit`]: super::Client::job_submit + #[derive(Debug, Clone)] + pub struct JobSubmit<'a> { + client: &'a super::Client, + body: Result, + } + + impl<'a> JobSubmit<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + body: Ok(types::builder::JobSubmit::default()), } - pub fn tasks(mut self, value: T) -> Self - where - T: std::convert::TryInto>, - T::Error: std::fmt::Display, - { - self.tasks = value - .try_into() - .map_err(|e| format!("error converting supplied value for tasks: {}", e)); - self + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.body = value + .try_into() + .map(From::from) + .map_err(|_| "conversion to `JobSubmit` for body failed".to_string()); + self + } + + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::JobSubmit) -> types::builder::JobSubmit, + { + self.body = self.body.map(f); + self + } + + ///Sends a `POST` request to `/0/jobs` + pub async fn send( + self, + ) -> Result, Error> { + let Self { client, body } = self; + let body = body + .and_then(std::convert::TryInto::::try_into) + .map_err(Error::InvalidRequest)?; + let url = format!("{}/0/jobs", client.baseurl,); + let request = client + .client + .post(url) + .header( + reqwest::header::ACCEPT, + reqwest::header::HeaderValue::from_static("application/json"), + ) + .json(&body) + .build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 201u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), } } + } - impl std::convert::TryFrom for super::Worker { - type Error = String; - fn try_from(value: Worker) -> Result { - Ok(Self { - deleted: value.deleted?, - id: value.id?, - instance_id: value.instance_id?, - lastping: value.lastping?, - recycle: value.recycle?, - tasks: value.tasks?, - }) + ///Builder for [`Client::job_cancel`] + /// + ///[`Client::job_cancel`]: super::Client::job_cancel + #[derive(Debug, Clone)] + pub struct JobCancel<'a> { + client: &'a super::Client, + job: Result, + } + + impl<'a> JobCancel<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + job: Err("job was not initialized".to_string()), } } - impl From for Worker { - fn from(value: super::Worker) -> Self { - Self { - deleted: Ok(value.deleted), - id: Ok(value.id), - instance_id: Ok(value.instance_id), - lastping: Ok(value.lastping), - recycle: Ok(value.recycle), - tasks: Ok(value.tasks), - } + pub fn job(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.job = value + .try_into() + .map_err(|_| "conversion to `String` for job failed".to_string()); + self + } + + ///Sends a `POST` request to `/0/jobs/{job}/cancel` + pub async fn send(self) -> Result, Error> { + let Self { client, job } = self; + let job = job.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/0/jobs/{}/cancel", + client.baseurl, + encode_path(&job.to_string()), + ); + let request = client + .client + .post(url) + .header( + reqwest::header::ACCEPT, + reqwest::header::HeaderValue::from_static("application/json"), + ) + .build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), } } + } - #[derive(Clone, Debug)] - pub struct WorkerAddOutput { - chunks: Result, String>, - path: Result, - size: Result, - } + ///Builder for [`Client::job_upload_chunk`] + /// + ///[`Client::job_upload_chunk`]: super::Client::job_upload_chunk + #[derive(Debug)] + pub struct JobUploadChunk<'a> { + client: &'a super::Client, + job: Result, + body: Result, + } - impl Default for WorkerAddOutput { - fn default() -> Self { - Self { - chunks: Err("no value supplied for chunks".to_string()), - path: Err("no value supplied for path".to_string()), - size: Err("no value supplied for size".to_string()), - } + impl<'a> JobUploadChunk<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + job: Err("job was not initialized".to_string()), + body: Err("body was not initialized".to_string()), } } - impl WorkerAddOutput { - pub fn chunks(mut self, value: T) -> Self - where - T: std::convert::TryInto>, - T::Error: std::fmt::Display, - { - self.chunks = value - .try_into() - .map_err(|e| format!("error converting supplied value for chunks: {}", e)); - self - } - pub fn path(mut self, value: T) -> Self - where - T: std::convert::TryInto, - T::Error: std::fmt::Display, - { - self.path = value - .try_into() - .map_err(|e| format!("error converting supplied value for path: {}", e)); - self - } - pub fn size(mut self, value: T) -> Self - where - T: std::convert::TryInto, - T::Error: std::fmt::Display, - { - self.size = value - .try_into() - .map_err(|e| format!("error converting supplied value for size: {}", e)); - self - } + pub fn job(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.job = value + .try_into() + .map_err(|_| "conversion to `String` for job failed".to_string()); + self } - impl std::convert::TryFrom for super::WorkerAddOutput { - type Error = String; - fn try_from(value: WorkerAddOutput) -> Result { - Ok(Self { - chunks: value.chunks?, - path: value.path?, - size: value.size?, - }) - } + pub fn body(mut self, value: B) -> Self + where + B: std::convert::TryInto, + { + self.body = value + .try_into() + .map_err(|_| "conversion to `reqwest::Body` for body failed".to_string()); + self } - impl From for WorkerAddOutput { - fn from(value: super::WorkerAddOutput) -> Self { - Self { - chunks: Ok(value.chunks), - path: Ok(value.path), - size: Ok(value.size), - } + ///Sends a `POST` request to `/0/jobs/{job}/chunk` + pub async fn send( + self, + ) -> Result, Error> { + let Self { client, job, body } = self; + let job = job.map_err(Error::InvalidRequest)?; + let body = body.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/0/jobs/{}/chunk", + client.baseurl, + encode_path(&job.to_string()), + ); + let request = client + .client + .post(url) + .header( + reqwest::header::ACCEPT, + reqwest::header::HeaderValue::from_static("application/json"), + ) + .header( + reqwest::header::CONTENT_TYPE, + reqwest::header::HeaderValue::from_static("application/octet-stream"), + ) + .body(body) + .build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 201u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), } } + } - #[derive(Clone, Debug)] - pub struct WorkerAppendTask { - payload: Result, - stream: Result, - time: Result, String>, - } + ///Builder for [`Client::job_events_get`] + /// + ///[`Client::job_events_get`]: super::Client::job_events_get + #[derive(Debug, Clone)] + pub struct JobEventsGet<'a> { + client: &'a super::Client, + job: Result, + minseq: Result, String>, + } - impl Default for WorkerAppendTask { - fn default() -> Self { - Self { - payload: Err("no value supplied for payload".to_string()), - stream: Err("no value supplied for stream".to_string()), - time: Err("no value supplied for time".to_string()), - } + impl<'a> JobEventsGet<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + job: Err("job was not initialized".to_string()), + minseq: Ok(None), } } - impl WorkerAppendTask { - pub fn payload(mut self, value: T) -> Self - where - T: std::convert::TryInto, - T::Error: std::fmt::Display, - { - self.payload = value - .try_into() - .map_err(|e| format!("error converting supplied value for payload: {}", e)); - self - } - pub fn stream(mut self, value: T) -> Self - where - T: std::convert::TryInto, - T::Error: std::fmt::Display, - { - self.stream = value - .try_into() - .map_err(|e| format!("error converting supplied value for stream: {}", e)); - self - } - pub fn time(mut self, value: T) -> Self - where - T: std::convert::TryInto>, - T::Error: std::fmt::Display, - { - self.time = value - .try_into() - .map_err(|e| format!("error converting supplied value for time: {}", e)); - self - } + pub fn job(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.job = value + .try_into() + .map_err(|_| "conversion to `String` for job failed".to_string()); + self } - impl std::convert::TryFrom for super::WorkerAppendTask { - type Error = String; - fn try_from(value: WorkerAppendTask) -> Result { - Ok(Self { - payload: value.payload?, - stream: value.stream?, - time: value.time?, - }) - } + pub fn minseq(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.minseq = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `u32` for minseq failed".to_string()); + self } - impl From for WorkerAppendTask { - fn from(value: super::WorkerAppendTask) -> Self { - Self { - payload: Ok(value.payload), - stream: Ok(value.stream), - time: Ok(value.time), - } + ///Sends a `GET` request to `/0/jobs/{job}/events` + pub async fn send( + self, + ) -> Result>, Error> { + let Self { + client, + job, + minseq, + } = self; + let job = job.map_err(Error::InvalidRequest)?; + let minseq = minseq.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/0/jobs/{}/events", + client.baseurl, + encode_path(&job.to_string()), + ); + let mut query = Vec::with_capacity(1usize); + if let Some(v) = &minseq { + query.push(("minseq", v.to_string())); + } + let request = client + .client + .get(url) + .header( + reqwest::header::ACCEPT, + reqwest::header::HeaderValue::from_static("application/json"), + ) + .query(&query) + .build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), } } + } - #[derive(Clone, Debug)] - pub struct WorkerBootstrap { - bootstrap: Result, - token: Result, - } + ///Builder for [`Client::job_outputs_get`] + /// + ///[`Client::job_outputs_get`]: super::Client::job_outputs_get + #[derive(Debug, Clone)] + pub struct JobOutputsGet<'a> { + client: &'a super::Client, + job: Result, + } - impl Default for WorkerBootstrap { - fn default() -> Self { - Self { - bootstrap: Err("no value supplied for bootstrap".to_string()), - token: Err("no value supplied for token".to_string()), - } + impl<'a> JobOutputsGet<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + job: Err("job was not initialized".to_string()), } } - impl WorkerBootstrap { - pub fn bootstrap(mut self, value: T) -> Self - where - T: std::convert::TryInto, - T::Error: std::fmt::Display, - { - self.bootstrap = value - .try_into() - .map_err(|e| format!("error converting supplied value for bootstrap: {}", e)); - self - } - pub fn token(mut self, value: T) -> Self - where - T: std::convert::TryInto, - T::Error: std::fmt::Display, - { - self.token = value - .try_into() - .map_err(|e| format!("error converting supplied value for token: {}", e)); - self - } + pub fn job(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.job = value + .try_into() + .map_err(|_| "conversion to `String` for job failed".to_string()); + self } - impl std::convert::TryFrom for super::WorkerBootstrap { - type Error = String; - fn try_from(value: WorkerBootstrap) -> Result { - Ok(Self { - bootstrap: value.bootstrap?, - token: value.token?, - }) + ///Sends a `GET` request to `/0/jobs/{job}/outputs` + pub async fn send( + self, + ) -> Result>, Error> { + let Self { client, job } = self; + let job = job.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/0/jobs/{}/outputs", + client.baseurl, + encode_path(&job.to_string()), + ); + let request = client + .client + .get(url) + .header( + reqwest::header::ACCEPT, + reqwest::header::HeaderValue::from_static("application/json"), + ) + .build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), } } + } - impl From for WorkerBootstrap { - fn from(value: super::WorkerBootstrap) -> Self { - Self { - bootstrap: Ok(value.bootstrap), - token: Ok(value.token), - } + ///Builder for [`Client::job_output_download`] + /// + ///[`Client::job_output_download`]: super::Client::job_output_download + #[derive(Debug, Clone)] + pub struct JobOutputDownload<'a> { + client: &'a super::Client, + job: Result, + output: Result, + } + + impl<'a> JobOutputDownload<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + job: Err("job was not initialized".to_string()), + output: Err("output was not initialized".to_string()), } } - #[derive(Clone, Debug)] - pub struct WorkerBootstrapResult { - id: Result, + pub fn job(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.job = value + .try_into() + .map_err(|_| "conversion to `String` for job failed".to_string()); + self } - impl Default for WorkerBootstrapResult { - fn default() -> Self { - Self { - id: Err("no value supplied for id".to_string()), - } - } + pub fn output(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.output = value + .try_into() + .map_err(|_| "conversion to `String` for output failed".to_string()); + self } - impl WorkerBootstrapResult { - pub fn id(mut self, value: T) -> Self - where - T: std::convert::TryInto, - T::Error: std::fmt::Display, - { - self.id = value - .try_into() - .map_err(|e| format!("error converting supplied value for id: {}", e)); - self + ///Sends a `GET` request to `/0/jobs/{job}/outputs/{output}` + pub async fn send(self) -> Result, Error> { + let Self { + client, + job, + output, + } = self; + let job = job.map_err(Error::InvalidRequest)?; + let output = output.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/0/jobs/{}/outputs/{}", + client.baseurl, + encode_path(&job.to_string()), + encode_path(&output.to_string()), + ); + let request = client.client.get(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200..=299 => Ok(ResponseValue::stream(response)), + _ => Err(Error::ErrorResponse(ResponseValue::stream(response))), } } + } - impl std::convert::TryFrom for super::WorkerBootstrapResult { - type Error = String; - fn try_from(value: WorkerBootstrapResult) -> Result { - Ok(Self { id: value.id? }) + ///Builder for [`Client::job_output_publish`] + /// + ///[`Client::job_output_publish`]: super::Client::job_output_publish + #[derive(Debug, Clone)] + pub struct JobOutputPublish<'a> { + client: &'a super::Client, + job: Result, + output: Result, + body: Result, + } + + impl<'a> JobOutputPublish<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + job: Err("job was not initialized".to_string()), + output: Err("output was not initialized".to_string()), + body: Ok(types::builder::JobOutputPublish::default()), } } - impl From for WorkerBootstrapResult { - fn from(value: super::WorkerBootstrapResult) -> Self { - Self { id: Ok(value.id) } - } + pub fn job(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.job = value + .try_into() + .map_err(|_| "conversion to `String` for job failed".to_string()); + self } - #[derive(Clone, Debug)] - pub struct WorkerCompleteTask { - failed: Result, + pub fn output(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.output = value + .try_into() + .map_err(|_| "conversion to `String` for output failed".to_string()); + self } - impl Default for WorkerCompleteTask { - fn default() -> Self { - Self { - failed: Err("no value supplied for failed".to_string()), - } - } + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.body = value + .try_into() + .map(From::from) + .map_err(|_| "conversion to `JobOutputPublish` for body failed".to_string()); + self } - impl WorkerCompleteTask { - pub fn failed(mut self, value: T) -> Self - where - T: std::convert::TryInto, - T::Error: std::fmt::Display, - { - self.failed = value - .try_into() - .map_err(|e| format!("error converting supplied value for failed: {}", e)); - self - } + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce( + types::builder::JobOutputPublish, + ) -> types::builder::JobOutputPublish, + { + self.body = self.body.map(f); + self } - impl std::convert::TryFrom for super::WorkerCompleteTask { - type Error = String; - fn try_from(value: WorkerCompleteTask) -> Result { - Ok(Self { - failed: value.failed?, - }) + ///Sends a `POST` request to `/0/jobs/{job}/outputs/{output}/publish` + pub async fn send(self) -> Result, Error> { + let Self { + client, + job, + output, + body, + } = self; + let job = job.map_err(Error::InvalidRequest)?; + let output = output.map_err(Error::InvalidRequest)?; + let body = body + .and_then(std::convert::TryInto::::try_into) + .map_err(Error::InvalidRequest)?; + let url = format!( + "{}/0/jobs/{}/outputs/{}/publish", + client.baseurl, + encode_path(&job.to_string()), + encode_path(&output.to_string()), + ); + let request = client + .client + .post(url) + .header( + reqwest::header::ACCEPT, + reqwest::header::HeaderValue::from_static("application/json"), + ) + .json(&body) + .build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), } } + } - impl From for WorkerCompleteTask { - fn from(value: super::WorkerCompleteTask) -> Self { - Self { - failed: Ok(value.failed), - } + ///Builder for [`Client::job_output_signed_url`] + /// + ///[`Client::job_output_signed_url`]: super::Client::job_output_signed_url + #[derive(Debug, Clone)] + pub struct JobOutputSignedUrl<'a> { + client: &'a super::Client, + job: Result, + output: Result, + body: Result, + } + + impl<'a> JobOutputSignedUrl<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + job: Err("job was not initialized".to_string()), + output: Err("output was not initialized".to_string()), + body: Ok(types::builder::JobOutputSignedUrl::default()), } } - #[derive(Clone, Debug)] - pub struct WorkerPingResult { - poweroff: Result, - task: Result, String>, + pub fn job(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.job = value + .try_into() + .map_err(|_| "conversion to `String` for job failed".to_string()); + self } - impl Default for WorkerPingResult { - fn default() -> Self { - Self { - poweroff: Err("no value supplied for poweroff".to_string()), - task: Ok(Default::default()), - } - } + pub fn output(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.output = value + .try_into() + .map_err(|_| "conversion to `String` for output failed".to_string()); + self } - impl WorkerPingResult { - pub fn poweroff(mut self, value: T) -> Self - where - T: std::convert::TryInto, - T::Error: std::fmt::Display, - { - self.poweroff = value - .try_into() - .map_err(|e| format!("error converting supplied value for poweroff: {}", e)); - self - } - pub fn task(mut self, value: T) -> Self - where - T: std::convert::TryInto>, - T::Error: std::fmt::Display, - { - self.task = value - .try_into() - .map_err(|e| format!("error converting supplied value for task: {}", e)); - self - } + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.body = value + .try_into() + .map(From::from) + .map_err(|_| "conversion to `JobOutputSignedUrl` for body failed".to_string()); + self + } + + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce( + types::builder::JobOutputSignedUrl, + ) -> types::builder::JobOutputSignedUrl, + { + self.body = self.body.map(f); + self } - impl std::convert::TryFrom for super::WorkerPingResult { - type Error = String; - fn try_from(value: WorkerPingResult) -> Result { - Ok(Self { - poweroff: value.poweroff?, - task: value.task?, - }) + ///Sends a `POST` request to `/0/jobs/{job}/outputs/{output}/sign` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + job, + output, + body, + } = self; + let job = job.map_err(Error::InvalidRequest)?; + let output = output.map_err(Error::InvalidRequest)?; + let body = body + .and_then(std::convert::TryInto::::try_into) + .map_err(Error::InvalidRequest)?; + let url = format!( + "{}/0/jobs/{}/outputs/{}/sign", + client.baseurl, + encode_path(&job.to_string()), + encode_path(&output.to_string()), + ); + let request = client + .client + .post(url) + .header( + reqwest::header::ACCEPT, + reqwest::header::HeaderValue::from_static("application/json"), + ) + .json(&body) + .build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), } } + } - impl From for WorkerPingResult { - fn from(value: super::WorkerPingResult) -> Self { - Self { - poweroff: Ok(value.poweroff), - task: Ok(value.task), - } + ///Builder for [`Client::job_store_get_all`] + /// + ///[`Client::job_store_get_all`]: super::Client::job_store_get_all + #[derive(Debug, Clone)] + pub struct JobStoreGetAll<'a> { + client: &'a super::Client, + job: Result, + } + + impl<'a> JobStoreGetAll<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + job: Err("job was not initialized".to_string()), } } - #[derive(Clone, Debug)] - pub struct WorkerPingTask { - id: Result, - output_rules: Result, String>, - script: Result, + pub fn job(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.job = value + .try_into() + .map_err(|_| "conversion to `String` for job failed".to_string()); + self } - impl Default for WorkerPingTask { - fn default() -> Self { - Self { - id: Err("no value supplied for id".to_string()), - output_rules: Err("no value supplied for output_rules".to_string()), - script: Err("no value supplied for script".to_string()), - } + ///Sends a `GET` request to `/0/jobs/{job}/store` + pub async fn send( + self, + ) -> Result< + ResponseValue>, + Error, + > { + let Self { client, job } = self; + let job = job.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/0/jobs/{}/store", + client.baseurl, + encode_path(&job.to_string()), + ); + let request = client + .client + .get(url) + .header( + reqwest::header::ACCEPT, + reqwest::header::HeaderValue::from_static("application/json"), + ) + .build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), } } + } - impl WorkerPingTask { - pub fn id(mut self, value: T) -> Self - where - T: std::convert::TryInto, - T::Error: std::fmt::Display, - { - self.id = value - .try_into() - .map_err(|e| format!("error converting supplied value for id: {}", e)); - self - } - pub fn output_rules(mut self, value: T) -> Self - where - T: std::convert::TryInto>, - T::Error: std::fmt::Display, - { - self.output_rules = value.try_into().map_err(|e| { - format!("error converting supplied value for output_rules: {}", e) - }); - self - } - pub fn script(mut self, value: T) -> Self - where - T: std::convert::TryInto, - T::Error: std::fmt::Display, - { - self.script = value - .try_into() - .map_err(|e| format!("error converting supplied value for script: {}", e)); - self - } - } + ///Builder for [`Client::job_store_put`] + /// + ///[`Client::job_store_put`]: super::Client::job_store_put + #[derive(Debug, Clone)] + pub struct JobStorePut<'a> { + client: &'a super::Client, + job: Result, + name: Result, + body: Result, + } - impl std::convert::TryFrom for super::WorkerPingTask { - type Error = String; - fn try_from(value: WorkerPingTask) -> Result { - Ok(Self { - id: value.id?, - output_rules: value.output_rules?, - script: value.script?, - }) + impl<'a> JobStorePut<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + job: Err("job was not initialized".to_string()), + name: Err("name was not initialized".to_string()), + body: Ok(types::builder::JobStoreValue::default()), } } - impl From for WorkerPingTask { - fn from(value: super::WorkerPingTask) -> Self { - Self { - id: Ok(value.id), - output_rules: Ok(value.output_rules), - script: Ok(value.script), - } - } + pub fn job(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.job = value + .try_into() + .map_err(|_| "conversion to `String` for job failed".to_string()); + self } - #[derive(Clone, Debug)] - pub struct WorkerTask { - id: Result, - name: Result, - owner: Result, + pub fn name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.name = value + .try_into() + .map_err(|_| "conversion to `String` for name failed".to_string()); + self } - impl Default for WorkerTask { - fn default() -> Self { - Self { - id: Err("no value supplied for id".to_string()), - name: Err("no value supplied for name".to_string()), - owner: Err("no value supplied for owner".to_string()), - } - } + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.body = value + .try_into() + .map(From::from) + .map_err(|_| "conversion to `JobStoreValue` for body failed".to_string()); + self } - impl WorkerTask { - pub fn id(mut self, value: T) -> Self - where - T: std::convert::TryInto, - T::Error: std::fmt::Display, - { - self.id = value - .try_into() - .map_err(|e| format!("error converting supplied value for id: {}", e)); - self - } - pub fn name(mut self, value: T) -> Self - where - T: std::convert::TryInto, - T::Error: std::fmt::Display, - { - self.name = value - .try_into() - .map_err(|e| format!("error converting supplied value for name: {}", e)); - self - } - pub fn owner(mut self, value: T) -> Self - where - T: std::convert::TryInto, - T::Error: std::fmt::Display, - { - self.owner = value - .try_into() - .map_err(|e| format!("error converting supplied value for owner: {}", e)); - self - } + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::JobStoreValue) -> types::builder::JobStoreValue, + { + self.body = self.body.map(f); + self } - impl std::convert::TryFrom for super::WorkerTask { - type Error = String; - fn try_from(value: WorkerTask) -> Result { - Ok(Self { - id: value.id?, - name: value.name?, - owner: value.owner?, - }) + ///Sends a `PUT` request to `/0/jobs/{job}/store/{name}` + pub async fn send(self) -> Result, Error> { + let Self { + client, + job, + name, + body, + } = self; + let job = job.map_err(Error::InvalidRequest)?; + let name = name.map_err(Error::InvalidRequest)?; + let body = body + .and_then(std::convert::TryInto::::try_into) + .map_err(Error::InvalidRequest)?; + let url = format!( + "{}/0/jobs/{}/store/{}", + client.baseurl, + encode_path(&job.to_string()), + encode_path(&name.to_string()), + ); + let request = client + .client + .put(url) + .header( + reqwest::header::ACCEPT, + reqwest::header::HeaderValue::from_static("application/json"), + ) + .json(&body) + .build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), } } + } - impl From for WorkerTask { - fn from(value: super::WorkerTask) -> Self { - Self { - id: Ok(value.id), - name: Ok(value.name), - owner: Ok(value.owner), - } + ///Builder for [`Client::public_file_download`] + /// + ///[`Client::public_file_download`]: super::Client::public_file_download + #[derive(Debug, Clone)] + pub struct PublicFileDownload<'a> { + client: &'a super::Client, + username: Result, + series: Result, + version: Result, + name: Result, + } + + impl<'a> PublicFileDownload<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + username: Err("username was not initialized".to_string()), + series: Err("series was not initialized".to_string()), + version: Err("version was not initialized".to_string()), + name: Err("name was not initialized".to_string()), } } - #[derive(Clone, Debug)] - pub struct WorkersResult { - workers: Result, String>, + pub fn username(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.username = value + .try_into() + .map_err(|_| "conversion to `String` for username failed".to_string()); + self } - - impl Default for WorkersResult { - fn default() -> Self { - Self { - workers: Err("no value supplied for workers".to_string()), - } - } + + pub fn series(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.series = value + .try_into() + .map_err(|_| "conversion to `String` for series failed".to_string()); + self } - impl WorkersResult { - pub fn workers(mut self, value: T) -> Self - where - T: std::convert::TryInto>, - T::Error: std::fmt::Display, - { - self.workers = value - .try_into() - .map_err(|e| format!("error converting supplied value for workers: {}", e)); - self - } + pub fn version(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.version = value + .try_into() + .map_err(|_| "conversion to `String` for version failed".to_string()); + self } - impl std::convert::TryFrom for super::WorkersResult { - type Error = String; - fn try_from(value: WorkersResult) -> Result { - Ok(Self { - workers: value.workers?, - }) - } + pub fn name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.name = value + .try_into() + .map_err(|_| "conversion to `String` for name failed".to_string()); + self } - impl From for WorkersResult { - fn from(value: super::WorkersResult) -> Self { - Self { - workers: Ok(value.workers), - } + ///Sends a `GET` request to + /// `/0/public/file/{username}/{series}/{version}/{name}` + pub async fn send(self) -> Result, Error> { + let Self { + client, + username, + series, + version, + name, + } = self; + let username = username.map_err(Error::InvalidRequest)?; + let series = series.map_err(Error::InvalidRequest)?; + let version = version.map_err(Error::InvalidRequest)?; + let name = name.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/0/public/file/{}/{}/{}/{}", + client.baseurl, + encode_path(&username.to_string()), + encode_path(&series.to_string()), + encode_path(&version.to_string()), + encode_path(&name.to_string()), + ); + let request = client.client.get(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200..=299 => Ok(ResponseValue::stream(response)), + _ => Err(Error::ErrorResponse(ResponseValue::stream(response))), } } } -} - -#[derive(Clone, Debug)] -///Client for Buildomat -/// -///Version: 1.0 -pub struct Client { - pub(crate) baseurl: String, - pub(crate) client: reqwest::Client, -} -impl Client { - /// Create a new client. + ///Builder for [`Client::quota`] /// - /// `baseurl` is the base URL provided to the internal - /// `reqwest::Client`, and should include a scheme and hostname, - /// as well as port and a path stem if applicable. - pub fn new(baseurl: &str) -> Self { - #[cfg(not(target_arch = "wasm32"))] - let client = { - let dur = std::time::Duration::from_secs(15); - reqwest::ClientBuilder::new() - .connect_timeout(dur) - .timeout(dur) - }; - #[cfg(target_arch = "wasm32")] - let client = reqwest::ClientBuilder::new(); - Self::new_with_client(baseurl, client.build().unwrap()) + ///[`Client::quota`]: super::Client::quota + #[derive(Debug, Clone)] + pub struct Quota<'a> { + client: &'a super::Client, } - /// Construct a new client with an existing `reqwest::Client`, - /// allowing more control over its configuration. - /// - /// `baseurl` is the base URL provided to the internal - /// `reqwest::Client`, and should include a scheme and hostname, - /// as well as port and a path stem if applicable. - pub fn new_with_client(baseurl: &str, client: reqwest::Client) -> Self { - Self { - baseurl: baseurl.to_string(), - client, + impl<'a> Quota<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { client: client } } - } - - /// Get the base URL to which requests are made. - pub fn baseurl(&self) -> &String { - &self.baseurl - } - /// Get the internal `reqwest::Client` used to make requests. - pub fn client(&self) -> &reqwest::Client { - &self.client + ///Sends a `GET` request to `/0/quota` + pub async fn send(self) -> Result, Error> { + let Self { client } = self; + let url = format!("{}/0/quota", client.baseurl,); + let request = client + .client + .get(url) + .header( + reqwest::header::ACCEPT, + reqwest::header::HeaderValue::from_static("application/json"), + ) + .build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } } - /// Get the version of this API. + ///Builder for [`Client::users_list`] /// - /// This string is pulled directly from the source OpenAPI - /// document and may be in any format the API selects. - pub fn api_version(&self) -> &'static str { - "1.0" + ///[`Client::users_list`]: super::Client::users_list + #[derive(Debug, Clone)] + pub struct UsersList<'a> { + client: &'a super::Client, + name: Result, String>, } -} -impl Client { - ///Sends a `POST` request to `/v1/control/hold` - /// - ///```ignore - /// let response = client.control_hold() - /// .send() - /// .await; - /// ``` - pub fn control_hold(&self) -> builder::ControlHold { - builder::ControlHold::new(self) - } + impl<'a> UsersList<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + name: Ok(None), + } + } - ///Sends a `POST` request to `/v1/control/resume` - /// - ///```ignore - /// let response = client.control_resume() - /// .send() - /// .await; - /// ``` - pub fn control_resume(&self) -> builder::ControlResume { - builder::ControlResume::new(self) - } + pub fn name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.name = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `String` for name failed".to_string()); + self + } - ///Sends a `GET` request to `/v1/task/{task}` - /// - ///```ignore - /// let response = client.task_get() - /// .task(task) - /// .send() - /// .await; - /// ``` - pub fn task_get(&self) -> builder::TaskGet { - builder::TaskGet::new(self) + ///Sends a `GET` request to `/0/users` + pub async fn send(self) -> Result>, Error> { + let Self { client, name } = self; + let name = name.map_err(Error::InvalidRequest)?; + let url = format!("{}/0/users", client.baseurl,); + let mut query = Vec::with_capacity(1usize); + if let Some(v) = &name { + query.push(("name", v.to_string())); + } + let request = client + .client + .get(url) + .header( + reqwest::header::ACCEPT, + reqwest::header::HeaderValue::from_static("application/json"), + ) + .query(&query) + .build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } } - ///Sends a `GET` request to `/v1/tasks` + ///Builder for [`Client::user_create`] /// - ///```ignore - /// let response = client.tasks_get() - /// .send() - /// .await; - /// ``` - pub fn tasks_get(&self) -> builder::TasksGet { - builder::TasksGet::new(self) + ///[`Client::user_create`]: super::Client::user_create + #[derive(Debug, Clone)] + pub struct UserCreate<'a> { + client: &'a super::Client, + body: Result, } - ///Sends a `POST` request to `/v1/tasks` - /// - ///```ignore - /// let response = client.task_submit() - /// .body(body) - /// .send() - /// .await; - /// ``` - pub fn task_submit(&self) -> builder::TaskSubmit { - builder::TaskSubmit::new(self) - } + impl<'a> UserCreate<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + body: Ok(types::builder::UserCreate::default()), + } + } - ///Sends a `GET` request to `/v1/tasks/{task}/events` - /// - ///```ignore - /// let response = client.task_events_get() - /// .task(task) - /// .minseq(minseq) - /// .send() - /// .await; - /// ``` - pub fn task_events_get(&self) -> builder::TaskEventsGet { - builder::TaskEventsGet::new(self) - } + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.body = value + .try_into() + .map(From::from) + .map_err(|_| "conversion to `UserCreate` for body failed".to_string()); + self + } - ///Sends a `GET` request to `/v1/tasks/{task}/outputs` - /// - ///```ignore - /// let response = client.task_outputs_get() - /// .task(task) - /// .send() - /// .await; - /// ``` - pub fn task_outputs_get(&self) -> builder::TaskOutputsGet { - builder::TaskOutputsGet::new(self) - } + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::UserCreate) -> types::builder::UserCreate, + { + self.body = self.body.map(f); + self + } - ///Sends a `GET` request to `/v1/tasks/{task}/outputs/{output}` - /// - ///```ignore - /// let response = client.task_output_download() - /// .task(task) - /// .output(output) - /// .send() - /// .await; - /// ``` - pub fn task_output_download(&self) -> builder::TaskOutputDownload { - builder::TaskOutputDownload::new(self) + ///Sends a `POST` request to `/0/users` + pub async fn send( + self, + ) -> Result, Error> { + let Self { client, body } = self; + let body = body + .and_then(std::convert::TryInto::::try_into) + .map_err(Error::InvalidRequest)?; + let url = format!("{}/0/users", client.baseurl,); + let request = client + .client + .post(url) + .header( + reqwest::header::ACCEPT, + reqwest::header::HeaderValue::from_static("application/json"), + ) + .json(&body) + .build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 201u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } } - ///Sends a `POST` request to `/v1/users` + ///Builder for [`Client::user_get`] /// - ///```ignore - /// let response = client.user_create() - /// .body(body) - /// .send() - /// .await; - /// ``` - pub fn user_create(&self) -> builder::UserCreate { - builder::UserCreate::new(self) + ///[`Client::user_get`]: super::Client::user_get + #[derive(Debug, Clone)] + pub struct UserGet<'a> { + client: &'a super::Client, + user: Result, } - ///Sends a `GET` request to `/v1/whoami` - /// - ///```ignore - /// let response = client.whoami() - /// .send() - /// .await; - /// ``` - pub fn whoami(&self) -> builder::Whoami { - builder::Whoami::new(self) - } + impl<'a> UserGet<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + user: Err("user was not initialized".to_string()), + } + } - ///Sends a `PUT` request to `/v1/whoami/name` - /// - ///```ignore - /// let response = client.whoami_put_name() - /// .body(body) - /// .send() - /// .await; - /// ``` - pub fn whoami_put_name(&self) -> builder::WhoamiPutName { - builder::WhoamiPutName::new(self) - } + pub fn user(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.user = value + .try_into() + .map_err(|_| "conversion to `String` for user failed".to_string()); + self + } - ///Sends a `POST` request to `/v1/worker/bootstrap` - /// - ///```ignore - /// let response = client.worker_bootstrap() - /// .body(body) - /// .send() - /// .await; - /// ``` - pub fn worker_bootstrap(&self) -> builder::WorkerBootstrap { - builder::WorkerBootstrap::new(self) + ///Sends a `GET` request to `/0/users/{user}` + pub async fn send(self) -> Result, Error> { + let Self { client, user } = self; + let user = user.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/0/users/{}", + client.baseurl, + encode_path(&user.to_string()), + ); + let request = client + .client + .get(url) + .header( + reqwest::header::ACCEPT, + reqwest::header::HeaderValue::from_static("application/json"), + ) + .build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } } - ///Sends a `GET` request to `/v1/worker/ping` + ///Builder for [`Client::user_privilege_grant`] /// - ///```ignore - /// let response = client.worker_ping() - /// .send() - /// .await; - /// ``` - pub fn worker_ping(&self) -> builder::WorkerPing { - builder::WorkerPing::new(self) + ///[`Client::user_privilege_grant`]: super::Client::user_privilege_grant + #[derive(Debug, Clone)] + pub struct UserPrivilegeGrant<'a> { + client: &'a super::Client, + user: Result, + privilege: Result, } - ///Sends a `POST` request to `/v1/worker/task/{task}/append` - /// - ///```ignore - /// let response = client.worker_task_append() - /// .task(task) - /// .body(body) - /// .send() - /// .await; - /// ``` - pub fn worker_task_append(&self) -> builder::WorkerTaskAppend { - builder::WorkerTaskAppend::new(self) - } + impl<'a> UserPrivilegeGrant<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + user: Err("user was not initialized".to_string()), + privilege: Err("privilege was not initialized".to_string()), + } + } - ///Sends a `POST` request to `/v1/worker/task/{task}/chunk` - /// - ///```ignore - /// let response = client.worker_task_upload_chunk() - /// .task(task) - /// .body(body) - /// .send() - /// .await; - /// ``` - pub fn worker_task_upload_chunk(&self) -> builder::WorkerTaskUploadChunk { - builder::WorkerTaskUploadChunk::new(self) - } + pub fn user(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.user = value + .try_into() + .map_err(|_| "conversion to `String` for user failed".to_string()); + self + } - ///Sends a `POST` request to `/v1/worker/task/{task}/complete` - /// - ///```ignore - /// let response = client.worker_task_complete() - /// .task(task) - /// .body(body) - /// .send() - /// .await; - /// ``` - pub fn worker_task_complete(&self) -> builder::WorkerTaskComplete { - builder::WorkerTaskComplete::new(self) - } + pub fn privilege(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.privilege = value + .try_into() + .map_err(|_| "conversion to `String` for privilege failed".to_string()); + self + } - ///Sends a `POST` request to `/v1/worker/task/{task}/output` - /// - ///```ignore - /// let response = client.worker_task_add_output() - /// .task(task) - /// .body(body) - /// .send() - /// .await; - /// ``` - pub fn worker_task_add_output(&self) -> builder::WorkerTaskAddOutput { - builder::WorkerTaskAddOutput::new(self) + ///Sends a `PUT` request to `/0/users/{user}/privilege/{privilege}` + pub async fn send(self) -> Result, Error> { + let Self { + client, + user, + privilege, + } = self; + let user = user.map_err(Error::InvalidRequest)?; + let privilege = privilege.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/0/users/{}/privilege/{}", + client.baseurl, + encode_path(&user.to_string()), + encode_path(&privilege.to_string()), + ); + let request = client + .client + .put(url) + .header( + reqwest::header::ACCEPT, + reqwest::header::HeaderValue::from_static("application/json"), + ) + .build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } } - ///Sends a `GET` request to `/v1/workers` + ///Builder for [`Client::user_privilege_revoke`] /// - ///```ignore - /// let response = client.workers_list() - /// .send() - /// .await; - /// ``` - pub fn workers_list(&self) -> builder::WorkersList { - builder::WorkersList::new(self) + ///[`Client::user_privilege_revoke`]: super::Client::user_privilege_revoke + #[derive(Debug, Clone)] + pub struct UserPrivilegeRevoke<'a> { + client: &'a super::Client, + user: Result, + privilege: Result, } - ///Sends a `POST` request to `/v1/workers/recycle` - /// - ///```ignore - /// let response = client.workers_recycle() - /// .send() - /// .await; - /// ``` - pub fn workers_recycle(&self) -> builder::WorkersRecycle { - builder::WorkersRecycle::new(self) + impl<'a> UserPrivilegeRevoke<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + user: Err("user was not initialized".to_string()), + privilege: Err("privilege was not initialized".to_string()), + } + } + + pub fn user(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.user = value + .try_into() + .map_err(|_| "conversion to `String` for user failed".to_string()); + self + } + + pub fn privilege(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.privilege = value + .try_into() + .map_err(|_| "conversion to `String` for privilege failed".to_string()); + self + } + + ///Sends a `DELETE` request to `/0/users/{user}/privilege/{privilege}` + pub async fn send(self) -> Result, Error> { + let Self { + client, + user, + privilege, + } = self; + let user = user.map_err(Error::InvalidRequest)?; + let privilege = privilege.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/0/users/{}/privilege/{}", + client.baseurl, + encode_path(&user.to_string()), + encode_path(&privilege.to_string()), + ); + let request = client + .client + .delete(url) + .header( + reqwest::header::ACCEPT, + reqwest::header::HeaderValue::from_static("application/json"), + ) + .build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } } -} -pub mod builder { - use super::types; - #[allow(unused_imports)] - use super::{ - encode_path, ByteStream, Error, HeaderMap, HeaderValue, RequestBuilderExt, ResponseValue, - }; - ///Builder for [`Client::control_hold`] + ///Builder for [`Client::whoami`] /// - ///[`Client::control_hold`]: super::Client::control_hold + ///[`Client::whoami`]: super::Client::whoami #[derive(Debug, Clone)] - pub struct ControlHold<'a> { + pub struct Whoami<'a> { client: &'a super::Client, } - impl<'a> ControlHold<'a> { + impl<'a> Whoami<'a> { pub fn new(client: &'a super::Client) -> Self { Self { client: client } } - ///Sends a `POST` request to `/v1/control/hold` - pub async fn send(self) -> Result, Error<()>> { + ///Sends a `GET` request to `/0/whoami` + pub async fn send(self) -> Result, Error> { let Self { client } = self; - let url = format!("{}/v1/control/hold", client.baseurl,); + let url = format!("{}/0/whoami", client.baseurl,); let request = client .client - .post(url) + .get(url) .header( reqwest::header::ACCEPT, reqwest::header::HeaderValue::from_static("application/json"), @@ -1899,168 +9095,227 @@ pub mod builder { let response = result?; match response.status().as_u16() { 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), _ => Err(Error::UnexpectedResponse(response)), } } } - ///Builder for [`Client::control_resume`] + ///Builder for [`Client::worker_bootstrap`] /// - ///[`Client::control_resume`]: super::Client::control_resume + ///[`Client::worker_bootstrap`]: super::Client::worker_bootstrap #[derive(Debug, Clone)] - pub struct ControlResume<'a> { + pub struct WorkerBootstrap<'a> { client: &'a super::Client, + body: Result, } - impl<'a> ControlResume<'a> { + impl<'a> WorkerBootstrap<'a> { pub fn new(client: &'a super::Client) -> Self { - Self { client: client } + Self { + client: client, + body: Ok(types::builder::WorkerBootstrap::default()), + } + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.body = value + .try_into() + .map(From::from) + .map_err(|_| "conversion to `WorkerBootstrap` for body failed".to_string()); + self + } + + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::WorkerBootstrap) -> types::builder::WorkerBootstrap, + { + self.body = self.body.map(f); + self } - ///Sends a `POST` request to `/v1/control/resume` - pub async fn send(self) -> Result, Error<()>> { - let Self { client } = self; - let url = format!("{}/v1/control/resume", client.baseurl,); - let request = client.client.post(url).build()?; + ///Sends a `POST` request to `/0/worker/bootstrap` + pub async fn send( + self, + ) -> Result, Error> { + let Self { client, body } = self; + let body = body + .and_then(std::convert::TryInto::::try_into) + .map_err(Error::InvalidRequest)?; + let url = format!("{}/0/worker/bootstrap", client.baseurl,); + let request = client + .client + .post(url) + .header( + reqwest::header::ACCEPT, + reqwest::header::HeaderValue::from_static("application/json"), + ) + .json(&body) + .build()?; let result = client.client.execute(request).await; let response = result?; match response.status().as_u16() { - 200u16 => Ok(ResponseValue::empty(response)), + 201u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), _ => Err(Error::UnexpectedResponse(response)), } } } - ///Builder for [`Client::task_get`] + ///Builder for [`Client::worker_job_upload_chunk`] /// - ///[`Client::task_get`]: super::Client::task_get - #[derive(Debug, Clone)] - pub struct TaskGet<'a> { + ///[`Client::worker_job_upload_chunk`]: super::Client::worker_job_upload_chunk + #[derive(Debug)] + pub struct WorkerJobUploadChunk<'a> { client: &'a super::Client, - task: Result, + job: Result, + body: Result, } - impl<'a> TaskGet<'a> { + impl<'a> WorkerJobUploadChunk<'a> { pub fn new(client: &'a super::Client) -> Self { Self { client: client, - task: Err("task was not initialized".to_string()), + job: Err("job was not initialized".to_string()), + body: Err("body was not initialized".to_string()), } } - pub fn task(mut self, value: V) -> Self + pub fn job(mut self, value: V) -> Self where V: std::convert::TryInto, { - self.task = value + self.job = value .try_into() - .map_err(|_| "conversion to `String` for task failed".to_string()); + .map_err(|_| "conversion to `String` for job failed".to_string()); self } - ///Sends a `GET` request to `/v1/task/{task}` - pub async fn send(self) -> Result, Error<()>> { - let Self { client, task } = self; - let task = task.map_err(Error::InvalidRequest)?; + pub fn body(mut self, value: B) -> Self + where + B: std::convert::TryInto, + { + self.body = value + .try_into() + .map_err(|_| "conversion to `reqwest::Body` for body failed".to_string()); + self + } + + ///Sends a `POST` request to `/0/worker/job/{job}/chunk` + pub async fn send( + self, + ) -> Result, Error> { + let Self { client, job, body } = self; + let job = job.map_err(Error::InvalidRequest)?; + let body = body.map_err(Error::InvalidRequest)?; let url = format!( - "{}/v1/task/{}", + "{}/0/worker/job/{}/chunk", client.baseurl, - encode_path(&task.to_string()), + encode_path(&job.to_string()), ); let request = client .client - .get(url) + .post(url) .header( reqwest::header::ACCEPT, reqwest::header::HeaderValue::from_static("application/json"), ) - .build()?; - let result = client.client.execute(request).await; - let response = result?; - match response.status().as_u16() { - 200u16 => ResponseValue::from_response(response).await, - _ => Err(Error::UnexpectedResponse(response)), - } - } - } - - ///Builder for [`Client::tasks_get`] - /// - ///[`Client::tasks_get`]: super::Client::tasks_get - #[derive(Debug, Clone)] - pub struct TasksGet<'a> { - client: &'a super::Client, - } - - impl<'a> TasksGet<'a> { - pub fn new(client: &'a super::Client) -> Self { - Self { client: client } - } - - ///Sends a `GET` request to `/v1/tasks` - pub async fn send(self) -> Result>, Error<()>> { - let Self { client } = self; - let url = format!("{}/v1/tasks", client.baseurl,); - let request = client - .client - .get(url) .header( - reqwest::header::ACCEPT, - reqwest::header::HeaderValue::from_static("application/json"), + reqwest::header::CONTENT_TYPE, + reqwest::header::HeaderValue::from_static("application/octet-stream"), ) + .body(body) .build()?; let result = client.client.execute(request).await; let response = result?; match response.status().as_u16() { - 200u16 => ResponseValue::from_response(response).await, + 201u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), _ => Err(Error::UnexpectedResponse(response)), } } } - ///Builder for [`Client::task_submit`] + ///Builder for [`Client::worker_job_complete`] /// - ///[`Client::task_submit`]: super::Client::task_submit + ///[`Client::worker_job_complete`]: super::Client::worker_job_complete #[derive(Debug, Clone)] - pub struct TaskSubmit<'a> { + pub struct WorkerJobComplete<'a> { client: &'a super::Client, - body: Result, + job: Result, + body: Result, } - impl<'a> TaskSubmit<'a> { + impl<'a> WorkerJobComplete<'a> { pub fn new(client: &'a super::Client) -> Self { Self { client: client, - body: Ok(types::builder::TaskSubmit::default()), + job: Err("job was not initialized".to_string()), + body: Ok(types::builder::WorkerCompleteJob::default()), } } + pub fn job(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.job = value + .try_into() + .map_err(|_| "conversion to `String` for job failed".to_string()); + self + } + pub fn body(mut self, value: V) -> Self where - V: std::convert::TryInto, + V: std::convert::TryInto, { self.body = value .try_into() .map(From::from) - .map_err(|_| "conversion to `TaskSubmit` for body failed".to_string()); + .map_err(|_| "conversion to `WorkerCompleteJob` for body failed".to_string()); self } pub fn body_map(mut self, f: F) -> Self where - F: std::ops::FnOnce(types::builder::TaskSubmit) -> types::builder::TaskSubmit, + F: std::ops::FnOnce( + types::builder::WorkerCompleteJob, + ) -> types::builder::WorkerCompleteJob, { self.body = self.body.map(f); self } - ///Sends a `POST` request to `/v1/tasks` - pub async fn send(self) -> Result, Error<()>> { - let Self { client, body } = self; + ///Sends a `POST` request to `/0/worker/job/{job}/complete` + pub async fn send(self) -> Result, Error> { + let Self { client, job, body } = self; + let job = job.map_err(Error::InvalidRequest)?; let body = body - .and_then(std::convert::TryInto::::try_into) + .and_then(std::convert::TryInto::::try_into) .map_err(Error::InvalidRequest)?; - let url = format!("{}/v1/tasks", client.baseurl,); + let url = format!( + "{}/0/worker/job/{}/complete", + client.baseurl, + encode_path(&job.to_string()), + ); let request = client .client .post(url) @@ -2073,123 +9328,115 @@ pub mod builder { let result = client.client.execute(request).await; let response = result?; match response.status().as_u16() { - 201u16 => ResponseValue::from_response(response).await, + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), _ => Err(Error::UnexpectedResponse(response)), } } } - ///Builder for [`Client::task_events_get`] + ///Builder for [`Client::worker_job_input_download`] /// - ///[`Client::task_events_get`]: super::Client::task_events_get + ///[`Client::worker_job_input_download`]: super::Client::worker_job_input_download #[derive(Debug, Clone)] - pub struct TaskEventsGet<'a> { + pub struct WorkerJobInputDownload<'a> { client: &'a super::Client, - task: Result, - minseq: Result, String>, + job: Result, + input: Result, } - impl<'a> TaskEventsGet<'a> { + impl<'a> WorkerJobInputDownload<'a> { pub fn new(client: &'a super::Client) -> Self { Self { client: client, - task: Err("task was not initialized".to_string()), - minseq: Ok(None), + job: Err("job was not initialized".to_string()), + input: Err("input was not initialized".to_string()), } } - pub fn task(mut self, value: V) -> Self + pub fn job(mut self, value: V) -> Self where V: std::convert::TryInto, { - self.task = value + self.job = value .try_into() - .map_err(|_| "conversion to `String` for task failed".to_string()); + .map_err(|_| "conversion to `String` for job failed".to_string()); self } - pub fn minseq(mut self, value: V) -> Self + pub fn input(mut self, value: V) -> Self where - V: std::convert::TryInto, + V: std::convert::TryInto, { - self.minseq = value + self.input = value .try_into() - .map(Some) - .map_err(|_| "conversion to `u32` for minseq failed".to_string()); + .map_err(|_| "conversion to `String` for input failed".to_string()); self } - ///Sends a `GET` request to `/v1/tasks/{task}/events` - pub async fn send(self) -> Result>, Error<()>> { - let Self { - client, - task, - minseq, - } = self; - let task = task.map_err(Error::InvalidRequest)?; - let minseq = minseq.map_err(Error::InvalidRequest)?; + ///Sends a `GET` request to `/0/worker/job/{job}/inputs/{input}` + pub async fn send(self) -> Result, Error> { + let Self { client, job, input } = self; + let job = job.map_err(Error::InvalidRequest)?; + let input = input.map_err(Error::InvalidRequest)?; let url = format!( - "{}/v1/tasks/{}/events", + "{}/0/worker/job/{}/inputs/{}", client.baseurl, - encode_path(&task.to_string()), + encode_path(&job.to_string()), + encode_path(&input.to_string()), ); - let mut query = Vec::with_capacity(1usize); - if let Some(v) = &minseq { - query.push(("minseq", v.to_string())); - } - let request = client - .client - .get(url) - .header( - reqwest::header::ACCEPT, - reqwest::header::HeaderValue::from_static("application/json"), - ) - .query(&query) - .build()?; + let request = client.client.get(url).build()?; let result = client.client.execute(request).await; let response = result?; match response.status().as_u16() { - 200u16 => ResponseValue::from_response(response).await, - _ => Err(Error::UnexpectedResponse(response)), + 200..=299 => Ok(ResponseValue::stream(response)), + _ => Err(Error::ErrorResponse(ResponseValue::stream(response))), } } } - ///Builder for [`Client::task_outputs_get`] + ///Builder for [`Client::worker_job_quota`] /// - ///[`Client::task_outputs_get`]: super::Client::task_outputs_get + ///[`Client::worker_job_quota`]: super::Client::worker_job_quota #[derive(Debug, Clone)] - pub struct TaskOutputsGet<'a> { + pub struct WorkerJobQuota<'a> { client: &'a super::Client, - task: Result, + job: Result, } - impl<'a> TaskOutputsGet<'a> { + impl<'a> WorkerJobQuota<'a> { pub fn new(client: &'a super::Client) -> Self { Self { client: client, - task: Err("task was not initialized".to_string()), + job: Err("job was not initialized".to_string()), } } - pub fn task(mut self, value: V) -> Self + pub fn job(mut self, value: V) -> Self where V: std::convert::TryInto, { - self.task = value + self.job = value .try_into() - .map_err(|_| "conversion to `String` for task failed".to_string()); + .map_err(|_| "conversion to `String` for job failed".to_string()); self } - ///Sends a `GET` request to `/v1/tasks/{task}/outputs` - pub async fn send(self) -> Result>, Error<()>> { - let Self { client, task } = self; - let task = task.map_err(Error::InvalidRequest)?; + ///Sends a `GET` request to `/0/worker/job/{job}/quota` + pub async fn send( + self, + ) -> Result, Error> { + let Self { client, job } = self; + let job = job.map_err(Error::InvalidRequest)?; let url = format!( - "{}/v1/tasks/{}/outputs", + "{}/0/worker/job/{}/quota", client.baseurl, - encode_path(&task.to_string()), + encode_path(&job.to_string()), ); let request = client .client @@ -2203,121 +9450,176 @@ pub mod builder { let response = result?; match response.status().as_u16() { 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), _ => Err(Error::UnexpectedResponse(response)), } } } - ///Builder for [`Client::task_output_download`] + ///Builder for [`Client::worker_job_store_get`] /// - ///[`Client::task_output_download`]: super::Client::task_output_download + ///[`Client::worker_job_store_get`]: super::Client::worker_job_store_get #[derive(Debug, Clone)] - pub struct TaskOutputDownload<'a> { + pub struct WorkerJobStoreGet<'a> { client: &'a super::Client, - task: Result, - output: Result, + job: Result, + name: Result, } - impl<'a> TaskOutputDownload<'a> { + impl<'a> WorkerJobStoreGet<'a> { pub fn new(client: &'a super::Client) -> Self { Self { client: client, - task: Err("task was not initialized".to_string()), - output: Err("output was not initialized".to_string()), + job: Err("job was not initialized".to_string()), + name: Err("name was not initialized".to_string()), } } - pub fn task(mut self, value: V) -> Self + pub fn job(mut self, value: V) -> Self where V: std::convert::TryInto, { - self.task = value + self.job = value .try_into() - .map_err(|_| "conversion to `String` for task failed".to_string()); + .map_err(|_| "conversion to `String` for job failed".to_string()); self } - pub fn output(mut self, value: V) -> Self + pub fn name(mut self, value: V) -> Self where V: std::convert::TryInto, { - self.output = value + self.name = value .try_into() - .map_err(|_| "conversion to `String` for output failed".to_string()); + .map_err(|_| "conversion to `String` for name failed".to_string()); self } - ///Sends a `GET` request to `/v1/tasks/{task}/outputs/{output}` - pub async fn send(self) -> Result, Error<()>> { - let Self { - client, - task, - output, - } = self; - let task = task.map_err(Error::InvalidRequest)?; - let output = output.map_err(Error::InvalidRequest)?; + ///Sends a `GET` request to `/0/worker/job/{job}/store/{name}` + pub async fn send( + self, + ) -> Result, Error> { + let Self { client, job, name } = self; + let job = job.map_err(Error::InvalidRequest)?; + let name = name.map_err(Error::InvalidRequest)?; let url = format!( - "{}/v1/tasks/{}/outputs/{}", + "{}/0/worker/job/{}/store/{}", client.baseurl, - encode_path(&task.to_string()), - encode_path(&output.to_string()), + encode_path(&job.to_string()), + encode_path(&name.to_string()), ); - let request = client.client.get(url).build()?; + let request = client + .client + .get(url) + .header( + reqwest::header::ACCEPT, + reqwest::header::HeaderValue::from_static("application/json"), + ) + .build()?; let result = client.client.execute(request).await; let response = result?; match response.status().as_u16() { - 200..=299 => Ok(ResponseValue::stream(response)), + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), _ => Err(Error::UnexpectedResponse(response)), } } } - ///Builder for [`Client::user_create`] + ///Builder for [`Client::worker_job_store_put`] /// - ///[`Client::user_create`]: super::Client::user_create + ///[`Client::worker_job_store_put`]: super::Client::worker_job_store_put #[derive(Debug, Clone)] - pub struct UserCreate<'a> { + pub struct WorkerJobStorePut<'a> { client: &'a super::Client, - body: Result, + job: Result, + name: Result, + body: Result, } - impl<'a> UserCreate<'a> { + impl<'a> WorkerJobStorePut<'a> { pub fn new(client: &'a super::Client) -> Self { Self { client: client, - body: Ok(types::builder::UserCreate::default()), + job: Err("job was not initialized".to_string()), + name: Err("name was not initialized".to_string()), + body: Ok(types::builder::WorkerJobStoreValue::default()), } } + pub fn job(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.job = value + .try_into() + .map_err(|_| "conversion to `String` for job failed".to_string()); + self + } + + pub fn name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.name = value + .try_into() + .map_err(|_| "conversion to `String` for name failed".to_string()); + self + } + pub fn body(mut self, value: V) -> Self where - V: std::convert::TryInto, + V: std::convert::TryInto, { self.body = value .try_into() .map(From::from) - .map_err(|_| "conversion to `UserCreate` for body failed".to_string()); + .map_err(|_| "conversion to `WorkerJobStoreValue` for body failed".to_string()); self } pub fn body_map(mut self, f: F) -> Self where - F: std::ops::FnOnce(types::builder::UserCreate) -> types::builder::UserCreate, + F: std::ops::FnOnce( + types::builder::WorkerJobStoreValue, + ) -> types::builder::WorkerJobStoreValue, { self.body = self.body.map(f); self } - ///Sends a `POST` request to `/v1/users` - pub async fn send(self) -> Result, Error<()>> { - let Self { client, body } = self; + ///Sends a `PUT` request to `/0/worker/job/{job}/store/{name}` + pub async fn send(self) -> Result, Error> { + let Self { + client, + job, + name, + body, + } = self; + let job = job.map_err(Error::InvalidRequest)?; + let name = name.map_err(Error::InvalidRequest)?; let body = body - .and_then(std::convert::TryInto::::try_into) + .and_then(std::convert::TryInto::::try_into) .map_err(Error::InvalidRequest)?; - let url = format!("{}/v1/users", client.baseurl,); + let url = format!( + "{}/0/worker/job/{}/store/{}", + client.baseurl, + encode_path(&job.to_string()), + encode_path(&name.to_string()), + ); let request = client .client - .post(url) + .put(url) .header( reqwest::header::ACCEPT, reqwest::header::HeaderValue::from_static("application/json"), @@ -2327,140 +9629,202 @@ pub mod builder { let result = client.client.execute(request).await; let response = result?; match response.status().as_u16() { - 201u16 => ResponseValue::from_response(response).await, + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), _ => Err(Error::UnexpectedResponse(response)), } } } - ///Builder for [`Client::whoami`] + ///Builder for [`Client::worker_task_append`] /// - ///[`Client::whoami`]: super::Client::whoami + ///[`Client::worker_task_append`]: super::Client::worker_task_append #[derive(Debug, Clone)] - pub struct Whoami<'a> { + pub struct WorkerTaskAppend<'a> { client: &'a super::Client, + job: Result, + task: Result, + body: Result, } - impl<'a> Whoami<'a> { + impl<'a> WorkerTaskAppend<'a> { pub fn new(client: &'a super::Client) -> Self { - Self { client: client } - } - - ///Sends a `GET` request to `/v1/whoami` - pub async fn send(self) -> Result, Error<()>> { - let Self { client } = self; - let url = format!("{}/v1/whoami", client.baseurl,); - let request = client - .client - .get(url) - .header( - reqwest::header::ACCEPT, - reqwest::header::HeaderValue::from_static("application/json"), - ) - .build()?; - let result = client.client.execute(request).await; - let response = result?; - match response.status().as_u16() { - 200u16 => ResponseValue::from_response(response).await, - _ => Err(Error::UnexpectedResponse(response)), + Self { + client: client, + job: Err("job was not initialized".to_string()), + task: Err("task was not initialized".to_string()), + body: Ok(types::builder::WorkerAppendJob::default()), } } - } - ///Builder for [`Client::whoami_put_name`] - /// - ///[`Client::whoami_put_name`]: super::Client::whoami_put_name - #[derive(Debug)] - pub struct WhoamiPutName<'a> { - client: &'a super::Client, - body: Result, - } + pub fn job(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.job = value + .try_into() + .map_err(|_| "conversion to `String` for job failed".to_string()); + self + } - impl<'a> WhoamiPutName<'a> { - pub fn new(client: &'a super::Client) -> Self { - Self { - client: client, - body: Err("body was not initialized".to_string()), - } + pub fn task(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.task = value + .try_into() + .map_err(|_| "conversion to `u32` for task failed".to_string()); + self } pub fn body(mut self, value: V) -> Self where - V: std::convert::TryInto, + V: std::convert::TryInto, { self.body = value .try_into() - .map_err(|_| "conversion to `String` for body failed".to_string()) - .map(|v| v.into()); + .map(From::from) + .map_err(|_| "conversion to `WorkerAppendJob` for body failed".to_string()); self } - ///Sends a `PUT` request to `/v1/whoami/name` - pub async fn send(self) -> Result, Error<()>> { - let Self { client, body } = self; - let body = body.map_err(Error::InvalidRequest)?; - let url = format!("{}/v1/whoami/name", client.baseurl,); + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::WorkerAppendJob) -> types::builder::WorkerAppendJob, + { + self.body = self.body.map(f); + self + } + + ///Sends a `POST` request to `/0/worker/job/{job}/task/{task}/append` + pub async fn send(self) -> Result, Error> { + let Self { + client, + job, + task, + body, + } = self; + let job = job.map_err(Error::InvalidRequest)?; + let task = task.map_err(Error::InvalidRequest)?; + let body = body + .and_then(std::convert::TryInto::::try_into) + .map_err(Error::InvalidRequest)?; + let url = format!( + "{}/0/worker/job/{}/task/{}/append", + client.baseurl, + encode_path(&job.to_string()), + encode_path(&task.to_string()), + ); let request = client .client - .put(url) + .post(url) .header( - reqwest::header::CONTENT_TYPE, - reqwest::header::HeaderValue::from_static("text/plain"), + reqwest::header::ACCEPT, + reqwest::header::HeaderValue::from_static("application/json"), ) - .body(body) + .json(&body) .build()?; let result = client.client.execute(request).await; let response = result?; match response.status().as_u16() { - 200u16 => Ok(ResponseValue::empty(response)), + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), _ => Err(Error::UnexpectedResponse(response)), } } } - ///Builder for [`Client::worker_bootstrap`] + ///Builder for [`Client::worker_task_complete`] /// - ///[`Client::worker_bootstrap`]: super::Client::worker_bootstrap + ///[`Client::worker_task_complete`]: super::Client::worker_task_complete #[derive(Debug, Clone)] - pub struct WorkerBootstrap<'a> { + pub struct WorkerTaskComplete<'a> { client: &'a super::Client, - body: Result, + job: Result, + task: Result, + body: Result, } - impl<'a> WorkerBootstrap<'a> { + impl<'a> WorkerTaskComplete<'a> { pub fn new(client: &'a super::Client) -> Self { Self { client: client, - body: Ok(types::builder::WorkerBootstrap::default()), + job: Err("job was not initialized".to_string()), + task: Err("task was not initialized".to_string()), + body: Ok(types::builder::WorkerCompleteTask::default()), } } + pub fn job(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.job = value + .try_into() + .map_err(|_| "conversion to `String` for job failed".to_string()); + self + } + + pub fn task(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.task = value + .try_into() + .map_err(|_| "conversion to `u32` for task failed".to_string()); + self + } + pub fn body(mut self, value: V) -> Self where - V: std::convert::TryInto, + V: std::convert::TryInto, { self.body = value .try_into() .map(From::from) - .map_err(|_| "conversion to `WorkerBootstrap` for body failed".to_string()); + .map_err(|_| "conversion to `WorkerCompleteTask` for body failed".to_string()); self } pub fn body_map(mut self, f: F) -> Self where - F: std::ops::FnOnce(types::builder::WorkerBootstrap) -> types::builder::WorkerBootstrap, + F: std::ops::FnOnce( + types::builder::WorkerCompleteTask, + ) -> types::builder::WorkerCompleteTask, { self.body = self.body.map(f); self } - ///Sends a `POST` request to `/v1/worker/bootstrap` - pub async fn send(self) -> Result, Error<()>> { - let Self { client, body } = self; + ///Sends a `POST` request to `/0/worker/job/{job}/task/{task}/complete` + pub async fn send(self) -> Result, Error> { + let Self { + client, + job, + task, + body, + } = self; + let job = job.map_err(Error::InvalidRequest)?; + let task = task.map_err(Error::InvalidRequest)?; let body = body - .and_then(std::convert::TryInto::::try_into) + .and_then(std::convert::TryInto::::try_into) .map_err(Error::InvalidRequest)?; - let url = format!("{}/v1/worker/bootstrap", client.baseurl,); + let url = format!( + "{}/0/worker/job/{}/task/{}/complete", + client.baseurl, + encode_path(&job.to_string()), + encode_path(&task.to_string()), + ); let request = client .client .post(url) @@ -2473,7 +9837,13 @@ pub mod builder { let result = client.client.execute(request).await; let response = result?; match response.status().as_u16() { - 201u16 => ResponseValue::from_response(response).await, + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), _ => Err(Error::UnexpectedResponse(response)), } } @@ -2492,10 +9862,12 @@ pub mod builder { Self { client: client } } - ///Sends a `GET` request to `/v1/worker/ping` - pub async fn send(self) -> Result, Error<()>> { + ///Sends a `GET` request to `/0/worker/ping` + pub async fn send( + self, + ) -> Result, Error> { let Self { client } = self; - let url = format!("{}/v1/worker/ping", client.baseurl,); + let url = format!("{}/0/worker/ping", client.baseurl,); let request = client .client .get(url) @@ -2508,131 +9880,181 @@ pub mod builder { let response = result?; match response.status().as_u16() { 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), _ => Err(Error::UnexpectedResponse(response)), } } } - ///Builder for [`Client::worker_task_append`] + ///Builder for [`Client::workers_list`] /// - ///[`Client::worker_task_append`]: super::Client::worker_task_append + ///[`Client::workers_list`]: super::Client::workers_list #[derive(Debug, Clone)] - pub struct WorkerTaskAppend<'a> { + pub struct WorkersList<'a> { client: &'a super::Client, - task: Result, - body: Result, + active: Result, String>, } - impl<'a> WorkerTaskAppend<'a> { + impl<'a> WorkersList<'a> { pub fn new(client: &'a super::Client) -> Self { Self { client: client, - task: Err("task was not initialized".to_string()), - body: Ok(types::builder::WorkerAppendTask::default()), + active: Ok(None), } } - pub fn task(mut self, value: V) -> Self + pub fn active(mut self, value: V) -> Self where - V: std::convert::TryInto, + V: std::convert::TryInto, { - self.task = value + self.active = value .try_into() - .map_err(|_| "conversion to `String` for task failed".to_string()); + .map(Some) + .map_err(|_| "conversion to `bool` for active failed".to_string()); self } - pub fn body(mut self, value: V) -> Self - where - V: std::convert::TryInto, - { - self.body = value - .try_into() - .map(From::from) - .map_err(|_| "conversion to `WorkerAppendTask` for body failed".to_string()); - self + ///Sends a `GET` request to `/0/workers` + pub async fn send( + self, + ) -> Result, Error> { + let Self { client, active } = self; + let active = active.map_err(Error::InvalidRequest)?; + let url = format!("{}/0/workers", client.baseurl,); + let mut query = Vec::with_capacity(1usize); + if let Some(v) = &active { + query.push(("active", v.to_string())); + } + let request = client + .client + .get(url) + .header( + reqwest::header::ACCEPT, + reqwest::header::HeaderValue::from_static("application/json"), + ) + .query(&query) + .build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } } + } - pub fn body_map(mut self, f: F) -> Self - where - F: std::ops::FnOnce( - types::builder::WorkerAppendTask, - ) -> types::builder::WorkerAppendTask, - { - self.body = self.body.map(f); - self + ///Builder for [`Client::workers_recycle`] + /// + ///[`Client::workers_recycle`]: super::Client::workers_recycle + #[derive(Debug, Clone)] + pub struct WorkersRecycle<'a> { + client: &'a super::Client, + } + + impl<'a> WorkersRecycle<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { client: client } } - ///Sends a `POST` request to `/v1/worker/task/{task}/append` - pub async fn send(self) -> Result, Error<()>> { - let Self { client, task, body } = self; - let task = task.map_err(Error::InvalidRequest)?; - let body = body - .and_then(std::convert::TryInto::::try_into) - .map_err(Error::InvalidRequest)?; - let url = format!( - "{}/v1/worker/task/{}/append", - client.baseurl, - encode_path(&task.to_string()), - ); - let request = client.client.post(url).json(&body).build()?; + ///Sends a `POST` request to `/0/workers/recycle` + pub async fn send(self) -> Result, Error> { + let Self { client } = self; + let url = format!("{}/0/workers/recycle", client.baseurl,); + let request = client + .client + .post(url) + .header( + reqwest::header::ACCEPT, + reqwest::header::HeaderValue::from_static("application/json"), + ) + .build()?; let result = client.client.execute(request).await; let response = result?; match response.status().as_u16() { - 201u16 => Ok(ResponseValue::empty(response)), + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), _ => Err(Error::UnexpectedResponse(response)), } } } - ///Builder for [`Client::worker_task_upload_chunk`] + ///Builder for [`Client::job_add_input`] /// - ///[`Client::worker_task_upload_chunk`]: super::Client::worker_task_upload_chunk - #[derive(Debug)] - pub struct WorkerTaskUploadChunk<'a> { + ///[`Client::job_add_input`]: super::Client::job_add_input + #[derive(Debug, Clone)] + pub struct JobAddInput<'a> { client: &'a super::Client, - task: Result, - body: Result, + job: Result, + body: Result, } - impl<'a> WorkerTaskUploadChunk<'a> { + impl<'a> JobAddInput<'a> { pub fn new(client: &'a super::Client) -> Self { Self { client: client, - task: Err("task was not initialized".to_string()), - body: Err("body was not initialized".to_string()), + job: Err("job was not initialized".to_string()), + body: Ok(types::builder::JobAddInput::default()), } } - pub fn task(mut self, value: V) -> Self + pub fn job(mut self, value: V) -> Self where V: std::convert::TryInto, { - self.task = value + self.job = value .try_into() - .map_err(|_| "conversion to `String` for task failed".to_string()); + .map_err(|_| "conversion to `String` for job failed".to_string()); self } - pub fn body(mut self, value: B) -> Self + pub fn body(mut self, value: V) -> Self where - B: std::convert::TryInto, + V: std::convert::TryInto, { self.body = value .try_into() - .map_err(|_| "conversion to `reqwest::Body` for body failed".to_string()); + .map(From::from) + .map_err(|_| "conversion to `JobAddInput` for body failed".to_string()); self } - ///Sends a `POST` request to `/v1/worker/task/{task}/chunk` - pub async fn send(self) -> Result, Error<()>> { - let Self { client, task, body } = self; - let task = task.map_err(Error::InvalidRequest)?; - let body = body.map_err(Error::InvalidRequest)?; + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::JobAddInput) -> types::builder::JobAddInput, + { + self.body = self.body.map(f); + self + } + + ///Sends a `POST` request to `/1/jobs/{job}/input` + pub async fn send( + self, + ) -> Result, Error> { + let Self { client, job, body } = self; + let job = job.map_err(Error::InvalidRequest)?; + let body = body + .and_then(std::convert::TryInto::::try_into) + .map_err(Error::InvalidRequest)?; let url = format!( - "{}/v1/worker/task/{}/chunk", + "{}/1/jobs/{}/input", client.baseurl, - encode_path(&task.to_string()), + encode_path(&job.to_string()), ); let request = client .client @@ -2641,119 +10063,122 @@ pub mod builder { reqwest::header::ACCEPT, reqwest::header::HeaderValue::from_static("application/json"), ) - .header( - reqwest::header::CONTENT_TYPE, - reqwest::header::HeaderValue::from_static("application/octet-stream"), - ) - .body(body) + .json(&body) .build()?; let result = client.client.execute(request).await; let response = result?; match response.status().as_u16() { - 201u16 => ResponseValue::from_response(response).await, + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), _ => Err(Error::UnexpectedResponse(response)), } } } - ///Builder for [`Client::worker_task_complete`] + ///Builder for [`Client::worker_job_append`] /// - ///[`Client::worker_task_complete`]: super::Client::worker_task_complete + ///[`Client::worker_job_append`]: super::Client::worker_job_append #[derive(Debug, Clone)] - pub struct WorkerTaskComplete<'a> { + pub struct WorkerJobAppend<'a> { client: &'a super::Client, - task: Result, - body: Result, + job: Result, + body: Result, String>, } - impl<'a> WorkerTaskComplete<'a> { + impl<'a> WorkerJobAppend<'a> { pub fn new(client: &'a super::Client) -> Self { Self { client: client, - task: Err("task was not initialized".to_string()), - body: Ok(types::builder::WorkerCompleteTask::default()), + job: Err("job was not initialized".to_string()), + body: Err("body was not initialized".to_string()), } } - pub fn task(mut self, value: V) -> Self + pub fn job(mut self, value: V) -> Self where V: std::convert::TryInto, { - self.task = value + self.job = value .try_into() - .map_err(|_| "conversion to `String` for task failed".to_string()); + .map_err(|_| "conversion to `String` for job failed".to_string()); self } pub fn body(mut self, value: V) -> Self where - V: std::convert::TryInto, - { - self.body = value - .try_into() - .map(From::from) - .map_err(|_| "conversion to `WorkerCompleteTask` for body failed".to_string()); - self - } - - pub fn body_map(mut self, f: F) -> Self - where - F: std::ops::FnOnce( - types::builder::WorkerCompleteTask, - ) -> types::builder::WorkerCompleteTask, + V: std::convert::TryInto>, { - self.body = self.body.map(f); + self.body = value.try_into().map_err(|_| { + "conversion to `Vec < WorkerAppendJobOrTask >` for body failed".to_string() + }); self } - ///Sends a `POST` request to `/v1/worker/task/{task}/complete` - pub async fn send(self) -> Result, Error<()>> { - let Self { client, task, body } = self; - let task = task.map_err(Error::InvalidRequest)?; - let body = body - .and_then(std::convert::TryInto::::try_into) - .map_err(Error::InvalidRequest)?; + ///Sends a `POST` request to `/1/worker/job/{job}/append` + pub async fn send(self) -> Result, Error> { + let Self { client, job, body } = self; + let job = job.map_err(Error::InvalidRequest)?; + let body = body.map_err(Error::InvalidRequest)?; let url = format!( - "{}/v1/worker/task/{}/complete", + "{}/1/worker/job/{}/append", client.baseurl, - encode_path(&task.to_string()), + encode_path(&job.to_string()), ); - let request = client.client.post(url).json(&body).build()?; + let request = client + .client + .post(url) + .header( + reqwest::header::ACCEPT, + reqwest::header::HeaderValue::from_static("application/json"), + ) + .json(&body) + .build()?; let result = client.client.execute(request).await; let response = result?; match response.status().as_u16() { - 200u16 => Ok(ResponseValue::empty(response)), + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), _ => Err(Error::UnexpectedResponse(response)), } } } - ///Builder for [`Client::worker_task_add_output`] + ///Builder for [`Client::worker_job_add_output`] /// - ///[`Client::worker_task_add_output`]: super::Client::worker_task_add_output + ///[`Client::worker_job_add_output`]: super::Client::worker_job_add_output #[derive(Debug, Clone)] - pub struct WorkerTaskAddOutput<'a> { + pub struct WorkerJobAddOutput<'a> { client: &'a super::Client, - task: Result, + job: Result, body: Result, } - impl<'a> WorkerTaskAddOutput<'a> { + impl<'a> WorkerJobAddOutput<'a> { pub fn new(client: &'a super::Client) -> Self { Self { client: client, - task: Err("task was not initialized".to_string()), + job: Err("job was not initialized".to_string()), body: Ok(types::builder::WorkerAddOutput::default()), } } - pub fn task(mut self, value: V) -> Self + pub fn job(mut self, value: V) -> Self where V: std::convert::TryInto, { - self.task = value + self.job = value .try_into() - .map_err(|_| "conversion to `String` for task failed".to_string()); + .map_err(|_| "conversion to `String` for job failed".to_string()); self } @@ -2776,84 +10201,39 @@ pub mod builder { self } - ///Sends a `POST` request to `/v1/worker/task/{task}/output` - pub async fn send(self) -> Result, Error<()>> { - let Self { client, task, body } = self; - let task = task.map_err(Error::InvalidRequest)?; + ///Sends a `POST` request to `/1/worker/job/{job}/output` + pub async fn send( + self, + ) -> Result, Error> { + let Self { client, job, body } = self; + let job = job.map_err(Error::InvalidRequest)?; let body = body .and_then(std::convert::TryInto::::try_into) .map_err(Error::InvalidRequest)?; let url = format!( - "{}/v1/worker/task/{}/output", + "{}/1/worker/job/{}/output", client.baseurl, - encode_path(&task.to_string()), + encode_path(&job.to_string()), ); - let request = client.client.post(url).json(&body).build()?; - let result = client.client.execute(request).await; - let response = result?; - match response.status().as_u16() { - 201u16 => Ok(ResponseValue::empty(response)), - _ => Err(Error::UnexpectedResponse(response)), - } - } - } - - ///Builder for [`Client::workers_list`] - /// - ///[`Client::workers_list`]: super::Client::workers_list - #[derive(Debug, Clone)] - pub struct WorkersList<'a> { - client: &'a super::Client, - } - - impl<'a> WorkersList<'a> { - pub fn new(client: &'a super::Client) -> Self { - Self { client: client } - } - - ///Sends a `GET` request to `/v1/workers` - pub async fn send(self) -> Result, Error<()>> { - let Self { client } = self; - let url = format!("{}/v1/workers", client.baseurl,); let request = client .client - .get(url) + .post(url) .header( reqwest::header::ACCEPT, reqwest::header::HeaderValue::from_static("application/json"), ) + .json(&body) .build()?; let result = client.client.execute(request).await; let response = result?; match response.status().as_u16() { 200u16 => ResponseValue::from_response(response).await, - _ => Err(Error::UnexpectedResponse(response)), - } - } - } - - ///Builder for [`Client::workers_recycle`] - /// - ///[`Client::workers_recycle`]: super::Client::workers_recycle - #[derive(Debug, Clone)] - pub struct WorkersRecycle<'a> { - client: &'a super::Client, - } - - impl<'a> WorkersRecycle<'a> { - pub fn new(client: &'a super::Client) -> Self { - Self { client: client } - } - - ///Sends a `POST` request to `/v1/workers/recycle` - pub async fn send(self) -> Result, Error<()>> { - let Self { client } = self; - let url = format!("{}/v1/workers/recycle", client.baseurl,); - let request = client.client.post(url).build()?; - let result = client.client.execute(request).await; - let response = result?; - match response.status().as_u16() { - 200u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), _ => Err(Error::UnexpectedResponse(response)), } } diff --git a/progenitor-impl/tests/output/buildomat-cli.out b/progenitor-impl/tests/output/buildomat-cli.out index 02c3a6a1..ea6422cf 100644 --- a/progenitor-impl/tests/output/buildomat-cli.out +++ b/progenitor-impl/tests/output/buildomat-cli.out @@ -10,60 +10,136 @@ impl Cli { pub fn get_command(cmd: CliCommand) -> clap::Command { match cmd { + CliCommand::FactoryCreate => Self::cli_factory_create(), + CliCommand::AdminJobsGet => Self::cli_admin_jobs_get(), + CliCommand::AdminJobGet => Self::cli_admin_job_get(), + CliCommand::AdminJobArchiveRequest => Self::cli_admin_job_archive_request(), + CliCommand::TargetCreate => Self::cli_target_create(), + CliCommand::TargetsList => Self::cli_targets_list(), + CliCommand::TargetRedirect => Self::cli_target_redirect(), + CliCommand::TargetRename => Self::cli_target_rename(), + CliCommand::TargetRequireNoPrivilege => Self::cli_target_require_no_privilege(), + CliCommand::TargetRequirePrivilege => Self::cli_target_require_privilege(), + CliCommand::WorkerRecycle => Self::cli_worker_recycle(), CliCommand::ControlHold => Self::cli_control_hold(), CliCommand::ControlResume => Self::cli_control_resume(), - CliCommand::TaskGet => Self::cli_task_get(), - CliCommand::TasksGet => Self::cli_tasks_get(), - CliCommand::TaskSubmit => Self::cli_task_submit(), - CliCommand::TaskEventsGet => Self::cli_task_events_get(), - CliCommand::TaskOutputsGet => Self::cli_task_outputs_get(), - CliCommand::TaskOutputDownload => Self::cli_task_output_download(), + CliCommand::FactoryLease => Self::cli_factory_lease(), + CliCommand::FactoryLeaseRenew => Self::cli_factory_lease_renew(), + CliCommand::FactoryPing => Self::cli_factory_ping(), + CliCommand::FactoryWorkerCreate => Self::cli_factory_worker_create(), + CliCommand::FactoryWorkerGet => Self::cli_factory_worker_get(), + CliCommand::FactoryWorkerDestroy => Self::cli_factory_worker_destroy(), + CliCommand::FactoryWorkerAssociate => Self::cli_factory_worker_associate(), + CliCommand::FactoryWorkerAppend => Self::cli_factory_worker_append(), + CliCommand::FactoryWorkerFlush => Self::cli_factory_worker_flush(), + CliCommand::FactoryWorkers => Self::cli_factory_workers(), + CliCommand::JobGet => Self::cli_job_get(), + CliCommand::JobsGet => Self::cli_jobs_get(), + CliCommand::JobSubmit => Self::cli_job_submit(), + CliCommand::JobCancel => Self::cli_job_cancel(), + CliCommand::JobUploadChunk => Self::cli_job_upload_chunk(), + CliCommand::JobEventsGet => Self::cli_job_events_get(), + CliCommand::JobOutputsGet => Self::cli_job_outputs_get(), + CliCommand::JobOutputDownload => Self::cli_job_output_download(), + CliCommand::JobOutputPublish => Self::cli_job_output_publish(), + CliCommand::JobOutputSignedUrl => Self::cli_job_output_signed_url(), + CliCommand::JobStoreGetAll => Self::cli_job_store_get_all(), + CliCommand::JobStorePut => Self::cli_job_store_put(), + CliCommand::PublicFileDownload => Self::cli_public_file_download(), + CliCommand::Quota => Self::cli_quota(), + CliCommand::UsersList => Self::cli_users_list(), CliCommand::UserCreate => Self::cli_user_create(), + CliCommand::UserGet => Self::cli_user_get(), + CliCommand::UserPrivilegeGrant => Self::cli_user_privilege_grant(), + CliCommand::UserPrivilegeRevoke => Self::cli_user_privilege_revoke(), CliCommand::Whoami => Self::cli_whoami(), - CliCommand::WhoamiPutName => Self::cli_whoami_put_name(), CliCommand::WorkerBootstrap => Self::cli_worker_bootstrap(), - CliCommand::WorkerPing => Self::cli_worker_ping(), + CliCommand::WorkerJobUploadChunk => Self::cli_worker_job_upload_chunk(), + CliCommand::WorkerJobComplete => Self::cli_worker_job_complete(), + CliCommand::WorkerJobInputDownload => Self::cli_worker_job_input_download(), + CliCommand::WorkerJobQuota => Self::cli_worker_job_quota(), + CliCommand::WorkerJobStoreGet => Self::cli_worker_job_store_get(), + CliCommand::WorkerJobStorePut => Self::cli_worker_job_store_put(), CliCommand::WorkerTaskAppend => Self::cli_worker_task_append(), - CliCommand::WorkerTaskUploadChunk => Self::cli_worker_task_upload_chunk(), CliCommand::WorkerTaskComplete => Self::cli_worker_task_complete(), - CliCommand::WorkerTaskAddOutput => Self::cli_worker_task_add_output(), + CliCommand::WorkerPing => Self::cli_worker_ping(), CliCommand::WorkersList => Self::cli_workers_list(), CliCommand::WorkersRecycle => Self::cli_workers_recycle(), + CliCommand::JobAddInput => Self::cli_job_add_input(), + CliCommand::WorkerJobAppend => Self::cli_worker_job_append(), + CliCommand::WorkerJobAddOutput => Self::cli_worker_job_add_output(), } } - pub fn cli_control_hold() -> clap::Command { + pub fn cli_factory_create() -> clap::Command { clap::Command::new("") + .arg( + clap::Arg::new("name") + .long("name") + .value_parser(clap::value_parser!(String)) + .required_unless_present("json-body"), + ) + .arg( + clap::Arg::new("json-body") + .long("json-body") + .value_name("JSON-FILE") + .required(false) + .value_parser(clap::value_parser!(std::path::PathBuf)) + .help("Path to a file that contains the full json body."), + ) + .arg( + clap::Arg::new("json-body-template") + .long("json-body-template") + .action(clap::ArgAction::SetTrue) + .help("XXX"), + ) } - pub fn cli_control_resume() -> clap::Command { + pub fn cli_admin_jobs_get() -> clap::Command { clap::Command::new("") + .arg( + clap::Arg::new("active") + .long("active") + .value_parser(clap::value_parser!(bool)) + .required(false), + ) + .arg( + clap::Arg::new("completed") + .long("completed") + .value_parser(clap::value_parser!(u64)) + .required(false), + ) } - pub fn cli_task_get() -> clap::Command { + pub fn cli_admin_job_get() -> clap::Command { clap::Command::new("").arg( - clap::Arg::new("task") - .long("task") + clap::Arg::new("job") + .long("job") .value_parser(clap::value_parser!(String)) .required(true), ) } - pub fn cli_tasks_get() -> clap::Command { - clap::Command::new("") + pub fn cli_admin_job_archive_request() -> clap::Command { + clap::Command::new("").arg( + clap::Arg::new("job") + .long("job") + .value_parser(clap::value_parser!(String)) + .required(true), + ) } - pub fn cli_task_submit() -> clap::Command { + pub fn cli_target_create() -> clap::Command { clap::Command::new("") .arg( - clap::Arg::new("name") - .long("name") + clap::Arg::new("desc") + .long("desc") .value_parser(clap::value_parser!(String)) .required_unless_present("json-body"), ) .arg( - clap::Arg::new("script") - .long("script") + clap::Arg::new("name") + .long("name") .value_parser(clap::value_parser!(String)) .required_unless_present("json-body"), ) @@ -83,54 +159,59 @@ impl Cli { ) } - pub fn cli_task_events_get() -> clap::Command { + pub fn cli_targets_list() -> clap::Command { + clap::Command::new("") + } + + pub fn cli_target_redirect() -> clap::Command { clap::Command::new("") .arg( - clap::Arg::new("minseq") - .long("minseq") - .value_parser(clap::value_parser!(u32)) + clap::Arg::new("redirect") + .long("redirect") + .value_parser(clap::value_parser!(String)) .required(false), ) .arg( - clap::Arg::new("task") - .long("task") + clap::Arg::new("target") + .long("target") .value_parser(clap::value_parser!(String)) .required(true), ) + .arg( + clap::Arg::new("json-body") + .long("json-body") + .value_name("JSON-FILE") + .required(false) + .value_parser(clap::value_parser!(std::path::PathBuf)) + .help("Path to a file that contains the full json body."), + ) + .arg( + clap::Arg::new("json-body-template") + .long("json-body-template") + .action(clap::ArgAction::SetTrue) + .help("XXX"), + ) } - pub fn cli_task_outputs_get() -> clap::Command { - clap::Command::new("").arg( - clap::Arg::new("task") - .long("task") - .value_parser(clap::value_parser!(String)) - .required(true), - ) - } - - pub fn cli_task_output_download() -> clap::Command { + pub fn cli_target_rename() -> clap::Command { clap::Command::new("") .arg( - clap::Arg::new("output") - .long("output") + clap::Arg::new("new-name") + .long("new-name") .value_parser(clap::value_parser!(String)) - .required(true), + .required_unless_present("json-body"), ) .arg( - clap::Arg::new("task") - .long("task") + clap::Arg::new("signpost-description") + .long("signpost-description") .value_parser(clap::value_parser!(String)) - .required(true), + .required_unless_present("json-body"), ) - } - - pub fn cli_user_create() -> clap::Command { - clap::Command::new("") .arg( - clap::Arg::new("name") - .long("name") + clap::Arg::new("target") + .long("target") .value_parser(clap::value_parser!(String)) - .required_unless_present("json-body"), + .required(true), ) .arg( clap::Arg::new("json-body") @@ -148,33 +229,55 @@ impl Cli { ) } - pub fn cli_whoami() -> clap::Command { - clap::Command::new("") - } - - pub fn cli_whoami_put_name() -> clap::Command { - clap::Command::new("") + pub fn cli_target_require_no_privilege() -> clap::Command { + clap::Command::new("").arg( + clap::Arg::new("target") + .long("target") + .value_parser(clap::value_parser!(String)) + .required(true), + ) } - pub fn cli_worker_bootstrap() -> clap::Command { + pub fn cli_target_require_privilege() -> clap::Command { clap::Command::new("") .arg( - clap::Arg::new("bootstrap") - .long("bootstrap") + clap::Arg::new("privilege") + .long("privilege") .value_parser(clap::value_parser!(String)) - .required_unless_present("json-body"), + .required(true), ) .arg( - clap::Arg::new("token") - .long("token") + clap::Arg::new("target") + .long("target") .value_parser(clap::value_parser!(String)) - .required_unless_present("json-body"), + .required(true), ) + } + + pub fn cli_worker_recycle() -> clap::Command { + clap::Command::new("").arg( + clap::Arg::new("worker") + .long("worker") + .value_parser(clap::value_parser!(String)) + .required(true), + ) + } + + pub fn cli_control_hold() -> clap::Command { + clap::Command::new("") + } + + pub fn cli_control_resume() -> clap::Command { + clap::Command::new("") + } + + pub fn cli_factory_lease() -> clap::Command { + clap::Command::new("") .arg( clap::Arg::new("json-body") .long("json-body") .value_name("JSON-FILE") - .required(false) + .required(true) .value_parser(clap::value_parser!(std::path::PathBuf)) .help("Path to a file that contains the full json body."), ) @@ -186,35 +289,38 @@ impl Cli { ) } - pub fn cli_worker_ping() -> clap::Command { + pub fn cli_factory_lease_renew() -> clap::Command { + clap::Command::new("").arg( + clap::Arg::new("job") + .long("job") + .value_parser(clap::value_parser!(String)) + .required(true), + ) + } + + pub fn cli_factory_ping() -> clap::Command { clap::Command::new("") } - pub fn cli_worker_task_append() -> clap::Command { + pub fn cli_factory_worker_create() -> clap::Command { clap::Command::new("") .arg( - clap::Arg::new("payload") - .long("payload") + clap::Arg::new("job") + .long("job") .value_parser(clap::value_parser!(String)) - .required_unless_present("json-body"), + .required(false), ) .arg( - clap::Arg::new("stream") - .long("stream") + clap::Arg::new("target") + .long("target") .value_parser(clap::value_parser!(String)) .required_unless_present("json-body"), ) .arg( - clap::Arg::new("task") - .long("task") - .value_parser(clap::value_parser!(String)) - .required(true), - ) - .arg( - clap::Arg::new("time") - .long("time") - .value_parser(clap::value_parser!(chrono::DateTime)) - .required_unless_present("json-body"), + clap::Arg::new("wait-for-flush") + .long("wait-for-flush") + .value_parser(clap::value_parser!(bool)) + .required(false), ) .arg( clap::Arg::new("json-body") @@ -232,26 +338,35 @@ impl Cli { ) } - pub fn cli_worker_task_upload_chunk() -> clap::Command { + pub fn cli_factory_worker_get() -> clap::Command { clap::Command::new("").arg( - clap::Arg::new("task") - .long("task") + clap::Arg::new("worker") + .long("worker") .value_parser(clap::value_parser!(String)) .required(true), ) } - pub fn cli_worker_task_complete() -> clap::Command { + pub fn cli_factory_worker_destroy() -> clap::Command { + clap::Command::new("").arg( + clap::Arg::new("worker") + .long("worker") + .value_parser(clap::value_parser!(String)) + .required(true), + ) + } + + pub fn cli_factory_worker_associate() -> clap::Command { clap::Command::new("") .arg( - clap::Arg::new("failed") - .long("failed") - .value_parser(clap::value_parser!(bool)) + clap::Arg::new("private") + .long("private") + .value_parser(clap::value_parser!(String)) .required_unless_present("json-body"), ) .arg( - clap::Arg::new("task") - .long("task") + clap::Arg::new("worker") + .long("worker") .value_parser(clap::value_parser!(String)) .required(true), ) @@ -271,23 +386,29 @@ impl Cli { ) } - pub fn cli_worker_task_add_output() -> clap::Command { + pub fn cli_factory_worker_append() -> clap::Command { clap::Command::new("") .arg( - clap::Arg::new("path") - .long("path") + clap::Arg::new("payload") + .long("payload") .value_parser(clap::value_parser!(String)) .required_unless_present("json-body"), ) .arg( - clap::Arg::new("size") - .long("size") - .value_parser(clap::value_parser!(i64)) + clap::Arg::new("stream") + .long("stream") + .value_parser(clap::value_parser!(String)) .required_unless_present("json-body"), ) .arg( - clap::Arg::new("task") - .long("task") + clap::Arg::new("time") + .long("time") + .value_parser(clap::value_parser!(chrono::DateTime)) + .required_unless_present("json-body"), + ) + .arg( + clap::Arg::new("worker") + .long("worker") .value_parser(clap::value_parser!(String)) .required(true), ) @@ -295,7 +416,7 @@ impl Cli { clap::Arg::new("json-body") .long("json-body") .value_name("JSON-FILE") - .required(true) + .required(false) .value_parser(clap::value_parser!(std::path::PathBuf)) .help("Path to a file that contains the full json body."), ) @@ -307,164 +428,2109 @@ impl Cli { ) } - pub fn cli_workers_list() -> clap::Command { - clap::Command::new("") + pub fn cli_factory_worker_flush() -> clap::Command { + clap::Command::new("").arg( + clap::Arg::new("worker") + .long("worker") + .value_parser(clap::value_parser!(String)) + .required(true), + ) } - pub fn cli_workers_recycle() -> clap::Command { + pub fn cli_factory_workers() -> clap::Command { clap::Command::new("") } -} - -impl Cli { - pub fn new_with_override(client: sdk::Client, over: T) -> Self { - Self { client, over } - } - pub async fn execute(&self, cmd: CliCommand, matches: &clap::ArgMatches) { - match cmd { - CliCommand::ControlHold => { - self.execute_control_hold(matches).await; - } - CliCommand::ControlResume => { - self.execute_control_resume(matches).await; - } - CliCommand::TaskGet => { - self.execute_task_get(matches).await; - } - CliCommand::TasksGet => { - self.execute_tasks_get(matches).await; - } - CliCommand::TaskSubmit => { - self.execute_task_submit(matches).await; - } - CliCommand::TaskEventsGet => { - self.execute_task_events_get(matches).await; - } - CliCommand::TaskOutputsGet => { - self.execute_task_outputs_get(matches).await; - } - CliCommand::TaskOutputDownload => { - self.execute_task_output_download(matches).await; - } - CliCommand::UserCreate => { - self.execute_user_create(matches).await; - } - CliCommand::Whoami => { - self.execute_whoami(matches).await; - } - CliCommand::WhoamiPutName => { - self.execute_whoami_put_name(matches).await; - } - CliCommand::WorkerBootstrap => { - self.execute_worker_bootstrap(matches).await; - } - CliCommand::WorkerPing => { - self.execute_worker_ping(matches).await; - } - CliCommand::WorkerTaskAppend => { - self.execute_worker_task_append(matches).await; - } - CliCommand::WorkerTaskUploadChunk => { - self.execute_worker_task_upload_chunk(matches).await; - } - CliCommand::WorkerTaskComplete => { - self.execute_worker_task_complete(matches).await; - } - CliCommand::WorkerTaskAddOutput => { - self.execute_worker_task_add_output(matches).await; - } - CliCommand::WorkersList => { - self.execute_workers_list(matches).await; - } - CliCommand::WorkersRecycle => { - self.execute_workers_recycle(matches).await; - } - } + pub fn cli_job_get() -> clap::Command { + clap::Command::new("").arg( + clap::Arg::new("job") + .long("job") + .value_parser(clap::value_parser!(String)) + .required(true), + ) } - pub async fn execute_control_hold(&self, matches: &clap::ArgMatches) { - let mut request = self.client.control_hold(); - self.over - .execute_control_hold(matches, &mut request) - .unwrap(); - let result = request.send().await; - match result { - Ok(r) => { - println!("success\n{:#?}", r) - } - Err(r) => { - println!("success\n{:#?}", r) - } - } + pub fn cli_jobs_get() -> clap::Command { + clap::Command::new("") } - pub async fn execute_control_resume(&self, matches: &clap::ArgMatches) { - let mut request = self.client.control_resume(); + pub fn cli_job_submit() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("name") + .long("name") + .value_parser(clap::value_parser!(String)) + .required_unless_present("json-body"), + ) + .arg( + clap::Arg::new("target") + .long("target") + .value_parser(clap::value_parser!(String)) + .required_unless_present("json-body"), + ) + .arg( + clap::Arg::new("json-body") + .long("json-body") + .value_name("JSON-FILE") + .required(true) + .value_parser(clap::value_parser!(std::path::PathBuf)) + .help("Path to a file that contains the full json body."), + ) + .arg( + clap::Arg::new("json-body-template") + .long("json-body-template") + .action(clap::ArgAction::SetTrue) + .help("XXX"), + ) + } + + pub fn cli_job_cancel() -> clap::Command { + clap::Command::new("").arg( + clap::Arg::new("job") + .long("job") + .value_parser(clap::value_parser!(String)) + .required(true), + ) + } + + pub fn cli_job_upload_chunk() -> clap::Command { + clap::Command::new("").arg( + clap::Arg::new("job") + .long("job") + .value_parser(clap::value_parser!(String)) + .required(true), + ) + } + + pub fn cli_job_events_get() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("job") + .long("job") + .value_parser(clap::value_parser!(String)) + .required(true), + ) + .arg( + clap::Arg::new("minseq") + .long("minseq") + .value_parser(clap::value_parser!(u32)) + .required(false), + ) + } + + pub fn cli_job_outputs_get() -> clap::Command { + clap::Command::new("").arg( + clap::Arg::new("job") + .long("job") + .value_parser(clap::value_parser!(String)) + .required(true), + ) + } + + pub fn cli_job_output_download() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("job") + .long("job") + .value_parser(clap::value_parser!(String)) + .required(true), + ) + .arg( + clap::Arg::new("output") + .long("output") + .value_parser(clap::value_parser!(String)) + .required(true), + ) + } + + pub fn cli_job_output_publish() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("job") + .long("job") + .value_parser(clap::value_parser!(String)) + .required(true), + ) + .arg( + clap::Arg::new("name") + .long("name") + .value_parser(clap::value_parser!(String)) + .required_unless_present("json-body"), + ) + .arg( + clap::Arg::new("output") + .long("output") + .value_parser(clap::value_parser!(String)) + .required(true), + ) + .arg( + clap::Arg::new("series") + .long("series") + .value_parser(clap::value_parser!(String)) + .required_unless_present("json-body"), + ) + .arg( + clap::Arg::new("version") + .long("version") + .value_parser(clap::value_parser!(String)) + .required_unless_present("json-body"), + ) + .arg( + clap::Arg::new("json-body") + .long("json-body") + .value_name("JSON-FILE") + .required(false) + .value_parser(clap::value_parser!(std::path::PathBuf)) + .help("Path to a file that contains the full json body."), + ) + .arg( + clap::Arg::new("json-body-template") + .long("json-body-template") + .action(clap::ArgAction::SetTrue) + .help("XXX"), + ) + } + + pub fn cli_job_output_signed_url() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("content-disposition") + .long("content-disposition") + .value_parser(clap::value_parser!(String)) + .required(false), + ) + .arg( + clap::Arg::new("content-type") + .long("content-type") + .value_parser(clap::value_parser!(String)) + .required(false), + ) + .arg( + clap::Arg::new("expiry-seconds") + .long("expiry-seconds") + .value_parser(clap::value_parser!(u64)) + .required_unless_present("json-body"), + ) + .arg( + clap::Arg::new("job") + .long("job") + .value_parser(clap::value_parser!(String)) + .required(true), + ) + .arg( + clap::Arg::new("output") + .long("output") + .value_parser(clap::value_parser!(String)) + .required(true), + ) + .arg( + clap::Arg::new("json-body") + .long("json-body") + .value_name("JSON-FILE") + .required(false) + .value_parser(clap::value_parser!(std::path::PathBuf)) + .help("Path to a file that contains the full json body."), + ) + .arg( + clap::Arg::new("json-body-template") + .long("json-body-template") + .action(clap::ArgAction::SetTrue) + .help("XXX"), + ) + } + + pub fn cli_job_store_get_all() -> clap::Command { + clap::Command::new("").arg( + clap::Arg::new("job") + .long("job") + .value_parser(clap::value_parser!(String)) + .required(true), + ) + } + + pub fn cli_job_store_put() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("job") + .long("job") + .value_parser(clap::value_parser!(String)) + .required(true), + ) + .arg( + clap::Arg::new("name") + .long("name") + .value_parser(clap::value_parser!(String)) + .required(true), + ) + .arg( + clap::Arg::new("secret") + .long("secret") + .value_parser(clap::value_parser!(bool)) + .required_unless_present("json-body"), + ) + .arg( + clap::Arg::new("value") + .long("value") + .value_parser(clap::value_parser!(String)) + .required_unless_present("json-body"), + ) + .arg( + clap::Arg::new("json-body") + .long("json-body") + .value_name("JSON-FILE") + .required(false) + .value_parser(clap::value_parser!(std::path::PathBuf)) + .help("Path to a file that contains the full json body."), + ) + .arg( + clap::Arg::new("json-body-template") + .long("json-body-template") + .action(clap::ArgAction::SetTrue) + .help("XXX"), + ) + } + + pub fn cli_public_file_download() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("name") + .long("name") + .value_parser(clap::value_parser!(String)) + .required(true), + ) + .arg( + clap::Arg::new("series") + .long("series") + .value_parser(clap::value_parser!(String)) + .required(true), + ) + .arg( + clap::Arg::new("username") + .long("username") + .value_parser(clap::value_parser!(String)) + .required(true), + ) + .arg( + clap::Arg::new("version") + .long("version") + .value_parser(clap::value_parser!(String)) + .required(true), + ) + } + + pub fn cli_quota() -> clap::Command { + clap::Command::new("") + } + + pub fn cli_users_list() -> clap::Command { + clap::Command::new("").arg( + clap::Arg::new("name") + .long("name") + .value_parser(clap::value_parser!(String)) + .required(false), + ) + } + + pub fn cli_user_create() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("name") + .long("name") + .value_parser(clap::value_parser!(String)) + .required_unless_present("json-body"), + ) + .arg( + clap::Arg::new("json-body") + .long("json-body") + .value_name("JSON-FILE") + .required(false) + .value_parser(clap::value_parser!(std::path::PathBuf)) + .help("Path to a file that contains the full json body."), + ) + .arg( + clap::Arg::new("json-body-template") + .long("json-body-template") + .action(clap::ArgAction::SetTrue) + .help("XXX"), + ) + } + + pub fn cli_user_get() -> clap::Command { + clap::Command::new("").arg( + clap::Arg::new("user") + .long("user") + .value_parser(clap::value_parser!(String)) + .required(true), + ) + } + + pub fn cli_user_privilege_grant() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("privilege") + .long("privilege") + .value_parser(clap::value_parser!(String)) + .required(true), + ) + .arg( + clap::Arg::new("user") + .long("user") + .value_parser(clap::value_parser!(String)) + .required(true), + ) + } + + pub fn cli_user_privilege_revoke() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("privilege") + .long("privilege") + .value_parser(clap::value_parser!(String)) + .required(true), + ) + .arg( + clap::Arg::new("user") + .long("user") + .value_parser(clap::value_parser!(String)) + .required(true), + ) + } + + pub fn cli_whoami() -> clap::Command { + clap::Command::new("") + } + + pub fn cli_worker_bootstrap() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("bootstrap") + .long("bootstrap") + .value_parser(clap::value_parser!(String)) + .required_unless_present("json-body"), + ) + .arg( + clap::Arg::new("token") + .long("token") + .value_parser(clap::value_parser!(String)) + .required_unless_present("json-body"), + ) + .arg( + clap::Arg::new("json-body") + .long("json-body") + .value_name("JSON-FILE") + .required(false) + .value_parser(clap::value_parser!(std::path::PathBuf)) + .help("Path to a file that contains the full json body."), + ) + .arg( + clap::Arg::new("json-body-template") + .long("json-body-template") + .action(clap::ArgAction::SetTrue) + .help("XXX"), + ) + } + + pub fn cli_worker_job_upload_chunk() -> clap::Command { + clap::Command::new("").arg( + clap::Arg::new("job") + .long("job") + .value_parser(clap::value_parser!(String)) + .required(true), + ) + } + + pub fn cli_worker_job_complete() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("failed") + .long("failed") + .value_parser(clap::value_parser!(bool)) + .required_unless_present("json-body"), + ) + .arg( + clap::Arg::new("job") + .long("job") + .value_parser(clap::value_parser!(String)) + .required(true), + ) + .arg( + clap::Arg::new("json-body") + .long("json-body") + .value_name("JSON-FILE") + .required(false) + .value_parser(clap::value_parser!(std::path::PathBuf)) + .help("Path to a file that contains the full json body."), + ) + .arg( + clap::Arg::new("json-body-template") + .long("json-body-template") + .action(clap::ArgAction::SetTrue) + .help("XXX"), + ) + } + + pub fn cli_worker_job_input_download() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("input") + .long("input") + .value_parser(clap::value_parser!(String)) + .required(true), + ) + .arg( + clap::Arg::new("job") + .long("job") + .value_parser(clap::value_parser!(String)) + .required(true), + ) + } + + pub fn cli_worker_job_quota() -> clap::Command { + clap::Command::new("").arg( + clap::Arg::new("job") + .long("job") + .value_parser(clap::value_parser!(String)) + .required(true), + ) + } + + pub fn cli_worker_job_store_get() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("job") + .long("job") + .value_parser(clap::value_parser!(String)) + .required(true), + ) + .arg( + clap::Arg::new("name") + .long("name") + .value_parser(clap::value_parser!(String)) + .required(true), + ) + } + + pub fn cli_worker_job_store_put() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("job") + .long("job") + .value_parser(clap::value_parser!(String)) + .required(true), + ) + .arg( + clap::Arg::new("name") + .long("name") + .value_parser(clap::value_parser!(String)) + .required(true), + ) + .arg( + clap::Arg::new("secret") + .long("secret") + .value_parser(clap::value_parser!(bool)) + .required_unless_present("json-body"), + ) + .arg( + clap::Arg::new("value") + .long("value") + .value_parser(clap::value_parser!(String)) + .required_unless_present("json-body"), + ) + .arg( + clap::Arg::new("json-body") + .long("json-body") + .value_name("JSON-FILE") + .required(false) + .value_parser(clap::value_parser!(std::path::PathBuf)) + .help("Path to a file that contains the full json body."), + ) + .arg( + clap::Arg::new("json-body-template") + .long("json-body-template") + .action(clap::ArgAction::SetTrue) + .help("XXX"), + ) + } + + pub fn cli_worker_task_append() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("job") + .long("job") + .value_parser(clap::value_parser!(String)) + .required(true), + ) + .arg( + clap::Arg::new("payload") + .long("payload") + .value_parser(clap::value_parser!(String)) + .required_unless_present("json-body"), + ) + .arg( + clap::Arg::new("stream") + .long("stream") + .value_parser(clap::value_parser!(String)) + .required_unless_present("json-body"), + ) + .arg( + clap::Arg::new("task") + .long("task") + .value_parser(clap::value_parser!(u32)) + .required(true), + ) + .arg( + clap::Arg::new("time") + .long("time") + .value_parser(clap::value_parser!(chrono::DateTime)) + .required_unless_present("json-body"), + ) + .arg( + clap::Arg::new("json-body") + .long("json-body") + .value_name("JSON-FILE") + .required(false) + .value_parser(clap::value_parser!(std::path::PathBuf)) + .help("Path to a file that contains the full json body."), + ) + .arg( + clap::Arg::new("json-body-template") + .long("json-body-template") + .action(clap::ArgAction::SetTrue) + .help("XXX"), + ) + } + + pub fn cli_worker_task_complete() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("failed") + .long("failed") + .value_parser(clap::value_parser!(bool)) + .required_unless_present("json-body"), + ) + .arg( + clap::Arg::new("job") + .long("job") + .value_parser(clap::value_parser!(String)) + .required(true), + ) + .arg( + clap::Arg::new("task") + .long("task") + .value_parser(clap::value_parser!(u32)) + .required(true), + ) + .arg( + clap::Arg::new("json-body") + .long("json-body") + .value_name("JSON-FILE") + .required(false) + .value_parser(clap::value_parser!(std::path::PathBuf)) + .help("Path to a file that contains the full json body."), + ) + .arg( + clap::Arg::new("json-body-template") + .long("json-body-template") + .action(clap::ArgAction::SetTrue) + .help("XXX"), + ) + } + + pub fn cli_worker_ping() -> clap::Command { + clap::Command::new("") + } + + pub fn cli_workers_list() -> clap::Command { + clap::Command::new("").arg( + clap::Arg::new("active") + .long("active") + .value_parser(clap::value_parser!(bool)) + .required(false), + ) + } + + pub fn cli_workers_recycle() -> clap::Command { + clap::Command::new("") + } + + pub fn cli_job_add_input() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("commit-id") + .long("commit-id") + .value_parser(clap::value_parser!(String)) + .required_unless_present("json-body"), + ) + .arg( + clap::Arg::new("job") + .long("job") + .value_parser(clap::value_parser!(String)) + .required(true), + ) + .arg( + clap::Arg::new("name") + .long("name") + .value_parser(clap::value_parser!(String)) + .required_unless_present("json-body"), + ) + .arg( + clap::Arg::new("size") + .long("size") + .value_parser(clap::value_parser!(u64)) + .required_unless_present("json-body"), + ) + .arg( + clap::Arg::new("json-body") + .long("json-body") + .value_name("JSON-FILE") + .required(true) + .value_parser(clap::value_parser!(std::path::PathBuf)) + .help("Path to a file that contains the full json body."), + ) + .arg( + clap::Arg::new("json-body-template") + .long("json-body-template") + .action(clap::ArgAction::SetTrue) + .help("XXX"), + ) + } + + pub fn cli_worker_job_append() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("job") + .long("job") + .value_parser(clap::value_parser!(String)) + .required(true), + ) + .arg( + clap::Arg::new("json-body") + .long("json-body") + .value_name("JSON-FILE") + .required(true) + .value_parser(clap::value_parser!(std::path::PathBuf)) + .help("Path to a file that contains the full json body."), + ) + .arg( + clap::Arg::new("json-body-template") + .long("json-body-template") + .action(clap::ArgAction::SetTrue) + .help("XXX"), + ) + } + + pub fn cli_worker_job_add_output() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("commit-id") + .long("commit-id") + .value_parser(clap::value_parser!(String)) + .required_unless_present("json-body"), + ) + .arg( + clap::Arg::new("job") + .long("job") + .value_parser(clap::value_parser!(String)) + .required(true), + ) + .arg( + clap::Arg::new("path") + .long("path") + .value_parser(clap::value_parser!(String)) + .required_unless_present("json-body"), + ) + .arg( + clap::Arg::new("size") + .long("size") + .value_parser(clap::value_parser!(u64)) + .required_unless_present("json-body"), + ) + .arg( + clap::Arg::new("json-body") + .long("json-body") + .value_name("JSON-FILE") + .required(true) + .value_parser(clap::value_parser!(std::path::PathBuf)) + .help("Path to a file that contains the full json body."), + ) + .arg( + clap::Arg::new("json-body-template") + .long("json-body-template") + .action(clap::ArgAction::SetTrue) + .help("XXX"), + ) + } +} + +impl Cli { + pub fn new_with_override(client: sdk::Client, over: T) -> Self { + Self { client, over } + } + + pub async fn execute(&self, cmd: CliCommand, matches: &clap::ArgMatches) { + match cmd { + CliCommand::FactoryCreate => { + self.execute_factory_create(matches).await; + } + CliCommand::AdminJobsGet => { + self.execute_admin_jobs_get(matches).await; + } + CliCommand::AdminJobGet => { + self.execute_admin_job_get(matches).await; + } + CliCommand::AdminJobArchiveRequest => { + self.execute_admin_job_archive_request(matches).await; + } + CliCommand::TargetCreate => { + self.execute_target_create(matches).await; + } + CliCommand::TargetsList => { + self.execute_targets_list(matches).await; + } + CliCommand::TargetRedirect => { + self.execute_target_redirect(matches).await; + } + CliCommand::TargetRename => { + self.execute_target_rename(matches).await; + } + CliCommand::TargetRequireNoPrivilege => { + self.execute_target_require_no_privilege(matches).await; + } + CliCommand::TargetRequirePrivilege => { + self.execute_target_require_privilege(matches).await; + } + CliCommand::WorkerRecycle => { + self.execute_worker_recycle(matches).await; + } + CliCommand::ControlHold => { + self.execute_control_hold(matches).await; + } + CliCommand::ControlResume => { + self.execute_control_resume(matches).await; + } + CliCommand::FactoryLease => { + self.execute_factory_lease(matches).await; + } + CliCommand::FactoryLeaseRenew => { + self.execute_factory_lease_renew(matches).await; + } + CliCommand::FactoryPing => { + self.execute_factory_ping(matches).await; + } + CliCommand::FactoryWorkerCreate => { + self.execute_factory_worker_create(matches).await; + } + CliCommand::FactoryWorkerGet => { + self.execute_factory_worker_get(matches).await; + } + CliCommand::FactoryWorkerDestroy => { + self.execute_factory_worker_destroy(matches).await; + } + CliCommand::FactoryWorkerAssociate => { + self.execute_factory_worker_associate(matches).await; + } + CliCommand::FactoryWorkerAppend => { + self.execute_factory_worker_append(matches).await; + } + CliCommand::FactoryWorkerFlush => { + self.execute_factory_worker_flush(matches).await; + } + CliCommand::FactoryWorkers => { + self.execute_factory_workers(matches).await; + } + CliCommand::JobGet => { + self.execute_job_get(matches).await; + } + CliCommand::JobsGet => { + self.execute_jobs_get(matches).await; + } + CliCommand::JobSubmit => { + self.execute_job_submit(matches).await; + } + CliCommand::JobCancel => { + self.execute_job_cancel(matches).await; + } + CliCommand::JobUploadChunk => { + self.execute_job_upload_chunk(matches).await; + } + CliCommand::JobEventsGet => { + self.execute_job_events_get(matches).await; + } + CliCommand::JobOutputsGet => { + self.execute_job_outputs_get(matches).await; + } + CliCommand::JobOutputDownload => { + self.execute_job_output_download(matches).await; + } + CliCommand::JobOutputPublish => { + self.execute_job_output_publish(matches).await; + } + CliCommand::JobOutputSignedUrl => { + self.execute_job_output_signed_url(matches).await; + } + CliCommand::JobStoreGetAll => { + self.execute_job_store_get_all(matches).await; + } + CliCommand::JobStorePut => { + self.execute_job_store_put(matches).await; + } + CliCommand::PublicFileDownload => { + self.execute_public_file_download(matches).await; + } + CliCommand::Quota => { + self.execute_quota(matches).await; + } + CliCommand::UsersList => { + self.execute_users_list(matches).await; + } + CliCommand::UserCreate => { + self.execute_user_create(matches).await; + } + CliCommand::UserGet => { + self.execute_user_get(matches).await; + } + CliCommand::UserPrivilegeGrant => { + self.execute_user_privilege_grant(matches).await; + } + CliCommand::UserPrivilegeRevoke => { + self.execute_user_privilege_revoke(matches).await; + } + CliCommand::Whoami => { + self.execute_whoami(matches).await; + } + CliCommand::WorkerBootstrap => { + self.execute_worker_bootstrap(matches).await; + } + CliCommand::WorkerJobUploadChunk => { + self.execute_worker_job_upload_chunk(matches).await; + } + CliCommand::WorkerJobComplete => { + self.execute_worker_job_complete(matches).await; + } + CliCommand::WorkerJobInputDownload => { + self.execute_worker_job_input_download(matches).await; + } + CliCommand::WorkerJobQuota => { + self.execute_worker_job_quota(matches).await; + } + CliCommand::WorkerJobStoreGet => { + self.execute_worker_job_store_get(matches).await; + } + CliCommand::WorkerJobStorePut => { + self.execute_worker_job_store_put(matches).await; + } + CliCommand::WorkerTaskAppend => { + self.execute_worker_task_append(matches).await; + } + CliCommand::WorkerTaskComplete => { + self.execute_worker_task_complete(matches).await; + } + CliCommand::WorkerPing => { + self.execute_worker_ping(matches).await; + } + CliCommand::WorkersList => { + self.execute_workers_list(matches).await; + } + CliCommand::WorkersRecycle => { + self.execute_workers_recycle(matches).await; + } + CliCommand::JobAddInput => { + self.execute_job_add_input(matches).await; + } + CliCommand::WorkerJobAppend => { + self.execute_worker_job_append(matches).await; + } + CliCommand::WorkerJobAddOutput => { + self.execute_worker_job_add_output(matches).await; + } + } + } + + pub async fn execute_factory_create(&self, matches: &clap::ArgMatches) { + let mut request = self.client.factory_create(); + if let Some(value) = matches.get_one::("name") { + request = request.body_map(|body| body.name(value.clone())) + } + + if let Some(value) = matches.get_one::("json-body") { + let body_txt = std::fs::read_to_string(value).unwrap(); + let body_value = serde_json::from_str::(&body_txt).unwrap(); + request = request.body(body_value); + } + + self.over + .execute_factory_create(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub async fn execute_admin_jobs_get(&self, matches: &clap::ArgMatches) { + let mut request = self.client.admin_jobs_get(); + if let Some(value) = matches.get_one::("active") { + request = request.active(value.clone()); + } + + if let Some(value) = matches.get_one::("completed") { + request = request.completed(value.clone()); + } + + self.over + .execute_admin_jobs_get(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub async fn execute_admin_job_get(&self, matches: &clap::ArgMatches) { + let mut request = self.client.admin_job_get(); + if let Some(value) = matches.get_one::("job") { + request = request.job(value.clone()); + } + + self.over + .execute_admin_job_get(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub async fn execute_admin_job_archive_request(&self, matches: &clap::ArgMatches) { + let mut request = self.client.admin_job_archive_request(); + if let Some(value) = matches.get_one::("job") { + request = request.job(value.clone()); + } + + self.over + .execute_admin_job_archive_request(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub async fn execute_target_create(&self, matches: &clap::ArgMatches) { + let mut request = self.client.target_create(); + if let Some(value) = matches.get_one::("desc") { + request = request.body_map(|body| body.desc(value.clone())) + } + + if let Some(value) = matches.get_one::("name") { + request = request.body_map(|body| body.name(value.clone())) + } + + if let Some(value) = matches.get_one::("json-body") { + let body_txt = std::fs::read_to_string(value).unwrap(); + let body_value = serde_json::from_str::(&body_txt).unwrap(); + request = request.body(body_value); + } + + self.over + .execute_target_create(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub async fn execute_targets_list(&self, matches: &clap::ArgMatches) { + let mut request = self.client.targets_list(); + self.over + .execute_targets_list(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub async fn execute_target_redirect(&self, matches: &clap::ArgMatches) { + let mut request = self.client.target_redirect(); + if let Some(value) = matches.get_one::("redirect") { + request = request.body_map(|body| body.redirect(value.clone())) + } + + if let Some(value) = matches.get_one::("target") { + request = request.target(value.clone()); + } + + if let Some(value) = matches.get_one::("json-body") { + let body_txt = std::fs::read_to_string(value).unwrap(); + let body_value = serde_json::from_str::(&body_txt).unwrap(); + request = request.body(body_value); + } + + self.over + .execute_target_redirect(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub async fn execute_target_rename(&self, matches: &clap::ArgMatches) { + let mut request = self.client.target_rename(); + if let Some(value) = matches.get_one::("new-name") { + request = request.body_map(|body| body.new_name(value.clone())) + } + + if let Some(value) = matches.get_one::("signpost-description") { + request = request.body_map(|body| body.signpost_description(value.clone())) + } + + if let Some(value) = matches.get_one::("target") { + request = request.target(value.clone()); + } + + if let Some(value) = matches.get_one::("json-body") { + let body_txt = std::fs::read_to_string(value).unwrap(); + let body_value = serde_json::from_str::(&body_txt).unwrap(); + request = request.body(body_value); + } + + self.over + .execute_target_rename(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub async fn execute_target_require_no_privilege(&self, matches: &clap::ArgMatches) { + let mut request = self.client.target_require_no_privilege(); + if let Some(value) = matches.get_one::("target") { + request = request.target(value.clone()); + } + + self.over + .execute_target_require_no_privilege(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub async fn execute_target_require_privilege(&self, matches: &clap::ArgMatches) { + let mut request = self.client.target_require_privilege(); + if let Some(value) = matches.get_one::("privilege") { + request = request.privilege(value.clone()); + } + + if let Some(value) = matches.get_one::("target") { + request = request.target(value.clone()); + } + + self.over + .execute_target_require_privilege(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub async fn execute_worker_recycle(&self, matches: &clap::ArgMatches) { + let mut request = self.client.worker_recycle(); + if let Some(value) = matches.get_one::("worker") { + request = request.worker(value.clone()); + } + + self.over + .execute_worker_recycle(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub async fn execute_control_hold(&self, matches: &clap::ArgMatches) { + let mut request = self.client.control_hold(); + self.over + .execute_control_hold(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub async fn execute_control_resume(&self, matches: &clap::ArgMatches) { + let mut request = self.client.control_resume(); + self.over + .execute_control_resume(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub async fn execute_factory_lease(&self, matches: &clap::ArgMatches) { + let mut request = self.client.factory_lease(); + if let Some(value) = matches.get_one::("json-body") { + let body_txt = std::fs::read_to_string(value).unwrap(); + let body_value = serde_json::from_str::(&body_txt).unwrap(); + request = request.body(body_value); + } + + self.over + .execute_factory_lease(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub async fn execute_factory_lease_renew(&self, matches: &clap::ArgMatches) { + let mut request = self.client.factory_lease_renew(); + if let Some(value) = matches.get_one::("job") { + request = request.job(value.clone()); + } + + self.over + .execute_factory_lease_renew(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub async fn execute_factory_ping(&self, matches: &clap::ArgMatches) { + let mut request = self.client.factory_ping(); + self.over + .execute_factory_ping(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub async fn execute_factory_worker_create(&self, matches: &clap::ArgMatches) { + let mut request = self.client.factory_worker_create(); + if let Some(value) = matches.get_one::("job") { + request = request.body_map(|body| body.job(value.clone())) + } + + if let Some(value) = matches.get_one::("target") { + request = request.body_map(|body| body.target(value.clone())) + } + + if let Some(value) = matches.get_one::("wait-for-flush") { + request = request.body_map(|body| body.wait_for_flush(value.clone())) + } + + if let Some(value) = matches.get_one::("json-body") { + let body_txt = std::fs::read_to_string(value).unwrap(); + let body_value = serde_json::from_str::(&body_txt).unwrap(); + request = request.body(body_value); + } + + self.over + .execute_factory_worker_create(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub async fn execute_factory_worker_get(&self, matches: &clap::ArgMatches) { + let mut request = self.client.factory_worker_get(); + if let Some(value) = matches.get_one::("worker") { + request = request.worker(value.clone()); + } + + self.over + .execute_factory_worker_get(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub async fn execute_factory_worker_destroy(&self, matches: &clap::ArgMatches) { + let mut request = self.client.factory_worker_destroy(); + if let Some(value) = matches.get_one::("worker") { + request = request.worker(value.clone()); + } + + self.over + .execute_factory_worker_destroy(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub async fn execute_factory_worker_associate(&self, matches: &clap::ArgMatches) { + let mut request = self.client.factory_worker_associate(); + if let Some(value) = matches.get_one::("private") { + request = request.body_map(|body| body.private(value.clone())) + } + + if let Some(value) = matches.get_one::("worker") { + request = request.worker(value.clone()); + } + + if let Some(value) = matches.get_one::("json-body") { + let body_txt = std::fs::read_to_string(value).unwrap(); + let body_value = + serde_json::from_str::(&body_txt).unwrap(); + request = request.body(body_value); + } + + self.over + .execute_factory_worker_associate(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub async fn execute_factory_worker_append(&self, matches: &clap::ArgMatches) { + let mut request = self.client.factory_worker_append(); + if let Some(value) = matches.get_one::("payload") { + request = request.body_map(|body| body.payload(value.clone())) + } + + if let Some(value) = matches.get_one::("stream") { + request = request.body_map(|body| body.stream(value.clone())) + } + + if let Some(value) = matches.get_one::>("time") { + request = request.body_map(|body| body.time(value.clone())) + } + + if let Some(value) = matches.get_one::("worker") { + request = request.worker(value.clone()); + } + + if let Some(value) = matches.get_one::("json-body") { + let body_txt = std::fs::read_to_string(value).unwrap(); + let body_value = serde_json::from_str::(&body_txt).unwrap(); + request = request.body(body_value); + } + + self.over + .execute_factory_worker_append(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub async fn execute_factory_worker_flush(&self, matches: &clap::ArgMatches) { + let mut request = self.client.factory_worker_flush(); + if let Some(value) = matches.get_one::("worker") { + request = request.worker(value.clone()); + } + + self.over + .execute_factory_worker_flush(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub async fn execute_factory_workers(&self, matches: &clap::ArgMatches) { + let mut request = self.client.factory_workers(); + self.over + .execute_factory_workers(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub async fn execute_job_get(&self, matches: &clap::ArgMatches) { + let mut request = self.client.job_get(); + if let Some(value) = matches.get_one::("job") { + request = request.job(value.clone()); + } + + self.over.execute_job_get(matches, &mut request).unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub async fn execute_jobs_get(&self, matches: &clap::ArgMatches) { + let mut request = self.client.jobs_get(); + self.over.execute_jobs_get(matches, &mut request).unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub async fn execute_job_submit(&self, matches: &clap::ArgMatches) { + let mut request = self.client.job_submit(); + if let Some(value) = matches.get_one::("name") { + request = request.body_map(|body| body.name(value.clone())) + } + + if let Some(value) = matches.get_one::("target") { + request = request.body_map(|body| body.target(value.clone())) + } + + if let Some(value) = matches.get_one::("json-body") { + let body_txt = std::fs::read_to_string(value).unwrap(); + let body_value = serde_json::from_str::(&body_txt).unwrap(); + request = request.body(body_value); + } + + self.over.execute_job_submit(matches, &mut request).unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub async fn execute_job_cancel(&self, matches: &clap::ArgMatches) { + let mut request = self.client.job_cancel(); + if let Some(value) = matches.get_one::("job") { + request = request.job(value.clone()); + } + + self.over.execute_job_cancel(matches, &mut request).unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub async fn execute_job_upload_chunk(&self, matches: &clap::ArgMatches) { + let mut request = self.client.job_upload_chunk(); + if let Some(value) = matches.get_one::("job") { + request = request.job(value.clone()); + } + + self.over + .execute_job_upload_chunk(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub async fn execute_job_events_get(&self, matches: &clap::ArgMatches) { + let mut request = self.client.job_events_get(); + if let Some(value) = matches.get_one::("job") { + request = request.job(value.clone()); + } + + if let Some(value) = matches.get_one::("minseq") { + request = request.minseq(value.clone()); + } + + self.over + .execute_job_events_get(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub async fn execute_job_outputs_get(&self, matches: &clap::ArgMatches) { + let mut request = self.client.job_outputs_get(); + if let Some(value) = matches.get_one::("job") { + request = request.job(value.clone()); + } + + self.over + .execute_job_outputs_get(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub async fn execute_job_output_download(&self, matches: &clap::ArgMatches) { + let mut request = self.client.job_output_download(); + if let Some(value) = matches.get_one::("job") { + request = request.job(value.clone()); + } + + if let Some(value) = matches.get_one::("output") { + request = request.output(value.clone()); + } + + self.over + .execute_job_output_download(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + todo!() + } + Err(r) => { + todo!() + } + } + } + + pub async fn execute_job_output_publish(&self, matches: &clap::ArgMatches) { + let mut request = self.client.job_output_publish(); + if let Some(value) = matches.get_one::("job") { + request = request.job(value.clone()); + } + + if let Some(value) = matches.get_one::("name") { + request = request.body_map(|body| body.name(value.clone())) + } + + if let Some(value) = matches.get_one::("output") { + request = request.output(value.clone()); + } + + if let Some(value) = matches.get_one::("series") { + request = request.body_map(|body| body.series(value.clone())) + } + + if let Some(value) = matches.get_one::("version") { + request = request.body_map(|body| body.version(value.clone())) + } + + if let Some(value) = matches.get_one::("json-body") { + let body_txt = std::fs::read_to_string(value).unwrap(); + let body_value = serde_json::from_str::(&body_txt).unwrap(); + request = request.body(body_value); + } + + self.over + .execute_job_output_publish(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub async fn execute_job_output_signed_url(&self, matches: &clap::ArgMatches) { + let mut request = self.client.job_output_signed_url(); + if let Some(value) = matches.get_one::("content-disposition") { + request = request.body_map(|body| body.content_disposition(value.clone())) + } + + if let Some(value) = matches.get_one::("content-type") { + request = request.body_map(|body| body.content_type(value.clone())) + } + + if let Some(value) = matches.get_one::("expiry-seconds") { + request = request.body_map(|body| body.expiry_seconds(value.clone())) + } + + if let Some(value) = matches.get_one::("job") { + request = request.job(value.clone()); + } + + if let Some(value) = matches.get_one::("output") { + request = request.output(value.clone()); + } + + if let Some(value) = matches.get_one::("json-body") { + let body_txt = std::fs::read_to_string(value).unwrap(); + let body_value = serde_json::from_str::(&body_txt).unwrap(); + request = request.body(body_value); + } + + self.over + .execute_job_output_signed_url(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub async fn execute_job_store_get_all(&self, matches: &clap::ArgMatches) { + let mut request = self.client.job_store_get_all(); + if let Some(value) = matches.get_one::("job") { + request = request.job(value.clone()); + } + + self.over + .execute_job_store_get_all(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub async fn execute_job_store_put(&self, matches: &clap::ArgMatches) { + let mut request = self.client.job_store_put(); + if let Some(value) = matches.get_one::("job") { + request = request.job(value.clone()); + } + + if let Some(value) = matches.get_one::("name") { + request = request.name(value.clone()); + } + + if let Some(value) = matches.get_one::("secret") { + request = request.body_map(|body| body.secret(value.clone())) + } + + if let Some(value) = matches.get_one::("value") { + request = request.body_map(|body| body.value(value.clone())) + } + + if let Some(value) = matches.get_one::("json-body") { + let body_txt = std::fs::read_to_string(value).unwrap(); + let body_value = serde_json::from_str::(&body_txt).unwrap(); + request = request.body(body_value); + } + + self.over + .execute_job_store_put(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub async fn execute_public_file_download(&self, matches: &clap::ArgMatches) { + let mut request = self.client.public_file_download(); + if let Some(value) = matches.get_one::("name") { + request = request.name(value.clone()); + } + + if let Some(value) = matches.get_one::("series") { + request = request.series(value.clone()); + } + + if let Some(value) = matches.get_one::("username") { + request = request.username(value.clone()); + } + + if let Some(value) = matches.get_one::("version") { + request = request.version(value.clone()); + } + + self.over + .execute_public_file_download(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + todo!() + } + Err(r) => { + todo!() + } + } + } + + pub async fn execute_quota(&self, matches: &clap::ArgMatches) { + let mut request = self.client.quota(); + self.over.execute_quota(matches, &mut request).unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub async fn execute_users_list(&self, matches: &clap::ArgMatches) { + let mut request = self.client.users_list(); + if let Some(value) = matches.get_one::("name") { + request = request.name(value.clone()); + } + + self.over.execute_users_list(matches, &mut request).unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub async fn execute_user_create(&self, matches: &clap::ArgMatches) { + let mut request = self.client.user_create(); + if let Some(value) = matches.get_one::("name") { + request = request.body_map(|body| body.name(value.clone())) + } + + if let Some(value) = matches.get_one::("json-body") { + let body_txt = std::fs::read_to_string(value).unwrap(); + let body_value = serde_json::from_str::(&body_txt).unwrap(); + request = request.body(body_value); + } + + self.over + .execute_user_create(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub async fn execute_user_get(&self, matches: &clap::ArgMatches) { + let mut request = self.client.user_get(); + if let Some(value) = matches.get_one::("user") { + request = request.user(value.clone()); + } + + self.over.execute_user_get(matches, &mut request).unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub async fn execute_user_privilege_grant(&self, matches: &clap::ArgMatches) { + let mut request = self.client.user_privilege_grant(); + if let Some(value) = matches.get_one::("privilege") { + request = request.privilege(value.clone()); + } + + if let Some(value) = matches.get_one::("user") { + request = request.user(value.clone()); + } + + self.over + .execute_user_privilege_grant(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub async fn execute_user_privilege_revoke(&self, matches: &clap::ArgMatches) { + let mut request = self.client.user_privilege_revoke(); + if let Some(value) = matches.get_one::("privilege") { + request = request.privilege(value.clone()); + } + + if let Some(value) = matches.get_one::("user") { + request = request.user(value.clone()); + } + + self.over + .execute_user_privilege_revoke(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub async fn execute_whoami(&self, matches: &clap::ArgMatches) { + let mut request = self.client.whoami(); + self.over.execute_whoami(matches, &mut request).unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub async fn execute_worker_bootstrap(&self, matches: &clap::ArgMatches) { + let mut request = self.client.worker_bootstrap(); + if let Some(value) = matches.get_one::("bootstrap") { + request = request.body_map(|body| body.bootstrap(value.clone())) + } + + if let Some(value) = matches.get_one::("token") { + request = request.body_map(|body| body.token(value.clone())) + } + + if let Some(value) = matches.get_one::("json-body") { + let body_txt = std::fs::read_to_string(value).unwrap(); + let body_value = serde_json::from_str::(&body_txt).unwrap(); + request = request.body(body_value); + } + + self.over + .execute_worker_bootstrap(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub async fn execute_worker_job_upload_chunk(&self, matches: &clap::ArgMatches) { + let mut request = self.client.worker_job_upload_chunk(); + if let Some(value) = matches.get_one::("job") { + request = request.job(value.clone()); + } + + self.over + .execute_worker_job_upload_chunk(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub async fn execute_worker_job_complete(&self, matches: &clap::ArgMatches) { + let mut request = self.client.worker_job_complete(); + if let Some(value) = matches.get_one::("failed") { + request = request.body_map(|body| body.failed(value.clone())) + } + + if let Some(value) = matches.get_one::("job") { + request = request.job(value.clone()); + } + + if let Some(value) = matches.get_one::("json-body") { + let body_txt = std::fs::read_to_string(value).unwrap(); + let body_value = serde_json::from_str::(&body_txt).unwrap(); + request = request.body(body_value); + } + + self.over + .execute_worker_job_complete(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub async fn execute_worker_job_input_download(&self, matches: &clap::ArgMatches) { + let mut request = self.client.worker_job_input_download(); + if let Some(value) = matches.get_one::("input") { + request = request.input(value.clone()); + } + + if let Some(value) = matches.get_one::("job") { + request = request.job(value.clone()); + } + self.over - .execute_control_resume(matches, &mut request) + .execute_worker_job_input_download(matches, &mut request) .unwrap(); let result = request.send().await; match result { Ok(r) => { - println!("success\n{:#?}", r) + todo!() } Err(r) => { - println!("success\n{:#?}", r) + todo!() } } } - pub async fn execute_task_get(&self, matches: &clap::ArgMatches) { - let mut request = self.client.task_get(); - if let Some(value) = matches.get_one::("task") { - request = request.task(value.clone()); + pub async fn execute_worker_job_quota(&self, matches: &clap::ArgMatches) { + let mut request = self.client.worker_job_quota(); + if let Some(value) = matches.get_one::("job") { + request = request.job(value.clone()); } - self.over.execute_task_get(matches, &mut request).unwrap(); + self.over + .execute_worker_job_quota(matches, &mut request) + .unwrap(); let result = request.send().await; match result { Ok(r) => { println!("success\n{:#?}", r) } Err(r) => { - println!("success\n{:#?}", r) + println!("error\n{:#?}", r) } } } - pub async fn execute_tasks_get(&self, matches: &clap::ArgMatches) { - let mut request = self.client.tasks_get(); - self.over.execute_tasks_get(matches, &mut request).unwrap(); + pub async fn execute_worker_job_store_get(&self, matches: &clap::ArgMatches) { + let mut request = self.client.worker_job_store_get(); + if let Some(value) = matches.get_one::("job") { + request = request.job(value.clone()); + } + + if let Some(value) = matches.get_one::("name") { + request = request.name(value.clone()); + } + + self.over + .execute_worker_job_store_get(matches, &mut request) + .unwrap(); let result = request.send().await; match result { Ok(r) => { println!("success\n{:#?}", r) } Err(r) => { - println!("success\n{:#?}", r) + println!("error\n{:#?}", r) } } } - pub async fn execute_task_submit(&self, matches: &clap::ArgMatches) { - let mut request = self.client.task_submit(); + pub async fn execute_worker_job_store_put(&self, matches: &clap::ArgMatches) { + let mut request = self.client.worker_job_store_put(); + if let Some(value) = matches.get_one::("job") { + request = request.job(value.clone()); + } + if let Some(value) = matches.get_one::("name") { - request = request.body_map(|body| body.name(value.clone())) + request = request.name(value.clone()); + } + + if let Some(value) = matches.get_one::("secret") { + request = request.body_map(|body| body.secret(value.clone())) } - if let Some(value) = matches.get_one::("script") { - request = request.body_map(|body| body.script(value.clone())) + if let Some(value) = matches.get_one::("value") { + request = request.body_map(|body| body.value(value.clone())) } if let Some(value) = matches.get_one::("json-body") { let body_txt = std::fs::read_to_string(value).unwrap(); - let body_value = serde_json::from_str::(&body_txt).unwrap(); + let body_value = serde_json::from_str::(&body_txt).unwrap(); request = request.body(body_value); } self.over - .execute_task_submit(matches, &mut request) + .execute_worker_job_store_put(matches, &mut request) .unwrap(); let result = request.send().await; match result { @@ -472,23 +2538,41 @@ impl Cli { println!("success\n{:#?}", r) } Err(r) => { - println!("success\n{:#?}", r) + println!("error\n{:#?}", r) } } } - pub async fn execute_task_events_get(&self, matches: &clap::ArgMatches) { - let mut request = self.client.task_events_get(); - if let Some(value) = matches.get_one::("minseq") { - request = request.minseq(value.clone()); + pub async fn execute_worker_task_append(&self, matches: &clap::ArgMatches) { + let mut request = self.client.worker_task_append(); + if let Some(value) = matches.get_one::("job") { + request = request.job(value.clone()); + } + + if let Some(value) = matches.get_one::("payload") { + request = request.body_map(|body| body.payload(value.clone())) + } + + if let Some(value) = matches.get_one::("stream") { + request = request.body_map(|body| body.stream(value.clone())) } - if let Some(value) = matches.get_one::("task") { + if let Some(value) = matches.get_one::("task") { request = request.task(value.clone()); } + if let Some(value) = matches.get_one::>("time") { + request = request.body_map(|body| body.time(value.clone())) + } + + if let Some(value) = matches.get_one::("json-body") { + let body_txt = std::fs::read_to_string(value).unwrap(); + let body_value = serde_json::from_str::(&body_txt).unwrap(); + request = request.body(body_value); + } + self.over - .execute_task_events_get(matches, &mut request) + .execute_worker_task_append(matches, &mut request) .unwrap(); let result = request.send().await; match result { @@ -496,19 +2580,33 @@ impl Cli { println!("success\n{:#?}", r) } Err(r) => { - println!("success\n{:#?}", r) + println!("error\n{:#?}", r) } } } - pub async fn execute_task_outputs_get(&self, matches: &clap::ArgMatches) { - let mut request = self.client.task_outputs_get(); - if let Some(value) = matches.get_one::("task") { + pub async fn execute_worker_task_complete(&self, matches: &clap::ArgMatches) { + let mut request = self.client.worker_task_complete(); + if let Some(value) = matches.get_one::("failed") { + request = request.body_map(|body| body.failed(value.clone())) + } + + if let Some(value) = matches.get_one::("job") { + request = request.job(value.clone()); + } + + if let Some(value) = matches.get_one::("task") { request = request.task(value.clone()); } + if let Some(value) = matches.get_one::("json-body") { + let body_txt = std::fs::read_to_string(value).unwrap(); + let body_value = serde_json::from_str::(&body_txt).unwrap(); + request = request.body(body_value); + } + self.over - .execute_task_outputs_get(matches, &mut request) + .execute_worker_task_complete(matches, &mut request) .unwrap(); let result = request.send().await; match result { @@ -516,49 +2614,35 @@ impl Cli { println!("success\n{:#?}", r) } Err(r) => { - println!("success\n{:#?}", r) + println!("error\n{:#?}", r) } } } - pub async fn execute_task_output_download(&self, matches: &clap::ArgMatches) { - let mut request = self.client.task_output_download(); - if let Some(value) = matches.get_one::("output") { - request = request.output(value.clone()); - } - - if let Some(value) = matches.get_one::("task") { - request = request.task(value.clone()); - } - + pub async fn execute_worker_ping(&self, matches: &clap::ArgMatches) { + let mut request = self.client.worker_ping(); self.over - .execute_task_output_download(matches, &mut request) + .execute_worker_ping(matches, &mut request) .unwrap(); let result = request.send().await; match result { Ok(r) => { - todo!() + println!("success\n{:#?}", r) } Err(r) => { - println!("success\n{:#?}", r) + println!("error\n{:#?}", r) } } } - pub async fn execute_user_create(&self, matches: &clap::ArgMatches) { - let mut request = self.client.user_create(); - if let Some(value) = matches.get_one::("name") { - request = request.body_map(|body| body.name(value.clone())) - } - - if let Some(value) = matches.get_one::("json-body") { - let body_txt = std::fs::read_to_string(value).unwrap(); - let body_value = serde_json::from_str::(&body_txt).unwrap(); - request = request.body(body_value); + pub async fn execute_workers_list(&self, matches: &clap::ArgMatches) { + let mut request = self.client.workers_list(); + if let Some(value) = matches.get_one::("active") { + request = request.active(value.clone()); } self.over - .execute_user_create(matches, &mut request) + .execute_workers_list(matches, &mut request) .unwrap(); let result = request.send().await; match result { @@ -566,29 +2650,53 @@ impl Cli { println!("success\n{:#?}", r) } Err(r) => { - println!("success\n{:#?}", r) + println!("error\n{:#?}", r) } } } - pub async fn execute_whoami(&self, matches: &clap::ArgMatches) { - let mut request = self.client.whoami(); - self.over.execute_whoami(matches, &mut request).unwrap(); + pub async fn execute_workers_recycle(&self, matches: &clap::ArgMatches) { + let mut request = self.client.workers_recycle(); + self.over + .execute_workers_recycle(matches, &mut request) + .unwrap(); let result = request.send().await; match result { Ok(r) => { println!("success\n{:#?}", r) } Err(r) => { - println!("success\n{:#?}", r) + println!("error\n{:#?}", r) } } } - pub async fn execute_whoami_put_name(&self, matches: &clap::ArgMatches) { - let mut request = self.client.whoami_put_name(); + pub async fn execute_job_add_input(&self, matches: &clap::ArgMatches) { + let mut request = self.client.job_add_input(); + if let Some(value) = matches.get_one::("commit-id") { + request = request.body_map(|body| body.commit_id(value.clone())) + } + + if let Some(value) = matches.get_one::("job") { + request = request.job(value.clone()); + } + + if let Some(value) = matches.get_one::("name") { + request = request.body_map(|body| body.name(value.clone())) + } + + if let Some(value) = matches.get_one::("size") { + request = request.body_map(|body| body.size(value.clone())) + } + + if let Some(value) = matches.get_one::("json-body") { + let body_txt = std::fs::read_to_string(value).unwrap(); + let body_value = serde_json::from_str::(&body_txt).unwrap(); + request = request.body(body_value); + } + self.over - .execute_whoami_put_name(matches, &mut request) + .execute_job_add_input(matches, &mut request) .unwrap(); let result = request.send().await; match result { @@ -596,29 +2704,26 @@ impl Cli { println!("success\n{:#?}", r) } Err(r) => { - println!("success\n{:#?}", r) + println!("error\n{:#?}", r) } } } - pub async fn execute_worker_bootstrap(&self, matches: &clap::ArgMatches) { - let mut request = self.client.worker_bootstrap(); - if let Some(value) = matches.get_one::("bootstrap") { - request = request.body_map(|body| body.bootstrap(value.clone())) - } - - if let Some(value) = matches.get_one::("token") { - request = request.body_map(|body| body.token(value.clone())) + pub async fn execute_worker_job_append(&self, matches: &clap::ArgMatches) { + let mut request = self.client.worker_job_append(); + if let Some(value) = matches.get_one::("job") { + request = request.job(value.clone()); } if let Some(value) = matches.get_one::("json-body") { let body_txt = std::fs::read_to_string(value).unwrap(); - let body_value = serde_json::from_str::(&body_txt).unwrap(); + let body_value = + serde_json::from_str::>(&body_txt).unwrap(); request = request.body(body_value); } self.over - .execute_worker_bootstrap(matches, &mut request) + .execute_worker_job_append(matches, &mut request) .unwrap(); let result = request.send().await; match result { @@ -626,15 +2731,37 @@ impl Cli { println!("success\n{:#?}", r) } Err(r) => { - println!("success\n{:#?}", r) + println!("error\n{:#?}", r) } } } - pub async fn execute_worker_ping(&self, matches: &clap::ArgMatches) { - let mut request = self.client.worker_ping(); + pub async fn execute_worker_job_add_output(&self, matches: &clap::ArgMatches) { + let mut request = self.client.worker_job_add_output(); + if let Some(value) = matches.get_one::("commit-id") { + request = request.body_map(|body| body.commit_id(value.clone())) + } + + if let Some(value) = matches.get_one::("job") { + request = request.job(value.clone()); + } + + if let Some(value) = matches.get_one::("path") { + request = request.body_map(|body| body.path(value.clone())) + } + + if let Some(value) = matches.get_one::("size") { + request = request.body_map(|body| body.size(value.clone())) + } + + if let Some(value) = matches.get_one::("json-body") { + let body_txt = std::fs::read_to_string(value).unwrap(); + let body_value = serde_json::from_str::(&body_txt).unwrap(); + request = request.body(body_value); + } + self.over - .execute_worker_ping(matches, &mut request) + .execute_worker_job_add_output(matches, &mut request) .unwrap(); let result = request.send().await; match result { @@ -642,283 +2769,417 @@ impl Cli { println!("success\n{:#?}", r) } Err(r) => { - println!("success\n{:#?}", r) + println!("error\n{:#?}", r) } } } +} + +pub trait CliOverride { + fn execute_factory_create( + &self, + matches: &clap::ArgMatches, + request: &mut builder::FactoryCreate, + ) -> Result<(), String> { + Ok(()) + } + + fn execute_admin_jobs_get( + &self, + matches: &clap::ArgMatches, + request: &mut builder::AdminJobsGet, + ) -> Result<(), String> { + Ok(()) + } + + fn execute_admin_job_get( + &self, + matches: &clap::ArgMatches, + request: &mut builder::AdminJobGet, + ) -> Result<(), String> { + Ok(()) + } + + fn execute_admin_job_archive_request( + &self, + matches: &clap::ArgMatches, + request: &mut builder::AdminJobArchiveRequest, + ) -> Result<(), String> { + Ok(()) + } + + fn execute_target_create( + &self, + matches: &clap::ArgMatches, + request: &mut builder::TargetCreate, + ) -> Result<(), String> { + Ok(()) + } + + fn execute_targets_list( + &self, + matches: &clap::ArgMatches, + request: &mut builder::TargetsList, + ) -> Result<(), String> { + Ok(()) + } + + fn execute_target_redirect( + &self, + matches: &clap::ArgMatches, + request: &mut builder::TargetRedirect, + ) -> Result<(), String> { + Ok(()) + } + + fn execute_target_rename( + &self, + matches: &clap::ArgMatches, + request: &mut builder::TargetRename, + ) -> Result<(), String> { + Ok(()) + } + + fn execute_target_require_no_privilege( + &self, + matches: &clap::ArgMatches, + request: &mut builder::TargetRequireNoPrivilege, + ) -> Result<(), String> { + Ok(()) + } + + fn execute_target_require_privilege( + &self, + matches: &clap::ArgMatches, + request: &mut builder::TargetRequirePrivilege, + ) -> Result<(), String> { + Ok(()) + } + + fn execute_worker_recycle( + &self, + matches: &clap::ArgMatches, + request: &mut builder::WorkerRecycle, + ) -> Result<(), String> { + Ok(()) + } + + fn execute_control_hold( + &self, + matches: &clap::ArgMatches, + request: &mut builder::ControlHold, + ) -> Result<(), String> { + Ok(()) + } + + fn execute_control_resume( + &self, + matches: &clap::ArgMatches, + request: &mut builder::ControlResume, + ) -> Result<(), String> { + Ok(()) + } + + fn execute_factory_lease( + &self, + matches: &clap::ArgMatches, + request: &mut builder::FactoryLease, + ) -> Result<(), String> { + Ok(()) + } + + fn execute_factory_lease_renew( + &self, + matches: &clap::ArgMatches, + request: &mut builder::FactoryLeaseRenew, + ) -> Result<(), String> { + Ok(()) + } + + fn execute_factory_ping( + &self, + matches: &clap::ArgMatches, + request: &mut builder::FactoryPing, + ) -> Result<(), String> { + Ok(()) + } + + fn execute_factory_worker_create( + &self, + matches: &clap::ArgMatches, + request: &mut builder::FactoryWorkerCreate, + ) -> Result<(), String> { + Ok(()) + } - pub async fn execute_worker_task_append(&self, matches: &clap::ArgMatches) { - let mut request = self.client.worker_task_append(); - if let Some(value) = matches.get_one::("payload") { - request = request.body_map(|body| body.payload(value.clone())) - } + fn execute_factory_worker_get( + &self, + matches: &clap::ArgMatches, + request: &mut builder::FactoryWorkerGet, + ) -> Result<(), String> { + Ok(()) + } - if let Some(value) = matches.get_one::("stream") { - request = request.body_map(|body| body.stream(value.clone())) - } + fn execute_factory_worker_destroy( + &self, + matches: &clap::ArgMatches, + request: &mut builder::FactoryWorkerDestroy, + ) -> Result<(), String> { + Ok(()) + } - if let Some(value) = matches.get_one::("task") { - request = request.task(value.clone()); - } + fn execute_factory_worker_associate( + &self, + matches: &clap::ArgMatches, + request: &mut builder::FactoryWorkerAssociate, + ) -> Result<(), String> { + Ok(()) + } - if let Some(value) = matches.get_one::>("time") { - request = request.body_map(|body| body.time(value.clone())) - } + fn execute_factory_worker_append( + &self, + matches: &clap::ArgMatches, + request: &mut builder::FactoryWorkerAppend, + ) -> Result<(), String> { + Ok(()) + } - if let Some(value) = matches.get_one::("json-body") { - let body_txt = std::fs::read_to_string(value).unwrap(); - let body_value = serde_json::from_str::(&body_txt).unwrap(); - request = request.body(body_value); - } + fn execute_factory_worker_flush( + &self, + matches: &clap::ArgMatches, + request: &mut builder::FactoryWorkerFlush, + ) -> Result<(), String> { + Ok(()) + } - self.over - .execute_worker_task_append(matches, &mut request) - .unwrap(); - let result = request.send().await; - match result { - Ok(r) => { - println!("success\n{:#?}", r) - } - Err(r) => { - println!("success\n{:#?}", r) - } - } + fn execute_factory_workers( + &self, + matches: &clap::ArgMatches, + request: &mut builder::FactoryWorkers, + ) -> Result<(), String> { + Ok(()) } - pub async fn execute_worker_task_upload_chunk(&self, matches: &clap::ArgMatches) { - let mut request = self.client.worker_task_upload_chunk(); - if let Some(value) = matches.get_one::("task") { - request = request.task(value.clone()); - } + fn execute_job_get( + &self, + matches: &clap::ArgMatches, + request: &mut builder::JobGet, + ) -> Result<(), String> { + Ok(()) + } - self.over - .execute_worker_task_upload_chunk(matches, &mut request) - .unwrap(); - let result = request.send().await; - match result { - Ok(r) => { - println!("success\n{:#?}", r) - } - Err(r) => { - println!("success\n{:#?}", r) - } - } + fn execute_jobs_get( + &self, + matches: &clap::ArgMatches, + request: &mut builder::JobsGet, + ) -> Result<(), String> { + Ok(()) } - pub async fn execute_worker_task_complete(&self, matches: &clap::ArgMatches) { - let mut request = self.client.worker_task_complete(); - if let Some(value) = matches.get_one::("failed") { - request = request.body_map(|body| body.failed(value.clone())) - } + fn execute_job_submit( + &self, + matches: &clap::ArgMatches, + request: &mut builder::JobSubmit, + ) -> Result<(), String> { + Ok(()) + } - if let Some(value) = matches.get_one::("task") { - request = request.task(value.clone()); - } + fn execute_job_cancel( + &self, + matches: &clap::ArgMatches, + request: &mut builder::JobCancel, + ) -> Result<(), String> { + Ok(()) + } - if let Some(value) = matches.get_one::("json-body") { - let body_txt = std::fs::read_to_string(value).unwrap(); - let body_value = serde_json::from_str::(&body_txt).unwrap(); - request = request.body(body_value); - } + fn execute_job_upload_chunk( + &self, + matches: &clap::ArgMatches, + request: &mut builder::JobUploadChunk, + ) -> Result<(), String> { + Ok(()) + } - self.over - .execute_worker_task_complete(matches, &mut request) - .unwrap(); - let result = request.send().await; - match result { - Ok(r) => { - println!("success\n{:#?}", r) - } - Err(r) => { - println!("success\n{:#?}", r) - } - } + fn execute_job_events_get( + &self, + matches: &clap::ArgMatches, + request: &mut builder::JobEventsGet, + ) -> Result<(), String> { + Ok(()) } - pub async fn execute_worker_task_add_output(&self, matches: &clap::ArgMatches) { - let mut request = self.client.worker_task_add_output(); - if let Some(value) = matches.get_one::("path") { - request = request.body_map(|body| body.path(value.clone())) - } + fn execute_job_outputs_get( + &self, + matches: &clap::ArgMatches, + request: &mut builder::JobOutputsGet, + ) -> Result<(), String> { + Ok(()) + } - if let Some(value) = matches.get_one::("size") { - request = request.body_map(|body| body.size(value.clone())) - } + fn execute_job_output_download( + &self, + matches: &clap::ArgMatches, + request: &mut builder::JobOutputDownload, + ) -> Result<(), String> { + Ok(()) + } - if let Some(value) = matches.get_one::("task") { - request = request.task(value.clone()); - } + fn execute_job_output_publish( + &self, + matches: &clap::ArgMatches, + request: &mut builder::JobOutputPublish, + ) -> Result<(), String> { + Ok(()) + } - if let Some(value) = matches.get_one::("json-body") { - let body_txt = std::fs::read_to_string(value).unwrap(); - let body_value = serde_json::from_str::(&body_txt).unwrap(); - request = request.body(body_value); - } + fn execute_job_output_signed_url( + &self, + matches: &clap::ArgMatches, + request: &mut builder::JobOutputSignedUrl, + ) -> Result<(), String> { + Ok(()) + } - self.over - .execute_worker_task_add_output(matches, &mut request) - .unwrap(); - let result = request.send().await; - match result { - Ok(r) => { - println!("success\n{:#?}", r) - } - Err(r) => { - println!("success\n{:#?}", r) - } - } + fn execute_job_store_get_all( + &self, + matches: &clap::ArgMatches, + request: &mut builder::JobStoreGetAll, + ) -> Result<(), String> { + Ok(()) } - pub async fn execute_workers_list(&self, matches: &clap::ArgMatches) { - let mut request = self.client.workers_list(); - self.over - .execute_workers_list(matches, &mut request) - .unwrap(); - let result = request.send().await; - match result { - Ok(r) => { - println!("success\n{:#?}", r) - } - Err(r) => { - println!("success\n{:#?}", r) - } - } + fn execute_job_store_put( + &self, + matches: &clap::ArgMatches, + request: &mut builder::JobStorePut, + ) -> Result<(), String> { + Ok(()) } - pub async fn execute_workers_recycle(&self, matches: &clap::ArgMatches) { - let mut request = self.client.workers_recycle(); - self.over - .execute_workers_recycle(matches, &mut request) - .unwrap(); - let result = request.send().await; - match result { - Ok(r) => { - println!("success\n{:#?}", r) - } - Err(r) => { - println!("success\n{:#?}", r) - } - } + fn execute_public_file_download( + &self, + matches: &clap::ArgMatches, + request: &mut builder::PublicFileDownload, + ) -> Result<(), String> { + Ok(()) } -} -pub trait CliOverride { - fn execute_control_hold( + fn execute_quota( &self, matches: &clap::ArgMatches, - request: &mut builder::ControlHold, + request: &mut builder::Quota, ) -> Result<(), String> { Ok(()) } - fn execute_control_resume( + fn execute_users_list( &self, matches: &clap::ArgMatches, - request: &mut builder::ControlResume, + request: &mut builder::UsersList, ) -> Result<(), String> { Ok(()) } - fn execute_task_get( + fn execute_user_create( &self, matches: &clap::ArgMatches, - request: &mut builder::TaskGet, + request: &mut builder::UserCreate, ) -> Result<(), String> { Ok(()) } - fn execute_tasks_get( + fn execute_user_get( &self, matches: &clap::ArgMatches, - request: &mut builder::TasksGet, + request: &mut builder::UserGet, ) -> Result<(), String> { Ok(()) } - fn execute_task_submit( + fn execute_user_privilege_grant( &self, matches: &clap::ArgMatches, - request: &mut builder::TaskSubmit, + request: &mut builder::UserPrivilegeGrant, ) -> Result<(), String> { Ok(()) } - fn execute_task_events_get( + fn execute_user_privilege_revoke( &self, matches: &clap::ArgMatches, - request: &mut builder::TaskEventsGet, + request: &mut builder::UserPrivilegeRevoke, ) -> Result<(), String> { Ok(()) } - fn execute_task_outputs_get( + fn execute_whoami( &self, matches: &clap::ArgMatches, - request: &mut builder::TaskOutputsGet, + request: &mut builder::Whoami, ) -> Result<(), String> { Ok(()) } - fn execute_task_output_download( + fn execute_worker_bootstrap( &self, matches: &clap::ArgMatches, - request: &mut builder::TaskOutputDownload, + request: &mut builder::WorkerBootstrap, ) -> Result<(), String> { Ok(()) } - fn execute_user_create( + fn execute_worker_job_upload_chunk( &self, matches: &clap::ArgMatches, - request: &mut builder::UserCreate, + request: &mut builder::WorkerJobUploadChunk, ) -> Result<(), String> { Ok(()) } - fn execute_whoami( + fn execute_worker_job_complete( &self, matches: &clap::ArgMatches, - request: &mut builder::Whoami, + request: &mut builder::WorkerJobComplete, ) -> Result<(), String> { Ok(()) } - fn execute_whoami_put_name( + fn execute_worker_job_input_download( &self, matches: &clap::ArgMatches, - request: &mut builder::WhoamiPutName, + request: &mut builder::WorkerJobInputDownload, ) -> Result<(), String> { Ok(()) } - fn execute_worker_bootstrap( + fn execute_worker_job_quota( &self, matches: &clap::ArgMatches, - request: &mut builder::WorkerBootstrap, + request: &mut builder::WorkerJobQuota, ) -> Result<(), String> { Ok(()) } - fn execute_worker_ping( + fn execute_worker_job_store_get( &self, matches: &clap::ArgMatches, - request: &mut builder::WorkerPing, + request: &mut builder::WorkerJobStoreGet, ) -> Result<(), String> { Ok(()) } - fn execute_worker_task_append( + fn execute_worker_job_store_put( &self, matches: &clap::ArgMatches, - request: &mut builder::WorkerTaskAppend, + request: &mut builder::WorkerJobStorePut, ) -> Result<(), String> { Ok(()) } - fn execute_worker_task_upload_chunk( + fn execute_worker_task_append( &self, matches: &clap::ArgMatches, - request: &mut builder::WorkerTaskUploadChunk, + request: &mut builder::WorkerTaskAppend, ) -> Result<(), String> { Ok(()) } @@ -931,10 +3192,10 @@ pub trait CliOverride { Ok(()) } - fn execute_worker_task_add_output( + fn execute_worker_ping( &self, matches: &clap::ArgMatches, - request: &mut builder::WorkerTaskAddOutput, + request: &mut builder::WorkerPing, ) -> Result<(), String> { Ok(()) } @@ -954,55 +3215,157 @@ pub trait CliOverride { ) -> Result<(), String> { Ok(()) } + + fn execute_job_add_input( + &self, + matches: &clap::ArgMatches, + request: &mut builder::JobAddInput, + ) -> Result<(), String> { + Ok(()) + } + + fn execute_worker_job_append( + &self, + matches: &clap::ArgMatches, + request: &mut builder::WorkerJobAppend, + ) -> Result<(), String> { + Ok(()) + } + + fn execute_worker_job_add_output( + &self, + matches: &clap::ArgMatches, + request: &mut builder::WorkerJobAddOutput, + ) -> Result<(), String> { + Ok(()) + } } impl CliOverride for () {} #[derive(Copy, Clone, Debug)] pub enum CliCommand { + FactoryCreate, + AdminJobsGet, + AdminJobGet, + AdminJobArchiveRequest, + TargetCreate, + TargetsList, + TargetRedirect, + TargetRename, + TargetRequireNoPrivilege, + TargetRequirePrivilege, + WorkerRecycle, ControlHold, ControlResume, - TaskGet, - TasksGet, - TaskSubmit, - TaskEventsGet, - TaskOutputsGet, - TaskOutputDownload, + FactoryLease, + FactoryLeaseRenew, + FactoryPing, + FactoryWorkerCreate, + FactoryWorkerGet, + FactoryWorkerDestroy, + FactoryWorkerAssociate, + FactoryWorkerAppend, + FactoryWorkerFlush, + FactoryWorkers, + JobGet, + JobsGet, + JobSubmit, + JobCancel, + JobUploadChunk, + JobEventsGet, + JobOutputsGet, + JobOutputDownload, + JobOutputPublish, + JobOutputSignedUrl, + JobStoreGetAll, + JobStorePut, + PublicFileDownload, + Quota, + UsersList, UserCreate, + UserGet, + UserPrivilegeGrant, + UserPrivilegeRevoke, Whoami, - WhoamiPutName, WorkerBootstrap, - WorkerPing, + WorkerJobUploadChunk, + WorkerJobComplete, + WorkerJobInputDownload, + WorkerJobQuota, + WorkerJobStoreGet, + WorkerJobStorePut, WorkerTaskAppend, - WorkerTaskUploadChunk, WorkerTaskComplete, - WorkerTaskAddOutput, + WorkerPing, WorkersList, WorkersRecycle, + JobAddInput, + WorkerJobAppend, + WorkerJobAddOutput, } impl CliCommand { pub fn iter() -> impl Iterator { vec![ + CliCommand::FactoryCreate, + CliCommand::AdminJobsGet, + CliCommand::AdminJobGet, + CliCommand::AdminJobArchiveRequest, + CliCommand::TargetCreate, + CliCommand::TargetsList, + CliCommand::TargetRedirect, + CliCommand::TargetRename, + CliCommand::TargetRequireNoPrivilege, + CliCommand::TargetRequirePrivilege, + CliCommand::WorkerRecycle, CliCommand::ControlHold, CliCommand::ControlResume, - CliCommand::TaskGet, - CliCommand::TasksGet, - CliCommand::TaskSubmit, - CliCommand::TaskEventsGet, - CliCommand::TaskOutputsGet, - CliCommand::TaskOutputDownload, + CliCommand::FactoryLease, + CliCommand::FactoryLeaseRenew, + CliCommand::FactoryPing, + CliCommand::FactoryWorkerCreate, + CliCommand::FactoryWorkerGet, + CliCommand::FactoryWorkerDestroy, + CliCommand::FactoryWorkerAssociate, + CliCommand::FactoryWorkerAppend, + CliCommand::FactoryWorkerFlush, + CliCommand::FactoryWorkers, + CliCommand::JobGet, + CliCommand::JobsGet, + CliCommand::JobSubmit, + CliCommand::JobCancel, + CliCommand::JobUploadChunk, + CliCommand::JobEventsGet, + CliCommand::JobOutputsGet, + CliCommand::JobOutputDownload, + CliCommand::JobOutputPublish, + CliCommand::JobOutputSignedUrl, + CliCommand::JobStoreGetAll, + CliCommand::JobStorePut, + CliCommand::PublicFileDownload, + CliCommand::Quota, + CliCommand::UsersList, CliCommand::UserCreate, + CliCommand::UserGet, + CliCommand::UserPrivilegeGrant, + CliCommand::UserPrivilegeRevoke, CliCommand::Whoami, - CliCommand::WhoamiPutName, CliCommand::WorkerBootstrap, - CliCommand::WorkerPing, + CliCommand::WorkerJobUploadChunk, + CliCommand::WorkerJobComplete, + CliCommand::WorkerJobInputDownload, + CliCommand::WorkerJobQuota, + CliCommand::WorkerJobStoreGet, + CliCommand::WorkerJobStorePut, CliCommand::WorkerTaskAppend, - CliCommand::WorkerTaskUploadChunk, CliCommand::WorkerTaskComplete, - CliCommand::WorkerTaskAddOutput, + CliCommand::WorkerPing, CliCommand::WorkersList, CliCommand::WorkersRecycle, + CliCommand::JobAddInput, + CliCommand::WorkerJobAppend, + CliCommand::WorkerJobAddOutput, ] .into_iter() } diff --git a/progenitor-impl/tests/output/buildomat-httpmock.out b/progenitor-impl/tests/output/buildomat-httpmock.out index 1d25fd9c..1a04f61f 100644 --- a/progenitor-impl/tests/output/buildomat-httpmock.out +++ b/progenitor-impl/tests/output/buildomat-httpmock.out @@ -4,23 +4,27 @@ pub mod operations { #![doc = r" its inner type with a call to `into_inner()`. This can"] #![doc = r" be used to explicitly deviate from permitted values."] use sdk::*; - pub struct ControlHoldWhen(httpmock::When); - impl ControlHoldWhen { + pub struct FactoryCreateWhen(httpmock::When); + impl FactoryCreateWhen { pub fn new(inner: httpmock::When) -> Self { Self( inner .method(httpmock::Method::POST) - .path_matches(regex::Regex::new("^/v1/control/hold$").unwrap()), + .path_matches(regex::Regex::new("^/0/admin/factory$").unwrap()), ) } pub fn into_inner(self) -> httpmock::When { self.0 } + + pub fn body(self, value: &types::FactoryCreate) -> Self { + Self(self.0.json_body_obj(value)) + } } - pub struct ControlHoldThen(httpmock::Then); - impl ControlHoldThen { + pub struct FactoryCreateThen(httpmock::Then); + impl FactoryCreateThen { pub fn new(inner: httpmock::Then) -> Self { Self(inner) } @@ -29,53 +33,43 @@ pub mod operations { self.0 } - pub fn ok(self, value: ()) -> Self { + pub fn created(self, value: &types::FactoryCreateResult) -> Self { Self( self.0 - .status(200u16) + .status(201u16) .header("content-type", "application/json") .json_body_obj(value), ) } - } - pub struct ControlResumeWhen(httpmock::When); - impl ControlResumeWhen { - pub fn new(inner: httpmock::When) -> Self { + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); Self( - inner - .method(httpmock::Method::POST) - .path_matches(regex::Regex::new("^/v1/control/resume$").unwrap()), + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), ) } - pub fn into_inner(self) -> httpmock::When { - self.0 - } - } - - pub struct ControlResumeThen(httpmock::Then); - impl ControlResumeThen { - pub fn new(inner: httpmock::Then) -> Self { - Self(inner) - } - - pub fn into_inner(self) -> httpmock::Then { - self.0 - } - - pub fn ok(self) -> Self { - Self(self.0.status(200u16)) + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) } } - pub struct TaskGetWhen(httpmock::When); - impl TaskGetWhen { + pub struct AdminJobsGetWhen(httpmock::When); + impl AdminJobsGetWhen { pub fn new(inner: httpmock::When) -> Self { Self( inner .method(httpmock::Method::GET) - .path_matches(regex::Regex::new("^/v1/task/[^/]*$").unwrap()), + .path_matches(regex::Regex::new("^/0/admin/jobs$").unwrap()), ) } @@ -83,14 +77,41 @@ pub mod operations { self.0 } - pub fn task(self, value: &str) -> Self { - let re = regex::Regex::new(&format!("^/v1/task/{}$", value.to_string())).unwrap(); - Self(self.0.path_matches(re)) + pub fn active(self, value: T) -> Self + where + T: Into>, + { + if let Some(value) = value.into() { + Self(self.0.query_param("active", value.to_string())) + } else { + Self(self.0.matches(|req| { + req.query_params + .as_ref() + .and_then(|qs| qs.iter().find(|(key, _)| key == "active")) + .is_none() + })) + } + } + + pub fn completed(self, value: T) -> Self + where + T: Into>, + { + if let Some(value) = value.into() { + Self(self.0.query_param("completed", value.to_string())) + } else { + Self(self.0.matches(|req| { + req.query_params + .as_ref() + .and_then(|qs| qs.iter().find(|(key, _)| key == "completed")) + .is_none() + })) + } } } - pub struct TaskGetThen(httpmock::Then); - impl TaskGetThen { + pub struct AdminJobsGetThen(httpmock::Then); + impl AdminJobsGetThen { pub fn new(inner: httpmock::Then) -> Self { Self(inner) } @@ -99,7 +120,7 @@ pub mod operations { self.0 } - pub fn ok(self, value: &types::Task) -> Self { + pub fn ok(self, value: &Vec) -> Self { Self( self.0 .status(200u16) @@ -107,25 +128,50 @@ pub mod operations { .json_body_obj(value), ) } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } } - pub struct TasksGetWhen(httpmock::When); - impl TasksGetWhen { + pub struct AdminJobGetWhen(httpmock::When); + impl AdminJobGetWhen { pub fn new(inner: httpmock::When) -> Self { Self( inner .method(httpmock::Method::GET) - .path_matches(regex::Regex::new("^/v1/tasks$").unwrap()), + .path_matches(regex::Regex::new("^/0/admin/jobs/[^/]*$").unwrap()), ) } pub fn into_inner(self) -> httpmock::When { self.0 } + + pub fn job(self, value: &str) -> Self { + let re = regex::Regex::new(&format!("^/0/admin/jobs/{}$", value.to_string())).unwrap(); + Self(self.0.path_matches(re)) + } } - pub struct TasksGetThen(httpmock::Then); - impl TasksGetThen { + pub struct AdminJobGetThen(httpmock::Then); + impl AdminJobGetThen { pub fn new(inner: httpmock::Then) -> Self { Self(inner) } @@ -134,7 +180,7 @@ pub mod operations { self.0 } - pub fn ok(self, value: &Vec) -> Self { + pub fn ok(self, value: &types::Job) -> Self { Self( self.0 .status(200u16) @@ -142,15 +188,35 @@ pub mod operations { .json_body_obj(value), ) } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } } - pub struct TaskSubmitWhen(httpmock::When); - impl TaskSubmitWhen { + pub struct AdminJobArchiveRequestWhen(httpmock::When); + impl AdminJobArchiveRequestWhen { pub fn new(inner: httpmock::When) -> Self { Self( inner .method(httpmock::Method::POST) - .path_matches(regex::Regex::new("^/v1/tasks$").unwrap()), + .path_matches(regex::Regex::new("^/0/admin/jobs/[^/]*/archive$").unwrap()), ) } @@ -158,13 +224,15 @@ pub mod operations { self.0 } - pub fn body(self, value: &types::TaskSubmit) -> Self { - Self(self.0.json_body_obj(value)) + pub fn job(self, value: &str) -> Self { + let re = regex::Regex::new(&format!("^/0/admin/jobs/{}/archive$", value.to_string())) + .unwrap(); + Self(self.0.path_matches(re)) } } - pub struct TaskSubmitThen(httpmock::Then); - impl TaskSubmitThen { + pub struct AdminJobArchiveRequestThen(httpmock::Then); + impl AdminJobArchiveRequestThen { pub fn new(inner: httpmock::Then) -> Self { Self(inner) } @@ -173,23 +241,38 @@ pub mod operations { self.0 } - pub fn created(self, value: &types::TaskSubmitResult) -> Self { + pub fn no_content(self) -> Self { + Self(self.0.status(204u16)) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); Self( self.0 - .status(201u16) + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) .header("content-type", "application/json") .json_body_obj(value), ) } } - pub struct TaskEventsGetWhen(httpmock::When); - impl TaskEventsGetWhen { + pub struct TargetCreateWhen(httpmock::When); + impl TargetCreateWhen { pub fn new(inner: httpmock::When) -> Self { Self( inner - .method(httpmock::Method::GET) - .path_matches(regex::Regex::new("^/v1/tasks/[^/]*/events$").unwrap()), + .method(httpmock::Method::POST) + .path_matches(regex::Regex::new("^/0/admin/target$").unwrap()), ) } @@ -197,31 +280,13 @@ pub mod operations { self.0 } - pub fn task(self, value: &str) -> Self { - let re = - regex::Regex::new(&format!("^/v1/tasks/{}/events$", value.to_string())).unwrap(); - Self(self.0.path_matches(re)) - } - - pub fn minseq(self, value: T) -> Self - where - T: Into>, - { - if let Some(value) = value.into() { - Self(self.0.query_param("minseq", value.to_string())) - } else { - Self(self.0.matches(|req| { - req.query_params - .as_ref() - .and_then(|qs| qs.iter().find(|(key, _)| key == "minseq")) - .is_none() - })) - } + pub fn body(self, value: &types::TargetCreate) -> Self { + Self(self.0.json_body_obj(value)) } } - pub struct TaskEventsGetThen(httpmock::Then); - impl TaskEventsGetThen { + pub struct TargetCreateThen(httpmock::Then); + impl TargetCreateThen { pub fn new(inner: httpmock::Then) -> Self { Self(inner) } @@ -230,39 +295,53 @@ pub mod operations { self.0 } - pub fn ok(self, value: &Vec) -> Self { + pub fn created(self, value: &types::TargetCreateResult) -> Self { Self( self.0 - .status(200u16) + .status(201u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) .header("content-type", "application/json") .json_body_obj(value), ) } } - pub struct TaskOutputsGetWhen(httpmock::When); - impl TaskOutputsGetWhen { + pub struct TargetsListWhen(httpmock::When); + impl TargetsListWhen { pub fn new(inner: httpmock::When) -> Self { Self( inner .method(httpmock::Method::GET) - .path_matches(regex::Regex::new("^/v1/tasks/[^/]*/outputs$").unwrap()), + .path_matches(regex::Regex::new("^/0/admin/targets$").unwrap()), ) } pub fn into_inner(self) -> httpmock::When { self.0 } - - pub fn task(self, value: &str) -> Self { - let re = - regex::Regex::new(&format!("^/v1/tasks/{}/outputs$", value.to_string())).unwrap(); - Self(self.0.path_matches(re)) - } } - pub struct TaskOutputsGetThen(httpmock::Then); - impl TaskOutputsGetThen { + pub struct TargetsListThen(httpmock::Then); + impl TargetsListThen { pub fn new(inner: httpmock::Then) -> Self { Self(inner) } @@ -271,7 +350,7 @@ pub mod operations { self.0 } - pub fn ok(self, value: &Vec) -> Self { + pub fn ok(self, value: &Vec) -> Self { Self( self.0 .status(200u16) @@ -279,15 +358,35 @@ pub mod operations { .json_body_obj(value), ) } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } } - pub struct TaskOutputDownloadWhen(httpmock::When); - impl TaskOutputDownloadWhen { + pub struct TargetRedirectWhen(httpmock::When); + impl TargetRedirectWhen { pub fn new(inner: httpmock::When) -> Self { Self( inner - .method(httpmock::Method::GET) - .path_matches(regex::Regex::new("^/v1/tasks/[^/]*/outputs/[^/]*$").unwrap()), + .method(httpmock::Method::PUT) + .path_matches(regex::Regex::new("^/0/admin/targets/[^/]*/redirect$").unwrap()), ) } @@ -295,21 +394,22 @@ pub mod operations { self.0 } - pub fn task(self, value: &str) -> Self { - let re = regex::Regex::new(&format!("^/v1/tasks/{}/outputs/.*$", value.to_string())) - .unwrap(); + pub fn target(self, value: &str) -> Self { + let re = regex::Regex::new(&format!( + "^/0/admin/targets/{}/redirect$", + value.to_string() + )) + .unwrap(); Self(self.0.path_matches(re)) } - pub fn output(self, value: &str) -> Self { - let re = regex::Regex::new(&format!("^/v1/tasks/.*/outputs/{}$", value.to_string())) - .unwrap(); - Self(self.0.path_matches(re)) + pub fn body(self, value: &types::TargetRedirect) -> Self { + Self(self.0.json_body_obj(value)) } } - pub struct TaskOutputDownloadThen(httpmock::Then); - impl TaskOutputDownloadThen { + pub struct TargetRedirectThen(httpmock::Then); + impl TargetRedirectThen { pub fn new(inner: httpmock::Then) -> Self { Self(inner) } @@ -318,24 +418,38 @@ pub mod operations { self.0 } - pub fn success(self, status: u16, value: serde_json::Value) -> Self { - assert_eq!(status / 100u16, 2u16); + pub fn no_content(self) -> Self { + Self(self.0.status(204u16)) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); Self( self.0 .status(status) .header("content-type", "application/json") - .json_body(value), + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), ) } } - pub struct UserCreateWhen(httpmock::When); - impl UserCreateWhen { + pub struct TargetRenameWhen(httpmock::When); + impl TargetRenameWhen { pub fn new(inner: httpmock::When) -> Self { Self( inner .method(httpmock::Method::POST) - .path_matches(regex::Regex::new("^/v1/users$").unwrap()), + .path_matches(regex::Regex::new("^/0/admin/targets/[^/]*/rename$").unwrap()), ) } @@ -343,13 +457,19 @@ pub mod operations { self.0 } - pub fn body(self, value: &types::UserCreate) -> Self { + pub fn target(self, value: &str) -> Self { + let re = regex::Regex::new(&format!("^/0/admin/targets/{}/rename$", value.to_string())) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn body(self, value: &types::TargetRename) -> Self { Self(self.0.json_body_obj(value)) } } - pub struct UserCreateThen(httpmock::Then); - impl UserCreateThen { + pub struct TargetRenameThen(httpmock::Then); + impl TargetRenameThen { pub fn new(inner: httpmock::Then) -> Self { Self(inner) } @@ -358,7 +478,7 @@ pub mod operations { self.0 } - pub fn created(self, value: &types::UserCreateResult) -> Self { + pub fn created(self, value: &types::TargetCreateResult) -> Self { Self( self.0 .status(201u16) @@ -366,25 +486,52 @@ pub mod operations { .json_body_obj(value), ) } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } } - pub struct WhoamiWhen(httpmock::When); - impl WhoamiWhen { + pub struct TargetRequireNoPrivilegeWhen(httpmock::When); + impl TargetRequireNoPrivilegeWhen { pub fn new(inner: httpmock::When) -> Self { Self( inner - .method(httpmock::Method::GET) - .path_matches(regex::Regex::new("^/v1/whoami$").unwrap()), + .method(httpmock::Method::DELETE) + .path_matches(regex::Regex::new("^/0/admin/targets/[^/]*/require$").unwrap()), ) } pub fn into_inner(self) -> httpmock::When { self.0 } + + pub fn target(self, value: &str) -> Self { + let re = + regex::Regex::new(&format!("^/0/admin/targets/{}/require$", value.to_string())) + .unwrap(); + Self(self.0.path_matches(re)) + } } - pub struct WhoamiThen(httpmock::Then); - impl WhoamiThen { + pub struct TargetRequireNoPrivilegeThen(httpmock::Then); + impl TargetRequireNoPrivilegeThen { pub fn new(inner: httpmock::Then) -> Self { Self(inner) } @@ -393,23 +540,38 @@ pub mod operations { self.0 } - pub fn ok(self, value: &types::WhoamiResult) -> Self { + pub fn no_content(self) -> Self { + Self(self.0.status(204u16)) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); Self( self.0 - .status(200u16) + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) .header("content-type", "application/json") .json_body_obj(value), ) } } - pub struct WhoamiPutNameWhen(httpmock::When); - impl WhoamiPutNameWhen { + pub struct TargetRequirePrivilegeWhen(httpmock::When); + impl TargetRequirePrivilegeWhen { pub fn new(inner: httpmock::When) -> Self { Self( - inner - .method(httpmock::Method::PUT) - .path_matches(regex::Regex::new("^/v1/whoami/name$").unwrap()), + inner.method(httpmock::Method::PUT).path_matches( + regex::Regex::new("^/0/admin/targets/[^/]*/require/[^/]*$").unwrap(), + ), ) } @@ -417,13 +579,27 @@ pub mod operations { self.0 } - pub fn body(self, value: String) -> Self { - Self(self.0.body(value)) + pub fn target(self, value: &str) -> Self { + let re = regex::Regex::new(&format!( + "^/0/admin/targets/{}/require/.*$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn privilege(self, value: &str) -> Self { + let re = regex::Regex::new(&format!( + "^/0/admin/targets/.*/require/{}$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) } } - pub struct WhoamiPutNameThen(httpmock::Then); - impl WhoamiPutNameThen { + pub struct TargetRequirePrivilegeThen(httpmock::Then); + impl TargetRequirePrivilegeThen { pub fn new(inner: httpmock::Then) -> Self { Self(inner) } @@ -432,18 +608,38 @@ pub mod operations { self.0 } - pub fn ok(self) -> Self { - Self(self.0.status(200u16)) + pub fn no_content(self) -> Self { + Self(self.0.status(204u16)) } - } - pub struct WorkerBootstrapWhen(httpmock::When); - impl WorkerBootstrapWhen { - pub fn new(inner: httpmock::When) -> Self { + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); Self( - inner - .method(httpmock::Method::POST) - .path_matches(regex::Regex::new("^/v1/worker/bootstrap$").unwrap()), + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct WorkerRecycleWhen(httpmock::When); + impl WorkerRecycleWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::POST) + .path_matches(regex::Regex::new("^/0/admin/worker/[^/]*/recycle$").unwrap()), ) } @@ -451,13 +647,15 @@ pub mod operations { self.0 } - pub fn body(self, value: &types::WorkerBootstrap) -> Self { - Self(self.0.json_body_obj(value)) + pub fn worker(self, value: &str) -> Self { + let re = regex::Regex::new(&format!("^/0/admin/worker/{}/recycle$", value.to_string())) + .unwrap(); + Self(self.0.path_matches(re)) } } - pub struct WorkerBootstrapThen(httpmock::Then); - impl WorkerBootstrapThen { + pub struct WorkerRecycleThen(httpmock::Then); + impl WorkerRecycleThen { pub fn new(inner: httpmock::Then) -> Self { Self(inner) } @@ -466,23 +664,38 @@ pub mod operations { self.0 } - pub fn created(self, value: &types::WorkerBootstrapResult) -> Self { + pub fn no_content(self) -> Self { + Self(self.0.status(204u16)) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); Self( self.0 - .status(201u16) + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) .header("content-type", "application/json") .json_body_obj(value), ) } } - pub struct WorkerPingWhen(httpmock::When); - impl WorkerPingWhen { + pub struct ControlHoldWhen(httpmock::When); + impl ControlHoldWhen { pub fn new(inner: httpmock::When) -> Self { Self( inner - .method(httpmock::Method::GET) - .path_matches(regex::Regex::new("^/v1/worker/ping$").unwrap()), + .method(httpmock::Method::POST) + .path_matches(regex::Regex::new("^/0/control/hold$").unwrap()), ) } @@ -491,8 +704,8 @@ pub mod operations { } } - pub struct WorkerPingThen(httpmock::Then); - impl WorkerPingThen { + pub struct ControlHoldThen(httpmock::Then); + impl ControlHoldThen { pub fn new(inner: httpmock::Then) -> Self { Self(inner) } @@ -501,43 +714,48 @@ pub mod operations { self.0 } - pub fn ok(self, value: &types::WorkerPingResult) -> Self { + pub fn no_content(self) -> Self { + Self(self.0.status(204u16)) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); Self( self.0 - .status(200u16) + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) .header("content-type", "application/json") .json_body_obj(value), ) } } - pub struct WorkerTaskAppendWhen(httpmock::When); - impl WorkerTaskAppendWhen { + pub struct ControlResumeWhen(httpmock::When); + impl ControlResumeWhen { pub fn new(inner: httpmock::When) -> Self { Self( inner .method(httpmock::Method::POST) - .path_matches(regex::Regex::new("^/v1/worker/task/[^/]*/append$").unwrap()), + .path_matches(regex::Regex::new("^/0/control/resume$").unwrap()), ) } pub fn into_inner(self) -> httpmock::When { self.0 } - - pub fn task(self, value: &str) -> Self { - let re = regex::Regex::new(&format!("^/v1/worker/task/{}/append$", value.to_string())) - .unwrap(); - Self(self.0.path_matches(re)) - } - - pub fn body(self, value: &types::WorkerAppendTask) -> Self { - Self(self.0.json_body_obj(value)) - } } - pub struct WorkerTaskAppendThen(httpmock::Then); - impl WorkerTaskAppendThen { + pub struct ControlResumeThen(httpmock::Then); + impl ControlResumeThen { pub fn new(inner: httpmock::Then) -> Self { Self(inner) } @@ -546,18 +764,38 @@ pub mod operations { self.0 } - pub fn created(self) -> Self { - Self(self.0.status(201u16)) + pub fn no_content(self) -> Self { + Self(self.0.status(204u16)) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) } } - pub struct WorkerTaskUploadChunkWhen(httpmock::When); - impl WorkerTaskUploadChunkWhen { + pub struct FactoryLeaseWhen(httpmock::When); + impl FactoryLeaseWhen { pub fn new(inner: httpmock::When) -> Self { Self( inner .method(httpmock::Method::POST) - .path_matches(regex::Regex::new("^/v1/worker/task/[^/]*/chunk$").unwrap()), + .path_matches(regex::Regex::new("^/0/factory/lease$").unwrap()), ) } @@ -565,19 +803,13 @@ pub mod operations { self.0 } - pub fn task(self, value: &str) -> Self { - let re = regex::Regex::new(&format!("^/v1/worker/task/{}/chunk$", value.to_string())) - .unwrap(); - Self(self.0.path_matches(re)) - } - - pub fn body(self, value: serde_json::Value) -> Self { - Self(self.0.json_body(value)) + pub fn body(self, value: &types::FactoryWhatsNext) -> Self { + Self(self.0.json_body_obj(value)) } } - pub struct WorkerTaskUploadChunkThen(httpmock::Then); - impl WorkerTaskUploadChunkThen { + pub struct FactoryLeaseThen(httpmock::Then); + impl FactoryLeaseThen { pub fn new(inner: httpmock::Then) -> Self { Self(inner) } @@ -586,23 +818,43 @@ pub mod operations { self.0 } - pub fn created(self, value: &types::UploadedChunk) -> Self { + pub fn ok(self, value: &types::FactoryLeaseResult) -> Self { Self( self.0 - .status(201u16) + .status(200u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) .header("content-type", "application/json") .json_body_obj(value), ) } } - pub struct WorkerTaskCompleteWhen(httpmock::When); - impl WorkerTaskCompleteWhen { + pub struct FactoryLeaseRenewWhen(httpmock::When); + impl FactoryLeaseRenewWhen { pub fn new(inner: httpmock::When) -> Self { Self( inner .method(httpmock::Method::POST) - .path_matches(regex::Regex::new("^/v1/worker/task/[^/]*/complete$").unwrap()), + .path_matches(regex::Regex::new("^/0/factory/lease/[^/]*$").unwrap()), ) } @@ -610,20 +862,70 @@ pub mod operations { self.0 } - pub fn task(self, value: &str) -> Self { + pub fn job(self, value: &str) -> Self { let re = - regex::Regex::new(&format!("^/v1/worker/task/{}/complete$", value.to_string())) - .unwrap(); + regex::Regex::new(&format!("^/0/factory/lease/{}$", value.to_string())).unwrap(); Self(self.0.path_matches(re)) } + } - pub fn body(self, value: &types::WorkerCompleteTask) -> Self { - Self(self.0.json_body_obj(value)) + pub struct FactoryLeaseRenewThen(httpmock::Then); + impl FactoryLeaseRenewThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn ok(self, value: bool) -> Self { + Self( + self.0 + .status(200u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) } } - pub struct WorkerTaskCompleteThen(httpmock::Then); - impl WorkerTaskCompleteThen { + pub struct FactoryPingWhen(httpmock::When); + impl FactoryPingWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::GET) + .path_matches(regex::Regex::new("^/0/factory/ping$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + } + + pub struct FactoryPingThen(httpmock::Then); + impl FactoryPingThen { pub fn new(inner: httpmock::Then) -> Self { Self(inner) } @@ -632,18 +934,43 @@ pub mod operations { self.0 } - pub fn ok(self) -> Self { - Self(self.0.status(200u16)) + pub fn ok(self, value: &types::FactoryPingResult) -> Self { + Self( + self.0 + .status(200u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) } } - pub struct WorkerTaskAddOutputWhen(httpmock::When); - impl WorkerTaskAddOutputWhen { + pub struct FactoryWorkerCreateWhen(httpmock::When); + impl FactoryWorkerCreateWhen { pub fn new(inner: httpmock::When) -> Self { Self( inner .method(httpmock::Method::POST) - .path_matches(regex::Regex::new("^/v1/worker/task/[^/]*/output$").unwrap()), + .path_matches(regex::Regex::new("^/0/factory/worker$").unwrap()), ) } @@ -651,19 +978,13 @@ pub mod operations { self.0 } - pub fn task(self, value: &str) -> Self { - let re = regex::Regex::new(&format!("^/v1/worker/task/{}/output$", value.to_string())) - .unwrap(); - Self(self.0.path_matches(re)) - } - - pub fn body(self, value: &types::WorkerAddOutput) -> Self { + pub fn body(self, value: &types::FactoryWorkerCreate) -> Self { Self(self.0.json_body_obj(value)) } } - pub struct WorkerTaskAddOutputThen(httpmock::Then); - impl WorkerTaskAddOutputThen { + pub struct FactoryWorkerCreateThen(httpmock::Then); + impl FactoryWorkerCreateThen { pub fn new(inner: httpmock::Then) -> Self { Self(inner) } @@ -672,28 +993,59 @@ pub mod operations { self.0 } - pub fn created(self) -> Self { - Self(self.0.status(201u16)) + pub fn created(self, value: &types::FactoryWorker) -> Self { + Self( + self.0 + .status(201u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) } } - pub struct WorkersListWhen(httpmock::When); - impl WorkersListWhen { + pub struct FactoryWorkerGetWhen(httpmock::When); + impl FactoryWorkerGetWhen { pub fn new(inner: httpmock::When) -> Self { Self( inner .method(httpmock::Method::GET) - .path_matches(regex::Regex::new("^/v1/workers$").unwrap()), + .path_matches(regex::Regex::new("^/0/factory/worker/[^/]*$").unwrap()), ) } pub fn into_inner(self) -> httpmock::When { self.0 } + + pub fn worker(self, value: &str) -> Self { + let re = + regex::Regex::new(&format!("^/0/factory/worker/{}$", value.to_string())).unwrap(); + Self(self.0.path_matches(re)) + } } - pub struct WorkersListThen(httpmock::Then); - impl WorkersListThen { + pub struct FactoryWorkerGetThen(httpmock::Then); + impl FactoryWorkerGetThen { pub fn new(inner: httpmock::Then) -> Self { Self(inner) } @@ -702,7 +1054,7 @@ pub mod operations { self.0 } - pub fn ok(self, value: &types::WorkersResult) -> Self { + pub fn ok(self, value: &types::FactoryWorkerResult) -> Self { Self( self.0 .status(200u16) @@ -710,25 +1062,51 @@ pub mod operations { .json_body_obj(value), ) } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } } - pub struct WorkersRecycleWhen(httpmock::When); - impl WorkersRecycleWhen { + pub struct FactoryWorkerDestroyWhen(httpmock::When); + impl FactoryWorkerDestroyWhen { pub fn new(inner: httpmock::When) -> Self { Self( inner - .method(httpmock::Method::POST) - .path_matches(regex::Regex::new("^/v1/workers/recycle$").unwrap()), + .method(httpmock::Method::DELETE) + .path_matches(regex::Regex::new("^/0/factory/worker/[^/]*$").unwrap()), ) } pub fn into_inner(self) -> httpmock::When { self.0 } + + pub fn worker(self, value: &str) -> Self { + let re = + regex::Regex::new(&format!("^/0/factory/worker/{}$", value.to_string())).unwrap(); + Self(self.0.path_matches(re)) + } } - pub struct WorkersRecycleThen(httpmock::Then); - impl WorkersRecycleThen { + pub struct FactoryWorkerDestroyThen(httpmock::Then); + impl FactoryWorkerDestroyThen { pub fn new(inner: httpmock::Then) -> Self { Self(inner) } @@ -737,168 +1115,3073 @@ pub mod operations { self.0 } - pub fn ok(self) -> Self { - Self(self.0.status(200u16)) + pub fn ok(self, value: bool) -> Self { + Self( + self.0 + .status(200u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) } - } -} + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct FactoryWorkerAssociateWhen(httpmock::When); + impl FactoryWorkerAssociateWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::PATCH) + .path_matches(regex::Regex::new("^/0/factory/worker/[^/]*$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn worker(self, value: &str) -> Self { + let re = + regex::Regex::new(&format!("^/0/factory/worker/{}$", value.to_string())).unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn body(self, value: &types::FactoryWorkerAssociate) -> Self { + Self(self.0.json_body_obj(value)) + } + } + + pub struct FactoryWorkerAssociateThen(httpmock::Then); + impl FactoryWorkerAssociateThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn no_content(self) -> Self { + Self(self.0.status(204u16)) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct FactoryWorkerAppendWhen(httpmock::When); + impl FactoryWorkerAppendWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::POST) + .path_matches(regex::Regex::new("^/0/factory/worker/[^/]*/append$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn worker(self, value: &str) -> Self { + let re = + regex::Regex::new(&format!("^/0/factory/worker/{}/append$", value.to_string())) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn body(self, value: &types::FactoryWorkerAppend) -> Self { + Self(self.0.json_body_obj(value)) + } + } + + pub struct FactoryWorkerAppendThen(httpmock::Then); + impl FactoryWorkerAppendThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn ok(self, value: &types::FactoryWorkerAppendResult) -> Self { + Self( + self.0 + .status(200u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct FactoryWorkerFlushWhen(httpmock::When); + impl FactoryWorkerFlushWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::POST) + .path_matches(regex::Regex::new("^/0/factory/worker/[^/]*/flush$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn worker(self, value: &str) -> Self { + let re = regex::Regex::new(&format!("^/0/factory/worker/{}/flush$", value.to_string())) + .unwrap(); + Self(self.0.path_matches(re)) + } + } + + pub struct FactoryWorkerFlushThen(httpmock::Then); + impl FactoryWorkerFlushThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn no_content(self) -> Self { + Self(self.0.status(204u16)) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct FactoryWorkersWhen(httpmock::When); + impl FactoryWorkersWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::GET) + .path_matches(regex::Regex::new("^/0/factory/workers$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + } + + pub struct FactoryWorkersThen(httpmock::Then); + impl FactoryWorkersThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn ok(self, value: &Vec) -> Self { + Self( + self.0 + .status(200u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct JobGetWhen(httpmock::When); + impl JobGetWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::GET) + .path_matches(regex::Regex::new("^/0/job/[^/]*$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn job(self, value: &str) -> Self { + let re = regex::Regex::new(&format!("^/0/job/{}$", value.to_string())).unwrap(); + Self(self.0.path_matches(re)) + } + } + + pub struct JobGetThen(httpmock::Then); + impl JobGetThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn ok(self, value: &types::Job) -> Self { + Self( + self.0 + .status(200u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct JobsGetWhen(httpmock::When); + impl JobsGetWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::GET) + .path_matches(regex::Regex::new("^/0/jobs$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + } + + pub struct JobsGetThen(httpmock::Then); + impl JobsGetThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn ok(self, value: &Vec) -> Self { + Self( + self.0 + .status(200u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct JobSubmitWhen(httpmock::When); + impl JobSubmitWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::POST) + .path_matches(regex::Regex::new("^/0/jobs$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn body(self, value: &types::JobSubmit) -> Self { + Self(self.0.json_body_obj(value)) + } + } + + pub struct JobSubmitThen(httpmock::Then); + impl JobSubmitThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn created(self, value: &types::JobSubmitResult) -> Self { + Self( + self.0 + .status(201u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct JobCancelWhen(httpmock::When); + impl JobCancelWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::POST) + .path_matches(regex::Regex::new("^/0/jobs/[^/]*/cancel$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn job(self, value: &str) -> Self { + let re = regex::Regex::new(&format!("^/0/jobs/{}/cancel$", value.to_string())).unwrap(); + Self(self.0.path_matches(re)) + } + } + + pub struct JobCancelThen(httpmock::Then); + impl JobCancelThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn no_content(self) -> Self { + Self(self.0.status(204u16)) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct JobUploadChunkWhen(httpmock::When); + impl JobUploadChunkWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::POST) + .path_matches(regex::Regex::new("^/0/jobs/[^/]*/chunk$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn job(self, value: &str) -> Self { + let re = regex::Regex::new(&format!("^/0/jobs/{}/chunk$", value.to_string())).unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn body(self, value: serde_json::Value) -> Self { + Self(self.0.json_body(value)) + } + } + + pub struct JobUploadChunkThen(httpmock::Then); + impl JobUploadChunkThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn created(self, value: &types::UploadedChunk) -> Self { + Self( + self.0 + .status(201u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct JobEventsGetWhen(httpmock::When); + impl JobEventsGetWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::GET) + .path_matches(regex::Regex::new("^/0/jobs/[^/]*/events$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn job(self, value: &str) -> Self { + let re = regex::Regex::new(&format!("^/0/jobs/{}/events$", value.to_string())).unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn minseq(self, value: T) -> Self + where + T: Into>, + { + if let Some(value) = value.into() { + Self(self.0.query_param("minseq", value.to_string())) + } else { + Self(self.0.matches(|req| { + req.query_params + .as_ref() + .and_then(|qs| qs.iter().find(|(key, _)| key == "minseq")) + .is_none() + })) + } + } + } + + pub struct JobEventsGetThen(httpmock::Then); + impl JobEventsGetThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn ok(self, value: &Vec) -> Self { + Self( + self.0 + .status(200u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct JobOutputsGetWhen(httpmock::When); + impl JobOutputsGetWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::GET) + .path_matches(regex::Regex::new("^/0/jobs/[^/]*/outputs$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn job(self, value: &str) -> Self { + let re = + regex::Regex::new(&format!("^/0/jobs/{}/outputs$", value.to_string())).unwrap(); + Self(self.0.path_matches(re)) + } + } + + pub struct JobOutputsGetThen(httpmock::Then); + impl JobOutputsGetThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn ok(self, value: &Vec) -> Self { + Self( + self.0 + .status(200u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct JobOutputDownloadWhen(httpmock::When); + impl JobOutputDownloadWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::GET) + .path_matches(regex::Regex::new("^/0/jobs/[^/]*/outputs/[^/]*$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn job(self, value: &str) -> Self { + let re = + regex::Regex::new(&format!("^/0/jobs/{}/outputs/.*$", value.to_string())).unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn output(self, value: &str) -> Self { + let re = + regex::Regex::new(&format!("^/0/jobs/.*/outputs/{}$", value.to_string())).unwrap(); + Self(self.0.path_matches(re)) + } + } + + pub struct JobOutputDownloadThen(httpmock::Then); + impl JobOutputDownloadThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn default_response(self, status: u16, value: serde_json::Value) -> Self { + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body(value), + ) + } + } + + pub struct JobOutputPublishWhen(httpmock::When); + impl JobOutputPublishWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner.method(httpmock::Method::POST).path_matches( + regex::Regex::new("^/0/jobs/[^/]*/outputs/[^/]*/publish$").unwrap(), + ), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn job(self, value: &str) -> Self { + let re = regex::Regex::new(&format!( + "^/0/jobs/{}/outputs/.*/publish$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn output(self, value: &str) -> Self { + let re = regex::Regex::new(&format!( + "^/0/jobs/.*/outputs/{}/publish$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn body(self, value: &types::JobOutputPublish) -> Self { + Self(self.0.json_body_obj(value)) + } + } + + pub struct JobOutputPublishThen(httpmock::Then); + impl JobOutputPublishThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn no_content(self) -> Self { + Self(self.0.status(204u16)) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct JobOutputSignedUrlWhen(httpmock::When); + impl JobOutputSignedUrlWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::POST) + .path_matches(regex::Regex::new("^/0/jobs/[^/]*/outputs/[^/]*/sign$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn job(self, value: &str) -> Self { + let re = regex::Regex::new(&format!("^/0/jobs/{}/outputs/.*/sign$", value.to_string())) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn output(self, value: &str) -> Self { + let re = regex::Regex::new(&format!("^/0/jobs/.*/outputs/{}/sign$", value.to_string())) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn body(self, value: &types::JobOutputSignedUrl) -> Self { + Self(self.0.json_body_obj(value)) + } + } + + pub struct JobOutputSignedUrlThen(httpmock::Then); + impl JobOutputSignedUrlThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn ok(self, value: &types::JobOutputSignedUrlResult) -> Self { + Self( + self.0 + .status(200u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct JobStoreGetAllWhen(httpmock::When); + impl JobStoreGetAllWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::GET) + .path_matches(regex::Regex::new("^/0/jobs/[^/]*/store$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn job(self, value: &str) -> Self { + let re = regex::Regex::new(&format!("^/0/jobs/{}/store$", value.to_string())).unwrap(); + Self(self.0.path_matches(re)) + } + } + + pub struct JobStoreGetAllThen(httpmock::Then); + impl JobStoreGetAllThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn ok( + self, + value: &std::collections::HashMap, + ) -> Self { + Self( + self.0 + .status(200u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct JobStorePutWhen(httpmock::When); + impl JobStorePutWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::PUT) + .path_matches(regex::Regex::new("^/0/jobs/[^/]*/store/[^/]*$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn job(self, value: &str) -> Self { + let re = + regex::Regex::new(&format!("^/0/jobs/{}/store/.*$", value.to_string())).unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn name(self, value: &str) -> Self { + let re = + regex::Regex::new(&format!("^/0/jobs/.*/store/{}$", value.to_string())).unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn body(self, value: &types::JobStoreValue) -> Self { + Self(self.0.json_body_obj(value)) + } + } + + pub struct JobStorePutThen(httpmock::Then); + impl JobStorePutThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn no_content(self) -> Self { + Self(self.0.status(204u16)) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct PublicFileDownloadWhen(httpmock::When); + impl PublicFileDownloadWhen { + pub fn new(inner: httpmock::When) -> Self { + Self(inner.method(httpmock::Method::GET).path_matches( + regex::Regex::new("^/0/public/file/[^/]*/[^/]*/[^/]*/[^/]*$").unwrap(), + )) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn username(self, value: &str) -> Self { + let re = regex::Regex::new(&format!("^/0/public/file/{}/.*/.*/.*$", value.to_string())) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn series(self, value: &str) -> Self { + let re = regex::Regex::new(&format!("^/0/public/file/.*/{}/.*/.*$", value.to_string())) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn version(self, value: &str) -> Self { + let re = regex::Regex::new(&format!("^/0/public/file/.*/.*/{}/.*$", value.to_string())) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn name(self, value: &str) -> Self { + let re = regex::Regex::new(&format!("^/0/public/file/.*/.*/.*/{}$", value.to_string())) + .unwrap(); + Self(self.0.path_matches(re)) + } + } + + pub struct PublicFileDownloadThen(httpmock::Then); + impl PublicFileDownloadThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn default_response(self, status: u16, value: serde_json::Value) -> Self { + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body(value), + ) + } + } + + pub struct QuotaWhen(httpmock::When); + impl QuotaWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::GET) + .path_matches(regex::Regex::new("^/0/quota$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + } + + pub struct QuotaThen(httpmock::Then); + impl QuotaThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn ok(self, value: &types::Quota) -> Self { + Self( + self.0 + .status(200u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct UsersListWhen(httpmock::When); + impl UsersListWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::GET) + .path_matches(regex::Regex::new("^/0/users$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn name<'a, T>(self, value: T) -> Self + where + T: Into>, + { + if let Some(value) = value.into() { + Self(self.0.query_param("name", value.to_string())) + } else { + Self(self.0.matches(|req| { + req.query_params + .as_ref() + .and_then(|qs| qs.iter().find(|(key, _)| key == "name")) + .is_none() + })) + } + } + } + + pub struct UsersListThen(httpmock::Then); + impl UsersListThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn ok(self, value: &Vec) -> Self { + Self( + self.0 + .status(200u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct UserCreateWhen(httpmock::When); + impl UserCreateWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::POST) + .path_matches(regex::Regex::new("^/0/users$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn body(self, value: &types::UserCreate) -> Self { + Self(self.0.json_body_obj(value)) + } + } + + pub struct UserCreateThen(httpmock::Then); + impl UserCreateThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn created(self, value: &types::UserCreateResult) -> Self { + Self( + self.0 + .status(201u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct UserGetWhen(httpmock::When); + impl UserGetWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::GET) + .path_matches(regex::Regex::new("^/0/users/[^/]*$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn user(self, value: &str) -> Self { + let re = regex::Regex::new(&format!("^/0/users/{}$", value.to_string())).unwrap(); + Self(self.0.path_matches(re)) + } + } + + pub struct UserGetThen(httpmock::Then); + impl UserGetThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn ok(self, value: &types::User) -> Self { + Self( + self.0 + .status(200u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct UserPrivilegeGrantWhen(httpmock::When); + impl UserPrivilegeGrantWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::PUT) + .path_matches(regex::Regex::new("^/0/users/[^/]*/privilege/[^/]*$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn user(self, value: &str) -> Self { + let re = regex::Regex::new(&format!("^/0/users/{}/privilege/.*$", value.to_string())) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn privilege(self, value: &str) -> Self { + let re = regex::Regex::new(&format!("^/0/users/.*/privilege/{}$", value.to_string())) + .unwrap(); + Self(self.0.path_matches(re)) + } + } + + pub struct UserPrivilegeGrantThen(httpmock::Then); + impl UserPrivilegeGrantThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn no_content(self) -> Self { + Self(self.0.status(204u16)) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct UserPrivilegeRevokeWhen(httpmock::When); + impl UserPrivilegeRevokeWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::DELETE) + .path_matches(regex::Regex::new("^/0/users/[^/]*/privilege/[^/]*$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn user(self, value: &str) -> Self { + let re = regex::Regex::new(&format!("^/0/users/{}/privilege/.*$", value.to_string())) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn privilege(self, value: &str) -> Self { + let re = regex::Regex::new(&format!("^/0/users/.*/privilege/{}$", value.to_string())) + .unwrap(); + Self(self.0.path_matches(re)) + } + } + + pub struct UserPrivilegeRevokeThen(httpmock::Then); + impl UserPrivilegeRevokeThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn no_content(self) -> Self { + Self(self.0.status(204u16)) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct WhoamiWhen(httpmock::When); + impl WhoamiWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::GET) + .path_matches(regex::Regex::new("^/0/whoami$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + } + + pub struct WhoamiThen(httpmock::Then); + impl WhoamiThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn ok(self, value: &types::WhoamiResult) -> Self { + Self( + self.0 + .status(200u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct WorkerBootstrapWhen(httpmock::When); + impl WorkerBootstrapWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::POST) + .path_matches(regex::Regex::new("^/0/worker/bootstrap$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn body(self, value: &types::WorkerBootstrap) -> Self { + Self(self.0.json_body_obj(value)) + } + } + + pub struct WorkerBootstrapThen(httpmock::Then); + impl WorkerBootstrapThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn created(self, value: &types::WorkerBootstrapResult) -> Self { + Self( + self.0 + .status(201u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct WorkerJobUploadChunkWhen(httpmock::When); + impl WorkerJobUploadChunkWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::POST) + .path_matches(regex::Regex::new("^/0/worker/job/[^/]*/chunk$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn job(self, value: &str) -> Self { + let re = + regex::Regex::new(&format!("^/0/worker/job/{}/chunk$", value.to_string())).unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn body(self, value: serde_json::Value) -> Self { + Self(self.0.json_body(value)) + } + } + + pub struct WorkerJobUploadChunkThen(httpmock::Then); + impl WorkerJobUploadChunkThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn created(self, value: &types::UploadedChunk) -> Self { + Self( + self.0 + .status(201u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct WorkerJobCompleteWhen(httpmock::When); + impl WorkerJobCompleteWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::POST) + .path_matches(regex::Regex::new("^/0/worker/job/[^/]*/complete$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn job(self, value: &str) -> Self { + let re = regex::Regex::new(&format!("^/0/worker/job/{}/complete$", value.to_string())) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn body(self, value: &types::WorkerCompleteJob) -> Self { + Self(self.0.json_body_obj(value)) + } + } + + pub struct WorkerJobCompleteThen(httpmock::Then); + impl WorkerJobCompleteThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn no_content(self) -> Self { + Self(self.0.status(204u16)) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct WorkerJobInputDownloadWhen(httpmock::When); + impl WorkerJobInputDownloadWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::GET) + .path_matches(regex::Regex::new("^/0/worker/job/[^/]*/inputs/[^/]*$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn job(self, value: &str) -> Self { + let re = regex::Regex::new(&format!("^/0/worker/job/{}/inputs/.*$", value.to_string())) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn input(self, value: &str) -> Self { + let re = regex::Regex::new(&format!("^/0/worker/job/.*/inputs/{}$", value.to_string())) + .unwrap(); + Self(self.0.path_matches(re)) + } + } + + pub struct WorkerJobInputDownloadThen(httpmock::Then); + impl WorkerJobInputDownloadThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn default_response(self, status: u16, value: serde_json::Value) -> Self { + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body(value), + ) + } + } + + pub struct WorkerJobQuotaWhen(httpmock::When); + impl WorkerJobQuotaWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::GET) + .path_matches(regex::Regex::new("^/0/worker/job/[^/]*/quota$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn job(self, value: &str) -> Self { + let re = + regex::Regex::new(&format!("^/0/worker/job/{}/quota$", value.to_string())).unwrap(); + Self(self.0.path_matches(re)) + } + } + + pub struct WorkerJobQuotaThen(httpmock::Then); + impl WorkerJobQuotaThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn ok(self, value: &types::WorkerJobQuota) -> Self { + Self( + self.0 + .status(200u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct WorkerJobStoreGetWhen(httpmock::When); + impl WorkerJobStoreGetWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::GET) + .path_matches(regex::Regex::new("^/0/worker/job/[^/]*/store/[^/]*$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn job(self, value: &str) -> Self { + let re = regex::Regex::new(&format!("^/0/worker/job/{}/store/.*$", value.to_string())) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn name(self, value: &str) -> Self { + let re = regex::Regex::new(&format!("^/0/worker/job/.*/store/{}$", value.to_string())) + .unwrap(); + Self(self.0.path_matches(re)) + } + } + + pub struct WorkerJobStoreGetThen(httpmock::Then); + impl WorkerJobStoreGetThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn ok(self, value: &types::WorkerJobStoreGet) -> Self { + Self( + self.0 + .status(200u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct WorkerJobStorePutWhen(httpmock::When); + impl WorkerJobStorePutWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::PUT) + .path_matches(regex::Regex::new("^/0/worker/job/[^/]*/store/[^/]*$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn job(self, value: &str) -> Self { + let re = regex::Regex::new(&format!("^/0/worker/job/{}/store/.*$", value.to_string())) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn name(self, value: &str) -> Self { + let re = regex::Regex::new(&format!("^/0/worker/job/.*/store/{}$", value.to_string())) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn body(self, value: &types::WorkerJobStoreValue) -> Self { + Self(self.0.json_body_obj(value)) + } + } + + pub struct WorkerJobStorePutThen(httpmock::Then); + impl WorkerJobStorePutThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn no_content(self) -> Self { + Self(self.0.status(204u16)) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct WorkerTaskAppendWhen(httpmock::When); + impl WorkerTaskAppendWhen { + pub fn new(inner: httpmock::When) -> Self { + Self(inner.method(httpmock::Method::POST).path_matches( + regex::Regex::new("^/0/worker/job/[^/]*/task/[^/]*/append$").unwrap(), + )) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn job(self, value: &str) -> Self { + let re = regex::Regex::new(&format!( + "^/0/worker/job/{}/task/.*/append$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn task(self, value: u32) -> Self { + let re = regex::Regex::new(&format!( + "^/0/worker/job/.*/task/{}/append$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn body(self, value: &types::WorkerAppendJob) -> Self { + Self(self.0.json_body_obj(value)) + } + } + + pub struct WorkerTaskAppendThen(httpmock::Then); + impl WorkerTaskAppendThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn no_content(self) -> Self { + Self(self.0.status(204u16)) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct WorkerTaskCompleteWhen(httpmock::When); + impl WorkerTaskCompleteWhen { + pub fn new(inner: httpmock::When) -> Self { + Self(inner.method(httpmock::Method::POST).path_matches( + regex::Regex::new("^/0/worker/job/[^/]*/task/[^/]*/complete$").unwrap(), + )) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn job(self, value: &str) -> Self { + let re = regex::Regex::new(&format!( + "^/0/worker/job/{}/task/.*/complete$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn task(self, value: u32) -> Self { + let re = regex::Regex::new(&format!( + "^/0/worker/job/.*/task/{}/complete$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn body(self, value: &types::WorkerCompleteTask) -> Self { + Self(self.0.json_body_obj(value)) + } + } + + pub struct WorkerTaskCompleteThen(httpmock::Then); + impl WorkerTaskCompleteThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn no_content(self) -> Self { + Self(self.0.status(204u16)) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct WorkerPingWhen(httpmock::When); + impl WorkerPingWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::GET) + .path_matches(regex::Regex::new("^/0/worker/ping$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + } + + pub struct WorkerPingThen(httpmock::Then); + impl WorkerPingThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn ok(self, value: &types::WorkerPingResult) -> Self { + Self( + self.0 + .status(200u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct WorkersListWhen(httpmock::When); + impl WorkersListWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::GET) + .path_matches(regex::Regex::new("^/0/workers$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn active(self, value: T) -> Self + where + T: Into>, + { + if let Some(value) = value.into() { + Self(self.0.query_param("active", value.to_string())) + } else { + Self(self.0.matches(|req| { + req.query_params + .as_ref() + .and_then(|qs| qs.iter().find(|(key, _)| key == "active")) + .is_none() + })) + } + } + } + + pub struct WorkersListThen(httpmock::Then); + impl WorkersListThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn ok(self, value: &types::WorkersResult) -> Self { + Self( + self.0 + .status(200u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct WorkersRecycleWhen(httpmock::When); + impl WorkersRecycleWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::POST) + .path_matches(regex::Regex::new("^/0/workers/recycle$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + } + + pub struct WorkersRecycleThen(httpmock::Then); + impl WorkersRecycleThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn no_content(self) -> Self { + Self(self.0.status(204u16)) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct JobAddInputWhen(httpmock::When); + impl JobAddInputWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::POST) + .path_matches(regex::Regex::new("^/1/jobs/[^/]*/input$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn job(self, value: &str) -> Self { + let re = regex::Regex::new(&format!("^/1/jobs/{}/input$", value.to_string())).unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn body(self, value: &types::JobAddInput) -> Self { + Self(self.0.json_body_obj(value)) + } + } + + pub struct JobAddInputThen(httpmock::Then); + impl JobAddInputThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn ok(self, value: &types::JobAddInputResult) -> Self { + Self( + self.0 + .status(200u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct WorkerJobAppendWhen(httpmock::When); + impl WorkerJobAppendWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::POST) + .path_matches(regex::Regex::new("^/1/worker/job/[^/]*/append$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn job(self, value: &str) -> Self { + let re = regex::Regex::new(&format!("^/1/worker/job/{}/append$", value.to_string())) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn body(self, value: &Vec) -> Self { + Self(self.0.json_body_obj(value)) + } + } + + pub struct WorkerJobAppendThen(httpmock::Then); + impl WorkerJobAppendThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn no_content(self) -> Self { + Self(self.0.status(204u16)) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct WorkerJobAddOutputWhen(httpmock::When); + impl WorkerJobAddOutputWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::POST) + .path_matches(regex::Regex::new("^/1/worker/job/[^/]*/output$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn job(self, value: &str) -> Self { + let re = regex::Regex::new(&format!("^/1/worker/job/{}/output$", value.to_string())) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn body(self, value: &types::WorkerAddOutput) -> Self { + Self(self.0.json_body_obj(value)) + } + } + + pub struct WorkerJobAddOutputThen(httpmock::Then); + impl WorkerJobAddOutputThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn ok(self, value: &types::WorkerAddOutputResult) -> Self { + Self( + self.0 + .status(200u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } +} #[doc = r" An extension trait for [`MockServer`](httpmock::MockServer) that"] #[doc = r" adds a method for each operation. These are the equivalent of"] #[doc = r" type-checked [`mock()`](httpmock::MockServer::mock) calls."] pub trait MockServerExt { + fn factory_create(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::FactoryCreateWhen, operations::FactoryCreateThen); + fn admin_jobs_get(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::AdminJobsGetWhen, operations::AdminJobsGetThen); + fn admin_job_get(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::AdminJobGetWhen, operations::AdminJobGetThen); + fn admin_job_archive_request(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::AdminJobArchiveRequestWhen, operations::AdminJobArchiveRequestThen); + fn target_create(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::TargetCreateWhen, operations::TargetCreateThen); + fn targets_list(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::TargetsListWhen, operations::TargetsListThen); + fn target_redirect(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::TargetRedirectWhen, operations::TargetRedirectThen); + fn target_rename(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::TargetRenameWhen, operations::TargetRenameThen); + fn target_require_no_privilege(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce( + operations::TargetRequireNoPrivilegeWhen, + operations::TargetRequireNoPrivilegeThen, + ); + fn target_require_privilege(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::TargetRequirePrivilegeWhen, operations::TargetRequirePrivilegeThen); + fn worker_recycle(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::WorkerRecycleWhen, operations::WorkerRecycleThen); fn control_hold(&self, config_fn: F) -> httpmock::Mock where F: FnOnce(operations::ControlHoldWhen, operations::ControlHoldThen); fn control_resume(&self, config_fn: F) -> httpmock::Mock where - F: FnOnce(operations::ControlResumeWhen, operations::ControlResumeThen); - fn task_get(&self, config_fn: F) -> httpmock::Mock + F: FnOnce(operations::ControlResumeWhen, operations::ControlResumeThen); + fn factory_lease(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::FactoryLeaseWhen, operations::FactoryLeaseThen); + fn factory_lease_renew(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::FactoryLeaseRenewWhen, operations::FactoryLeaseRenewThen); + fn factory_ping(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::FactoryPingWhen, operations::FactoryPingThen); + fn factory_worker_create(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::FactoryWorkerCreateWhen, operations::FactoryWorkerCreateThen); + fn factory_worker_get(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::FactoryWorkerGetWhen, operations::FactoryWorkerGetThen); + fn factory_worker_destroy(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::FactoryWorkerDestroyWhen, operations::FactoryWorkerDestroyThen); + fn factory_worker_associate(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::FactoryWorkerAssociateWhen, operations::FactoryWorkerAssociateThen); + fn factory_worker_append(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::FactoryWorkerAppendWhen, operations::FactoryWorkerAppendThen); + fn factory_worker_flush(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::FactoryWorkerFlushWhen, operations::FactoryWorkerFlushThen); + fn factory_workers(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::FactoryWorkersWhen, operations::FactoryWorkersThen); + fn job_get(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::JobGetWhen, operations::JobGetThen); + fn jobs_get(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::JobsGetWhen, operations::JobsGetThen); + fn job_submit(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::JobSubmitWhen, operations::JobSubmitThen); + fn job_cancel(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::JobCancelWhen, operations::JobCancelThen); + fn job_upload_chunk(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::JobUploadChunkWhen, operations::JobUploadChunkThen); + fn job_events_get(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::JobEventsGetWhen, operations::JobEventsGetThen); + fn job_outputs_get(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::JobOutputsGetWhen, operations::JobOutputsGetThen); + fn job_output_download(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::JobOutputDownloadWhen, operations::JobOutputDownloadThen); + fn job_output_publish(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::JobOutputPublishWhen, operations::JobOutputPublishThen); + fn job_output_signed_url(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::JobOutputSignedUrlWhen, operations::JobOutputSignedUrlThen); + fn job_store_get_all(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::JobStoreGetAllWhen, operations::JobStoreGetAllThen); + fn job_store_put(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::JobStorePutWhen, operations::JobStorePutThen); + fn public_file_download(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::PublicFileDownloadWhen, operations::PublicFileDownloadThen); + fn quota(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::QuotaWhen, operations::QuotaThen); + fn users_list(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::UsersListWhen, operations::UsersListThen); + fn user_create(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::UserCreateWhen, operations::UserCreateThen); + fn user_get(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::UserGetWhen, operations::UserGetThen); + fn user_privilege_grant(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::UserPrivilegeGrantWhen, operations::UserPrivilegeGrantThen); + fn user_privilege_revoke(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::UserPrivilegeRevokeWhen, operations::UserPrivilegeRevokeThen); + fn whoami(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::WhoamiWhen, operations::WhoamiThen); + fn worker_bootstrap(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::WorkerBootstrapWhen, operations::WorkerBootstrapThen); + fn worker_job_upload_chunk(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::WorkerJobUploadChunkWhen, operations::WorkerJobUploadChunkThen); + fn worker_job_complete(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::WorkerJobCompleteWhen, operations::WorkerJobCompleteThen); + fn worker_job_input_download(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::WorkerJobInputDownloadWhen, operations::WorkerJobInputDownloadThen); + fn worker_job_quota(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::WorkerJobQuotaWhen, operations::WorkerJobQuotaThen); + fn worker_job_store_get(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::WorkerJobStoreGetWhen, operations::WorkerJobStoreGetThen); + fn worker_job_store_put(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::WorkerJobStorePutWhen, operations::WorkerJobStorePutThen); + fn worker_task_append(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::WorkerTaskAppendWhen, operations::WorkerTaskAppendThen); + fn worker_task_complete(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::WorkerTaskCompleteWhen, operations::WorkerTaskCompleteThen); + fn worker_ping(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::WorkerPingWhen, operations::WorkerPingThen); + fn workers_list(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::WorkersListWhen, operations::WorkersListThen); + fn workers_recycle(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::WorkersRecycleWhen, operations::WorkersRecycleThen); + fn job_add_input(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::JobAddInputWhen, operations::JobAddInputThen); + fn worker_job_append(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::WorkerJobAppendWhen, operations::WorkerJobAppendThen); + fn worker_job_add_output(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::WorkerJobAddOutputWhen, operations::WorkerJobAddOutputThen); +} + +impl MockServerExt for httpmock::MockServer { + fn factory_create(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::FactoryCreateWhen, operations::FactoryCreateThen), + { + self.mock(|when, then| { + config_fn( + operations::FactoryCreateWhen::new(when), + operations::FactoryCreateThen::new(then), + ) + }) + } + + fn admin_jobs_get(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::AdminJobsGetWhen, operations::AdminJobsGetThen), + { + self.mock(|when, then| { + config_fn( + operations::AdminJobsGetWhen::new(when), + operations::AdminJobsGetThen::new(then), + ) + }) + } + + fn admin_job_get(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::AdminJobGetWhen, operations::AdminJobGetThen), + { + self.mock(|when, then| { + config_fn( + operations::AdminJobGetWhen::new(when), + operations::AdminJobGetThen::new(then), + ) + }) + } + + fn admin_job_archive_request(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::AdminJobArchiveRequestWhen, operations::AdminJobArchiveRequestThen), + { + self.mock(|when, then| { + config_fn( + operations::AdminJobArchiveRequestWhen::new(when), + operations::AdminJobArchiveRequestThen::new(then), + ) + }) + } + + fn target_create(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::TargetCreateWhen, operations::TargetCreateThen), + { + self.mock(|when, then| { + config_fn( + operations::TargetCreateWhen::new(when), + operations::TargetCreateThen::new(then), + ) + }) + } + + fn targets_list(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::TargetsListWhen, operations::TargetsListThen), + { + self.mock(|when, then| { + config_fn( + operations::TargetsListWhen::new(when), + operations::TargetsListThen::new(then), + ) + }) + } + + fn target_redirect(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::TargetRedirectWhen, operations::TargetRedirectThen), + { + self.mock(|when, then| { + config_fn( + operations::TargetRedirectWhen::new(when), + operations::TargetRedirectThen::new(then), + ) + }) + } + + fn target_rename(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::TargetRenameWhen, operations::TargetRenameThen), + { + self.mock(|when, then| { + config_fn( + operations::TargetRenameWhen::new(when), + operations::TargetRenameThen::new(then), + ) + }) + } + + fn target_require_no_privilege(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce( + operations::TargetRequireNoPrivilegeWhen, + operations::TargetRequireNoPrivilegeThen, + ), + { + self.mock(|when, then| { + config_fn( + operations::TargetRequireNoPrivilegeWhen::new(when), + operations::TargetRequireNoPrivilegeThen::new(then), + ) + }) + } + + fn target_require_privilege(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::TargetRequirePrivilegeWhen, operations::TargetRequirePrivilegeThen), + { + self.mock(|when, then| { + config_fn( + operations::TargetRequirePrivilegeWhen::new(when), + operations::TargetRequirePrivilegeThen::new(then), + ) + }) + } + + fn worker_recycle(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::WorkerRecycleWhen, operations::WorkerRecycleThen), + { + self.mock(|when, then| { + config_fn( + operations::WorkerRecycleWhen::new(when), + operations::WorkerRecycleThen::new(then), + ) + }) + } + + fn control_hold(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::ControlHoldWhen, operations::ControlHoldThen), + { + self.mock(|when, then| { + config_fn( + operations::ControlHoldWhen::new(when), + operations::ControlHoldThen::new(then), + ) + }) + } + + fn control_resume(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::ControlResumeWhen, operations::ControlResumeThen), + { + self.mock(|when, then| { + config_fn( + operations::ControlResumeWhen::new(when), + operations::ControlResumeThen::new(then), + ) + }) + } + + fn factory_lease(&self, config_fn: F) -> httpmock::Mock where - F: FnOnce(operations::TaskGetWhen, operations::TaskGetThen); - fn tasks_get(&self, config_fn: F) -> httpmock::Mock + F: FnOnce(operations::FactoryLeaseWhen, operations::FactoryLeaseThen), + { + self.mock(|when, then| { + config_fn( + operations::FactoryLeaseWhen::new(when), + operations::FactoryLeaseThen::new(then), + ) + }) + } + + fn factory_lease_renew(&self, config_fn: F) -> httpmock::Mock where - F: FnOnce(operations::TasksGetWhen, operations::TasksGetThen); - fn task_submit(&self, config_fn: F) -> httpmock::Mock + F: FnOnce(operations::FactoryLeaseRenewWhen, operations::FactoryLeaseRenewThen), + { + self.mock(|when, then| { + config_fn( + operations::FactoryLeaseRenewWhen::new(when), + operations::FactoryLeaseRenewThen::new(then), + ) + }) + } + + fn factory_ping(&self, config_fn: F) -> httpmock::Mock where - F: FnOnce(operations::TaskSubmitWhen, operations::TaskSubmitThen); - fn task_events_get(&self, config_fn: F) -> httpmock::Mock + F: FnOnce(operations::FactoryPingWhen, operations::FactoryPingThen), + { + self.mock(|when, then| { + config_fn( + operations::FactoryPingWhen::new(when), + operations::FactoryPingThen::new(then), + ) + }) + } + + fn factory_worker_create(&self, config_fn: F) -> httpmock::Mock where - F: FnOnce(operations::TaskEventsGetWhen, operations::TaskEventsGetThen); - fn task_outputs_get(&self, config_fn: F) -> httpmock::Mock + F: FnOnce(operations::FactoryWorkerCreateWhen, operations::FactoryWorkerCreateThen), + { + self.mock(|when, then| { + config_fn( + operations::FactoryWorkerCreateWhen::new(when), + operations::FactoryWorkerCreateThen::new(then), + ) + }) + } + + fn factory_worker_get(&self, config_fn: F) -> httpmock::Mock where - F: FnOnce(operations::TaskOutputsGetWhen, operations::TaskOutputsGetThen); - fn task_output_download(&self, config_fn: F) -> httpmock::Mock + F: FnOnce(operations::FactoryWorkerGetWhen, operations::FactoryWorkerGetThen), + { + self.mock(|when, then| { + config_fn( + operations::FactoryWorkerGetWhen::new(when), + operations::FactoryWorkerGetThen::new(then), + ) + }) + } + + fn factory_worker_destroy(&self, config_fn: F) -> httpmock::Mock where - F: FnOnce(operations::TaskOutputDownloadWhen, operations::TaskOutputDownloadThen); - fn user_create(&self, config_fn: F) -> httpmock::Mock + F: FnOnce(operations::FactoryWorkerDestroyWhen, operations::FactoryWorkerDestroyThen), + { + self.mock(|when, then| { + config_fn( + operations::FactoryWorkerDestroyWhen::new(when), + operations::FactoryWorkerDestroyThen::new(then), + ) + }) + } + + fn factory_worker_associate(&self, config_fn: F) -> httpmock::Mock where - F: FnOnce(operations::UserCreateWhen, operations::UserCreateThen); - fn whoami(&self, config_fn: F) -> httpmock::Mock + F: FnOnce(operations::FactoryWorkerAssociateWhen, operations::FactoryWorkerAssociateThen), + { + self.mock(|when, then| { + config_fn( + operations::FactoryWorkerAssociateWhen::new(when), + operations::FactoryWorkerAssociateThen::new(then), + ) + }) + } + + fn factory_worker_append(&self, config_fn: F) -> httpmock::Mock where - F: FnOnce(operations::WhoamiWhen, operations::WhoamiThen); - fn whoami_put_name(&self, config_fn: F) -> httpmock::Mock + F: FnOnce(operations::FactoryWorkerAppendWhen, operations::FactoryWorkerAppendThen), + { + self.mock(|when, then| { + config_fn( + operations::FactoryWorkerAppendWhen::new(when), + operations::FactoryWorkerAppendThen::new(then), + ) + }) + } + + fn factory_worker_flush(&self, config_fn: F) -> httpmock::Mock where - F: FnOnce(operations::WhoamiPutNameWhen, operations::WhoamiPutNameThen); - fn worker_bootstrap(&self, config_fn: F) -> httpmock::Mock + F: FnOnce(operations::FactoryWorkerFlushWhen, operations::FactoryWorkerFlushThen), + { + self.mock(|when, then| { + config_fn( + operations::FactoryWorkerFlushWhen::new(when), + operations::FactoryWorkerFlushThen::new(then), + ) + }) + } + + fn factory_workers(&self, config_fn: F) -> httpmock::Mock where - F: FnOnce(operations::WorkerBootstrapWhen, operations::WorkerBootstrapThen); - fn worker_ping(&self, config_fn: F) -> httpmock::Mock + F: FnOnce(operations::FactoryWorkersWhen, operations::FactoryWorkersThen), + { + self.mock(|when, then| { + config_fn( + operations::FactoryWorkersWhen::new(when), + operations::FactoryWorkersThen::new(then), + ) + }) + } + + fn job_get(&self, config_fn: F) -> httpmock::Mock where - F: FnOnce(operations::WorkerPingWhen, operations::WorkerPingThen); - fn worker_task_append(&self, config_fn: F) -> httpmock::Mock + F: FnOnce(operations::JobGetWhen, operations::JobGetThen), + { + self.mock(|when, then| { + config_fn( + operations::JobGetWhen::new(when), + operations::JobGetThen::new(then), + ) + }) + } + + fn jobs_get(&self, config_fn: F) -> httpmock::Mock where - F: FnOnce(operations::WorkerTaskAppendWhen, operations::WorkerTaskAppendThen); - fn worker_task_upload_chunk(&self, config_fn: F) -> httpmock::Mock + F: FnOnce(operations::JobsGetWhen, operations::JobsGetThen), + { + self.mock(|when, then| { + config_fn( + operations::JobsGetWhen::new(when), + operations::JobsGetThen::new(then), + ) + }) + } + + fn job_submit(&self, config_fn: F) -> httpmock::Mock where - F: FnOnce(operations::WorkerTaskUploadChunkWhen, operations::WorkerTaskUploadChunkThen); - fn worker_task_complete(&self, config_fn: F) -> httpmock::Mock + F: FnOnce(operations::JobSubmitWhen, operations::JobSubmitThen), + { + self.mock(|when, then| { + config_fn( + operations::JobSubmitWhen::new(when), + operations::JobSubmitThen::new(then), + ) + }) + } + + fn job_cancel(&self, config_fn: F) -> httpmock::Mock where - F: FnOnce(operations::WorkerTaskCompleteWhen, operations::WorkerTaskCompleteThen); - fn worker_task_add_output(&self, config_fn: F) -> httpmock::Mock + F: FnOnce(operations::JobCancelWhen, operations::JobCancelThen), + { + self.mock(|when, then| { + config_fn( + operations::JobCancelWhen::new(when), + operations::JobCancelThen::new(then), + ) + }) + } + + fn job_upload_chunk(&self, config_fn: F) -> httpmock::Mock where - F: FnOnce(operations::WorkerTaskAddOutputWhen, operations::WorkerTaskAddOutputThen); - fn workers_list(&self, config_fn: F) -> httpmock::Mock + F: FnOnce(operations::JobUploadChunkWhen, operations::JobUploadChunkThen), + { + self.mock(|when, then| { + config_fn( + operations::JobUploadChunkWhen::new(when), + operations::JobUploadChunkThen::new(then), + ) + }) + } + + fn job_events_get(&self, config_fn: F) -> httpmock::Mock where - F: FnOnce(operations::WorkersListWhen, operations::WorkersListThen); - fn workers_recycle(&self, config_fn: F) -> httpmock::Mock + F: FnOnce(operations::JobEventsGetWhen, operations::JobEventsGetThen), + { + self.mock(|when, then| { + config_fn( + operations::JobEventsGetWhen::new(when), + operations::JobEventsGetThen::new(then), + ) + }) + } + + fn job_outputs_get(&self, config_fn: F) -> httpmock::Mock where - F: FnOnce(operations::WorkersRecycleWhen, operations::WorkersRecycleThen); -} + F: FnOnce(operations::JobOutputsGetWhen, operations::JobOutputsGetThen), + { + self.mock(|when, then| { + config_fn( + operations::JobOutputsGetWhen::new(when), + operations::JobOutputsGetThen::new(then), + ) + }) + } -impl MockServerExt for httpmock::MockServer { - fn control_hold(&self, config_fn: F) -> httpmock::Mock + fn job_output_download(&self, config_fn: F) -> httpmock::Mock where - F: FnOnce(operations::ControlHoldWhen, operations::ControlHoldThen), + F: FnOnce(operations::JobOutputDownloadWhen, operations::JobOutputDownloadThen), { self.mock(|when, then| { config_fn( - operations::ControlHoldWhen::new(when), - operations::ControlHoldThen::new(then), + operations::JobOutputDownloadWhen::new(when), + operations::JobOutputDownloadThen::new(then), ) }) } - fn control_resume(&self, config_fn: F) -> httpmock::Mock + fn job_output_publish(&self, config_fn: F) -> httpmock::Mock where - F: FnOnce(operations::ControlResumeWhen, operations::ControlResumeThen), + F: FnOnce(operations::JobOutputPublishWhen, operations::JobOutputPublishThen), { self.mock(|when, then| { config_fn( - operations::ControlResumeWhen::new(when), - operations::ControlResumeThen::new(then), + operations::JobOutputPublishWhen::new(when), + operations::JobOutputPublishThen::new(then), ) }) } - fn task_get(&self, config_fn: F) -> httpmock::Mock + fn job_output_signed_url(&self, config_fn: F) -> httpmock::Mock where - F: FnOnce(operations::TaskGetWhen, operations::TaskGetThen), + F: FnOnce(operations::JobOutputSignedUrlWhen, operations::JobOutputSignedUrlThen), { self.mock(|when, then| { config_fn( - operations::TaskGetWhen::new(when), - operations::TaskGetThen::new(then), + operations::JobOutputSignedUrlWhen::new(when), + operations::JobOutputSignedUrlThen::new(then), ) }) } - fn tasks_get(&self, config_fn: F) -> httpmock::Mock + fn job_store_get_all(&self, config_fn: F) -> httpmock::Mock where - F: FnOnce(operations::TasksGetWhen, operations::TasksGetThen), + F: FnOnce(operations::JobStoreGetAllWhen, operations::JobStoreGetAllThen), { self.mock(|when, then| { config_fn( - operations::TasksGetWhen::new(when), - operations::TasksGetThen::new(then), + operations::JobStoreGetAllWhen::new(when), + operations::JobStoreGetAllThen::new(then), ) }) } - fn task_submit(&self, config_fn: F) -> httpmock::Mock + fn job_store_put(&self, config_fn: F) -> httpmock::Mock where - F: FnOnce(operations::TaskSubmitWhen, operations::TaskSubmitThen), + F: FnOnce(operations::JobStorePutWhen, operations::JobStorePutThen), { self.mock(|when, then| { config_fn( - operations::TaskSubmitWhen::new(when), - operations::TaskSubmitThen::new(then), + operations::JobStorePutWhen::new(when), + operations::JobStorePutThen::new(then), ) }) } - fn task_events_get(&self, config_fn: F) -> httpmock::Mock + fn public_file_download(&self, config_fn: F) -> httpmock::Mock where - F: FnOnce(operations::TaskEventsGetWhen, operations::TaskEventsGetThen), + F: FnOnce(operations::PublicFileDownloadWhen, operations::PublicFileDownloadThen), { self.mock(|when, then| { config_fn( - operations::TaskEventsGetWhen::new(when), - operations::TaskEventsGetThen::new(then), + operations::PublicFileDownloadWhen::new(when), + operations::PublicFileDownloadThen::new(then), ) }) } - fn task_outputs_get(&self, config_fn: F) -> httpmock::Mock + fn quota(&self, config_fn: F) -> httpmock::Mock where - F: FnOnce(operations::TaskOutputsGetWhen, operations::TaskOutputsGetThen), + F: FnOnce(operations::QuotaWhen, operations::QuotaThen), { self.mock(|when, then| { config_fn( - operations::TaskOutputsGetWhen::new(when), - operations::TaskOutputsGetThen::new(then), + operations::QuotaWhen::new(when), + operations::QuotaThen::new(then), ) }) } - fn task_output_download(&self, config_fn: F) -> httpmock::Mock + fn users_list(&self, config_fn: F) -> httpmock::Mock where - F: FnOnce(operations::TaskOutputDownloadWhen, operations::TaskOutputDownloadThen), + F: FnOnce(operations::UsersListWhen, operations::UsersListThen), { self.mock(|when, then| { config_fn( - operations::TaskOutputDownloadWhen::new(when), - operations::TaskOutputDownloadThen::new(then), + operations::UsersListWhen::new(when), + operations::UsersListThen::new(then), ) }) } @@ -915,26 +4198,50 @@ impl MockServerExt for httpmock::MockServer { }) } - fn whoami(&self, config_fn: F) -> httpmock::Mock + fn user_get(&self, config_fn: F) -> httpmock::Mock where - F: FnOnce(operations::WhoamiWhen, operations::WhoamiThen), + F: FnOnce(operations::UserGetWhen, operations::UserGetThen), { self.mock(|when, then| { config_fn( - operations::WhoamiWhen::new(when), - operations::WhoamiThen::new(then), + operations::UserGetWhen::new(when), + operations::UserGetThen::new(then), + ) + }) + } + + fn user_privilege_grant(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::UserPrivilegeGrantWhen, operations::UserPrivilegeGrantThen), + { + self.mock(|when, then| { + config_fn( + operations::UserPrivilegeGrantWhen::new(when), + operations::UserPrivilegeGrantThen::new(then), + ) + }) + } + + fn user_privilege_revoke(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::UserPrivilegeRevokeWhen, operations::UserPrivilegeRevokeThen), + { + self.mock(|when, then| { + config_fn( + operations::UserPrivilegeRevokeWhen::new(when), + operations::UserPrivilegeRevokeThen::new(then), ) }) } - fn whoami_put_name(&self, config_fn: F) -> httpmock::Mock + fn whoami(&self, config_fn: F) -> httpmock::Mock where - F: FnOnce(operations::WhoamiPutNameWhen, operations::WhoamiPutNameThen), + F: FnOnce(operations::WhoamiWhen, operations::WhoamiThen), { self.mock(|when, then| { config_fn( - operations::WhoamiPutNameWhen::new(when), - operations::WhoamiPutNameThen::new(then), + operations::WhoamiWhen::new(when), + operations::WhoamiThen::new(then), ) }) } @@ -951,38 +4258,86 @@ impl MockServerExt for httpmock::MockServer { }) } - fn worker_ping(&self, config_fn: F) -> httpmock::Mock + fn worker_job_upload_chunk(&self, config_fn: F) -> httpmock::Mock where - F: FnOnce(operations::WorkerPingWhen, operations::WorkerPingThen), + F: FnOnce(operations::WorkerJobUploadChunkWhen, operations::WorkerJobUploadChunkThen), { self.mock(|when, then| { config_fn( - operations::WorkerPingWhen::new(when), - operations::WorkerPingThen::new(then), + operations::WorkerJobUploadChunkWhen::new(when), + operations::WorkerJobUploadChunkThen::new(then), ) }) } - fn worker_task_append(&self, config_fn: F) -> httpmock::Mock + fn worker_job_complete(&self, config_fn: F) -> httpmock::Mock where - F: FnOnce(operations::WorkerTaskAppendWhen, operations::WorkerTaskAppendThen), + F: FnOnce(operations::WorkerJobCompleteWhen, operations::WorkerJobCompleteThen), { self.mock(|when, then| { config_fn( - operations::WorkerTaskAppendWhen::new(when), - operations::WorkerTaskAppendThen::new(then), + operations::WorkerJobCompleteWhen::new(when), + operations::WorkerJobCompleteThen::new(then), ) }) } - fn worker_task_upload_chunk(&self, config_fn: F) -> httpmock::Mock + fn worker_job_input_download(&self, config_fn: F) -> httpmock::Mock where - F: FnOnce(operations::WorkerTaskUploadChunkWhen, operations::WorkerTaskUploadChunkThen), + F: FnOnce(operations::WorkerJobInputDownloadWhen, operations::WorkerJobInputDownloadThen), { self.mock(|when, then| { config_fn( - operations::WorkerTaskUploadChunkWhen::new(when), - operations::WorkerTaskUploadChunkThen::new(then), + operations::WorkerJobInputDownloadWhen::new(when), + operations::WorkerJobInputDownloadThen::new(then), + ) + }) + } + + fn worker_job_quota(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::WorkerJobQuotaWhen, operations::WorkerJobQuotaThen), + { + self.mock(|when, then| { + config_fn( + operations::WorkerJobQuotaWhen::new(when), + operations::WorkerJobQuotaThen::new(then), + ) + }) + } + + fn worker_job_store_get(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::WorkerJobStoreGetWhen, operations::WorkerJobStoreGetThen), + { + self.mock(|when, then| { + config_fn( + operations::WorkerJobStoreGetWhen::new(when), + operations::WorkerJobStoreGetThen::new(then), + ) + }) + } + + fn worker_job_store_put(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::WorkerJobStorePutWhen, operations::WorkerJobStorePutThen), + { + self.mock(|when, then| { + config_fn( + operations::WorkerJobStorePutWhen::new(when), + operations::WorkerJobStorePutThen::new(then), + ) + }) + } + + fn worker_task_append(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::WorkerTaskAppendWhen, operations::WorkerTaskAppendThen), + { + self.mock(|when, then| { + config_fn( + operations::WorkerTaskAppendWhen::new(when), + operations::WorkerTaskAppendThen::new(then), ) }) } @@ -999,14 +4354,14 @@ impl MockServerExt for httpmock::MockServer { }) } - fn worker_task_add_output(&self, config_fn: F) -> httpmock::Mock + fn worker_ping(&self, config_fn: F) -> httpmock::Mock where - F: FnOnce(operations::WorkerTaskAddOutputWhen, operations::WorkerTaskAddOutputThen), + F: FnOnce(operations::WorkerPingWhen, operations::WorkerPingThen), { self.mock(|when, then| { config_fn( - operations::WorkerTaskAddOutputWhen::new(when), - operations::WorkerTaskAddOutputThen::new(then), + operations::WorkerPingWhen::new(when), + operations::WorkerPingThen::new(then), ) }) } @@ -1034,4 +4389,40 @@ impl MockServerExt for httpmock::MockServer { ) }) } + + fn job_add_input(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::JobAddInputWhen, operations::JobAddInputThen), + { + self.mock(|when, then| { + config_fn( + operations::JobAddInputWhen::new(when), + operations::JobAddInputThen::new(then), + ) + }) + } + + fn worker_job_append(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::WorkerJobAppendWhen, operations::WorkerJobAppendThen), + { + self.mock(|when, then| { + config_fn( + operations::WorkerJobAppendWhen::new(when), + operations::WorkerJobAppendThen::new(then), + ) + }) + } + + fn worker_job_add_output(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::WorkerJobAddOutputWhen, operations::WorkerJobAddOutputThen), + { + self.mock(|when, then| { + config_fn( + operations::WorkerJobAddOutputWhen::new(when), + operations::WorkerJobAddOutputThen::new(then), + ) + }) + } } diff --git a/progenitor-impl/tests/output/buildomat-positional.out b/progenitor-impl/tests/output/buildomat-positional.out index 1713415c..c6106eed 100644 --- a/progenitor-impl/tests/output/buildomat-positional.out +++ b/progenitor-impl/tests/output/buildomat-positional.out @@ -8,315 +8,1935 @@ pub mod types { #[allow(unused_imports)] use std::convert::TryFrom; #[derive(Clone, Debug, Deserialize, Serialize)] - pub struct Task { + pub struct DependSubmit { + pub copy_outputs: bool, + pub on_completed: bool, + pub on_failed: bool, + pub prior_job: String, + } + + impl From<&DependSubmit> for DependSubmit { + fn from(value: &DependSubmit) -> Self { + value.clone() + } + } + + ///Error information from a response. + #[derive(Clone, Debug, Deserialize, Serialize)] + pub struct Error { + #[serde(default, skip_serializing_if = "Option::is_none")] + pub error_code: Option, + pub message: String, + pub request_id: String, + } + + impl From<&Error> for Error { + fn from(value: &Error) -> Self { + value.clone() + } + } + + #[derive(Clone, Debug, Deserialize, Serialize)] + pub struct FactoryAddresses { + pub cidr: String, + pub count: u32, + pub first: String, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub gateway: Option, + pub name: String, + pub routed: bool, + } + + impl From<&FactoryAddresses> for FactoryAddresses { + fn from(value: &FactoryAddresses) -> Self { + value.clone() + } + } + + #[derive(Clone, Debug, Deserialize, Serialize)] + pub struct FactoryCreate { + pub name: String, + } + + impl From<&FactoryCreate> for FactoryCreate { + fn from(value: &FactoryCreate) -> Self { + value.clone() + } + } + + #[derive(Clone, Debug, Deserialize, Serialize)] + pub struct FactoryCreateResult { pub id: String, pub name: String, - pub output_rules: Vec, - pub script: String, - pub state: String, + pub token: String, } - impl From<&Task> for Task { - fn from(value: &Task) -> Self { + impl From<&FactoryCreateResult> for FactoryCreateResult { + fn from(value: &FactoryCreateResult) -> Self { + value.clone() + } + } + + #[derive(Clone, Debug, Deserialize, Serialize)] + pub struct FactoryLease { + pub job: String, + pub target: String, + } + + impl From<&FactoryLease> for FactoryLease { + fn from(value: &FactoryLease) -> Self { + value.clone() + } + } + + #[derive(Clone, Debug, Deserialize, Serialize)] + pub struct FactoryLeaseResult { + #[serde(default, skip_serializing_if = "Option::is_none")] + pub lease: Option, + } + + impl From<&FactoryLeaseResult> for FactoryLeaseResult { + fn from(value: &FactoryLeaseResult) -> Self { + value.clone() + } + } + + #[derive(Clone, Debug, Deserialize, Serialize)] + #[serde(tag = "v")] + pub enum FactoryMetadata { + #[serde(rename = "1")] + _1 { + #[serde(default, skip_serializing_if = "Vec::is_empty")] + addresses: Vec, + }, + } + + impl From<&FactoryMetadata> for FactoryMetadata { + fn from(value: &FactoryMetadata) -> Self { + value.clone() + } + } + + #[derive(Clone, Debug, Deserialize, Serialize)] + pub struct FactoryPingResult { + pub ok: bool, + } + + impl From<&FactoryPingResult> for FactoryPingResult { + fn from(value: &FactoryPingResult) -> Self { + value.clone() + } + } + + #[derive(Clone, Debug, Deserialize, Serialize)] + pub struct FactoryWhatsNext { + pub supported_targets: Vec, + } + + impl From<&FactoryWhatsNext> for FactoryWhatsNext { + fn from(value: &FactoryWhatsNext) -> Self { + value.clone() + } + } + + #[derive(Clone, Debug, Deserialize, Serialize)] + pub struct FactoryWorker { + pub bootstrap: String, + pub id: String, + pub online: bool, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub private: Option, + pub recycle: bool, + } + + impl From<&FactoryWorker> for FactoryWorker { + fn from(value: &FactoryWorker) -> Self { value.clone() } } #[derive(Clone, Debug, Deserialize, Serialize)] - pub struct TaskEvent { + pub struct FactoryWorkerAppend { pub payload: String, - pub seq: u32, pub stream: String, pub time: chrono::DateTime, } - impl From<&TaskEvent> for TaskEvent { - fn from(value: &TaskEvent) -> Self { + impl From<&FactoryWorkerAppend> for FactoryWorkerAppend { + fn from(value: &FactoryWorkerAppend) -> Self { value.clone() } } #[derive(Clone, Debug, Deserialize, Serialize)] - pub struct TaskOutput { - pub id: String, - pub path: String, - pub size: u64, + pub struct FactoryWorkerAppendResult { + pub retry: bool, } - impl From<&TaskOutput> for TaskOutput { - fn from(value: &TaskOutput) -> Self { + impl From<&FactoryWorkerAppendResult> for FactoryWorkerAppendResult { + fn from(value: &FactoryWorkerAppendResult) -> Self { value.clone() } } #[derive(Clone, Debug, Deserialize, Serialize)] - pub struct TaskSubmit { - pub name: String, - #[serde(default, skip_serializing_if = "Vec::is_empty")] - pub output_rules: Vec, - pub script: String, + pub struct FactoryWorkerAssociate { + #[serde(default, skip_serializing_if = "Option::is_none")] + pub metadata: Option, + pub private: String, } - impl From<&TaskSubmit> for TaskSubmit { - fn from(value: &TaskSubmit) -> Self { + impl From<&FactoryWorkerAssociate> for FactoryWorkerAssociate { + fn from(value: &FactoryWorkerAssociate) -> Self { value.clone() } } #[derive(Clone, Debug, Deserialize, Serialize)] - pub struct TaskSubmitResult { - pub id: String, + pub struct FactoryWorkerCreate { + #[serde(default, skip_serializing_if = "Option::is_none")] + pub job: Option, + pub target: String, + #[serde(default)] + pub wait_for_flush: bool, } - impl From<&TaskSubmitResult> for TaskSubmitResult { - fn from(value: &TaskSubmitResult) -> Self { + impl From<&FactoryWorkerCreate> for FactoryWorkerCreate { + fn from(value: &FactoryWorkerCreate) -> Self { value.clone() } } #[derive(Clone, Debug, Deserialize, Serialize)] - pub struct UploadedChunk { - pub id: String, + pub struct FactoryWorkerResult { + #[serde(default, skip_serializing_if = "Option::is_none")] + pub worker: Option, } - impl From<&UploadedChunk> for UploadedChunk { - fn from(value: &UploadedChunk) -> Self { + impl From<&FactoryWorkerResult> for FactoryWorkerResult { + fn from(value: &FactoryWorkerResult) -> Self { value.clone() } } #[derive(Clone, Debug, Deserialize, Serialize)] - pub struct UserCreate { + pub struct Job { + pub cancelled: bool, + pub id: String, pub name: String, + pub output_rules: Vec, + pub owner: String, + pub state: String, + pub tags: std::collections::HashMap, + pub target: String, + pub target_real: String, + pub tasks: Vec, + #[serde(default, skip_serializing_if = "std::collections::HashMap::is_empty")] + pub times: std::collections::HashMap>, } - impl From<&UserCreate> for UserCreate { - fn from(value: &UserCreate) -> Self { + impl From<&Job> for Job { + fn from(value: &Job) -> Self { value.clone() } } #[derive(Clone, Debug, Deserialize, Serialize)] - pub struct UserCreateResult { - pub id: String, + pub struct JobAddInput { + pub chunks: Vec, + pub commit_id: String, pub name: String, - pub token: String, + pub size: u64, } - impl From<&UserCreateResult> for UserCreateResult { - fn from(value: &UserCreateResult) -> Self { + impl From<&JobAddInput> for JobAddInput { + fn from(value: &JobAddInput) -> Self { value.clone() } } #[derive(Clone, Debug, Deserialize, Serialize)] - pub struct WhoamiResult { - pub id: String, - pub name: String, + pub struct JobAddInputResult { + pub complete: bool, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub error: Option, } - impl From<&WhoamiResult> for WhoamiResult { - fn from(value: &WhoamiResult) -> Self { + impl From<&JobAddInputResult> for JobAddInputResult { + fn from(value: &JobAddInputResult) -> Self { value.clone() } } #[derive(Clone, Debug, Deserialize, Serialize)] - pub struct Worker { - pub deleted: bool, - pub id: String, + pub struct JobEvent { + pub payload: String, + pub seq: u32, + pub stream: String, #[serde(default, skip_serializing_if = "Option::is_none")] - pub instance_id: Option, + pub task: Option, + pub time: chrono::DateTime, #[serde(default, skip_serializing_if = "Option::is_none")] - pub lastping: Option>, - pub recycle: bool, - pub tasks: Vec, + pub time_remote: Option>, } - impl From<&Worker> for Worker { - fn from(value: &Worker) -> Self { + impl From<&JobEvent> for JobEvent { + fn from(value: &JobEvent) -> Self { value.clone() } } #[derive(Clone, Debug, Deserialize, Serialize)] - pub struct WorkerAddOutput { - pub chunks: Vec, + pub struct JobOutput { + pub id: String, pub path: String, - pub size: i64, + pub size: u64, } - impl From<&WorkerAddOutput> for WorkerAddOutput { - fn from(value: &WorkerAddOutput) -> Self { + impl From<&JobOutput> for JobOutput { + fn from(value: &JobOutput) -> Self { value.clone() } } #[derive(Clone, Debug, Deserialize, Serialize)] - pub struct WorkerAppendTask { - pub payload: String, - pub stream: String, - pub time: chrono::DateTime, + pub struct JobOutputPublish { + pub name: String, + pub series: String, + pub version: String, } - impl From<&WorkerAppendTask> for WorkerAppendTask { - fn from(value: &WorkerAppendTask) -> Self { + impl From<&JobOutputPublish> for JobOutputPublish { + fn from(value: &JobOutputPublish) -> Self { value.clone() } } #[derive(Clone, Debug, Deserialize, Serialize)] - pub struct WorkerBootstrap { - pub bootstrap: String, - pub token: String, + pub struct JobOutputSignedUrl { + #[serde(default, skip_serializing_if = "Option::is_none")] + pub content_disposition: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub content_type: Option, + pub expiry_seconds: u64, } - impl From<&WorkerBootstrap> for WorkerBootstrap { - fn from(value: &WorkerBootstrap) -> Self { + impl From<&JobOutputSignedUrl> for JobOutputSignedUrl { + fn from(value: &JobOutputSignedUrl) -> Self { value.clone() } } #[derive(Clone, Debug, Deserialize, Serialize)] - pub struct WorkerBootstrapResult { - pub id: String, + pub struct JobOutputSignedUrlResult { + pub url: String, } - impl From<&WorkerBootstrapResult> for WorkerBootstrapResult { - fn from(value: &WorkerBootstrapResult) -> Self { + impl From<&JobOutputSignedUrlResult> for JobOutputSignedUrlResult { + fn from(value: &JobOutputSignedUrlResult) -> Self { value.clone() } } #[derive(Clone, Debug, Deserialize, Serialize)] - pub struct WorkerCompleteTask { - pub failed: bool, + pub struct JobStoreValue { + pub secret: bool, + pub value: String, } - impl From<&WorkerCompleteTask> for WorkerCompleteTask { - fn from(value: &WorkerCompleteTask) -> Self { + impl From<&JobStoreValue> for JobStoreValue { + fn from(value: &JobStoreValue) -> Self { value.clone() } } #[derive(Clone, Debug, Deserialize, Serialize)] - pub struct WorkerPingResult { - pub poweroff: bool, + pub struct JobStoreValueInfo { + pub secret: bool, + pub source: String, + pub time_update: chrono::DateTime, #[serde(default, skip_serializing_if = "Option::is_none")] - pub task: Option, + pub value: Option, } - impl From<&WorkerPingResult> for WorkerPingResult { - fn from(value: &WorkerPingResult) -> Self { + impl From<&JobStoreValueInfo> for JobStoreValueInfo { + fn from(value: &JobStoreValueInfo) -> Self { value.clone() } } #[derive(Clone, Debug, Deserialize, Serialize)] - pub struct WorkerPingTask { - pub id: String, + pub struct JobSubmit { + #[serde(default, skip_serializing_if = "std::collections::HashMap::is_empty")] + pub depends: std::collections::HashMap, + #[serde(default, skip_serializing_if = "Vec::is_empty")] + pub inputs: Vec, + pub name: String, pub output_rules: Vec, - pub script: String, + #[serde(default, skip_serializing_if = "std::collections::HashMap::is_empty")] + pub tags: std::collections::HashMap, + pub target: String, + pub tasks: Vec, } - impl From<&WorkerPingTask> for WorkerPingTask { - fn from(value: &WorkerPingTask) -> Self { + impl From<&JobSubmit> for JobSubmit { + fn from(value: &JobSubmit) -> Self { + value.clone() + } + } + + #[derive(Clone, Debug, Deserialize, Serialize)] + pub struct JobSubmitResult { + pub id: String, + } + + impl From<&JobSubmitResult> for JobSubmitResult { + fn from(value: &JobSubmitResult) -> Self { + value.clone() + } + } + + #[derive(Clone, Debug, Deserialize, Serialize)] + pub struct Quota { + pub max_bytes_per_input: u64, + } + + impl From<&Quota> for Quota { + fn from(value: &Quota) -> Self { value.clone() } } #[derive(Clone, Debug, Deserialize, Serialize)] - pub struct WorkerTask { + pub struct Target { + pub desc: String, pub id: String, pub name: String, - pub owner: String, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub privilege: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub redirect: Option, } - impl From<&WorkerTask> for WorkerTask { - fn from(value: &WorkerTask) -> Self { + impl From<&Target> for Target { + fn from(value: &Target) -> Self { value.clone() } } #[derive(Clone, Debug, Deserialize, Serialize)] - pub struct WorkersResult { - pub workers: Vec, + pub struct TargetCreate { + pub desc: String, + pub name: String, } - impl From<&WorkersResult> for WorkersResult { - fn from(value: &WorkersResult) -> Self { + impl From<&TargetCreate> for TargetCreate { + fn from(value: &TargetCreate) -> Self { value.clone() } } -} -#[derive(Clone, Debug)] -///Client for Buildomat -/// -///Version: 1.0 -pub struct Client { - pub(crate) baseurl: String, - pub(crate) client: reqwest::Client, -} + #[derive(Clone, Debug, Deserialize, Serialize)] + pub struct TargetCreateResult { + pub id: String, + } -impl Client { - /// Create a new client. - /// - /// `baseurl` is the base URL provided to the internal - /// `reqwest::Client`, and should include a scheme and hostname, - /// as well as port and a path stem if applicable. - pub fn new(baseurl: &str) -> Self { - #[cfg(not(target_arch = "wasm32"))] - let client = { - let dur = std::time::Duration::from_secs(15); - reqwest::ClientBuilder::new() - .connect_timeout(dur) - .timeout(dur) - }; - #[cfg(target_arch = "wasm32")] - let client = reqwest::ClientBuilder::new(); - Self::new_with_client(baseurl, client.build().unwrap()) + impl From<&TargetCreateResult> for TargetCreateResult { + fn from(value: &TargetCreateResult) -> Self { + value.clone() + } } - /// Construct a new client with an existing `reqwest::Client`, - /// allowing more control over its configuration. - /// - /// `baseurl` is the base URL provided to the internal - /// `reqwest::Client`, and should include a scheme and hostname, - /// as well as port and a path stem if applicable. - pub fn new_with_client(baseurl: &str, client: reqwest::Client) -> Self { - Self { - baseurl: baseurl.to_string(), - client, + #[derive(Clone, Debug, Deserialize, Serialize)] + pub struct TargetRedirect { + #[serde(default, skip_serializing_if = "Option::is_none")] + pub redirect: Option, + } + + impl From<&TargetRedirect> for TargetRedirect { + fn from(value: &TargetRedirect) -> Self { + value.clone() } } - /// Get the base URL to which requests are made. - pub fn baseurl(&self) -> &String { - &self.baseurl + #[derive(Clone, Debug, Deserialize, Serialize)] + pub struct TargetRename { + pub new_name: String, + pub signpost_description: String, } - /// Get the internal `reqwest::Client` used to make requests. - pub fn client(&self) -> &reqwest::Client { - &self.client + impl From<&TargetRename> for TargetRename { + fn from(value: &TargetRename) -> Self { + value.clone() + } } - /// Get the version of this API. - /// - /// This string is pulled directly from the source OpenAPI - /// document and may be in any format the API selects. - pub fn api_version(&self) -> &'static str { - "1.0" + #[derive(Clone, Debug, Deserialize, Serialize)] + pub struct Task { + pub env: std::collections::HashMap, + pub env_clear: bool, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub gid: Option, + pub name: String, + pub script: String, + pub state: String, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub uid: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub workdir: Option, + } + + impl From<&Task> for Task { + fn from(value: &Task) -> Self { + value.clone() + } + } + + #[derive(Clone, Debug, Deserialize, Serialize)] + pub struct TaskSubmit { + pub env: std::collections::HashMap, + pub env_clear: bool, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub gid: Option, + pub name: String, + pub script: String, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub uid: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub workdir: Option, + } + + impl From<&TaskSubmit> for TaskSubmit { + fn from(value: &TaskSubmit) -> Self { + value.clone() + } + } + + #[derive(Clone, Debug, Deserialize, Serialize)] + pub struct UploadedChunk { + pub id: String, + } + + impl From<&UploadedChunk> for UploadedChunk { + fn from(value: &UploadedChunk) -> Self { + value.clone() + } + } + + #[derive(Clone, Debug, Deserialize, Serialize)] + pub struct User { + pub id: String, + pub name: String, + pub privileges: Vec, + pub time_create: chrono::DateTime, + } + + impl From<&User> for User { + fn from(value: &User) -> Self { + value.clone() + } + } + + #[derive(Clone, Debug, Deserialize, Serialize)] + pub struct UserCreate { + pub name: String, + } + + impl From<&UserCreate> for UserCreate { + fn from(value: &UserCreate) -> Self { + value.clone() + } + } + + #[derive(Clone, Debug, Deserialize, Serialize)] + pub struct UserCreateResult { + pub id: String, + pub name: String, + pub token: String, + } + + impl From<&UserCreateResult> for UserCreateResult { + fn from(value: &UserCreateResult) -> Self { + value.clone() + } + } + + #[derive(Clone, Debug, Deserialize, Serialize)] + pub struct WhoamiResult { + pub id: String, + pub name: String, + } + + impl From<&WhoamiResult> for WhoamiResult { + fn from(value: &WhoamiResult) -> Self { + value.clone() + } + } + + #[derive(Clone, Debug, Deserialize, Serialize)] + pub struct Worker { + pub bootstrap: bool, + pub deleted: bool, + pub factory: String, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub factory_private: Option, + pub id: String, + pub jobs: Vec, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub lastping: Option>, + pub recycle: bool, + pub target: String, + } + + impl From<&Worker> for Worker { + fn from(value: &Worker) -> Self { + value.clone() + } + } + + #[derive(Clone, Debug, Deserialize, Serialize)] + pub struct WorkerAddOutput { + pub chunks: Vec, + pub commit_id: String, + pub path: String, + pub size: u64, + } + + impl From<&WorkerAddOutput> for WorkerAddOutput { + fn from(value: &WorkerAddOutput) -> Self { + value.clone() + } + } + + #[derive(Clone, Debug, Deserialize, Serialize)] + pub struct WorkerAddOutputResult { + pub complete: bool, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub error: Option, + } + + impl From<&WorkerAddOutputResult> for WorkerAddOutputResult { + fn from(value: &WorkerAddOutputResult) -> Self { + value.clone() + } + } + + #[derive(Clone, Debug, Deserialize, Serialize)] + pub struct WorkerAppendJob { + pub payload: String, + pub stream: String, + pub time: chrono::DateTime, + } + + impl From<&WorkerAppendJob> for WorkerAppendJob { + fn from(value: &WorkerAppendJob) -> Self { + value.clone() + } + } + + #[derive(Clone, Debug, Deserialize, Serialize)] + pub struct WorkerAppendJobOrTask { + pub payload: String, + pub stream: String, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub task: Option, + pub time: chrono::DateTime, + } + + impl From<&WorkerAppendJobOrTask> for WorkerAppendJobOrTask { + fn from(value: &WorkerAppendJobOrTask) -> Self { + value.clone() + } + } + + #[derive(Clone, Debug, Deserialize, Serialize)] + pub struct WorkerBootstrap { + pub bootstrap: String, + pub token: String, + } + + impl From<&WorkerBootstrap> for WorkerBootstrap { + fn from(value: &WorkerBootstrap) -> Self { + value.clone() + } + } + + #[derive(Clone, Debug, Deserialize, Serialize)] + pub struct WorkerBootstrapResult { + pub id: String, + } + + impl From<&WorkerBootstrapResult> for WorkerBootstrapResult { + fn from(value: &WorkerBootstrapResult) -> Self { + value.clone() + } + } + + #[derive(Clone, Debug, Deserialize, Serialize)] + pub struct WorkerCompleteJob { + pub failed: bool, + } + + impl From<&WorkerCompleteJob> for WorkerCompleteJob { + fn from(value: &WorkerCompleteJob) -> Self { + value.clone() + } + } + + #[derive(Clone, Debug, Deserialize, Serialize)] + pub struct WorkerCompleteTask { + pub failed: bool, + } + + impl From<&WorkerCompleteTask> for WorkerCompleteTask { + fn from(value: &WorkerCompleteTask) -> Self { + value.clone() + } + } + + #[derive(Clone, Debug, Deserialize, Serialize)] + pub struct WorkerJob { + pub id: String, + pub name: String, + pub owner: String, + pub state: String, + pub tags: std::collections::HashMap, + } + + impl From<&WorkerJob> for WorkerJob { + fn from(value: &WorkerJob) -> Self { + value.clone() + } + } + + #[derive(Clone, Debug, Deserialize, Serialize)] + pub struct WorkerJobQuota { + pub max_bytes_per_output: u64, + } + + impl From<&WorkerJobQuota> for WorkerJobQuota { + fn from(value: &WorkerJobQuota) -> Self { + value.clone() + } + } + + #[derive(Clone, Debug, Deserialize, Serialize)] + pub struct WorkerJobStoreGet { + #[serde(default, skip_serializing_if = "Option::is_none")] + pub value: Option, + } + + impl From<&WorkerJobStoreGet> for WorkerJobStoreGet { + fn from(value: &WorkerJobStoreGet) -> Self { + value.clone() + } + } + + #[derive(Clone, Debug, Deserialize, Serialize)] + pub struct WorkerJobStoreValue { + pub secret: bool, + pub value: String, + } + + impl From<&WorkerJobStoreValue> for WorkerJobStoreValue { + fn from(value: &WorkerJobStoreValue) -> Self { + value.clone() + } + } + + #[derive(Clone, Debug, Deserialize, Serialize)] + pub struct WorkerPingInput { + pub id: String, + pub name: String, + } + + impl From<&WorkerPingInput> for WorkerPingInput { + fn from(value: &WorkerPingInput) -> Self { + value.clone() + } + } + + #[derive(Clone, Debug, Deserialize, Serialize)] + pub struct WorkerPingJob { + pub id: String, + pub inputs: Vec, + pub name: String, + pub output_rules: Vec, + pub tasks: Vec, + } + + impl From<&WorkerPingJob> for WorkerPingJob { + fn from(value: &WorkerPingJob) -> Self { + value.clone() + } + } + + #[derive(Clone, Debug, Deserialize, Serialize)] + pub struct WorkerPingOutputRule { + pub ignore: bool, + pub require_match: bool, + pub rule: String, + pub size_change_ok: bool, + } + + impl From<&WorkerPingOutputRule> for WorkerPingOutputRule { + fn from(value: &WorkerPingOutputRule) -> Self { + value.clone() + } + } + + #[derive(Clone, Debug, Deserialize, Serialize)] + pub struct WorkerPingResult { + #[serde(default, skip_serializing_if = "Option::is_none")] + pub factory_metadata: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub job: Option, + pub poweroff: bool, + } + + impl From<&WorkerPingResult> for WorkerPingResult { + fn from(value: &WorkerPingResult) -> Self { + value.clone() + } + } + + #[derive(Clone, Debug, Deserialize, Serialize)] + pub struct WorkerPingTask { + pub env: std::collections::HashMap, + pub env_clear: bool, + pub gid: u32, + pub id: u32, + pub name: String, + pub script: String, + pub uid: u32, + pub workdir: String, + } + + impl From<&WorkerPingTask> for WorkerPingTask { + fn from(value: &WorkerPingTask) -> Self { + value.clone() + } + } + + #[derive(Clone, Debug, Deserialize, Serialize)] + pub struct WorkersResult { + pub workers: Vec, + } + + impl From<&WorkersResult> for WorkersResult { + fn from(value: &WorkersResult) -> Self { + value.clone() + } + } +} + +#[derive(Clone, Debug)] +///Client for Buildomat +/// +///Version: 1.0 +pub struct Client { + pub(crate) baseurl: String, + pub(crate) client: reqwest::Client, +} + +impl Client { + /// Create a new client. + /// + /// `baseurl` is the base URL provided to the internal + /// `reqwest::Client`, and should include a scheme and hostname, + /// as well as port and a path stem if applicable. + pub fn new(baseurl: &str) -> Self { + #[cfg(not(target_arch = "wasm32"))] + let client = { + let dur = std::time::Duration::from_secs(15); + reqwest::ClientBuilder::new() + .connect_timeout(dur) + .timeout(dur) + }; + #[cfg(target_arch = "wasm32")] + let client = reqwest::ClientBuilder::new(); + Self::new_with_client(baseurl, client.build().unwrap()) + } + + /// Construct a new client with an existing `reqwest::Client`, + /// allowing more control over its configuration. + /// + /// `baseurl` is the base URL provided to the internal + /// `reqwest::Client`, and should include a scheme and hostname, + /// as well as port and a path stem if applicable. + pub fn new_with_client(baseurl: &str, client: reqwest::Client) -> Self { + Self { + baseurl: baseurl.to_string(), + client, + } + } + + /// Get the base URL to which requests are made. + pub fn baseurl(&self) -> &String { + &self.baseurl + } + + /// Get the internal `reqwest::Client` used to make requests. + pub fn client(&self) -> &reqwest::Client { + &self.client + } + + /// Get the version of this API. + /// + /// This string is pulled directly from the source OpenAPI + /// document and may be in any format the API selects. + pub fn api_version(&self) -> &'static str { + "1.0" + } +} + +impl Client { + ///Sends a `POST` request to `/0/admin/factory` + pub async fn factory_create<'a>( + &'a self, + body: &'a types::FactoryCreate, + ) -> Result, Error> { + let url = format!("{}/0/admin/factory", self.baseurl,); + let request = self + .client + .post(url) + .header( + reqwest::header::ACCEPT, + reqwest::header::HeaderValue::from_static("application/json"), + ) + .json(&body) + .build()?; + let result = self.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 201u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Sends a `GET` request to `/0/admin/jobs` + pub async fn admin_jobs_get<'a>( + &'a self, + active: Option, + completed: Option, + ) -> Result>, Error> { + let url = format!("{}/0/admin/jobs", self.baseurl,); + let mut query = Vec::with_capacity(2usize); + if let Some(v) = &active { + query.push(("active", v.to_string())); + } + + if let Some(v) = &completed { + query.push(("completed", v.to_string())); + } + + let request = self + .client + .get(url) + .header( + reqwest::header::ACCEPT, + reqwest::header::HeaderValue::from_static("application/json"), + ) + .query(&query) + .build()?; + let result = self.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Sends a `GET` request to `/0/admin/jobs/{job}` + pub async fn admin_job_get<'a>( + &'a self, + job: &'a str, + ) -> Result, Error> { + let url = format!( + "{}/0/admin/jobs/{}", + self.baseurl, + encode_path(&job.to_string()), + ); + let request = self + .client + .get(url) + .header( + reqwest::header::ACCEPT, + reqwest::header::HeaderValue::from_static("application/json"), + ) + .build()?; + let result = self.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Sends a `POST` request to `/0/admin/jobs/{job}/archive` + pub async fn admin_job_archive_request<'a>( + &'a self, + job: &'a str, + ) -> Result, Error> { + let url = format!( + "{}/0/admin/jobs/{}/archive", + self.baseurl, + encode_path(&job.to_string()), + ); + let request = self + .client + .post(url) + .header( + reqwest::header::ACCEPT, + reqwest::header::HeaderValue::from_static("application/json"), + ) + .build()?; + let result = self.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Sends a `POST` request to `/0/admin/target` + pub async fn target_create<'a>( + &'a self, + body: &'a types::TargetCreate, + ) -> Result, Error> { + let url = format!("{}/0/admin/target", self.baseurl,); + let request = self + .client + .post(url) + .header( + reqwest::header::ACCEPT, + reqwest::header::HeaderValue::from_static("application/json"), + ) + .json(&body) + .build()?; + let result = self.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 201u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Sends a `GET` request to `/0/admin/targets` + pub async fn targets_list<'a>( + &'a self, + ) -> Result>, Error> { + let url = format!("{}/0/admin/targets", self.baseurl,); + let request = self + .client + .get(url) + .header( + reqwest::header::ACCEPT, + reqwest::header::HeaderValue::from_static("application/json"), + ) + .build()?; + let result = self.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Sends a `PUT` request to `/0/admin/targets/{target}/redirect` + pub async fn target_redirect<'a>( + &'a self, + target: &'a str, + body: &'a types::TargetRedirect, + ) -> Result, Error> { + let url = format!( + "{}/0/admin/targets/{}/redirect", + self.baseurl, + encode_path(&target.to_string()), + ); + let request = self + .client + .put(url) + .header( + reqwest::header::ACCEPT, + reqwest::header::HeaderValue::from_static("application/json"), + ) + .json(&body) + .build()?; + let result = self.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Sends a `POST` request to `/0/admin/targets/{target}/rename` + pub async fn target_rename<'a>( + &'a self, + target: &'a str, + body: &'a types::TargetRename, + ) -> Result, Error> { + let url = format!( + "{}/0/admin/targets/{}/rename", + self.baseurl, + encode_path(&target.to_string()), + ); + let request = self + .client + .post(url) + .header( + reqwest::header::ACCEPT, + reqwest::header::HeaderValue::from_static("application/json"), + ) + .json(&body) + .build()?; + let result = self.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 201u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Sends a `DELETE` request to `/0/admin/targets/{target}/require` + pub async fn target_require_no_privilege<'a>( + &'a self, + target: &'a str, + ) -> Result, Error> { + let url = format!( + "{}/0/admin/targets/{}/require", + self.baseurl, + encode_path(&target.to_string()), + ); + let request = self + .client + .delete(url) + .header( + reqwest::header::ACCEPT, + reqwest::header::HeaderValue::from_static("application/json"), + ) + .build()?; + let result = self.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Sends a `PUT` request to `/0/admin/targets/{target}/require/{privilege}` + pub async fn target_require_privilege<'a>( + &'a self, + target: &'a str, + privilege: &'a str, + ) -> Result, Error> { + let url = format!( + "{}/0/admin/targets/{}/require/{}", + self.baseurl, + encode_path(&target.to_string()), + encode_path(&privilege.to_string()), + ); + let request = self + .client + .put(url) + .header( + reqwest::header::ACCEPT, + reqwest::header::HeaderValue::from_static("application/json"), + ) + .build()?; + let result = self.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Sends a `POST` request to `/0/admin/worker/{worker}/recycle` + pub async fn worker_recycle<'a>( + &'a self, + worker: &'a str, + ) -> Result, Error> { + let url = format!( + "{}/0/admin/worker/{}/recycle", + self.baseurl, + encode_path(&worker.to_string()), + ); + let request = self + .client + .post(url) + .header( + reqwest::header::ACCEPT, + reqwest::header::HeaderValue::from_static("application/json"), + ) + .build()?; + let result = self.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Sends a `POST` request to `/0/control/hold` + pub async fn control_hold<'a>(&'a self) -> Result, Error> { + let url = format!("{}/0/control/hold", self.baseurl,); + let request = self + .client + .post(url) + .header( + reqwest::header::ACCEPT, + reqwest::header::HeaderValue::from_static("application/json"), + ) + .build()?; + let result = self.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Sends a `POST` request to `/0/control/resume` + pub async fn control_resume<'a>(&'a self) -> Result, Error> { + let url = format!("{}/0/control/resume", self.baseurl,); + let request = self + .client + .post(url) + .header( + reqwest::header::ACCEPT, + reqwest::header::HeaderValue::from_static("application/json"), + ) + .build()?; + let result = self.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Sends a `POST` request to `/0/factory/lease` + pub async fn factory_lease<'a>( + &'a self, + body: &'a types::FactoryWhatsNext, + ) -> Result, Error> { + let url = format!("{}/0/factory/lease", self.baseurl,); + let request = self + .client + .post(url) + .header( + reqwest::header::ACCEPT, + reqwest::header::HeaderValue::from_static("application/json"), + ) + .json(&body) + .build()?; + let result = self.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Sends a `POST` request to `/0/factory/lease/{job}` + pub async fn factory_lease_renew<'a>( + &'a self, + job: &'a str, + ) -> Result, Error> { + let url = format!( + "{}/0/factory/lease/{}", + self.baseurl, + encode_path(&job.to_string()), + ); + let request = self + .client + .post(url) + .header( + reqwest::header::ACCEPT, + reqwest::header::HeaderValue::from_static("application/json"), + ) + .build()?; + let result = self.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Sends a `GET` request to `/0/factory/ping` + pub async fn factory_ping<'a>( + &'a self, + ) -> Result, Error> { + let url = format!("{}/0/factory/ping", self.baseurl,); + let request = self + .client + .get(url) + .header( + reqwest::header::ACCEPT, + reqwest::header::HeaderValue::from_static("application/json"), + ) + .build()?; + let result = self.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Sends a `POST` request to `/0/factory/worker` + pub async fn factory_worker_create<'a>( + &'a self, + body: &'a types::FactoryWorkerCreate, + ) -> Result, Error> { + let url = format!("{}/0/factory/worker", self.baseurl,); + let request = self + .client + .post(url) + .header( + reqwest::header::ACCEPT, + reqwest::header::HeaderValue::from_static("application/json"), + ) + .json(&body) + .build()?; + let result = self.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 201u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Sends a `GET` request to `/0/factory/worker/{worker}` + pub async fn factory_worker_get<'a>( + &'a self, + worker: &'a str, + ) -> Result, Error> { + let url = format!( + "{}/0/factory/worker/{}", + self.baseurl, + encode_path(&worker.to_string()), + ); + let request = self + .client + .get(url) + .header( + reqwest::header::ACCEPT, + reqwest::header::HeaderValue::from_static("application/json"), + ) + .build()?; + let result = self.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Sends a `DELETE` request to `/0/factory/worker/{worker}` + pub async fn factory_worker_destroy<'a>( + &'a self, + worker: &'a str, + ) -> Result, Error> { + let url = format!( + "{}/0/factory/worker/{}", + self.baseurl, + encode_path(&worker.to_string()), + ); + let request = self + .client + .delete(url) + .header( + reqwest::header::ACCEPT, + reqwest::header::HeaderValue::from_static("application/json"), + ) + .build()?; + let result = self.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Sends a `PATCH` request to `/0/factory/worker/{worker}` + pub async fn factory_worker_associate<'a>( + &'a self, + worker: &'a str, + body: &'a types::FactoryWorkerAssociate, + ) -> Result, Error> { + let url = format!( + "{}/0/factory/worker/{}", + self.baseurl, + encode_path(&worker.to_string()), + ); + let request = self + .client + .patch(url) + .header( + reqwest::header::ACCEPT, + reqwest::header::HeaderValue::from_static("application/json"), + ) + .json(&body) + .build()?; + let result = self.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Sends a `POST` request to `/0/factory/worker/{worker}/append` + pub async fn factory_worker_append<'a>( + &'a self, + worker: &'a str, + body: &'a types::FactoryWorkerAppend, + ) -> Result, Error> { + let url = format!( + "{}/0/factory/worker/{}/append", + self.baseurl, + encode_path(&worker.to_string()), + ); + let request = self + .client + .post(url) + .header( + reqwest::header::ACCEPT, + reqwest::header::HeaderValue::from_static("application/json"), + ) + .json(&body) + .build()?; + let result = self.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Sends a `POST` request to `/0/factory/worker/{worker}/flush` + pub async fn factory_worker_flush<'a>( + &'a self, + worker: &'a str, + ) -> Result, Error> { + let url = format!( + "{}/0/factory/worker/{}/flush", + self.baseurl, + encode_path(&worker.to_string()), + ); + let request = self + .client + .post(url) + .header( + reqwest::header::ACCEPT, + reqwest::header::HeaderValue::from_static("application/json"), + ) + .build()?; + let result = self.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Sends a `GET` request to `/0/factory/workers` + pub async fn factory_workers<'a>( + &'a self, + ) -> Result>, Error> { + let url = format!("{}/0/factory/workers", self.baseurl,); + let request = self + .client + .get(url) + .header( + reqwest::header::ACCEPT, + reqwest::header::HeaderValue::from_static("application/json"), + ) + .build()?; + let result = self.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Sends a `GET` request to `/0/job/{job}` + pub async fn job_get<'a>( + &'a self, + job: &'a str, + ) -> Result, Error> { + let url = format!("{}/0/job/{}", self.baseurl, encode_path(&job.to_string()),); + let request = self + .client + .get(url) + .header( + reqwest::header::ACCEPT, + reqwest::header::HeaderValue::from_static("application/json"), + ) + .build()?; + let result = self.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Sends a `GET` request to `/0/jobs` + pub async fn jobs_get<'a>( + &'a self, + ) -> Result>, Error> { + let url = format!("{}/0/jobs", self.baseurl,); + let request = self + .client + .get(url) + .header( + reqwest::header::ACCEPT, + reqwest::header::HeaderValue::from_static("application/json"), + ) + .build()?; + let result = self.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Sends a `POST` request to `/0/jobs` + pub async fn job_submit<'a>( + &'a self, + body: &'a types::JobSubmit, + ) -> Result, Error> { + let url = format!("{}/0/jobs", self.baseurl,); + let request = self + .client + .post(url) + .header( + reqwest::header::ACCEPT, + reqwest::header::HeaderValue::from_static("application/json"), + ) + .json(&body) + .build()?; + let result = self.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 201u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Sends a `POST` request to `/0/jobs/{job}/cancel` + pub async fn job_cancel<'a>( + &'a self, + job: &'a str, + ) -> Result, Error> { + let url = format!( + "{}/0/jobs/{}/cancel", + self.baseurl, + encode_path(&job.to_string()), + ); + let request = self + .client + .post(url) + .header( + reqwest::header::ACCEPT, + reqwest::header::HeaderValue::from_static("application/json"), + ) + .build()?; + let result = self.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Sends a `POST` request to `/0/jobs/{job}/chunk` + pub async fn job_upload_chunk<'a, B: Into>( + &'a self, + job: &'a str, + body: B, + ) -> Result, Error> { + let url = format!( + "{}/0/jobs/{}/chunk", + self.baseurl, + encode_path(&job.to_string()), + ); + let request = self + .client + .post(url) + .header( + reqwest::header::ACCEPT, + reqwest::header::HeaderValue::from_static("application/json"), + ) + .header( + reqwest::header::CONTENT_TYPE, + reqwest::header::HeaderValue::from_static("application/octet-stream"), + ) + .body(body) + .build()?; + let result = self.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 201u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Sends a `GET` request to `/0/jobs/{job}/events` + pub async fn job_events_get<'a>( + &'a self, + job: &'a str, + minseq: Option, + ) -> Result>, Error> { + let url = format!( + "{}/0/jobs/{}/events", + self.baseurl, + encode_path(&job.to_string()), + ); + let mut query = Vec::with_capacity(1usize); + if let Some(v) = &minseq { + query.push(("minseq", v.to_string())); + } + + let request = self + .client + .get(url) + .header( + reqwest::header::ACCEPT, + reqwest::header::HeaderValue::from_static("application/json"), + ) + .query(&query) + .build()?; + let result = self.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Sends a `GET` request to `/0/jobs/{job}/outputs` + pub async fn job_outputs_get<'a>( + &'a self, + job: &'a str, + ) -> Result>, Error> { + let url = format!( + "{}/0/jobs/{}/outputs", + self.baseurl, + encode_path(&job.to_string()), + ); + let request = self + .client + .get(url) + .header( + reqwest::header::ACCEPT, + reqwest::header::HeaderValue::from_static("application/json"), + ) + .build()?; + let result = self.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Sends a `GET` request to `/0/jobs/{job}/outputs/{output}` + pub async fn job_output_download<'a>( + &'a self, + job: &'a str, + output: &'a str, + ) -> Result, Error> { + let url = format!( + "{}/0/jobs/{}/outputs/{}", + self.baseurl, + encode_path(&job.to_string()), + encode_path(&output.to_string()), + ); + let request = self.client.get(url).build()?; + let result = self.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200..=299 => Ok(ResponseValue::stream(response)), + _ => Err(Error::ErrorResponse(ResponseValue::stream(response))), + } + } + + ///Sends a `POST` request to `/0/jobs/{job}/outputs/{output}/publish` + pub async fn job_output_publish<'a>( + &'a self, + job: &'a str, + output: &'a str, + body: &'a types::JobOutputPublish, + ) -> Result, Error> { + let url = format!( + "{}/0/jobs/{}/outputs/{}/publish", + self.baseurl, + encode_path(&job.to_string()), + encode_path(&output.to_string()), + ); + let request = self + .client + .post(url) + .header( + reqwest::header::ACCEPT, + reqwest::header::HeaderValue::from_static("application/json"), + ) + .json(&body) + .build()?; + let result = self.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Sends a `POST` request to `/0/jobs/{job}/outputs/{output}/sign` + pub async fn job_output_signed_url<'a>( + &'a self, + job: &'a str, + output: &'a str, + body: &'a types::JobOutputSignedUrl, + ) -> Result, Error> { + let url = format!( + "{}/0/jobs/{}/outputs/{}/sign", + self.baseurl, + encode_path(&job.to_string()), + encode_path(&output.to_string()), + ); + let request = self + .client + .post(url) + .header( + reqwest::header::ACCEPT, + reqwest::header::HeaderValue::from_static("application/json"), + ) + .json(&body) + .build()?; + let result = self.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } } -} -impl Client { - ///Sends a `POST` request to `/v1/control/hold` - pub async fn control_hold<'a>(&'a self) -> Result, Error<()>> { - let url = format!("{}/v1/control/hold", self.baseurl,); + ///Sends a `GET` request to `/0/jobs/{job}/store` + pub async fn job_store_get_all<'a>( + &'a self, + job: &'a str, + ) -> Result< + ResponseValue>, + Error, + > { + let url = format!( + "{}/0/jobs/{}/store", + self.baseurl, + encode_path(&job.to_string()), + ); let request = self .client - .post(url) + .get(url) .header( reqwest::header::ACCEPT, reqwest::header::HeaderValue::from_static("application/json"), @@ -326,32 +1946,81 @@ impl Client { let response = result?; match response.status().as_u16() { 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), _ => Err(Error::UnexpectedResponse(response)), } } - ///Sends a `POST` request to `/v1/control/resume` - pub async fn control_resume<'a>(&'a self) -> Result, Error<()>> { - let url = format!("{}/v1/control/resume", self.baseurl,); - let request = self.client.post(url).build()?; + ///Sends a `PUT` request to `/0/jobs/{job}/store/{name}` + pub async fn job_store_put<'a>( + &'a self, + job: &'a str, + name: &'a str, + body: &'a types::JobStoreValue, + ) -> Result, Error> { + let url = format!( + "{}/0/jobs/{}/store/{}", + self.baseurl, + encode_path(&job.to_string()), + encode_path(&name.to_string()), + ); + let request = self + .client + .put(url) + .header( + reqwest::header::ACCEPT, + reqwest::header::HeaderValue::from_static("application/json"), + ) + .json(&body) + .build()?; let result = self.client.execute(request).await; let response = result?; match response.status().as_u16() { - 200u16 => Ok(ResponseValue::empty(response)), + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), _ => Err(Error::UnexpectedResponse(response)), } } - ///Sends a `GET` request to `/v1/task/{task}` - pub async fn task_get<'a>( + ///Sends a `GET` request to + /// `/0/public/file/{username}/{series}/{version}/{name}` + pub async fn public_file_download<'a>( &'a self, - task: &'a str, - ) -> Result, Error<()>> { + username: &'a str, + series: &'a str, + version: &'a str, + name: &'a str, + ) -> Result, Error> { let url = format!( - "{}/v1/task/{}", + "{}/0/public/file/{}/{}/{}/{}", self.baseurl, - encode_path(&task.to_string()), + encode_path(&username.to_string()), + encode_path(&series.to_string()), + encode_path(&version.to_string()), + encode_path(&name.to_string()), ); + let request = self.client.get(url).build()?; + let result = self.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200..=299 => Ok(ResponseValue::stream(response)), + _ => Err(Error::ErrorResponse(ResponseValue::stream(response))), + } + } + + ///Sends a `GET` request to `/0/quota` + pub async fn quota<'a>(&'a self) -> Result, Error> { + let url = format!("{}/0/quota", self.baseurl,); let request = self .client .get(url) @@ -364,13 +2033,27 @@ impl Client { let response = result?; match response.status().as_u16() { 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), _ => Err(Error::UnexpectedResponse(response)), } } - ///Sends a `GET` request to `/v1/tasks` - pub async fn tasks_get<'a>(&'a self) -> Result>, Error<()>> { - let url = format!("{}/v1/tasks", self.baseurl,); + ///Sends a `GET` request to `/0/users` + pub async fn users_list<'a>( + &'a self, + name: Option<&'a str>, + ) -> Result>, Error> { + let url = format!("{}/0/users", self.baseurl,); + let mut query = Vec::with_capacity(1usize); + if let Some(v) = &name { + query.push(("name", v.to_string())); + } + let request = self .client .get(url) @@ -378,21 +2061,28 @@ impl Client { reqwest::header::ACCEPT, reqwest::header::HeaderValue::from_static("application/json"), ) + .query(&query) .build()?; let result = self.client.execute(request).await; let response = result?; match response.status().as_u16() { 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), _ => Err(Error::UnexpectedResponse(response)), } } - ///Sends a `POST` request to `/v1/tasks` - pub async fn task_submit<'a>( + ///Sends a `POST` request to `/0/users` + pub async fn user_create<'a>( &'a self, - body: &'a types::TaskSubmit, - ) -> Result, Error<()>> { - let url = format!("{}/v1/tasks", self.baseurl,); + body: &'a types::UserCreate, + ) -> Result, Error> { + let url = format!("{}/0/users", self.baseurl,); let request = self .client .post(url) @@ -406,26 +2096,26 @@ impl Client { let response = result?; match response.status().as_u16() { 201u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), _ => Err(Error::UnexpectedResponse(response)), } } - ///Sends a `GET` request to `/v1/tasks/{task}/events` - pub async fn task_events_get<'a>( + ///Sends a `GET` request to `/0/users/{user}` + pub async fn user_get<'a>( &'a self, - task: &'a str, - minseq: Option, - ) -> Result>, Error<()>> { + user: &'a str, + ) -> Result, Error> { let url = format!( - "{}/v1/tasks/{}/events", + "{}/0/users/{}", self.baseurl, - encode_path(&task.to_string()), + encode_path(&user.to_string()), ); - let mut query = Vec::with_capacity(1usize); - if let Some(v) = &minseq { - query.push(("minseq", v.to_string())); - } - let request = self .client .get(url) @@ -433,29 +2123,36 @@ impl Client { reqwest::header::ACCEPT, reqwest::header::HeaderValue::from_static("application/json"), ) - .query(&query) .build()?; let result = self.client.execute(request).await; let response = result?; match response.status().as_u16() { 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), _ => Err(Error::UnexpectedResponse(response)), } } - ///Sends a `GET` request to `/v1/tasks/{task}/outputs` - pub async fn task_outputs_get<'a>( + ///Sends a `PUT` request to `/0/users/{user}/privilege/{privilege}` + pub async fn user_privilege_grant<'a>( &'a self, - task: &'a str, - ) -> Result>, Error<()>> { + user: &'a str, + privilege: &'a str, + ) -> Result, Error> { let url = format!( - "{}/v1/tasks/{}/outputs", + "{}/0/users/{}/privilege/{}", self.baseurl, - encode_path(&task.to_string()), + encode_path(&user.to_string()), + encode_path(&privilege.to_string()), ); let request = self .client - .get(url) + .put(url) .header( reqwest::header::ACCEPT, reqwest::header::HeaderValue::from_static("application/json"), @@ -464,103 +2161,156 @@ impl Client { let result = self.client.execute(request).await; let response = result?; match response.status().as_u16() { - 200u16 => ResponseValue::from_response(response).await, + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), _ => Err(Error::UnexpectedResponse(response)), } } - ///Sends a `GET` request to `/v1/tasks/{task}/outputs/{output}` - pub async fn task_output_download<'a>( + ///Sends a `DELETE` request to `/0/users/{user}/privilege/{privilege}` + pub async fn user_privilege_revoke<'a>( &'a self, - task: &'a str, - output: &'a str, - ) -> Result, Error<()>> { + user: &'a str, + privilege: &'a str, + ) -> Result, Error> { let url = format!( - "{}/v1/tasks/{}/outputs/{}", + "{}/0/users/{}/privilege/{}", self.baseurl, - encode_path(&task.to_string()), - encode_path(&output.to_string()), + encode_path(&user.to_string()), + encode_path(&privilege.to_string()), ); - let request = self.client.get(url).build()?; + let request = self + .client + .delete(url) + .header( + reqwest::header::ACCEPT, + reqwest::header::HeaderValue::from_static("application/json"), + ) + .build()?; let result = self.client.execute(request).await; let response = result?; match response.status().as_u16() { - 200..=299 => Ok(ResponseValue::stream(response)), + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), _ => Err(Error::UnexpectedResponse(response)), } } - ///Sends a `POST` request to `/v1/users` - pub async fn user_create<'a>( + ///Sends a `GET` request to `/0/whoami` + pub async fn whoami<'a>( &'a self, - body: &'a types::UserCreate, - ) -> Result, Error<()>> { - let url = format!("{}/v1/users", self.baseurl,); + ) -> Result, Error> { + let url = format!("{}/0/whoami", self.baseurl,); let request = self .client - .post(url) + .get(url) .header( reqwest::header::ACCEPT, reqwest::header::HeaderValue::from_static("application/json"), ) - .json(&body) .build()?; let result = self.client.execute(request).await; let response = result?; match response.status().as_u16() { - 201u16 => ResponseValue::from_response(response).await, + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), _ => Err(Error::UnexpectedResponse(response)), } } - ///Sends a `GET` request to `/v1/whoami` - pub async fn whoami<'a>(&'a self) -> Result, Error<()>> { - let url = format!("{}/v1/whoami", self.baseurl,); + ///Sends a `POST` request to `/0/worker/bootstrap` + pub async fn worker_bootstrap<'a>( + &'a self, + body: &'a types::WorkerBootstrap, + ) -> Result, Error> { + let url = format!("{}/0/worker/bootstrap", self.baseurl,); let request = self .client - .get(url) + .post(url) .header( reqwest::header::ACCEPT, reqwest::header::HeaderValue::from_static("application/json"), ) + .json(&body) .build()?; let result = self.client.execute(request).await; let response = result?; match response.status().as_u16() { - 200u16 => ResponseValue::from_response(response).await, + 201u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), _ => Err(Error::UnexpectedResponse(response)), } } - ///Sends a `PUT` request to `/v1/whoami/name` - pub async fn whoami_put_name<'a>( + ///Sends a `POST` request to `/0/worker/job/{job}/chunk` + pub async fn worker_job_upload_chunk<'a, B: Into>( &'a self, - body: String, - ) -> Result, Error<()>> { - let url = format!("{}/v1/whoami/name", self.baseurl,); + job: &'a str, + body: B, + ) -> Result, Error> { + let url = format!( + "{}/0/worker/job/{}/chunk", + self.baseurl, + encode_path(&job.to_string()), + ); let request = self .client - .put(url) + .post(url) + .header( + reqwest::header::ACCEPT, + reqwest::header::HeaderValue::from_static("application/json"), + ) .header( reqwest::header::CONTENT_TYPE, - reqwest::header::HeaderValue::from_static("text/plain"), + reqwest::header::HeaderValue::from_static("application/octet-stream"), ) .body(body) .build()?; let result = self.client.execute(request).await; let response = result?; match response.status().as_u16() { - 200u16 => Ok(ResponseValue::empty(response)), + 201u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), _ => Err(Error::UnexpectedResponse(response)), } } - ///Sends a `POST` request to `/v1/worker/bootstrap` - pub async fn worker_bootstrap<'a>( + ///Sends a `POST` request to `/0/worker/job/{job}/complete` + pub async fn worker_job_complete<'a>( &'a self, - body: &'a types::WorkerBootstrap, - ) -> Result, Error<()>> { - let url = format!("{}/v1/worker/bootstrap", self.baseurl,); + job: &'a str, + body: &'a types::WorkerCompleteJob, + ) -> Result, Error> { + let url = format!( + "{}/0/worker/job/{}/complete", + self.baseurl, + encode_path(&job.to_string()), + ); let request = self .client .post(url) @@ -573,16 +2323,48 @@ impl Client { let result = self.client.execute(request).await; let response = result?; match response.status().as_u16() { - 201u16 => ResponseValue::from_response(response).await, + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), _ => Err(Error::UnexpectedResponse(response)), } } - ///Sends a `GET` request to `/v1/worker/ping` - pub async fn worker_ping<'a>( + ///Sends a `GET` request to `/0/worker/job/{job}/inputs/{input}` + pub async fn worker_job_input_download<'a>( + &'a self, + job: &'a str, + input: &'a str, + ) -> Result, Error> { + let url = format!( + "{}/0/worker/job/{}/inputs/{}", + self.baseurl, + encode_path(&job.to_string()), + encode_path(&input.to_string()), + ); + let request = self.client.get(url).build()?; + let result = self.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200..=299 => Ok(ResponseValue::stream(response)), + _ => Err(Error::ErrorResponse(ResponseValue::stream(response))), + } + } + + ///Sends a `GET` request to `/0/worker/job/{job}/quota` + pub async fn worker_job_quota<'a>( &'a self, - ) -> Result, Error<()>> { - let url = format!("{}/v1/worker/ping", self.baseurl,); + job: &'a str, + ) -> Result, Error> { + let url = format!( + "{}/0/worker/job/{}/quota", + self.baseurl, + encode_path(&job.to_string()), + ); let request = self .client .get(url) @@ -595,39 +2377,97 @@ impl Client { let response = result?; match response.status().as_u16() { 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), _ => Err(Error::UnexpectedResponse(response)), } } - ///Sends a `POST` request to `/v1/worker/task/{task}/append` - pub async fn worker_task_append<'a>( + ///Sends a `GET` request to `/0/worker/job/{job}/store/{name}` + pub async fn worker_job_store_get<'a>( &'a self, - task: &'a str, - body: &'a types::WorkerAppendTask, - ) -> Result, Error<()>> { + job: &'a str, + name: &'a str, + ) -> Result, Error> { let url = format!( - "{}/v1/worker/task/{}/append", + "{}/0/worker/job/{}/store/{}", self.baseurl, - encode_path(&task.to_string()), + encode_path(&job.to_string()), + encode_path(&name.to_string()), + ); + let request = self + .client + .get(url) + .header( + reqwest::header::ACCEPT, + reqwest::header::HeaderValue::from_static("application/json"), + ) + .build()?; + let result = self.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Sends a `PUT` request to `/0/worker/job/{job}/store/{name}` + pub async fn worker_job_store_put<'a>( + &'a self, + job: &'a str, + name: &'a str, + body: &'a types::WorkerJobStoreValue, + ) -> Result, Error> { + let url = format!( + "{}/0/worker/job/{}/store/{}", + self.baseurl, + encode_path(&job.to_string()), + encode_path(&name.to_string()), ); - let request = self.client.post(url).json(&body).build()?; + let request = self + .client + .put(url) + .header( + reqwest::header::ACCEPT, + reqwest::header::HeaderValue::from_static("application/json"), + ) + .json(&body) + .build()?; let result = self.client.execute(request).await; let response = result?; match response.status().as_u16() { - 201u16 => Ok(ResponseValue::empty(response)), + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), _ => Err(Error::UnexpectedResponse(response)), } } - ///Sends a `POST` request to `/v1/worker/task/{task}/chunk` - pub async fn worker_task_upload_chunk<'a, B: Into>( + ///Sends a `POST` request to `/0/worker/job/{job}/task/{task}/append` + pub async fn worker_task_append<'a>( &'a self, - task: &'a str, - body: B, - ) -> Result, Error<()>> { + job: &'a str, + task: u32, + body: &'a types::WorkerAppendJob, + ) -> Result, Error> { let url = format!( - "{}/v1/worker/task/{}/chunk", + "{}/0/worker/job/{}/task/{}/append", self.baseurl, + encode_path(&job.to_string()), encode_path(&task.to_string()), ); let request = self @@ -637,65 +2477,96 @@ impl Client { reqwest::header::ACCEPT, reqwest::header::HeaderValue::from_static("application/json"), ) - .header( - reqwest::header::CONTENT_TYPE, - reqwest::header::HeaderValue::from_static("application/octet-stream"), - ) - .body(body) + .json(&body) .build()?; let result = self.client.execute(request).await; let response = result?; match response.status().as_u16() { - 201u16 => ResponseValue::from_response(response).await, + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), _ => Err(Error::UnexpectedResponse(response)), } } - ///Sends a `POST` request to `/v1/worker/task/{task}/complete` + ///Sends a `POST` request to `/0/worker/job/{job}/task/{task}/complete` pub async fn worker_task_complete<'a>( &'a self, - task: &'a str, + job: &'a str, + task: u32, body: &'a types::WorkerCompleteTask, - ) -> Result, Error<()>> { + ) -> Result, Error> { let url = format!( - "{}/v1/worker/task/{}/complete", + "{}/0/worker/job/{}/task/{}/complete", self.baseurl, + encode_path(&job.to_string()), encode_path(&task.to_string()), ); - let request = self.client.post(url).json(&body).build()?; + let request = self + .client + .post(url) + .header( + reqwest::header::ACCEPT, + reqwest::header::HeaderValue::from_static("application/json"), + ) + .json(&body) + .build()?; let result = self.client.execute(request).await; let response = result?; match response.status().as_u16() { - 200u16 => Ok(ResponseValue::empty(response)), + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), _ => Err(Error::UnexpectedResponse(response)), } } - ///Sends a `POST` request to `/v1/worker/task/{task}/output` - pub async fn worker_task_add_output<'a>( + ///Sends a `GET` request to `/0/worker/ping` + pub async fn worker_ping<'a>( &'a self, - task: &'a str, - body: &'a types::WorkerAddOutput, - ) -> Result, Error<()>> { - let url = format!( - "{}/v1/worker/task/{}/output", - self.baseurl, - encode_path(&task.to_string()), - ); - let request = self.client.post(url).json(&body).build()?; + ) -> Result, Error> { + let url = format!("{}/0/worker/ping", self.baseurl,); + let request = self + .client + .get(url) + .header( + reqwest::header::ACCEPT, + reqwest::header::HeaderValue::from_static("application/json"), + ) + .build()?; let result = self.client.execute(request).await; let response = result?; match response.status().as_u16() { - 201u16 => Ok(ResponseValue::empty(response)), + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), _ => Err(Error::UnexpectedResponse(response)), } } - ///Sends a `GET` request to `/v1/workers` + ///Sends a `GET` request to `/0/workers` pub async fn workers_list<'a>( &'a self, - ) -> Result, Error<()>> { - let url = format!("{}/v1/workers", self.baseurl,); + active: Option, + ) -> Result, Error> { + let url = format!("{}/0/workers", self.baseurl,); + let mut query = Vec::with_capacity(1usize); + if let Some(v) = &active { + query.push(("active", v.to_string())); + } + let request = self .client .get(url) @@ -703,23 +2574,145 @@ impl Client { reqwest::header::ACCEPT, reqwest::header::HeaderValue::from_static("application/json"), ) + .query(&query) + .build()?; + let result = self.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Sends a `POST` request to `/0/workers/recycle` + pub async fn workers_recycle<'a>(&'a self) -> Result, Error> { + let url = format!("{}/0/workers/recycle", self.baseurl,); + let request = self + .client + .post(url) + .header( + reqwest::header::ACCEPT, + reqwest::header::HeaderValue::from_static("application/json"), + ) + .build()?; + let result = self.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Sends a `POST` request to `/1/jobs/{job}/input` + pub async fn job_add_input<'a>( + &'a self, + job: &'a str, + body: &'a types::JobAddInput, + ) -> Result, Error> { + let url = format!( + "{}/1/jobs/{}/input", + self.baseurl, + encode_path(&job.to_string()), + ); + let request = self + .client + .post(url) + .header( + reqwest::header::ACCEPT, + reqwest::header::HeaderValue::from_static("application/json"), + ) + .json(&body) .build()?; let result = self.client.execute(request).await; let response = result?; match response.status().as_u16() { 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Sends a `POST` request to `/1/worker/job/{job}/append` + pub async fn worker_job_append<'a>( + &'a self, + job: &'a str, + body: &'a Vec, + ) -> Result, Error> { + let url = format!( + "{}/1/worker/job/{}/append", + self.baseurl, + encode_path(&job.to_string()), + ); + let request = self + .client + .post(url) + .header( + reqwest::header::ACCEPT, + reqwest::header::HeaderValue::from_static("application/json"), + ) + .json(&body) + .build()?; + let result = self.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), _ => Err(Error::UnexpectedResponse(response)), } } - ///Sends a `POST` request to `/v1/workers/recycle` - pub async fn workers_recycle<'a>(&'a self) -> Result, Error<()>> { - let url = format!("{}/v1/workers/recycle", self.baseurl,); - let request = self.client.post(url).build()?; + ///Sends a `POST` request to `/1/worker/job/{job}/output` + pub async fn worker_job_add_output<'a>( + &'a self, + job: &'a str, + body: &'a types::WorkerAddOutput, + ) -> Result, Error> { + let url = format!( + "{}/1/worker/job/{}/output", + self.baseurl, + encode_path(&job.to_string()), + ); + let request = self + .client + .post(url) + .header( + reqwest::header::ACCEPT, + reqwest::header::HeaderValue::from_static("application/json"), + ) + .json(&body) + .build()?; let result = self.client.execute(request).await; let response = result?; match response.status().as_u16() { - 200u16 => Ok(ResponseValue::empty(response)), + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), _ => Err(Error::UnexpectedResponse(response)), } } diff --git a/progenitor/tests/build_buildomat.rs b/progenitor/tests/build_buildomat.rs index aea37474..4730bd2b 100644 --- a/progenitor/tests/build_buildomat.rs +++ b/progenitor/tests/build_buildomat.rs @@ -4,7 +4,7 @@ mod positional { progenitor::generate_api!("../sample_openapi/buildomat.json"); fn _ignore() { - let _ = Client::new("").worker_task_upload_chunk("task", vec![0]); + let _ = Client::new("").worker_job_upload_chunk("job", vec![0]); } } @@ -17,8 +17,8 @@ mod builder_untagged { fn _ignore() { let _ = Client::new("") - .worker_task_upload_chunk() - .task("task") + .worker_job_upload_chunk() + .job("job") .body(vec![0]) .send(); } @@ -33,8 +33,8 @@ mod builder_tagged { fn _ignore() { let _ = Client::new("") - .worker_task_upload_chunk() - .task("task") + .worker_job_upload_chunk() + .job("job") .body(vec![0]) .send(); } diff --git a/sample_openapi/buildomat.json b/sample_openapi/buildomat.json index 0803561b..2881689d 100644 --- a/sample_openapi/buildomat.json +++ b/sample_openapi/buildomat.json @@ -5,90 +5,14 @@ "version": "1.0" }, "paths": { - "/v1/control/hold": { + "/0/admin/factory": { "post": { - "operationId": "control_hold", - "responses": { - "200": { - "description": "successful operation", - "content": { - "application/json; charset=utf-8": { - "schema": { - "enum": [ - null - ] - } - } - } - } - } - } - }, - "/v1/control/resume": { - "post": { - "operationId": "control_resume", - "responses": { - "200": { - "description": "successful operation" - } - } - } - }, - "/v1/task/{task}": { - "get": { - "operationId": "task_get", - "parameters": [ - { - "in": "path", - "name": "task", - "required": true, - "schema": { - "type": "string" - }, - "style": "simple" - } - ], - "responses": { - "200": { - "description": "successful operation", - "content": { - "application/json; charset=utf-8": { - "schema": { - "$ref": "#/components/schemas/Task" - } - } - } - } - } - } - }, - "/v1/tasks": { - "get": { - "operationId": "tasks_get", - "responses": { - "200": { - "description": "successful operation", - "content": { - "application/json; charset=utf-8": { - "schema": { - "title": "Array_of_Task", - "type": "array", - "items": { - "$ref": "#/components/schemas/Task" - } - } - } - } - } - } - }, - "post": { - "operationId": "task_submit", + "operationId": "factory_create", "requestBody": { "content": { - "application/json; charset=utf-8": { + "application/json": { "schema": { - "$ref": "#/components/schemas/TaskSubmit" + "$ref": "#/components/schemas/FactoryCreate" } } }, @@ -98,187 +22,135 @@ "201": { "description": "successful creation", "content": { - "application/json; charset=utf-8": { + "application/json": { "schema": { - "$ref": "#/components/schemas/TaskSubmitResult" + "$ref": "#/components/schemas/FactoryCreateResult" } } } + }, + "4XX": { + "$ref": "#/components/responses/Error" + }, + "5XX": { + "$ref": "#/components/responses/Error" } } } }, - "/v1/tasks/{task}/events": { + "/0/admin/jobs": { "get": { - "operationId": "task_events_get", + "operationId": "admin_jobs_get", "parameters": [ { - "in": "path", - "name": "task", - "required": true, + "in": "query", + "name": "active", "schema": { - "type": "string" - }, - "style": "simple" + "type": "boolean" + } }, { "in": "query", - "name": "minseq", + "name": "completed", "schema": { + "nullable": true, "type": "integer", - "format": "uint", + "format": "uint64", "minimum": 0 - }, - "style": "form" + } } ], "responses": { "200": { "description": "successful operation", "content": { - "application/json; charset=utf-8": { + "application/json": { "schema": { - "title": "Array_of_TaskEvent", + "title": "Array_of_Job", "type": "array", "items": { - "$ref": "#/components/schemas/TaskEvent" + "$ref": "#/components/schemas/Job" } } } } + }, + "4XX": { + "$ref": "#/components/responses/Error" + }, + "5XX": { + "$ref": "#/components/responses/Error" } } } }, - "/v1/tasks/{task}/outputs": { + "/0/admin/jobs/{job}": { "get": { - "operationId": "task_outputs_get", + "operationId": "admin_job_get", "parameters": [ { "in": "path", - "name": "task", + "name": "job", "required": true, "schema": { "type": "string" - }, - "style": "simple" + } } ], "responses": { "200": { "description": "successful operation", "content": { - "application/json; charset=utf-8": { + "application/json": { "schema": { - "title": "Array_of_TaskOutput", - "type": "array", - "items": { - "$ref": "#/components/schemas/TaskOutput" - } + "$ref": "#/components/schemas/Job" } } } + }, + "4XX": { + "$ref": "#/components/responses/Error" + }, + "5XX": { + "$ref": "#/components/responses/Error" } } } }, - "/v1/tasks/{task}/outputs/{output}": { - "get": { - "operationId": "task_output_download", + "/0/admin/jobs/{job}/archive": { + "post": { + "operationId": "admin_job_archive_request", "parameters": [ { "in": "path", - "name": "output", - "required": true, - "schema": { - "type": "string" - }, - "style": "simple" - }, - { - "in": "path", - "name": "task", + "name": "job", "required": true, "schema": { "type": "string" - }, - "style": "simple" - } - ], - "responses": {} - } - }, - "/v1/users": { - "post": { - "operationId": "user_create", - "requestBody": { - "content": { - "application/json; charset=utf-8": { - "schema": { - "$ref": "#/components/schemas/UserCreate" - } - } - }, - "required": true - }, - "responses": { - "201": { - "description": "successful creation", - "content": { - "application/json; charset=utf-8": { - "schema": { - "$ref": "#/components/schemas/UserCreateResult" - } - } - } - } - } - } - }, - "/v1/whoami": { - "get": { - "operationId": "whoami", - "responses": { - "200": { - "description": "successful operation", - "content": { - "application/json; charset=utf-8": { - "schema": { - "$ref": "#/components/schemas/WhoamiResult" - } - } - } - } - } - } - }, - "/v1/whoami/name": { - "put": { - "operationId": "whoami_put_name", - "requestBody": { - "content": { - "text/plain": { - "schema": { - "type": "string" - } } } - }, + ], "responses": { - "200": { - "description": "successful operation" + "204": { + "description": "resource updated" + }, + "4XX": { + "$ref": "#/components/responses/Error" + }, + "5XX": { + "$ref": "#/components/responses/Error" } } } }, - "/v1/worker/bootstrap": { + "/0/admin/target": { "post": { - "operationId": "worker_bootstrap", + "operationId": "target_create", "requestBody": { "content": { - "application/json; charset=utf-8": { + "application/json": { "schema": { - "$ref": "#/components/schemas/WorkerBootstrap" + "$ref": "#/components/schemas/TargetCreate" } } }, @@ -288,84 +160,103 @@ "201": { "description": "successful creation", "content": { - "application/json; charset=utf-8": { + "application/json": { "schema": { - "$ref": "#/components/schemas/WorkerBootstrapResult" + "$ref": "#/components/schemas/TargetCreateResult" } } } + }, + "4XX": { + "$ref": "#/components/responses/Error" + }, + "5XX": { + "$ref": "#/components/responses/Error" } } } }, - "/v1/worker/ping": { + "/0/admin/targets": { "get": { - "operationId": "worker_ping", + "operationId": "targets_list", "responses": { "200": { "description": "successful operation", "content": { - "application/json; charset=utf-8": { + "application/json": { "schema": { - "$ref": "#/components/schemas/WorkerPingResult" + "title": "Array_of_Target", + "type": "array", + "items": { + "$ref": "#/components/schemas/Target" + } } } } + }, + "4XX": { + "$ref": "#/components/responses/Error" + }, + "5XX": { + "$ref": "#/components/responses/Error" } } } }, - "/v1/worker/task/{task}/append": { - "post": { - "operationId": "worker_task_append", + "/0/admin/targets/{target}/redirect": { + "put": { + "operationId": "target_redirect", "parameters": [ { "in": "path", - "name": "task", + "name": "target", "required": true, "schema": { "type": "string" - }, - "style": "simple" + } } ], "requestBody": { "content": { - "application/json; charset=utf-8": { + "application/json": { "schema": { - "$ref": "#/components/schemas/WorkerAppendTask" + "$ref": "#/components/schemas/TargetRedirect" } } }, "required": true }, "responses": { - "201": { - "description": "successful creation" + "204": { + "description": "resource updated" + }, + "4XX": { + "$ref": "#/components/responses/Error" + }, + "5XX": { + "$ref": "#/components/responses/Error" } } } }, - "/v1/worker/task/{task}/chunk": { + "/0/admin/targets/{target}/rename": { "post": { - "operationId": "worker_task_upload_chunk", + "operationId": "target_rename", "parameters": [ { "in": "path", - "name": "task", + "name": "target", "required": true, "schema": { "type": "string" - }, - "style": "simple" + } } ], "requestBody": { "content": { - "application/octet-stream": { + "application/json": { "schema": { - "type": "string", - "format": "binary" + "$ref": "#/components/schemas/TargetRename" } } }, @@ -375,139 +266,2140 @@ "201": { "description": "successful creation", "content": { - "application/json; charset=utf-8": { + "application/json": { "schema": { - "$ref": "#/components/schemas/UploadedChunk" + "$ref": "#/components/schemas/TargetCreateResult" } } } + }, + "4XX": { + "$ref": "#/components/responses/Error" + }, + "5XX": { + "$ref": "#/components/responses/Error" } } } }, - "/v1/worker/task/{task}/complete": { - "post": { - "operationId": "worker_task_complete", + "/0/admin/targets/{target}/require": { + "delete": { + "operationId": "target_require_no_privilege", "parameters": [ { "in": "path", - "name": "task", + "name": "target", "required": true, "schema": { "type": "string" - }, - "style": "simple" + } } ], - "requestBody": { - "content": { - "application/json; charset=utf-8": { - "schema": { - "$ref": "#/components/schemas/WorkerCompleteTask" - } + "responses": { + "204": { + "description": "resource updated" + }, + "4XX": { + "$ref": "#/components/responses/Error" + }, + "5XX": { + "$ref": "#/components/responses/Error" + } + } + } + }, + "/0/admin/targets/{target}/require/{privilege}": { + "put": { + "operationId": "target_require_privilege", + "parameters": [ + { + "in": "path", + "name": "privilege", + "required": true, + "schema": { + "type": "string" } }, - "required": true - }, + { + "in": "path", + "name": "target", + "required": true, + "schema": { + "type": "string" + } + } + ], "responses": { - "200": { - "description": "successful operation" + "204": { + "description": "resource updated" + }, + "4XX": { + "$ref": "#/components/responses/Error" + }, + "5XX": { + "$ref": "#/components/responses/Error" } } } }, - "/v1/worker/task/{task}/output": { + "/0/admin/worker/{worker}/recycle": { "post": { - "operationId": "worker_task_add_output", + "operationId": "worker_recycle", "parameters": [ { "in": "path", - "name": "task", + "name": "worker", "required": true, "schema": { "type": "string" - }, - "style": "simple" + } } ], + "responses": { + "204": { + "description": "resource updated" + }, + "4XX": { + "$ref": "#/components/responses/Error" + }, + "5XX": { + "$ref": "#/components/responses/Error" + } + } + } + }, + "/0/control/hold": { + "post": { + "operationId": "control_hold", + "responses": { + "204": { + "description": "resource updated" + }, + "4XX": { + "$ref": "#/components/responses/Error" + }, + "5XX": { + "$ref": "#/components/responses/Error" + } + } + } + }, + "/0/control/resume": { + "post": { + "operationId": "control_resume", + "responses": { + "204": { + "description": "resource updated" + }, + "4XX": { + "$ref": "#/components/responses/Error" + }, + "5XX": { + "$ref": "#/components/responses/Error" + } + } + } + }, + "/0/factory/lease": { + "post": { + "operationId": "factory_lease", "requestBody": { "content": { - "application/json; charset=utf-8": { + "application/json": { "schema": { - "$ref": "#/components/schemas/WorkerAddOutput" + "$ref": "#/components/schemas/FactoryWhatsNext" } } }, "required": true }, - "responses": { - "201": { - "description": "successful creation" - } - } - } - }, - "/v1/workers": { - "get": { - "operationId": "workers_list", "responses": { "200": { "description": "successful operation", "content": { - "application/json; charset=utf-8": { + "application/json": { "schema": { - "$ref": "#/components/schemas/WorkersResult" + "$ref": "#/components/schemas/FactoryLeaseResult" } } } + }, + "4XX": { + "$ref": "#/components/responses/Error" + }, + "5XX": { + "$ref": "#/components/responses/Error" } } } }, - "/v1/workers/recycle": { + "/0/factory/lease/{job}": { + "post": { + "operationId": "factory_lease_renew", + "parameters": [ + { + "in": "path", + "name": "job", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "successful operation", + "content": { + "application/json": { + "schema": { + "title": "Boolean", + "type": "boolean" + } + } + } + }, + "4XX": { + "$ref": "#/components/responses/Error" + }, + "5XX": { + "$ref": "#/components/responses/Error" + } + } + } + }, + "/0/factory/ping": { + "get": { + "operationId": "factory_ping", + "responses": { + "200": { + "description": "successful operation", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/FactoryPingResult" + } + } + } + }, + "4XX": { + "$ref": "#/components/responses/Error" + }, + "5XX": { + "$ref": "#/components/responses/Error" + } + } + } + }, + "/0/factory/worker": { + "post": { + "operationId": "factory_worker_create", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/FactoryWorkerCreate" + } + } + }, + "required": true + }, + "responses": { + "201": { + "description": "successful creation", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/FactoryWorker" + } + } + } + }, + "4XX": { + "$ref": "#/components/responses/Error" + }, + "5XX": { + "$ref": "#/components/responses/Error" + } + } + } + }, + "/0/factory/worker/{worker}": { + "get": { + "operationId": "factory_worker_get", + "parameters": [ + { + "in": "path", + "name": "worker", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "successful operation", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/FactoryWorkerResult" + } + } + } + }, + "4XX": { + "$ref": "#/components/responses/Error" + }, + "5XX": { + "$ref": "#/components/responses/Error" + } + } + }, + "delete": { + "operationId": "factory_worker_destroy", + "parameters": [ + { + "in": "path", + "name": "worker", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "successful operation", + "content": { + "application/json": { + "schema": { + "title": "Boolean", + "type": "boolean" + } + } + } + }, + "4XX": { + "$ref": "#/components/responses/Error" + }, + "5XX": { + "$ref": "#/components/responses/Error" + } + } + }, + "patch": { + "operationId": "factory_worker_associate", + "parameters": [ + { + "in": "path", + "name": "worker", + "required": true, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/FactoryWorkerAssociate" + } + } + }, + "required": true + }, + "responses": { + "204": { + "description": "resource updated" + }, + "4XX": { + "$ref": "#/components/responses/Error" + }, + "5XX": { + "$ref": "#/components/responses/Error" + } + } + } + }, + "/0/factory/worker/{worker}/append": { + "post": { + "operationId": "factory_worker_append", + "parameters": [ + { + "in": "path", + "name": "worker", + "required": true, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/FactoryWorkerAppend" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "successful operation", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/FactoryWorkerAppendResult" + } + } + } + }, + "4XX": { + "$ref": "#/components/responses/Error" + }, + "5XX": { + "$ref": "#/components/responses/Error" + } + } + } + }, + "/0/factory/worker/{worker}/flush": { + "post": { + "operationId": "factory_worker_flush", + "parameters": [ + { + "in": "path", + "name": "worker", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "204": { + "description": "resource updated" + }, + "4XX": { + "$ref": "#/components/responses/Error" + }, + "5XX": { + "$ref": "#/components/responses/Error" + } + } + } + }, + "/0/factory/workers": { + "get": { + "operationId": "factory_workers", + "responses": { + "200": { + "description": "successful operation", + "content": { + "application/json": { + "schema": { + "title": "Array_of_FactoryWorker", + "type": "array", + "items": { + "$ref": "#/components/schemas/FactoryWorker" + } + } + } + } + }, + "4XX": { + "$ref": "#/components/responses/Error" + }, + "5XX": { + "$ref": "#/components/responses/Error" + } + } + } + }, + "/0/job/{job}": { + "get": { + "operationId": "job_get", + "parameters": [ + { + "in": "path", + "name": "job", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "successful operation", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Job" + } + } + } + }, + "4XX": { + "$ref": "#/components/responses/Error" + }, + "5XX": { + "$ref": "#/components/responses/Error" + } + } + } + }, + "/0/jobs": { + "get": { + "operationId": "jobs_get", + "responses": { + "200": { + "description": "successful operation", + "content": { + "application/json": { + "schema": { + "title": "Array_of_Job", + "type": "array", + "items": { + "$ref": "#/components/schemas/Job" + } + } + } + } + }, + "4XX": { + "$ref": "#/components/responses/Error" + }, + "5XX": { + "$ref": "#/components/responses/Error" + } + } + }, + "post": { + "operationId": "job_submit", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/JobSubmit" + } + } + }, + "required": true + }, + "responses": { + "201": { + "description": "successful creation", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/JobSubmitResult" + } + } + } + }, + "4XX": { + "$ref": "#/components/responses/Error" + }, + "5XX": { + "$ref": "#/components/responses/Error" + } + } + } + }, + "/0/jobs/{job}/cancel": { + "post": { + "operationId": "job_cancel", + "parameters": [ + { + "in": "path", + "name": "job", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "204": { + "description": "resource updated" + }, + "4XX": { + "$ref": "#/components/responses/Error" + }, + "5XX": { + "$ref": "#/components/responses/Error" + } + } + } + }, + "/0/jobs/{job}/chunk": { + "post": { + "operationId": "job_upload_chunk", + "parameters": [ + { + "in": "path", + "name": "job", + "required": true, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "content": { + "application/octet-stream": { + "schema": { + "type": "string", + "format": "binary" + } + } + }, + "required": true + }, + "responses": { + "201": { + "description": "successful creation", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/UploadedChunk" + } + } + } + }, + "4XX": { + "$ref": "#/components/responses/Error" + }, + "5XX": { + "$ref": "#/components/responses/Error" + } + } + } + }, + "/0/jobs/{job}/events": { + "get": { + "operationId": "job_events_get", + "parameters": [ + { + "in": "path", + "name": "job", + "required": true, + "schema": { + "type": "string" + } + }, + { + "in": "query", + "name": "minseq", + "schema": { + "nullable": true, + "type": "integer", + "format": "uint", + "minimum": 0 + } + } + ], + "responses": { + "200": { + "description": "successful operation", + "content": { + "application/json": { + "schema": { + "title": "Array_of_JobEvent", + "type": "array", + "items": { + "$ref": "#/components/schemas/JobEvent" + } + } + } + } + }, + "4XX": { + "$ref": "#/components/responses/Error" + }, + "5XX": { + "$ref": "#/components/responses/Error" + } + } + } + }, + "/0/jobs/{job}/outputs": { + "get": { + "operationId": "job_outputs_get", + "parameters": [ + { + "in": "path", + "name": "job", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "successful operation", + "content": { + "application/json": { + "schema": { + "title": "Array_of_JobOutput", + "type": "array", + "items": { + "$ref": "#/components/schemas/JobOutput" + } + } + } + } + }, + "4XX": { + "$ref": "#/components/responses/Error" + }, + "5XX": { + "$ref": "#/components/responses/Error" + } + } + } + }, + "/0/jobs/{job}/outputs/{output}": { + "get": { + "operationId": "job_output_download", + "parameters": [ + { + "in": "path", + "name": "job", + "required": true, + "schema": { + "type": "string" + } + }, + { + "in": "path", + "name": "output", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "default": { + "description": "", + "content": { + "*/*": { + "schema": {} + } + } + } + } + } + }, + "/0/jobs/{job}/outputs/{output}/publish": { + "post": { + "operationId": "job_output_publish", + "parameters": [ + { + "in": "path", + "name": "job", + "required": true, + "schema": { + "type": "string" + } + }, + { + "in": "path", + "name": "output", + "required": true, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/JobOutputPublish" + } + } + }, + "required": true + }, + "responses": { + "204": { + "description": "resource updated" + }, + "4XX": { + "$ref": "#/components/responses/Error" + }, + "5XX": { + "$ref": "#/components/responses/Error" + } + } + } + }, + "/0/jobs/{job}/outputs/{output}/sign": { + "post": { + "operationId": "job_output_signed_url", + "parameters": [ + { + "in": "path", + "name": "job", + "required": true, + "schema": { + "type": "string" + } + }, + { + "in": "path", + "name": "output", + "required": true, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/JobOutputSignedUrl" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "successful operation", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/JobOutputSignedUrlResult" + } + } + } + }, + "4XX": { + "$ref": "#/components/responses/Error" + }, + "5XX": { + "$ref": "#/components/responses/Error" + } + } + } + }, + "/0/jobs/{job}/store": { + "get": { + "operationId": "job_store_get_all", + "parameters": [ + { + "in": "path", + "name": "job", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "successful operation", + "content": { + "application/json": { + "schema": { + "title": "Map_of_JobStoreValueInfo", + "type": "object", + "additionalProperties": { + "$ref": "#/components/schemas/JobStoreValueInfo" + } + } + } + } + }, + "4XX": { + "$ref": "#/components/responses/Error" + }, + "5XX": { + "$ref": "#/components/responses/Error" + } + } + } + }, + "/0/jobs/{job}/store/{name}": { + "put": { + "operationId": "job_store_put", + "parameters": [ + { + "in": "path", + "name": "job", + "required": true, + "schema": { + "type": "string" + } + }, + { + "in": "path", + "name": "name", + "required": true, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/JobStoreValue" + } + } + }, + "required": true + }, + "responses": { + "204": { + "description": "resource updated" + }, + "4XX": { + "$ref": "#/components/responses/Error" + }, + "5XX": { + "$ref": "#/components/responses/Error" + } + } + } + }, + "/0/public/file/{username}/{series}/{version}/{name}": { + "get": { + "operationId": "public_file_download", + "parameters": [ + { + "in": "path", + "name": "name", + "required": true, + "schema": { + "type": "string" + } + }, + { + "in": "path", + "name": "series", + "required": true, + "schema": { + "type": "string" + } + }, + { + "in": "path", + "name": "username", + "required": true, + "schema": { + "type": "string" + } + }, + { + "in": "path", + "name": "version", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "default": { + "description": "", + "content": { + "*/*": { + "schema": {} + } + } + } + } + } + }, + "/0/quota": { + "get": { + "operationId": "quota", + "responses": { + "200": { + "description": "successful operation", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Quota" + } + } + } + }, + "4XX": { + "$ref": "#/components/responses/Error" + }, + "5XX": { + "$ref": "#/components/responses/Error" + } + } + } + }, + "/0/users": { + "get": { + "operationId": "users_list", + "parameters": [ + { + "in": "query", + "name": "name", + "schema": { + "nullable": true, + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "successful operation", + "content": { + "application/json": { + "schema": { + "title": "Array_of_User", + "type": "array", + "items": { + "$ref": "#/components/schemas/User" + } + } + } + } + }, + "4XX": { + "$ref": "#/components/responses/Error" + }, + "5XX": { + "$ref": "#/components/responses/Error" + } + } + }, + "post": { + "operationId": "user_create", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/UserCreate" + } + } + }, + "required": true + }, + "responses": { + "201": { + "description": "successful creation", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/UserCreateResult" + } + } + } + }, + "4XX": { + "$ref": "#/components/responses/Error" + }, + "5XX": { + "$ref": "#/components/responses/Error" + } + } + } + }, + "/0/users/{user}": { + "get": { + "operationId": "user_get", + "parameters": [ + { + "in": "path", + "name": "user", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "successful operation", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/User" + } + } + } + }, + "4XX": { + "$ref": "#/components/responses/Error" + }, + "5XX": { + "$ref": "#/components/responses/Error" + } + } + } + }, + "/0/users/{user}/privilege/{privilege}": { + "put": { + "operationId": "user_privilege_grant", + "parameters": [ + { + "in": "path", + "name": "privilege", + "required": true, + "schema": { + "type": "string" + } + }, + { + "in": "path", + "name": "user", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "204": { + "description": "resource updated" + }, + "4XX": { + "$ref": "#/components/responses/Error" + }, + "5XX": { + "$ref": "#/components/responses/Error" + } + } + }, + "delete": { + "operationId": "user_privilege_revoke", + "parameters": [ + { + "in": "path", + "name": "privilege", + "required": true, + "schema": { + "type": "string" + } + }, + { + "in": "path", + "name": "user", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "204": { + "description": "successful deletion" + }, + "4XX": { + "$ref": "#/components/responses/Error" + }, + "5XX": { + "$ref": "#/components/responses/Error" + } + } + } + }, + "/0/whoami": { + "get": { + "operationId": "whoami", + "responses": { + "200": { + "description": "successful operation", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/WhoamiResult" + } + } + } + }, + "4XX": { + "$ref": "#/components/responses/Error" + }, + "5XX": { + "$ref": "#/components/responses/Error" + } + } + } + }, + "/0/worker/bootstrap": { + "post": { + "operationId": "worker_bootstrap", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/WorkerBootstrap" + } + } + }, + "required": true + }, + "responses": { + "201": { + "description": "successful creation", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/WorkerBootstrapResult" + } + } + } + }, + "4XX": { + "$ref": "#/components/responses/Error" + }, + "5XX": { + "$ref": "#/components/responses/Error" + } + } + } + }, + "/0/worker/job/{job}/chunk": { + "post": { + "operationId": "worker_job_upload_chunk", + "parameters": [ + { + "in": "path", + "name": "job", + "required": true, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "content": { + "application/octet-stream": { + "schema": { + "type": "string", + "format": "binary" + } + } + }, + "required": true + }, + "responses": { + "201": { + "description": "successful creation", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/UploadedChunk" + } + } + } + }, + "4XX": { + "$ref": "#/components/responses/Error" + }, + "5XX": { + "$ref": "#/components/responses/Error" + } + } + } + }, + "/0/worker/job/{job}/complete": { + "post": { + "operationId": "worker_job_complete", + "parameters": [ + { + "in": "path", + "name": "job", + "required": true, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/WorkerCompleteJob" + } + } + }, + "required": true + }, + "responses": { + "204": { + "description": "resource updated" + }, + "4XX": { + "$ref": "#/components/responses/Error" + }, + "5XX": { + "$ref": "#/components/responses/Error" + } + } + } + }, + "/0/worker/job/{job}/inputs/{input}": { + "get": { + "operationId": "worker_job_input_download", + "parameters": [ + { + "in": "path", + "name": "input", + "required": true, + "schema": { + "type": "string" + } + }, + { + "in": "path", + "name": "job", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "default": { + "description": "", + "content": { + "*/*": { + "schema": {} + } + } + } + } + } + }, + "/0/worker/job/{job}/quota": { + "get": { + "operationId": "worker_job_quota", + "parameters": [ + { + "in": "path", + "name": "job", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "successful operation", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/WorkerJobQuota" + } + } + } + }, + "4XX": { + "$ref": "#/components/responses/Error" + }, + "5XX": { + "$ref": "#/components/responses/Error" + } + } + } + }, + "/0/worker/job/{job}/store/{name}": { + "get": { + "operationId": "worker_job_store_get", + "parameters": [ + { + "in": "path", + "name": "job", + "required": true, + "schema": { + "type": "string" + } + }, + { + "in": "path", + "name": "name", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "successful operation", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/WorkerJobStoreGet" + } + } + } + }, + "4XX": { + "$ref": "#/components/responses/Error" + }, + "5XX": { + "$ref": "#/components/responses/Error" + } + } + }, + "put": { + "operationId": "worker_job_store_put", + "parameters": [ + { + "in": "path", + "name": "job", + "required": true, + "schema": { + "type": "string" + } + }, + { + "in": "path", + "name": "name", + "required": true, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/WorkerJobStoreValue" + } + } + }, + "required": true + }, + "responses": { + "204": { + "description": "resource updated" + }, + "4XX": { + "$ref": "#/components/responses/Error" + }, + "5XX": { + "$ref": "#/components/responses/Error" + } + } + } + }, + "/0/worker/job/{job}/task/{task}/append": { + "post": { + "operationId": "worker_task_append", + "parameters": [ + { + "in": "path", + "name": "job", + "required": true, + "schema": { + "type": "string" + } + }, + { + "in": "path", + "name": "task", + "required": true, + "schema": { + "type": "integer", + "format": "uint32", + "minimum": 0 + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/WorkerAppendJob" + } + } + }, + "required": true + }, + "responses": { + "204": { + "description": "resource updated" + }, + "4XX": { + "$ref": "#/components/responses/Error" + }, + "5XX": { + "$ref": "#/components/responses/Error" + } + } + } + }, + "/0/worker/job/{job}/task/{task}/complete": { + "post": { + "operationId": "worker_task_complete", + "parameters": [ + { + "in": "path", + "name": "job", + "required": true, + "schema": { + "type": "string" + } + }, + { + "in": "path", + "name": "task", + "required": true, + "schema": { + "type": "integer", + "format": "uint32", + "minimum": 0 + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/WorkerCompleteTask" + } + } + }, + "required": true + }, + "responses": { + "204": { + "description": "resource updated" + }, + "4XX": { + "$ref": "#/components/responses/Error" + }, + "5XX": { + "$ref": "#/components/responses/Error" + } + } + } + }, + "/0/worker/ping": { + "get": { + "operationId": "worker_ping", + "responses": { + "200": { + "description": "successful operation", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/WorkerPingResult" + } + } + } + }, + "4XX": { + "$ref": "#/components/responses/Error" + }, + "5XX": { + "$ref": "#/components/responses/Error" + } + } + } + }, + "/0/workers": { + "get": { + "operationId": "workers_list", + "parameters": [ + { + "in": "query", + "name": "active", + "schema": { + "type": "boolean" + } + } + ], + "responses": { + "200": { + "description": "successful operation", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/WorkersResult" + } + } + } + }, + "4XX": { + "$ref": "#/components/responses/Error" + }, + "5XX": { + "$ref": "#/components/responses/Error" + } + } + } + }, + "/0/workers/recycle": { "post": { "operationId": "workers_recycle", + "responses": { + "204": { + "description": "resource updated" + }, + "4XX": { + "$ref": "#/components/responses/Error" + }, + "5XX": { + "$ref": "#/components/responses/Error" + } + } + } + }, + "/1/jobs/{job}/input": { + "post": { + "operationId": "job_add_input", + "parameters": [ + { + "in": "path", + "name": "job", + "required": true, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/JobAddInput" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "successful operation", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/JobAddInputResult" + } + } + } + }, + "4XX": { + "$ref": "#/components/responses/Error" + }, + "5XX": { + "$ref": "#/components/responses/Error" + } + } + } + }, + "/1/worker/job/{job}/append": { + "post": { + "operationId": "worker_job_append", + "parameters": [ + { + "in": "path", + "name": "job", + "required": true, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "title": "Array_of_WorkerAppendJobOrTask", + "type": "array", + "items": { + "$ref": "#/components/schemas/WorkerAppendJobOrTask" + } + } + } + }, + "required": true + }, + "responses": { + "204": { + "description": "resource updated" + }, + "4XX": { + "$ref": "#/components/responses/Error" + }, + "5XX": { + "$ref": "#/components/responses/Error" + } + } + } + }, + "/1/worker/job/{job}/output": { + "post": { + "operationId": "worker_job_add_output", + "parameters": [ + { + "in": "path", + "name": "job", + "required": true, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/WorkerAddOutput" + } + } + }, + "required": true + }, "responses": { "200": { - "description": "successful operation" + "description": "successful operation", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/WorkerAddOutputResult" + } + } + } + }, + "4XX": { + "$ref": "#/components/responses/Error" + }, + "5XX": { + "$ref": "#/components/responses/Error" } } } } }, "components": { + "responses": { + "Error": { + "description": "Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + } + } + }, "schemas": { - "Task": { + "DependSubmit": { + "type": "object", + "properties": { + "copy_outputs": { + "type": "boolean" + }, + "on_completed": { + "type": "boolean" + }, + "on_failed": { + "type": "boolean" + }, + "prior_job": { + "type": "string" + } + }, + "required": [ + "copy_outputs", + "on_completed", + "on_failed", + "prior_job" + ] + }, + "Error": { + "description": "Error information from a response.", + "type": "object", + "properties": { + "error_code": { + "type": "string" + }, + "message": { + "type": "string" + }, + "request_id": { + "type": "string" + } + }, + "required": [ + "message", + "request_id" + ] + }, + "FactoryAddresses": { + "type": "object", + "properties": { + "cidr": { + "type": "string" + }, + "count": { + "type": "integer", + "format": "uint32", + "minimum": 0 + }, + "first": { + "type": "string" + }, + "gateway": { + "nullable": true, + "type": "string" + }, + "name": { + "type": "string" + }, + "routed": { + "type": "boolean" + } + }, + "required": [ + "cidr", + "count", + "first", + "name", + "routed" + ] + }, + "FactoryCreate": { + "type": "object", + "properties": { + "name": { + "type": "string" + } + }, + "required": [ + "name" + ] + }, + "FactoryCreateResult": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "name": { + "type": "string" + }, + "token": { + "type": "string" + } + }, + "required": [ + "id", + "name", + "token" + ] + }, + "FactoryLease": { + "type": "object", + "properties": { + "job": { + "type": "string" + }, + "target": { + "type": "string" + } + }, + "required": [ + "job", + "target" + ] + }, + "FactoryLeaseResult": { + "type": "object", + "properties": { + "lease": { + "nullable": true, + "allOf": [ + { + "$ref": "#/components/schemas/FactoryLease" + } + ] + } + } + }, + "FactoryMetadata": { + "oneOf": [ + { + "type": "object", + "properties": { + "addresses": { + "default": [], + "type": "array", + "items": { + "$ref": "#/components/schemas/FactoryAddresses" + } + }, + "v": { + "type": "string", + "enum": [ + "1" + ] + } + }, + "required": [ + "v" + ] + } + ] + }, + "FactoryPingResult": { + "type": "object", + "properties": { + "ok": { + "type": "boolean" + } + }, + "required": [ + "ok" + ] + }, + "FactoryWhatsNext": { + "type": "object", + "properties": { + "supported_targets": { + "type": "array", + "items": { + "type": "string" + } + } + }, + "required": [ + "supported_targets" + ] + }, + "FactoryWorker": { + "type": "object", + "properties": { + "bootstrap": { + "type": "string" + }, + "id": { + "type": "string" + }, + "online": { + "type": "boolean" + }, + "private": { + "nullable": true, + "type": "string" + }, + "recycle": { + "type": "boolean" + } + }, + "required": [ + "bootstrap", + "id", + "online", + "recycle" + ] + }, + "FactoryWorkerAppend": { + "type": "object", + "properties": { + "payload": { + "type": "string" + }, + "stream": { + "type": "string" + }, + "time": { + "type": "string", + "format": "date-time" + } + }, + "required": [ + "payload", + "stream", + "time" + ] + }, + "FactoryWorkerAppendResult": { + "type": "object", + "properties": { + "retry": { + "type": "boolean" + } + }, + "required": [ + "retry" + ] + }, + "FactoryWorkerAssociate": { + "type": "object", + "properties": { + "metadata": { + "nullable": true, + "allOf": [ + { + "$ref": "#/components/schemas/FactoryMetadata" + } + ] + }, + "private": { + "type": "string" + } + }, + "required": [ + "private" + ] + }, + "FactoryWorkerCreate": { "type": "object", "properties": { + "job": { + "nullable": true, + "type": "string" + }, + "target": { + "type": "string" + }, + "wait_for_flush": { + "default": false, + "type": "boolean" + } + }, + "required": [ + "target" + ] + }, + "FactoryWorkerResult": { + "type": "object", + "properties": { + "worker": { + "nullable": true, + "allOf": [ + { + "$ref": "#/components/schemas/FactoryWorker" + } + ] + } + } + }, + "Job": { + "type": "object", + "properties": { + "cancelled": { + "type": "boolean" + }, "id": { "type": "string" }, - "name": { + "name": { + "type": "string" + }, + "output_rules": { + "type": "array", + "items": { + "type": "string" + } + }, + "owner": { + "type": "string" + }, + "state": { "type": "string" }, - "output_rules": { - "type": "array", - "items": { + "tags": { + "type": "object", + "additionalProperties": { "type": "string" } }, - "script": { + "target": { "type": "string" }, - "state": { + "target_real": { "type": "string" + }, + "tasks": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Task" + } + }, + "times": { + "default": {}, + "type": "object", + "additionalProperties": { + "type": "string", + "format": "date-time" + } } }, "required": [ + "cancelled", "id", "name", "output_rules", - "script", - "state" + "owner", + "state", + "tags", + "target", + "target_real", + "tasks" + ] + }, + "JobAddInput": { + "type": "object", + "properties": { + "chunks": { + "type": "array", + "items": { + "type": "string" + } + }, + "commit_id": { + "type": "string" + }, + "name": { + "type": "string" + }, + "size": { + "type": "integer", + "format": "uint64", + "minimum": 0 + } + }, + "required": [ + "chunks", + "commit_id", + "name", + "size" + ] + }, + "JobAddInputResult": { + "type": "object", + "properties": { + "complete": { + "type": "boolean" + }, + "error": { + "nullable": true, + "type": "string" + } + }, + "required": [ + "complete" ] }, - "TaskEvent": { + "JobEvent": { "type": "object", "properties": { "payload": { @@ -521,61 +2413,379 @@ "stream": { "type": "string" }, + "task": { + "nullable": true, + "type": "integer", + "format": "uint32", + "minimum": 0 + }, "time": { "type": "string", "format": "date-time" + }, + "time_remote": { + "nullable": true, + "type": "string", + "format": "date-time" + } + }, + "required": [ + "payload", + "seq", + "stream", + "time" + ] + }, + "JobOutput": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "path": { + "type": "string" + }, + "size": { + "type": "integer", + "format": "uint64", + "minimum": 0 + } + }, + "required": [ + "id", + "path", + "size" + ] + }, + "JobOutputPublish": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "series": { + "type": "string" + }, + "version": { + "type": "string" + } + }, + "required": [ + "name", + "series", + "version" + ] + }, + "JobOutputSignedUrl": { + "type": "object", + "properties": { + "content_disposition": { + "nullable": true, + "type": "string" + }, + "content_type": { + "nullable": true, + "type": "string" + }, + "expiry_seconds": { + "type": "integer", + "format": "uint64", + "minimum": 0 + } + }, + "required": [ + "expiry_seconds" + ] + }, + "JobOutputSignedUrlResult": { + "type": "object", + "properties": { + "url": { + "type": "string" + } + }, + "required": [ + "url" + ] + }, + "JobStoreValue": { + "type": "object", + "properties": { + "secret": { + "type": "boolean" + }, + "value": { + "type": "string" + } + }, + "required": [ + "secret", + "value" + ] + }, + "JobStoreValueInfo": { + "type": "object", + "properties": { + "secret": { + "type": "boolean" + }, + "source": { + "type": "string" + }, + "time_update": { + "type": "string", + "format": "date-time" + }, + "value": { + "nullable": true, + "type": "string" + } + }, + "required": [ + "secret", + "source", + "time_update" + ] + }, + "JobSubmit": { + "type": "object", + "properties": { + "depends": { + "type": "object", + "additionalProperties": { + "$ref": "#/components/schemas/DependSubmit" + } + }, + "inputs": { + "default": [], + "type": "array", + "items": { + "type": "string" + } + }, + "name": { + "type": "string" + }, + "output_rules": { + "type": "array", + "items": { + "type": "string" + } + }, + "tags": { + "default": {}, + "type": "object", + "additionalProperties": { + "type": "string" + } + }, + "target": { + "type": "string" + }, + "tasks": { + "type": "array", + "items": { + "$ref": "#/components/schemas/TaskSubmit" + } + } + }, + "required": [ + "name", + "output_rules", + "target", + "tasks" + ] + }, + "JobSubmitResult": { + "type": "object", + "properties": { + "id": { + "type": "string" + } + }, + "required": [ + "id" + ] + }, + "Quota": { + "type": "object", + "properties": { + "max_bytes_per_input": { + "type": "integer", + "format": "uint64", + "minimum": 0 + } + }, + "required": [ + "max_bytes_per_input" + ] + }, + "Target": { + "type": "object", + "properties": { + "desc": { + "type": "string" + }, + "id": { + "type": "string" + }, + "name": { + "type": "string" + }, + "privilege": { + "nullable": true, + "type": "string" + }, + "redirect": { + "nullable": true, + "type": "string" + } + }, + "required": [ + "desc", + "id", + "name" + ] + }, + "TargetCreate": { + "type": "object", + "properties": { + "desc": { + "type": "string" + }, + "name": { + "type": "string" + } + }, + "required": [ + "desc", + "name" + ] + }, + "TargetCreateResult": { + "type": "object", + "properties": { + "id": { + "type": "string" + } + }, + "required": [ + "id" + ] + }, + "TargetRedirect": { + "type": "object", + "properties": { + "redirect": { + "nullable": true, + "type": "string" + } + } + }, + "TargetRename": { + "type": "object", + "properties": { + "new_name": { + "type": "string" + }, + "signpost_description": { + "type": "string" } }, "required": [ - "payload", - "seq", - "stream", - "time" + "new_name", + "signpost_description" ] }, - "TaskOutput": { + "Task": { "type": "object", "properties": { - "id": { + "env": { + "type": "object", + "additionalProperties": { + "type": "string" + } + }, + "env_clear": { + "type": "boolean" + }, + "gid": { + "nullable": true, + "type": "integer", + "format": "uint32", + "minimum": 0 + }, + "name": { "type": "string" }, - "path": { + "script": { "type": "string" }, - "size": { + "state": { + "type": "string" + }, + "uid": { + "nullable": true, "type": "integer", - "format": "uint64", + "format": "uint32", "minimum": 0 + }, + "workdir": { + "nullable": true, + "type": "string" } }, "required": [ - "id", - "path", - "size" + "env", + "env_clear", + "name", + "script", + "state" ] }, "TaskSubmit": { "type": "object", "properties": { - "name": { - "type": "string" - }, - "output_rules": { - "type": "array", - "items": { + "env": { + "type": "object", + "additionalProperties": { "type": "string" } }, + "env_clear": { + "type": "boolean" + }, + "gid": { + "nullable": true, + "type": "integer", + "format": "uint32", + "minimum": 0 + }, + "name": { + "type": "string" + }, "script": { "type": "string" + }, + "uid": { + "nullable": true, + "type": "integer", + "format": "uint32", + "minimum": 0 + }, + "workdir": { + "nullable": true, + "type": "string" } }, "required": [ + "env", + "env_clear", "name", "script" ] }, - "TaskSubmitResult": { + "UploadedChunk": { "type": "object", "properties": { "id": { @@ -586,15 +2796,31 @@ "id" ] }, - "UploadedChunk": { + "User": { "type": "object", "properties": { "id": { "type": "string" + }, + "name": { + "type": "string" + }, + "privileges": { + "type": "array", + "items": { + "type": "string" + } + }, + "time_create": { + "type": "string", + "format": "date-time" } }, "required": [ - "id" + "id", + "name", + "privileges", + "time_create" ] }, "UserCreate": { @@ -645,34 +2871,48 @@ "Worker": { "type": "object", "properties": { + "bootstrap": { + "type": "boolean" + }, "deleted": { "type": "boolean" }, - "id": { + "factory": { + "type": "string" + }, + "factory_private": { + "nullable": true, "type": "string" }, - "instance_id": { + "id": { "type": "string" }, + "jobs": { + "type": "array", + "items": { + "$ref": "#/components/schemas/WorkerJob" + } + }, "lastping": { + "nullable": true, "type": "string", "format": "date-time" }, "recycle": { "type": "boolean" }, - "tasks": { - "type": "array", - "items": { - "$ref": "#/components/schemas/WorkerTask" - } + "target": { + "type": "string" } }, "required": [ + "bootstrap", "deleted", + "factory", "id", + "jobs", "recycle", - "tasks" + "target" ] }, "WorkerAddOutput": { @@ -684,21 +2924,61 @@ "type": "string" } }, + "commit_id": { + "type": "string" + }, "path": { "type": "string" }, "size": { "type": "integer", - "format": "int64" + "format": "uint64", + "minimum": 0 } }, "required": [ "chunks", + "commit_id", "path", "size" ] }, - "WorkerAppendTask": { + "WorkerAddOutputResult": { + "type": "object", + "properties": { + "complete": { + "type": "boolean" + }, + "error": { + "nullable": true, + "type": "string" + } + }, + "required": [ + "complete" + ] + }, + "WorkerAppendJob": { + "type": "object", + "properties": { + "payload": { + "type": "string" + }, + "stream": { + "type": "string" + }, + "time": { + "type": "string", + "format": "date-time" + } + }, + "required": [ + "payload", + "stream", + "time" + ] + }, + "WorkerAppendJobOrTask": { "type": "object", "properties": { "payload": { @@ -707,6 +2987,12 @@ "stream": { "type": "string" }, + "task": { + "nullable": true, + "type": "integer", + "format": "uint32", + "minimum": 0 + }, "time": { "type": "string", "format": "date-time" @@ -744,6 +3030,17 @@ "id" ] }, + "WorkerCompleteJob": { + "type": "object", + "properties": { + "failed": { + "type": "boolean" + } + }, + "required": [ + "failed" + ] + }, "WorkerCompleteTask": { "type": "object", "properties": { @@ -755,59 +3052,224 @@ "failed" ] }, - "WorkerPingResult": { + "WorkerJob": { "type": "object", "properties": { - "poweroff": { + "id": { + "type": "string" + }, + "name": { + "type": "string" + }, + "owner": { + "type": "string" + }, + "state": { + "type": "string" + }, + "tags": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + }, + "required": [ + "id", + "name", + "owner", + "state", + "tags" + ] + }, + "WorkerJobQuota": { + "type": "object", + "properties": { + "max_bytes_per_output": { + "type": "integer", + "format": "uint64", + "minimum": 0 + } + }, + "required": [ + "max_bytes_per_output" + ] + }, + "WorkerJobStoreGet": { + "type": "object", + "properties": { + "value": { + "nullable": true, + "allOf": [ + { + "$ref": "#/components/schemas/WorkerJobStoreValue" + } + ] + } + } + }, + "WorkerJobStoreValue": { + "type": "object", + "properties": { + "secret": { "type": "boolean" }, - "task": { - "$ref": "#/components/schemas/WorkerPingTask" + "value": { + "type": "string" } }, "required": [ - "poweroff" + "secret", + "value" ] }, - "WorkerPingTask": { + "WorkerPingInput": { "type": "object", "properties": { "id": { "type": "string" }, - "output_rules": { + "name": { + "type": "string" + } + }, + "required": [ + "id", + "name" + ] + }, + "WorkerPingJob": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "inputs": { "type": "array", "items": { - "type": "string" + "$ref": "#/components/schemas/WorkerPingInput" } }, - "script": { + "name": { "type": "string" + }, + "output_rules": { + "type": "array", + "items": { + "$ref": "#/components/schemas/WorkerPingOutputRule" + } + }, + "tasks": { + "type": "array", + "items": { + "$ref": "#/components/schemas/WorkerPingTask" + } } }, "required": [ "id", + "inputs", + "name", "output_rules", - "script" + "tasks" ] }, - "WorkerTask": { + "WorkerPingOutputRule": { "type": "object", "properties": { - "id": { + "ignore": { + "type": "boolean" + }, + "require_match": { + "type": "boolean" + }, + "rule": { "type": "string" }, + "size_change_ok": { + "type": "boolean" + } + }, + "required": [ + "ignore", + "require_match", + "rule", + "size_change_ok" + ] + }, + "WorkerPingResult": { + "type": "object", + "properties": { + "factory_metadata": { + "nullable": true, + "allOf": [ + { + "$ref": "#/components/schemas/FactoryMetadata" + } + ] + }, + "job": { + "nullable": true, + "allOf": [ + { + "$ref": "#/components/schemas/WorkerPingJob" + } + ] + }, + "poweroff": { + "type": "boolean" + } + }, + "required": [ + "poweroff" + ] + }, + "WorkerPingTask": { + "type": "object", + "properties": { + "env": { + "type": "object", + "additionalProperties": { + "type": "string" + } + }, + "env_clear": { + "type": "boolean" + }, + "gid": { + "type": "integer", + "format": "uint32", + "minimum": 0 + }, + "id": { + "type": "integer", + "format": "uint32", + "minimum": 0 + }, "name": { "type": "string" }, - "owner": { + "script": { + "type": "string" + }, + "uid": { + "type": "integer", + "format": "uint32", + "minimum": 0 + }, + "workdir": { "type": "string" } }, "required": [ + "env", + "env_clear", + "gid", "id", "name", - "owner" + "script", + "uid", + "workdir" ] }, "WorkersResult": {