Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(bolt): add server filters & update admin api + cli #804

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 7 additions & 19 deletions fern/definition/admin/clusters/__package__.yml
Original file line number Diff line number Diff line change
@@ -1,45 +1,33 @@
# yaml-language-server: $schema=https://raw.githubusercontent.com/fern-api/fern/main/fern.schema.json

imports:
localCommons: ../common.yml
localCommons: ./common.yml

service:
auth: true
base-path: /admin/clusters
endpoints:
getServerIps:
path: /server_ips
method: GET
request:
name: GetServerIpsRequest
query-parameters:
server_id: optional<uuid>
pool: optional<localCommons.PoolType>
response: GetServerIpsResponse
list:
path: ""
method: GET
docs: Get clusters
response: ListResponse
response: ListClustersResponse
create:
path: ""
method: POST
docs: Create a new cluster
request:
body: CreateRequest
response: CreateResponse
body: CreateClusterRequest
response: CreateClusterResponse

types:
GetServerIpsResponse:
properties:
ips: list<string>
ListResponse:
ListClustersResponse:
properties:
clusters: list<localCommons.Cluster>
CreateRequest:
CreateClusterRequest:
properties:
name_id: string
owner_team_id: optional<uuid>
CreateResponse:
CreateClusterResponse:
properties:
cluster_id: uuid
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# yaml-language-server: $schema=https://raw.githubusercontent.com/fern-api/fern/main/fern.schema.json

types:
PoolType:
enum:
Expand Down Expand Up @@ -39,3 +40,8 @@ types:
provider_api_token: optional<string>
pools: list<Pool>
build_delivery_method: BuildDeliveryMethod
Server:
properties:
server_id: uuid
public_ip: string

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# yaml-language-server: $schema=https://raw.githubusercontent.com/fern-api/fern/main/fern.schema.json

imports:
localCommons: ../../common.yml
localCommons: ./common.yml

service:
auth: true
Expand All @@ -14,46 +14,41 @@ service:
path: ""
method: GET
docs: Get datacenters of a cluster
response: ListResponse
response: ListDatacentersResponse
create:
path: ""
method: POST
request:
body: CreateRequest
response: CreateResponse
body: CreateDatacenterRequest
response: CreateDatacenterResponse
update:
path: /{datacenter_id}
path-parameters:
datacenter_id:
type: uuid
method: PATCH
request:
body: UpdateRequest
taint:
path: /{datacenter_id}/taint
path-parameters:
datacenter_id:
type: string
method: GET
body: UpdateDatacenterRequest

types:
ListResponse:
ListDatacentersResponse:
properties:
datacenters: list<localCommons.Datacenter>
CreateRequest:
CreateDatacenterRequest:
properties:
display_name: string
name_id: string
provider: localCommons.Provider
provider_datacenter_id: string
build_delivery_method: localCommons.BuildDeliveryMethod
CreateResponse:
CreateDatacenterResponse:
properties:
datacenter_id: uuid
UpdateRequest:
UpdateDatacenterRequest:
properties:
pool_type: localCommons.PoolType
hardware: list<localCommons.Hardware>
desired_count: optional<integer>
max_count: optional<integer>
drain_timeout: optional<long>

39 changes: 39 additions & 0 deletions fern/definition/admin/clusters/servers.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# yaml-language-server: $schema=https://raw.githubusercontent.com/fern-api/fern/main/fern.schema.json

imports:
localCommons: ./common.yml

service:
auth: true
base-path: /admin/clusters/{cluster_id}/servers
path-parameters:
cluster_id:
type: uuid
endpoints:
list:
path: ""
method: GET
request:
name: ListServersRequest
query-parameters:
server_id: optional<string>
datacenter: optional<string>
pool: optional<localCommons.PoolType>
public_ip: optional<string>
response: ListServersResponse
taint:
path: /taint
method: POST
request:
name: TaintServersRequest
query-parameters:
server_id: optional<string>
datacenter: optional<string>
pool: optional<localCommons.PoolType>
public_ip: optional<string>

types:
ListServersResponse:
properties:
servers: list<localCommons.Server>

71 changes: 14 additions & 57 deletions lib/bolt/cli/src/commands/cluster/datacenter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ pub enum DatacenterProvider {
Linode,
}

impl From<DatacenterProvider> for models::AdminProvider {
impl From<DatacenterProvider> for models::AdminClustersProvider {
fn from(provider: DatacenterProvider) -> Self {
match provider {
DatacenterProvider::Linode => models::AdminProvider::Linode,
DatacenterProvider::Linode => models::AdminClustersProvider::Linode,
}
}
}
Expand All @@ -24,13 +24,15 @@ pub enum DatacenterBuildDeliveryMethod {
S3Direct,
}

impl From<DatacenterBuildDeliveryMethod> for models::AdminBuildDeliveryMethod {
impl From<DatacenterBuildDeliveryMethod> for models::AdminClustersBuildDeliveryMethod {
fn from(method: DatacenterBuildDeliveryMethod) -> Self {
match method {
DatacenterBuildDeliveryMethod::TrafficServer => {
models::AdminBuildDeliveryMethod::TrafficServer
models::AdminClustersBuildDeliveryMethod::TrafficServer
}
DatacenterBuildDeliveryMethod::S3Direct => {
models::AdminClustersBuildDeliveryMethod::S3Direct
}
DatacenterBuildDeliveryMethod::S3Direct => models::AdminBuildDeliveryMethod::S3Direct,
}
}
}
Expand All @@ -42,12 +44,12 @@ pub enum DatacenterPoolType {
Ats,
}

impl From<DatacenterPoolType> for models::AdminPoolType {
impl From<DatacenterPoolType> for models::AdminClustersPoolType {
fn from(pool_type: DatacenterPoolType) -> Self {
match pool_type {
DatacenterPoolType::Job => models::AdminPoolType::Job,
DatacenterPoolType::Gg => models::AdminPoolType::Gg,
DatacenterPoolType::Ats => models::AdminPoolType::Ats,
DatacenterPoolType::Job => models::AdminClustersPoolType::Job,
DatacenterPoolType::Gg => models::AdminClustersPoolType::Gg,
DatacenterPoolType::Ats => models::AdminClustersPoolType::Ats,
}
}
}
Expand Down Expand Up @@ -81,15 +83,6 @@ pub enum SubCommand {
#[clap(long, short = 'c')]
cluster: String,
},
/// Taint a datacenter
Taint {
/// The name id of the cluster
#[clap(long, short = 'c')]
cluster: String,
/// The name id of the datacenter
#[clap(long, short = 'd')]
name_id: String,
},
/// Update a datacenter's pools
Update {
/// The name id of the cluster
Expand Down Expand Up @@ -153,7 +146,7 @@ impl SubCommand {
admin_clusters_datacenters_api::admin_clusters_datacenters_create(
&ctx.openapi_config_cloud().await?,
&cluster.cluster_id.to_string(),
models::AdminClustersDatacentersCreateRequest {
models::AdminClustersCreateDatacenterRequest {
name_id,
display_name,
provider: provider.into(),
Expand Down Expand Up @@ -193,42 +186,6 @@ impl SubCommand {
datacenter_id: d.datacenter_id,
}));
}
Self::Taint {
cluster: cluster_name_id,
name_id,
} => {
let clusters =
admin_clusters_api::admin_clusters_list(&ctx.openapi_config_cloud().await?)
.await?
.clusters;
let cluster = clusters.iter().find(|c| c.name_id == cluster_name_id);

let cluster = match cluster {
Some(c) => c,
None => bail!("cluster with the name id {} not found", cluster_name_id),
};

let datacenters = admin_clusters_datacenters_api::admin_clusters_datacenters_list(
&ctx.openapi_config_cloud().await?,
&cluster.cluster_id.to_string(),
)
.await?
.datacenters;

let datacenter = datacenters.iter().find(|d| d.name_id == name_id);

let datacenter = match datacenter {
Some(d) => d,
None => bail!("datacenter with the name id {} not found", name_id),
};

admin_clusters_datacenters_api::admin_clusters_datacenters_taint(
&ctx.openapi_config_cloud().await?,
&cluster.cluster_id.to_string(),
&datacenter.datacenter_id.to_string(),
)
.await?;
}
Self::Update {
cluster: cluster_name_id,
name_id,
Expand Down Expand Up @@ -268,12 +225,12 @@ impl SubCommand {
&ctx.openapi_config_cloud().await?,
&cluster.cluster_id.to_string(),
&datacenter.datacenter_id.to_string(),
models::AdminClustersDatacentersUpdateRequest {
models::AdminClustersUpdateDatacenterRequest {
desired_count,
drain_timeout,
hardware: hardware
.iter()
.map(|hardware| models::AdminHardware {
.map(|hardware| models::AdminClustersHardware {
provider_hardware: hardware.clone(),
})
.collect(),
Expand Down
Loading
Loading