Skip to content

Commit c8a06a0

Browse files
authored
feat(cargo-shuttle): re-enable resource dump command (#2090)
* feat(cargo-shuttle): re-enable resource dump command * url
1 parent d4ea7eb commit c8a06a0

File tree

2 files changed

+13
-15
lines changed

2 files changed

+13
-15
lines changed

api-client/src/lib.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ impl ShuttleApiClient {
173173
.await
174174
}
175175

176-
async fn _dump_service_resource(
176+
pub async fn dump_service_resource(
177177
&self,
178178
project: &str,
179179
resource_type: &ResourceType,
@@ -183,10 +183,7 @@ impl ShuttleApiClient {
183183

184184
let bytes = self
185185
.get(
186-
format!(
187-
"/projects/{project}/services/{project}/resources/{}/dump",
188-
r#type
189-
),
186+
format!("/projects/{project}/resources/{type}/dump"),
190187
Option::<()>::None,
191188
)
192189
.await?

cargo-shuttle/src/lib.rs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -153,10 +153,6 @@ impl Shuttle {
153153
}
154154

155155
pub async fn run(mut self, args: ShuttleArgs, provided_path_to_init: bool) -> Result<()> {
156-
if matches!(args.cmd, Command::Resource(ResourceCommand::Dump { .. })) {
157-
bail!("This command is not yet supported on the NEW platform (shuttle.dev).");
158-
}
159-
160156
self.output_mode = args.output_mode;
161157

162158
// Set up the API client for all commands that call the API
@@ -1208,12 +1204,17 @@ impl Shuttle {
12081204
Ok(())
12091205
}
12101206

1211-
async fn resource_dump(&self, _resource_type: &ResourceType) -> Result<()> {
1212-
unimplemented!();
1213-
// let client = self.client.as_ref().unwrap();
1214-
// let bytes = client...;
1215-
// std::io::stdout().write_all(&bytes).unwrap();
1216-
// Ok(())
1207+
async fn resource_dump(&self, resource_type: &ResourceType) -> Result<()> {
1208+
let client = self.client.as_ref().unwrap();
1209+
1210+
let bytes = client
1211+
.dump_service_resource(self.ctx.project_id(), resource_type)
1212+
.await?;
1213+
std::io::stdout()
1214+
.write_all(&bytes)
1215+
.context("writing output to stdout")?;
1216+
1217+
Ok(())
12171218
}
12181219

12191220
async fn list_certificates(&self, table_args: TableArgs) -> Result<()> {

0 commit comments

Comments
 (0)