diff --git a/CHANGELOG.md b/CHANGELOG.md index 90f9dbf..ec2d46d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] - Added support for SSM Parameter CRUD operations. + - start, stop, restart for service with `--wait` ## [0.2.41] - 2024-12-06 diff --git a/src/duplo_resource/service.py b/src/duplo_resource/service.py index 35c2a40..c8a6880 100644 --- a/src/duplo_resource/service.py +++ b/src/duplo_resource/service.py @@ -405,7 +405,8 @@ def bulk_update_image(self, @Command() def restart(self, - name: args.NAME) -> dict: + name: args.NAME, + wait: args.WAIT = False) -> dict: """Restart a service. Restart a service. @@ -417,6 +418,7 @@ def restart(self, Args: name: The name of the service to restart. + wait: Boolean flag to wait for service updates. Returns: A success message if the service was restarted successfully. @@ -425,11 +427,15 @@ def restart(self, DuploError: If the service could not be restarted. """ self.duplo.post(self.endpoint(f"ReplicationControllerReboot/{name}")) + if wait: + service = self.find(name) + self.wait(service, service) return {"message": f"Successfully restarted service '{name}'"} @Command() def stop(self, - name: args.NAME) -> dict: + name: args.NAME, + wait: args.WAIT = False) -> dict: """Stop a service. Stop a service. @@ -440,7 +446,8 @@ def stop(self, ``` Args: - name (str): The name of the service to stop. + name (str): The name of the service to stop. + wait: Boolean flag to wait for service updates. Returns: A success message if the service was stopped successfully. @@ -449,11 +456,15 @@ def stop(self, DuploError: If the service could not be stopped. """ self.duplo.post(self.endpoint(f"ReplicationControllerStop/{name}")) + if wait: + service = self.find(name) + self.wait(service, service) return {"message": f"Successfully stopped service '{name}'"} @Command() def start(self, - name: args.NAME) -> dict: + name: args.NAME, + wait: args.WAIT = False) -> dict: """Start a service. Start a service. @@ -465,6 +476,7 @@ def start(self, Args: name (str): The name of the service to start. + wait: Boolean flag to wait for service updates. Returns: A success message if the service was started successfully. @@ -473,6 +485,9 @@ def start(self, DuploError: If the service could not be started. """ self.duplo.post(self.endpoint(f"ReplicationControllerstart/{name}")) + if wait: + service = self.find(name) + self.wait(service, service) return {"message": f"Successfully started service '{name}'"} @Command()