From 85dd8a16ed237693f2269ae9ee5f3966b1e2121d Mon Sep 17 00:00:00 2001 From: MasterPtato Date: Mon, 4 Nov 2024 20:16:54 +0000 Subject: [PATCH] chore: remove api-admin artifacts --- packages/common/convert/src/impls/admin.rs | 164 ------------------ packages/common/convert/src/impls/mod.rs | 1 - .../api/admin/cluster/cluster-not-found.md | 9 - .../datacenter/datacenter-not-in-cluster.md | 9 - .../datacenter-not-found.md | 0 packages/services/cluster/src/types.rs | 4 +- scripts/openapi/gen_rust.sh | 1 - 7 files changed, 2 insertions(+), 186 deletions(-) delete mode 100644 packages/common/convert/src/impls/admin.rs delete mode 100644 packages/common/formatted-error/errors/api/admin/cluster/cluster-not-found.md delete mode 100644 packages/common/formatted-error/errors/api/admin/cluster/datacenter/datacenter-not-in-cluster.md rename packages/common/formatted-error/errors/{api/admin/cluster/datacenter => cluster}/datacenter-not-found.md (100%) diff --git a/packages/common/convert/src/impls/admin.rs b/packages/common/convert/src/impls/admin.rs deleted file mode 100644 index 95d05f1ef..000000000 --- a/packages/common/convert/src/impls/admin.rs +++ /dev/null @@ -1,164 +0,0 @@ -// NOTE: This file should be moved to cluster/types.rs but there is a circular dependency with region-get - -use rivet_api::models; -use rivet_operation::prelude::*; - -use crate::{ApiFrom, ApiInto, ApiTryFrom}; - -impl ApiFrom for cluster::types::PoolType { - fn api_from(value: models::AdminClustersPoolType) -> cluster::types::PoolType { - match value { - models::AdminClustersPoolType::Job => cluster::types::PoolType::Job, - models::AdminClustersPoolType::Gg => cluster::types::PoolType::Gg, - models::AdminClustersPoolType::Ats => cluster::types::PoolType::Ats, - models::AdminClustersPoolType::Pegboard => cluster::types::PoolType::Pegboard, - models::AdminClustersPoolType::PegboardIsolate => { - cluster::types::PoolType::PegboardIsolate - } - } - } -} - -impl ApiFrom for models::AdminClustersPoolType { - fn api_from(value: cluster::types::PoolType) -> models::AdminClustersPoolType { - match value { - cluster::types::PoolType::Job => models::AdminClustersPoolType::Job, - cluster::types::PoolType::Gg => models::AdminClustersPoolType::Gg, - cluster::types::PoolType::Ats => models::AdminClustersPoolType::Ats, - cluster::types::PoolType::Pegboard => models::AdminClustersPoolType::Pegboard, - cluster::types::PoolType::PegboardIsolate => { - models::AdminClustersPoolType::PegboardIsolate - } - } - } -} - -impl ApiFrom for cluster::types::Provider { - fn api_from(value: models::AdminClustersProvider) -> cluster::types::Provider { - match value { - models::AdminClustersProvider::Linode => cluster::types::Provider::Linode, - } - } -} - -impl ApiFrom for models::AdminClustersProvider { - fn api_from(value: cluster::types::Provider) -> models::AdminClustersProvider { - match value { - cluster::types::Provider::Linode => models::AdminClustersProvider::Linode, - } - } -} - -impl ApiFrom for cluster::types::BuildDeliveryMethod { - fn api_from( - value: models::AdminClustersBuildDeliveryMethod, - ) -> cluster::types::BuildDeliveryMethod { - match value { - models::AdminClustersBuildDeliveryMethod::TrafficServer => { - cluster::types::BuildDeliveryMethod::TrafficServer - } - models::AdminClustersBuildDeliveryMethod::S3Direct => { - cluster::types::BuildDeliveryMethod::S3Direct - } - } - } -} - -impl ApiFrom for models::AdminClustersBuildDeliveryMethod { - fn api_from( - value: cluster::types::BuildDeliveryMethod, - ) -> models::AdminClustersBuildDeliveryMethod { - match value { - cluster::types::BuildDeliveryMethod::TrafficServer => { - models::AdminClustersBuildDeliveryMethod::TrafficServer - } - cluster::types::BuildDeliveryMethod::S3Direct => { - models::AdminClustersBuildDeliveryMethod::S3Direct - } - } - } -} - -impl ApiTryFrom for models::AdminClustersCluster { - type Error = GlobalError; - - fn api_try_from(value: cluster::types::Cluster) -> GlobalResult { - Ok(models::AdminClustersCluster { - cluster_id: value.cluster_id, - name_id: value.name_id, - create_ts: value.create_ts, - owner_team_id: value.owner_team_id.map(Into::into), - }) - } -} - -impl ApiTryFrom for models::AdminClustersDatacenter { - type Error = GlobalError; - - fn api_try_from( - value: cluster::types::Datacenter, - ) -> GlobalResult { - Ok(models::AdminClustersDatacenter { - build_delivery_method: value.build_delivery_method.api_into(), - cluster_id: value.cluster_id, - datacenter_id: value.datacenter_id, - display_name: value.display_name, - name_id: value.name_id, - pools: value - .pools - .iter() - .map(|p| { - Ok(models::AdminClustersPool { - desired_count: p.desired_count.try_into()?, - drain_timeout_ms: p.drain_timeout.try_into()?, - hardware: p - .hardware - .iter() - .map(|h| models::AdminClustersHardware { - provider_hardware: h.provider_hardware.clone(), - }) - .collect::>(), - min_count: p.min_count.try_into()?, - max_count: p.max_count.try_into()?, - pool_type: p.pool_type.api_into(), - }) - }) - .collect::>>()?, - provider: value.provider.api_into(), - provider_datacenter_id: value.provider_datacenter_id, - prebakes_enabled: value.prebakes_enabled, - }) - } -} - -impl ApiFrom for cluster::types::PoolUpdate { - fn api_from(value: models::AdminClustersPoolUpdate) -> cluster::types::PoolUpdate { - cluster::types::PoolUpdate { - pool_type: value.pool_type.api_into(), - hardware: value - .hardware - .iter() - .map(|h| cluster::types::Hardware { - provider_hardware: h.provider_hardware.clone(), - }) - .collect(), - desired_count: value.desired_count.map(|c| c as u32), - min_count: value.min_count.map(|c| c as u32), - max_count: value.max_count.map(|c| c as u32), - drain_timeout: value.drain_timeout.map(|d| d as u64), - } - } -} - -impl ApiTryFrom for models::AdminClustersServer { - type Error = GlobalError; - - fn api_try_from(value: cluster::types::Server) -> GlobalResult { - Ok(models::AdminClustersServer { - server_id: value.server_id, - datacenter_id: value.datacenter_id, - pool_type: value.pool_type.api_into(), - public_ip: value.public_ip.map(|ip| ip.to_string()), - }) - } -} diff --git a/packages/common/convert/src/impls/mod.rs b/packages/common/convert/src/impls/mod.rs index f3a9ed673..b3690e6de 100644 --- a/packages/common/convert/src/impls/mod.rs +++ b/packages/common/convert/src/impls/mod.rs @@ -5,7 +5,6 @@ use rivet_operation::prelude::*; use crate::ApiFrom; -pub mod admin; pub mod api; pub mod cloud; pub mod group; diff --git a/packages/common/formatted-error/errors/api/admin/cluster/cluster-not-found.md b/packages/common/formatted-error/errors/api/admin/cluster/cluster-not-found.md deleted file mode 100644 index 1d2ba9312..000000000 --- a/packages/common/formatted-error/errors/api/admin/cluster/cluster-not-found.md +++ /dev/null @@ -1,9 +0,0 @@ ---- -name = "CLUSTER_NOT_FOUND" -description = "The requested cluster was not found." -http_status = 400 ---- - -# Cluster Not Found - -The requested cluster was not found. diff --git a/packages/common/formatted-error/errors/api/admin/cluster/datacenter/datacenter-not-in-cluster.md b/packages/common/formatted-error/errors/api/admin/cluster/datacenter/datacenter-not-in-cluster.md deleted file mode 100644 index 6627c1214..000000000 --- a/packages/common/formatted-error/errors/api/admin/cluster/datacenter/datacenter-not-in-cluster.md +++ /dev/null @@ -1,9 +0,0 @@ ---- -name = "CLUSTER_DATACENTER_NOT_IN_CLUSTER" -description = "The requested datacenter is not part of the requested cluster." -http_status = 400 ---- - -# Datacenter Not In Cluster - -The requested datacenter is not part of the requested cluster. diff --git a/packages/common/formatted-error/errors/api/admin/cluster/datacenter/datacenter-not-found.md b/packages/common/formatted-error/errors/cluster/datacenter-not-found.md similarity index 100% rename from packages/common/formatted-error/errors/api/admin/cluster/datacenter/datacenter-not-found.md rename to packages/common/formatted-error/errors/cluster/datacenter-not-found.md diff --git a/packages/services/cluster/src/types.rs b/packages/services/cluster/src/types.rs index ca46fa10a..7a897135c 100644 --- a/packages/services/cluster/src/types.rs +++ b/packages/services/cluster/src/types.rs @@ -8,7 +8,7 @@ use rivet_operation::prelude::proto::backend; use serde::{Deserialize, Serialize}; use strum::FromRepr; -#[derive(Debug, sqlx::FromRow)] +#[derive(Debug, Clone, sqlx::FromRow)] pub struct Cluster { pub cluster_id: Uuid, pub name_id: String, @@ -78,7 +78,7 @@ impl TryFrom for Pool { } } -#[derive(Serialize, Deserialize, Hash, Debug, Clone, Copy, PartialEq, Eq, FromRepr)] +#[derive(Serialize, Deserialize, Hash, Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, FromRepr)] pub enum PoolType { Job = 0, Gg = 1, diff --git a/scripts/openapi/gen_rust.sh b/scripts/openapi/gen_rust.sh index 8f790e333..432e0db7c 100755 --- a/scripts/openapi/gen_rust.sh +++ b/scripts/openapi/gen_rust.sh @@ -22,7 +22,6 @@ if [ "$FERN_GROUP" == "full" ]; then # Fix OpenAPI bug (https://github.com/OpenAPITools/openapi-generator/issues/14171) sed -i 's/CloudGamesLogStream/crate::models::CloudGamesLogStream/' "$GEN_PATH_RUST/src/apis/cloud_games_matchmaker_api.rs" sed -i 's/ActorLogStream/crate::models::ActorLogStream/' "$GEN_PATH_RUST/src/apis/actor_logs_api.rs" - sed -i 's/AdminClustersPoolType/crate::models::AdminClustersPoolType/' "$GEN_PATH_RUST/src/apis/admin_clusters_servers_api.rs" # Create variant specifically for the CLI cp -r $GEN_PATH_RUST $GEN_PATH_RUST_CLI