1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152
use crate::api::{ObjectVersion, TaskSpec}; use serde::{Deserialize, Serialize}; #[cfg(feature = "chrono")] use chrono::{DateTime, Utc}; pub type ServicesInfo = Vec<ServiceInfo>; #[derive(Clone, Debug, Serialize, Deserialize)] #[serde(rename_all = "PascalCase")] pub struct ServiceInfo { #[serde(rename = "ID")] pub id: String, pub version: ObjectVersion, #[cfg(feature = "chrono")] pub created_at: DateTime<Utc>, #[cfg(not(feature = "chrono"))] pub created_at: String, #[cfg(feature = "chrono")] pub updated_at: DateTime<Utc>, #[cfg(not(feature = "chrono"))] pub updated_at: String, pub spec: Option<ServiceSpec>, pub endpoint: Option<Endpoint>, pub update_status: Option<UpdateStatus>, pub service_status: Option<ServiceStatus>, pub job_status: Option<JobStatus>, } #[derive(Clone, Debug, Serialize, Deserialize)] #[serde(rename_all = "PascalCase")] pub struct Endpoint { pub spec: Option<EndpointSpec>, pub ports: Option<Vec<EndpointPortConfig>>, #[serde(rename = "VirtualIPs")] pub virtual_ips: Option<serde_json::Value>, } #[derive(Clone, Debug, Serialize, Deserialize)] #[serde(rename_all = "PascalCase")] pub struct EndpointSpec { pub mode: Option<String>, pub ports: Option<Vec<EndpointPortConfig>>, } #[derive(Clone, Debug, Serialize, Deserialize)] #[serde(rename_all = "PascalCase")] pub struct EndpointPortConfig { pub name: Option<String>, pub protocol: Option<String>, pub publish_mode: Option<String>, pub published_port: Option<u64>, pub target_port: Option<u64>, } #[derive(Clone, Debug, Serialize, Deserialize)] #[serde(rename_all = "PascalCase")] pub struct UpdateStatus { pub state: Option<String>, #[cfg(feature = "chrono")] pub started_at: Option<DateTime<Utc>>, #[cfg(not(feature = "chrono"))] pub started_at: Option<String>, #[cfg(feature = "chrono")] pub completed_at: Option<DateTime<Utc>>, #[cfg(not(feature = "chrono"))] pub completed_at: Option<String>, pub message: Option<String>, } #[derive(Clone, Debug, Serialize, Deserialize)] #[serde(rename_all = "PascalCase")] pub struct ServiceStatus { pub running_tasks: u64, pub desired_tasks: u64, pub completed_tasks: u64, } #[derive(Clone, Debug, Serialize, Deserialize)] #[serde(rename_all = "PascalCase")] pub struct JobStatus { pub job_iteration: ObjectVersion, #[cfg(feature = "chrono")] pub last_execution: Option<DateTime<Utc>>, #[cfg(not(feature = "chrono"))] pub last_execution: Option<String>, } #[derive(Clone, Debug, Serialize, Deserialize)] #[serde(rename_all = "PascalCase")] pub struct ServiceSpec { pub name: Option<String>, pub labels: serde_json::Value, pub task_template: Option<TaskSpec>, pub mode: Option<Mode>, pub update_config: Option<UpdateConfig>, pub rollback_config: Option<RollbackConfig>, pub networks: Option<Vec<NetworkAttachmentConfig>>, pub endpoint_spec: Option<EndpointSpec>, } #[derive(Clone, Debug, Serialize, Deserialize)] #[serde(rename_all = "PascalCase")] pub struct Mode { pub replicated: Option<Replicated>, pub global: Option<serde_json::Value>, pub replicated_job: Option<ReplicatedJob>, pub global_job: Option<serde_json::Value>, } #[derive(Clone, Debug, Serialize, Deserialize)] #[serde(rename_all = "PascalCase")] pub struct Replicated { pub replicas: Option<u64>, } #[derive(Clone, Debug, Serialize, Deserialize)] #[serde(rename_all = "PascalCase")] pub struct ReplicatedJob { pub max_concurrent: Option<u64>, pub total_completions: Option<u64>, } #[derive(Clone, Debug, Serialize, Deserialize)] #[serde(rename_all = "PascalCase")] pub struct UpdateConfig { pub parallelism: u64, pub delay: Option<u64>, pub failure_action: Option<String>, pub monitor: Option<u64>, pub max_failure_ratio: f32, pub order: String, } pub type RollbackConfig = UpdateConfig; #[derive(Clone, Debug, Serialize, Deserialize)] #[serde(rename_all = "PascalCase")] pub struct NetworkAttachmentConfig { pub target: Option<String>, pub aliases: Option<Vec<String>>, pub driver_opts: Option<serde_json::Value>, } #[derive(Clone, Debug, Serialize, Deserialize)] pub struct ServiceCreateInfo { #[serde(rename = "ID")] pub id: String, #[serde(rename = "Warning")] pub warning: Option<String>, }