diff --git a/surveilclient/tests/v2_0/config/test_services.py b/surveilclient/tests/v2_0/config/test_services.py index 2b67502..d511177 100644 --- a/surveilclient/tests/v2_0/config/test_services.py +++ b/surveilclient/tests/v2_0/config/test_services.py @@ -88,3 +88,22 @@ class TestServices(clienttest.ClientTest): body, "body" ) + + @httpretty.activate + def test_get(self): + httpretty.register_uri( + httpretty.GET, + "http://localhost:5311/v2/config/hosts/host_name/" + + "services/service_description", + body="{}" + ) + + body = self.client.config.services.get( + host_name="host_name", + service_description="service_description" + ) + + self.assertEqual( + body, + {} + ) diff --git a/surveilclient/v2_0/config/services.py b/surveilclient/v2_0/config/services.py index caf408f..f2c34a4 100644 --- a/surveilclient/v2_0/config/services.py +++ b/surveilclient/v2_0/config/services.py @@ -57,3 +57,13 @@ class ServicesManager(surveil_manager.SurveilManager): body='' ) return body + + def get(self, host_name, service_description): + """Get a service.""" + resp, body = self.http_client.json_request( + '/config/hosts/' + host_name + + '/services/' + service_description, + 'GET', + body='' + ) + return body diff --git a/surveilclient/v2_0/shell.py b/surveilclient/v2_0/shell.py index 36fa540..1f34e19 100644 --- a/surveilclient/v2_0/shell.py +++ b/surveilclient/v2_0/shell.py @@ -1437,6 +1437,28 @@ def do_config_service_delete(sc, args): args.service_description) +@cliutils.arg("--host_name", help="Name of the host") +@cliutils.arg("--service_description", help="The service_description") +def do_config_service_show(sc, args): + """Show a config service.""" + service = sc.config.services.get(args.host_name, args.service_description) + if args.json: + print(utils.json_formatter(service)) + elif service: + # Specify the shown order and all the properties to display + service_properties = [ + 'service_description', + 'use', + 'host_name', + 'contacts', + 'register', + 'name', + 'passive_checks_enabled', + ] + + utils.print_item(service, service_properties) + + @cliutils.arg("--timeperiod_name", help="New name of the timeperiod") @cliutils.arg("--exclude") @cliutils.arg("--periods", nargs='+')