From 66dab30f12abc79d9d4592c3906a962d0a71e30e Mon Sep 17 00:00:00 2001 From: Connor Doyle Date: Mon, 26 Jan 2015 16:43:34 -0800 Subject: [PATCH] Missing params to doc strings, marathon remove --force. --- dcos/api/marathon.py | 13 +++++++++++-- dcos/cli/marathon/main.py | 14 ++++++++++---- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/dcos/api/marathon.py b/dcos/api/marathon.py index 406e16b..30871c6 100644 --- a/dcos/api/marathon.py +++ b/dcos/api/marathon.py @@ -160,17 +160,26 @@ class Client(object): return self.scale_app(app_id, 0, force) - def remove_app(self, app_id): + def remove_app(self, app_id, force=None): """Completely removes the requested application. :param app_id: The ID of the application to suspend. :type app_id: str + :param force: Whether to override running deployments. + :type force: bool :returns: Status of trying to remove the application. :rtype: (bool, Error) """ + if force is None: + force = False + app_id = self._sanitize_app_id(app_id) - url = self._create_url('v2/apps' + app_id + '?force=true') + params = None + if force: + params = {'force': True} + + url = self._create_url('v2/apps{}'.format(app_id), params) response = requests.delete(url) if response.status_code == 200: diff --git a/dcos/cli/marathon/main.py b/dcos/cli/marathon/main.py index 4e919fd..e673fcd 100644 --- a/dcos/cli/marathon/main.py +++ b/dcos/cli/marathon/main.py @@ -6,7 +6,7 @@ Usage: dcos marathon start dcos marathon scale [--force] dcos marathon suspend [--force] - dcos marathon remove + dcos marathon remove [--force] dcos marathon --help dcos marathon --version @@ -50,7 +50,7 @@ def main(): return _suspend(args[''], args['--force'], toml_config) elif args['marathon'] and args['remove']: toml_config = config.Toml.load_from_path(config_path) - return _remove(args[''], toml_config) + return _remove(args[''], args['--force'], toml_config) else: print(options.make_generic_usage_error(__doc__)) return 1 @@ -154,6 +154,8 @@ def _scale(app_id, instances, force, config): :type app_id: str :param instances: The requested number of instances. :type instances: int + :param force: Whether to override running deployments. + :type force: bool :param config: Configuration dictionary :type config: config.Toml :returns: Process status @@ -176,6 +178,8 @@ def _suspend(app_id, force, config): :param app_id: ID of the app to suspend :type app_id: str + :param force: Whether to override running deployments. + :type force: bool :param config: Configuration dictionary :type config: config.Toml :returns: Process status @@ -193,11 +197,13 @@ def _suspend(app_id, force, config): return 0 -def _remove(app_id, config): +def _remove(app_id, force, config): """Remove a Marathon application. :param app_id: ID of the app to remove :type app_id: str + :param force: Whether to override running deployments. + :type force: bool :param config: Configuration dictionary :type config: config.Toml :returns: Process status @@ -205,7 +211,7 @@ def _remove(app_id, config): """ client = _create_client(config) - success, err = client.remove_app(app_id) + success, err = client.remove_app(app_id, force) if err is not None: print(err.error()) return 1