mirror of
https://github.com/moghtech/komodo.git
synced 2026-04-29 21:27:26 -05:00
add most basic read apis
This commit is contained in:
@@ -17,7 +17,7 @@ use super::KomodoReadRequest;
|
||||
description = "Get a specific action.",
|
||||
request_body(content = GetAction),
|
||||
responses(
|
||||
(status = 200, description = "The action", body = GetActionResponse),
|
||||
(status = 200, description = "The action", body = crate::entities::action::ActionSchema),
|
||||
),
|
||||
)]
|
||||
pub fn get_action() {}
|
||||
|
||||
@@ -17,7 +17,7 @@ use super::KomodoReadRequest;
|
||||
description = "Get a specific alerter.",
|
||||
request_body(content = GetAlerter),
|
||||
responses(
|
||||
(status = 200, description = "The alerter", body = GetAlerterResponse),
|
||||
(status = 200, description = "The alerter", body = crate::entities::alerter::AlerterSchema),
|
||||
),
|
||||
)]
|
||||
pub fn get_alerter() {}
|
||||
|
||||
@@ -20,7 +20,7 @@ use super::KomodoReadRequest;
|
||||
description = "Get a specific build.",
|
||||
request_body(content = GetBuild),
|
||||
responses(
|
||||
(status = 200, description = "The build", body = GetBuildResponse),
|
||||
(status = 200, description = "The build", body = crate::entities::build::BuildSchema),
|
||||
),
|
||||
)]
|
||||
pub fn get_build() {}
|
||||
|
||||
@@ -17,7 +17,7 @@ use super::KomodoReadRequest;
|
||||
description = "Get a specific builder by id or name.",
|
||||
request_body(content = GetBuilder),
|
||||
responses(
|
||||
(status = 200, description = "The builder", body = GetBuilderResponse),
|
||||
(status = 200, description = "The builder", body = crate::entities::builder::BuilderSchema),
|
||||
),
|
||||
)]
|
||||
pub fn get_builder() {}
|
||||
|
||||
@@ -26,7 +26,7 @@ use super::KomodoReadRequest;
|
||||
description = "Get a specific deployment by name or id.",
|
||||
request_body(content = GetDeployment),
|
||||
responses(
|
||||
(status = 200, description = "The deployment", body = GetDeploymentResponse),
|
||||
(status = 200, description = "The deployment", body = crate::entities::deployment::DeploymentSchema),
|
||||
),
|
||||
)]
|
||||
pub fn get_deployment() {}
|
||||
|
||||
@@ -17,7 +17,7 @@ use super::KomodoReadRequest;
|
||||
description = "Get a specific procedure.",
|
||||
request_body(content = GetProcedure),
|
||||
responses(
|
||||
(status = 200, description = "The procedure", body = GetProcedureResponse),
|
||||
(status = 200, description = "The procedure", body = crate::entities::procedure::ProcedureSchema),
|
||||
),
|
||||
)]
|
||||
pub fn get_procedure() {}
|
||||
|
||||
@@ -17,7 +17,7 @@ use super::KomodoReadRequest;
|
||||
description = "Get a specific repo.",
|
||||
request_body(content = GetRepo),
|
||||
responses(
|
||||
(status = 200, description = "The repo", body = GetRepoResponse),
|
||||
(status = 200, description = "The repo", body = crate::entities::repo::RepoSchema),
|
||||
),
|
||||
)]
|
||||
pub fn get_repo() {}
|
||||
|
||||
@@ -24,7 +24,7 @@ use super::KomodoReadRequest;
|
||||
description = "Get a specific server.",
|
||||
request_body(content = GetServer),
|
||||
responses(
|
||||
(status = 200, description = "The server", body = GetServerResponse),
|
||||
(status = 200, description = "The server", body = crate::entities::server::ServerSchema),
|
||||
),
|
||||
)]
|
||||
pub fn get_server() {}
|
||||
|
||||
@@ -24,7 +24,7 @@ use super::KomodoReadRequest;
|
||||
description = "Get a specific stack.",
|
||||
request_body(content = GetStack),
|
||||
responses(
|
||||
(status = 200, description = "The stack", body = GetStackResponse),
|
||||
(status = 200, description = "The stack", body = crate::entities::stack::StackSchema),
|
||||
),
|
||||
)]
|
||||
pub fn get_stack() {}
|
||||
|
||||
@@ -29,7 +29,7 @@ use super::KomodoReadRequest;
|
||||
description = "Get a specific swarm.",
|
||||
request_body(content = GetSwarm),
|
||||
responses(
|
||||
(status = 200, description = "The swarm", body = GetSwarmResponse),
|
||||
(status = 200, description = "The swarm", body = crate::entities::swarm::SwarmSchema),
|
||||
),
|
||||
)]
|
||||
pub fn get_swarm() {}
|
||||
@@ -39,7 +39,7 @@ pub fn get_swarm() {}
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, Resolve)]
|
||||
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
|
||||
#[empty_traits(KomodoReadRequest)]
|
||||
#[response(Swarm)]
|
||||
#[response(GetSwarmResponse)]
|
||||
#[error(mogh_error::Error)]
|
||||
pub struct GetSwarm {
|
||||
/// Id or name
|
||||
|
||||
@@ -18,7 +18,7 @@ use super::KomodoReadRequest;
|
||||
description = "Get a specific sync.",
|
||||
request_body(content = GetResourceSync),
|
||||
responses(
|
||||
(status = 200, description = "The resource sync", body = GetResourceSyncResponse),
|
||||
(status = 200, description = "The resource sync", body = crate::entities::sync::ResourceSyncSchema),
|
||||
),
|
||||
)]
|
||||
pub fn get_resource_sync() {}
|
||||
|
||||
@@ -64,6 +64,13 @@ pub enum ActionState {
|
||||
Running,
|
||||
}
|
||||
|
||||
#[cfg(feature = "utoipa")]
|
||||
#[derive(utoipa::ToSchema)]
|
||||
#[schema(as = Action)]
|
||||
pub struct ActionSchema(
|
||||
#[schema(inline)] pub Resource<ActionConfig, NoData>,
|
||||
);
|
||||
|
||||
#[typeshare]
|
||||
pub type Action = Resource<ActionConfig, NoData>;
|
||||
|
||||
|
||||
@@ -14,6 +14,14 @@ use super::{
|
||||
resource::{Resource, ResourceListItem, ResourceQuery},
|
||||
};
|
||||
|
||||
#[cfg(feature = "utoipa")]
|
||||
#[derive(utoipa::ToSchema)]
|
||||
#[schema(as = Alerter)]
|
||||
pub struct AlerterSchema(
|
||||
#[schema(inline)]
|
||||
pub Resource<AlerterConfig, crate::entities::NoData>,
|
||||
);
|
||||
|
||||
#[typeshare]
|
||||
pub type Alerter = Resource<AlerterConfig, ()>;
|
||||
|
||||
|
||||
@@ -23,6 +23,13 @@ use super::{
|
||||
resource::{Resource, ResourceListItem, ResourceQuery},
|
||||
};
|
||||
|
||||
#[cfg(feature = "utoipa")]
|
||||
#[derive(utoipa::ToSchema)]
|
||||
#[schema(as = Build)]
|
||||
pub struct BuildSchema(
|
||||
#[schema(inline)] pub Resource<BuildConfig, BuildInfo>,
|
||||
);
|
||||
|
||||
#[typeshare]
|
||||
pub type Build = Resource<BuildConfig, BuildInfo>;
|
||||
|
||||
|
||||
@@ -14,6 +14,14 @@ use super::{
|
||||
resource::{AddFilters, Resource, ResourceListItem, ResourceQuery},
|
||||
};
|
||||
|
||||
#[cfg(feature = "utoipa")]
|
||||
#[derive(utoipa::ToSchema)]
|
||||
#[schema(as = Builder)]
|
||||
pub struct BuilderSchema(
|
||||
#[schema(inline)]
|
||||
pub Resource<BuilderConfig, crate::entities::NoData>,
|
||||
);
|
||||
|
||||
#[typeshare]
|
||||
pub type Builder = Resource<BuilderConfig, ()>;
|
||||
|
||||
|
||||
@@ -25,6 +25,14 @@ use super::{
|
||||
resource::{Resource, ResourceListItem, ResourceQuery},
|
||||
};
|
||||
|
||||
#[cfg(feature = "utoipa")]
|
||||
#[derive(utoipa::ToSchema)]
|
||||
#[schema(as = Deployment)]
|
||||
pub struct DeploymentSchema(
|
||||
#[schema(inline)]
|
||||
pub Resource<DeploymentConfig, crate::entities::NoData>,
|
||||
);
|
||||
|
||||
#[typeshare]
|
||||
pub type Deployment = Resource<DeploymentConfig, ()>;
|
||||
|
||||
|
||||
@@ -61,6 +61,14 @@ pub enum ProcedureState {
|
||||
Unknown,
|
||||
}
|
||||
|
||||
#[cfg(feature = "utoipa")]
|
||||
#[derive(utoipa::ToSchema)]
|
||||
#[schema(as = Procedure)]
|
||||
pub struct ProcedureSchema(
|
||||
#[schema(inline)]
|
||||
pub Resource<ProcedureConfig, crate::entities::NoData>,
|
||||
);
|
||||
|
||||
/// Procedures run a series of stages sequentially, where
|
||||
/// each stage runs executions in parallel.
|
||||
#[typeshare]
|
||||
|
||||
@@ -76,6 +76,13 @@ pub enum RepoState {
|
||||
Building,
|
||||
}
|
||||
|
||||
#[cfg(feature = "utoipa")]
|
||||
#[derive(utoipa::ToSchema)]
|
||||
#[schema(as = Repo)]
|
||||
pub struct RepoSchema(
|
||||
#[schema(inline)] pub Resource<RepoConfig, RepoInfo>,
|
||||
);
|
||||
|
||||
#[typeshare]
|
||||
pub type Repo = Resource<RepoConfig, RepoInfo>;
|
||||
|
||||
|
||||
@@ -20,7 +20,10 @@ use super::{
|
||||
#[typeshare]
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, Builder)]
|
||||
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
|
||||
pub struct Resource<Config: Default, Info: Default = ()> {
|
||||
pub struct Resource<Config, Info: Default = ()>
|
||||
where
|
||||
Config: Default,
|
||||
{
|
||||
/// The Mongo ID of the resource.
|
||||
/// This field is de/serialized from/to JSON as
|
||||
/// `{ "_id": { "$oid": "..." }, ...(rest of serialized Resource<T>) }`
|
||||
@@ -31,6 +34,7 @@ pub struct Resource<Config: Default, Info: Default = ()> {
|
||||
with = "bson::serde_helpers::hex_string_as_object_id"
|
||||
)]
|
||||
#[builder(setter(skip))]
|
||||
#[cfg_attr(feature = "utoipa", schema(value_type = crate::entities::MongoIdObj))]
|
||||
pub id: MongoId,
|
||||
|
||||
/// The resource name.
|
||||
|
||||
@@ -18,6 +18,13 @@ use super::{
|
||||
resource::{AddFilters, Resource, ResourceListItem, ResourceQuery},
|
||||
};
|
||||
|
||||
#[cfg(feature = "utoipa")]
|
||||
#[derive(utoipa::ToSchema)]
|
||||
#[schema(as = Server)]
|
||||
pub struct ServerSchema(
|
||||
#[schema(inline)] pub Resource<ServerConfig, ServerInfo>,
|
||||
);
|
||||
|
||||
#[typeshare]
|
||||
pub type Server = Resource<ServerConfig, ServerInfo>;
|
||||
|
||||
|
||||
@@ -32,6 +32,13 @@ use super::{
|
||||
resource::{Resource, ResourceListItem, ResourceQuery},
|
||||
};
|
||||
|
||||
#[cfg(feature = "utoipa")]
|
||||
#[derive(utoipa::ToSchema)]
|
||||
#[schema(as = Stack)]
|
||||
pub struct StackSchema(
|
||||
#[schema(inline)] pub Resource<StackConfig, StackInfo>,
|
||||
);
|
||||
|
||||
#[typeshare]
|
||||
pub type Stack = Resource<StackConfig, StackInfo>;
|
||||
|
||||
|
||||
@@ -53,6 +53,13 @@ pub enum SwarmState {
|
||||
Unknown,
|
||||
}
|
||||
|
||||
#[cfg(feature = "utoipa")]
|
||||
#[derive(utoipa::ToSchema)]
|
||||
#[schema(as = Swarm)]
|
||||
pub struct SwarmSchema(
|
||||
#[schema(inline)] pub Resource<SwarmConfig, SwarmInfo>,
|
||||
);
|
||||
|
||||
#[typeshare]
|
||||
pub type Swarm = Resource<SwarmConfig, SwarmInfo>;
|
||||
|
||||
|
||||
@@ -81,6 +81,13 @@ pub enum ResourceSyncState {
|
||||
Unknown,
|
||||
}
|
||||
|
||||
#[cfg(feature = "utoipa")]
|
||||
#[derive(utoipa::ToSchema)]
|
||||
#[schema(as = ResourceSync)]
|
||||
pub struct ResourceSyncSchema(
|
||||
#[schema(inline)] pub Resource<ResourceSyncConfig, ResourceSyncInfo>,
|
||||
);
|
||||
|
||||
#[typeshare]
|
||||
pub type ResourceSync =
|
||||
Resource<ResourceSyncConfig, ResourceSyncInfo>;
|
||||
|
||||
@@ -22,14 +22,78 @@ mod read {
|
||||
user::set_last_seen_update,
|
||||
user::create_api_key,
|
||||
user::delete_api_key,
|
||||
// // ======
|
||||
// // READ
|
||||
// // ======
|
||||
// ======
|
||||
// READ
|
||||
// ======
|
||||
read::get_version,
|
||||
read::get_core_info,
|
||||
read::list_git_providers_from_config,
|
||||
read::list_docker_registries_from_config,
|
||||
read::list_secrets,
|
||||
// swarm
|
||||
read::list_swarms,
|
||||
read::list_full_swarms,
|
||||
read::get_swarm,
|
||||
read::get_swarm_action_state,
|
||||
read::get_swarms_summary,
|
||||
// server
|
||||
read::list_servers,
|
||||
read::list_full_servers,
|
||||
read::get_server,
|
||||
read::get_server_action_state,
|
||||
read::get_servers_summary,
|
||||
// stack
|
||||
read::list_stacks,
|
||||
read::list_full_stacks,
|
||||
read::get_stack,
|
||||
read::get_stack_action_state,
|
||||
read::get_stacks_summary,
|
||||
// deployment
|
||||
read::list_deployments,
|
||||
read::list_full_deployments,
|
||||
read::get_deployment,
|
||||
read::get_deployment_action_state,
|
||||
read::get_deployments_summary,
|
||||
// build
|
||||
read::list_builds,
|
||||
read::list_full_builds,
|
||||
read::get_build,
|
||||
read::get_build_action_state,
|
||||
read::get_builds_summary,
|
||||
// repo
|
||||
read::list_repos,
|
||||
read::list_full_repos,
|
||||
read::get_repo,
|
||||
read::get_repo_action_state,
|
||||
read::get_repos_summary,
|
||||
// procedure
|
||||
read::list_procedures,
|
||||
read::list_full_procedures,
|
||||
read::get_procedure,
|
||||
read::get_procedure_action_state,
|
||||
read::get_procedures_summary,
|
||||
// action
|
||||
read::list_actions,
|
||||
read::list_full_actions,
|
||||
read::get_action,
|
||||
read::get_action_action_state,
|
||||
read::get_actions_summary,
|
||||
// builder
|
||||
read::list_builders,
|
||||
read::list_full_builders,
|
||||
read::get_builder,
|
||||
read::get_builders_summary,
|
||||
// alerter
|
||||
read::list_alerters,
|
||||
read::list_full_alerters,
|
||||
read::get_alerter,
|
||||
read::get_alerters_summary,
|
||||
// resource_sync
|
||||
read::list_resource_syncs,
|
||||
read::list_full_resource_syncs,
|
||||
read::get_resource_sync,
|
||||
read::get_resource_sync_action_state,
|
||||
read::get_resource_syncs_summary,
|
||||
),
|
||||
)]
|
||||
pub struct KomodoApi;
|
||||
|
||||
Reference in New Issue
Block a user