Skip to content

Commit

Permalink
Merge branch 'main' into bump-account_sdk
Browse files Browse the repository at this point in the history
  • Loading branch information
kariy authored Aug 20, 2024
2 parents a95f01e + 4bd1e85 commit c47b4c7
Show file tree
Hide file tree
Showing 8 changed files with 250 additions and 92 deletions.
2 changes: 2 additions & 0 deletions .graphqlrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
schema: slot/schema.json
documents: slot/src/graphql/**/*.graphql
14 changes: 12 additions & 2 deletions cli/src/command/deployments/create.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use slot::credential::Credentials;
use slot::graphql::deployments::create_deployment::CreateDeploymentCreateDeployment::{
KatanaConfig, MadaraConfig, ToriiConfig,
};
use slot::graphql::deployments::create_deployment::{self, *};
use slot::graphql::deployments::create_deployment::*;
use slot::graphql::deployments::CreateDeployment;
use slot::graphql::{GraphQLQuery, Response};

Expand All @@ -18,11 +18,18 @@ use super::{services::CreateServiceCommands, Tier};
pub struct CreateArgs {
#[arg(help = "The name of the project.")]
pub project: String,

#[arg(short, long, default_value = "basic")]
#[arg(value_name = "tier")]
#[arg(help = "Deployment tier.")]
pub tier: Tier,

#[arg(short, long)]
#[arg(help = "The list of regions to deploy to.")]
#[arg(value_name = "regions")]
#[arg(value_delimiter = ',')]
pub regions: Option<Vec<String>>,

#[command(subcommand)]
create_commands: CreateServiceCommands,
}
Expand Down Expand Up @@ -88,19 +95,22 @@ impl CreateArgs {

let tier = match &self.tier {
Tier::Basic => DeploymentTier::basic,
Tier::Rare => DeploymentTier::rare,
Tier::Epic => DeploymentTier::epic,
};

let request_body = CreateDeployment::build_query(Variables {
project: self.project.clone(),
tier,
service,
wait: Some(true),
regions: self.regions.clone(),
});

let user = Credentials::load()?;
let client = Client::new_with_token(user.access_token);

let res: Response<create_deployment::ResponseData> = client.query(&request_body).await?;
let res: Response<ResponseData> = client.query(&request_body).await?;
if let Some(errors) = res.errors.clone() {
for err in errors {
println!("Error: {}", err.message);
Expand Down
2 changes: 2 additions & 0 deletions cli/src/command/deployments/fork.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ impl ForkArgs {

let tier = match &self.tier {
Tier::Basic => DeploymentTier::basic,
Tier::Rare => DeploymentTier::rare,
Tier::Epic => DeploymentTier::epic,
};

let request_body = ForkDeployment::build_query(Variables {
Expand Down
2 changes: 2 additions & 0 deletions cli/src/command/deployments/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,6 @@ impl Deployments {
#[derive(clap::ValueEnum, Clone, Debug, serde::Serialize)]
pub enum Tier {
Basic,
Rare,
Epic,
}
11 changes: 4 additions & 7 deletions cli/src/command/deployments/update.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#![allow(clippy::enum_variant_names)]

use super::services::UpdateServiceCommands;
use crate::command::deployments::Tier;
use anyhow::Result;
use clap::Args;
use slot::api::Client;
Expand All @@ -13,13 +15,6 @@ use slot::graphql::deployments::update_deployment::{
use slot::graphql::deployments::{update_deployment::*, UpdateDeployment};
use slot::graphql::{GraphQLQuery, Response};

use super::services::UpdateServiceCommands;

#[derive(clap::ValueEnum, Clone, Debug, serde::Serialize)]
pub enum Tier {
Basic,
}

#[derive(Debug, Args)]
#[command(next_help_heading = "Update options")]
pub struct UpdateArgs {
Expand Down Expand Up @@ -59,6 +54,8 @@ impl UpdateArgs {

let tier = match &self.tier {
Tier::Basic => DeploymentTier::basic,
Tier::Rare => DeploymentTier::rare,
Tier::Epic => DeploymentTier::epic,
};

let request_body = UpdateDeployment::build_query(Variables {
Expand Down
5 changes: 4 additions & 1 deletion scripts/pull_schema.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#!/bin/bash

graphql-client introspect-schema --output schema.json https://api.cartridge.gg/query
# https://github.com/graphql-rust/graphql-client/blob/main/graphql_client_cli/README.md
# cargo install graphql_client_cli

graphql-client introspect-schema --output slot/schema.json https://api.cartridge.gg/query
Loading

0 comments on commit c47b4c7

Please sign in to comment.