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

feat(c-s beta): implement resource delete #1745

Merged
merged 5 commits into from
Apr 19, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
feat: enable beta client resource deletion
  • Loading branch information
oddgrd committed Apr 19, 2024
commit 14583b525556b96a57273683f1bf879075015812
25 changes: 17 additions & 8 deletions cargo-shuttle/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,11 @@ impl ShuttleApiClient {
}

pub async fn get_service_resources(&self, project: &str) -> Result<Vec<resource::Response>> {
let path = format!("/projects/{project}/services/{project}/resources");
let path = if self.beta {
format!("/projects/{project}/resources")
} else {
format!("/projects/{project}/services/{project}/resources")
};

self.get(path).await
}
Expand All @@ -152,13 +156,18 @@ impl ShuttleApiClient {
project: &str,
resource_type: &resource::Type,
) -> Result<()> {
let path = format!(
"/projects/{project}/services/{project}/resources/{}",
utf8_percent_encode(
&resource_type.to_string(),
percent_encoding::NON_ALPHANUMERIC
),
);
let r#type = resource_type.to_string();

let r#type = utf8_percent_encode(&r#type, percent_encoding::NON_ALPHANUMERIC).to_owned();

let path = if self.beta {
format!("/projects/{project}/resources/{}", r#type)
} else {
format!(
"/projects/{project}/services/{project}/resources/{}",
r#type
)
};

self.delete(path).await
}
Expand Down
8 changes: 1 addition & 7 deletions cargo-shuttle/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,13 +130,7 @@ impl Shuttle {
) {
unimplemented!("This command is deprecated on the beta platform");
}
if matches!(
args.cmd,
Command::Resource(..)
| Command::Stop
| Command::Clean
| Command::Status
) {
if matches!(args.cmd, Command::Stop | Command::Clean | Command::Status) {
unimplemented!("This command is not yet implemented on the beta platform");
}
eprintln!("INFO: Using beta platform API");
Expand Down