diff --git a/src/adapters/ingresses/apig.rs b/src/adapters/ingresses/apig.rs index 754289c..ea5c4f2 100644 --- a/src/adapters/ingresses/apig.rs +++ b/src/adapters/ingresses/apig.rs @@ -163,6 +163,27 @@ impl AwsApiGateway { Ok(()) } + + async fn delete_canary(&self, api_name: &str, stage_name: &str) -> Result<()> { + let api = self.get_api_id_by_name(api_name).await?; + + // Updates the stage to delete any canary settings from the API Gateway + let patch_op = PatchOperation::builder() + .op(Op::Remove) + .path("/canarySettings") + .build(); + + self.apig_client + .update_stage() + .rest_api_id(api.id.unwrap_or_default()) + .stage_name(stage_name) + .patch_operations(patch_op) + .send() + .await + .into_diagnostic()?; + + Ok(()) + } } /// given a path to a file, load it as an array of bytes. @@ -200,4 +221,11 @@ impl Ingress for AwsApiGateway { Ok(()) } + + async fn rollback_canary(&mut self) -> Result<()> { + self.delete_canary(&self.gateway_name, &self.stage_name) + .await?; + + Ok(()) + } } diff --git a/src/adapters/ingresses/mod.rs b/src/adapters/ingresses/mod.rs index 653bd93..83bbf08 100644 --- a/src/adapters/ingresses/mod.rs +++ b/src/adapters/ingresses/mod.rs @@ -13,7 +13,7 @@ pub trait Ingress { async fn deploy(&mut self) -> Result<()>; // TODO: define the other methods on this type. - // async fn yank_canary(&mut self) -> Result<()>; + async fn rollback_canary(&mut self) -> Result<()>; // async fn promote_canary(&mut self) -> Result<()>; async fn set_canary_traffic(&mut self, percent: WholePercent) -> Result<()>; } @@ -29,6 +29,10 @@ impl Ingress for MockIngress { async fn set_canary_traffic(&mut self, _percent: WholePercent) -> Result<()> { todo!() } + + async fn rollback_canary(&mut self) -> Result<()> { + todo!() + } } impl From for BoxIngress {