use derive_empty_traits::EmptyTraits;
use resolver_api::Resolve;
use serde::{Deserialize, Serialize};
use typeshare::typeshare;
use crate::entities::{
I64, SearchCombinator, U64,
deployment::{
Deployment, DeploymentActionState, DeploymentListItem,
DeploymentQuery, DeploymentState,
},
docker::{
container::{Container, ContainerListItem, ContainerStats},
service::SwarmService,
},
update::Log,
};
use super::KomodoReadRequest;
#[typeshare]
#[derive(
Serialize, Deserialize, Debug, Clone, Resolve, EmptyTraits,
)]
#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
#[empty_traits(KomodoReadRequest)]
#[response(GetDeploymentResponse)]
#[error(serror::Error)]
pub struct GetDeployment {
#[serde(alias = "id", alias = "name")]
pub deployment: String,
}
#[typeshare]
pub type GetDeploymentResponse = Deployment;
#[typeshare]
#[derive(
Serialize, Deserialize, Debug, Clone, Default, Resolve, EmptyTraits,
)]
#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
#[empty_traits(KomodoReadRequest)]
#[response(ListDeploymentsResponse)]
#[error(serror::Error)]
pub struct ListDeployments {
#[serde(default)]
pub query: DeploymentQuery,
}
#[typeshare]
pub type ListDeploymentsResponse = Vec<DeploymentListItem>;
#[typeshare]
#[derive(
Serialize, Deserialize, Debug, Clone, Default, Resolve, EmptyTraits,
)]
#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
#[empty_traits(KomodoReadRequest)]
#[response(ListFullDeploymentsResponse)]
#[error(serror::Error)]
pub struct ListFullDeployments {
#[serde(default)]
pub query: DeploymentQuery,
}
#[typeshare]
pub type ListFullDeploymentsResponse = Vec<Deployment>;
#[typeshare]
#[derive(
Serialize, Deserialize, Debug, Clone, Resolve, EmptyTraits,
)]
#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
#[empty_traits(KomodoReadRequest)]
#[response(GetDeploymentContainerResponse)]
#[error(serror::Error)]
pub struct GetDeploymentContainer {
#[serde(alias = "id", alias = "name")]
pub deployment: String,
}
#[typeshare]
#[derive(Serialize, Deserialize, Debug, Clone)]
#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
pub struct GetDeploymentContainerResponse {
pub state: DeploymentState,
pub container: Option<ContainerListItem>,
}
#[typeshare]
#[derive(
Serialize, Deserialize, Debug, Clone, Resolve, EmptyTraits,
)]
#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
#[empty_traits(KomodoReadRequest)]
#[response(InspectDeploymentContainerResponse)]
#[error(serror::Error)]
pub struct InspectDeploymentContainer {
#[serde(alias = "id", alias = "name")]
pub deployment: String,
}
#[typeshare]
pub type InspectDeploymentContainerResponse = Container;
#[typeshare]
#[derive(
Serialize, Deserialize, Debug, Clone, Resolve, EmptyTraits,
)]
#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
#[empty_traits(KomodoReadRequest)]
#[response(InspectDeploymentSwarmServiceResponse)]
#[error(serror::Error)]
pub struct InspectDeploymentSwarmService {
#[serde(alias = "id", alias = "name")]
pub deployment: String,
}
#[typeshare]
pub type InspectDeploymentSwarmServiceResponse = SwarmService;
#[typeshare]
#[derive(
Serialize, Deserialize, Debug, Clone, Resolve, EmptyTraits,
)]
#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
#[empty_traits(KomodoReadRequest)]
#[response(GetDeploymentLogResponse)]
#[error(serror::Error)]
pub struct GetDeploymentLog {
#[serde(alias = "id", alias = "name")]
pub deployment: String,
#[serde(default = "default_tail")]
pub tail: U64,
#[serde(default)]
pub timestamps: bool,
}
fn default_tail() -> u64 {
50
}
#[typeshare]
pub type GetDeploymentLogResponse = Log;
#[typeshare]
#[derive(
Serialize, Deserialize, Debug, Clone, Resolve, EmptyTraits,
)]
#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
#[empty_traits(KomodoReadRequest)]
#[response(SearchDeploymentLogResponse)]
#[error(serror::Error)]
pub struct SearchDeploymentLog {
#[serde(alias = "id", alias = "name")]
pub deployment: String,
pub terms: Vec<String>,
#[serde(default)]
pub combinator: SearchCombinator,
#[serde(default)]
pub invert: bool,
#[serde(default)]
pub timestamps: bool,
}
#[typeshare]
pub type SearchDeploymentLogResponse = Log;
#[typeshare]
#[derive(
Serialize, Deserialize, Debug, Clone, Resolve, EmptyTraits,
)]
#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
#[empty_traits(KomodoReadRequest)]
#[response(GetDeploymentStatsResponse)]
#[error(serror::Error)]
pub struct GetDeploymentStats {
#[serde(alias = "id", alias = "name")]
pub deployment: String,
}
#[typeshare]
pub type GetDeploymentStatsResponse = ContainerStats;
#[typeshare]
#[derive(
Serialize, Deserialize, Debug, Clone, Resolve, EmptyTraits,
)]
#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
#[empty_traits(KomodoReadRequest)]
#[response(DeploymentActionState)]
#[error(serror::Error)]
pub struct GetDeploymentActionState {
#[serde(alias = "id", alias = "name")]
pub deployment: String,
}
#[typeshare]
pub type GetDeploymentActionStateResponse = DeploymentActionState;
#[typeshare]
#[derive(
Serialize, Deserialize, Debug, Clone, Resolve, EmptyTraits,
)]
#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
#[empty_traits(KomodoReadRequest)]
#[response(GetDeploymentsSummaryResponse)]
#[error(serror::Error)]
pub struct GetDeploymentsSummary {}
#[typeshare]
#[derive(Serialize, Deserialize, Debug, Clone, Default)]
#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
pub struct GetDeploymentsSummaryResponse {
pub total: I64,
pub running: I64,
pub stopped: I64,
pub not_deployed: I64,
pub unhealthy: I64,
pub unknown: I64,
}
#[typeshare]
#[derive(
Serialize, Deserialize, Debug, Clone, Resolve, EmptyTraits,
)]
#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
#[empty_traits(KomodoReadRequest)]
#[response(ListCommonDeploymentExtraArgsResponse)]
#[error(serror::Error)]
pub struct ListCommonDeploymentExtraArgs {
#[serde(default)]
pub query: DeploymentQuery,
}
#[typeshare]
pub type ListCommonDeploymentExtraArgsResponse = Vec<String>;