From 833750b577f65adde6ab383ffdc54ab6b805b7b1 Mon Sep 17 00:00:00 2001 From: Patrick Michaud Date: Thu, 27 Oct 2016 13:53:17 -0700 Subject: [PATCH] Adding more deployment endpoint code to Service * Fixes the URL for PATH_DEPLOYMENT_SERVERCLASSES * Exposes deployment_apps, deployment_clients and server_classes in the Service class * Adding virtualenv related entries to .gitignore --- .gitignore | 8 ++++++- splunklib/client.py | 56 ++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 62 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index ebd4782f2..6750ab243 100644 --- a/.gitignore +++ b/.gitignore @@ -26,4 +26,10 @@ dist/ examples/searchcommands_app/package/default/commands.conf examples/searchcommands_app/package/bin/packages tests/searchcommands/apps/app_with_logging_configuration/*.log -*.observed \ No newline at end of file +*.observed + +# virtualenv files +/bin/ +/include/ +/lib/ +/local/ diff --git a/splunklib/client.py b/splunklib/client.py index b5dd96561..ca87bcb0a 100644 --- a/splunklib/client.py +++ b/splunklib/client.py @@ -84,10 +84,11 @@ PATH_CAPABILITIES = "authorization/capabilities/" PATH_CONF = "configs/conf-%s/" PATH_PROPERTIES = "properties/" +PATH_DEPLOYMENT_APPS = "deployment/server/applications" PATH_DEPLOYMENT_CLIENTS = "deployment/client/" PATH_DEPLOYMENT_TENANTS = "deployment/tenants/" PATH_DEPLOYMENT_SERVERS = "deployment/server/" -PATH_DEPLOYMENT_SERVERCLASSES = "deployment/serverclass/" +PATH_DEPLOYMENT_SERVERCLASSES = "deployment/server/serverclasses" PATH_EVENT_TYPES = "saved/eventtypes/" PATH_FIRED_ALERTS = "alerts/fired_alerts/" PATH_INDEXES = "data/indexes/" @@ -415,6 +416,22 @@ def capabilities(self): response = self.get(PATH_CAPABILITIES) return _load_atom(response, MATCH_ENTRY_CONTENT).capabilities + @property + def deployment_apps(self): + """Returns the collection of deployment apps on this Splunk instance. + + :return: A :class:`ReadOnlyCollection` of :class:`DeploymentApp` entities. + """ + return DeploymentApps(self) + + @property + def deployment_clients(self): + """Returns the collection of deployment clients on this Splunk instance. + + :return: A :class:`ReadOnlyCollection` of :class:`DeploymentClient` entities. + """ + return DeploymentClient(self) + @property def event_types(self): """Returns the collection of event types defined in this Splunk instance. @@ -500,6 +517,14 @@ def modular_input_kinds(self): else: raise IllegalOperationException("Modular inputs are not supported before Splunk version 5.") + @property + def server_classes(self): + """Returns the collection of server classes on this Splunk instance. + + :return: A :class:`ReadOnlyCollection` of :class:`ServerClass` entities. + """ + return ServerClasses(self) + @property def storage_passwords(self): """Returns the collection of the storage passwords on this Splunk instance. @@ -1883,6 +1908,25 @@ def count(self): """ return int(self.content.get('triggered_alert_count', 0)) +class DeploymentApp(Entity): + pass + + +class DeploymentApps(Collection): + """This class represents a collection of deployment apps.""" + def __init__(self, service): + Collection.__init__(self, service, PATH_DEPLOYMENT_APPS, item=ServerClass) + +class DeploymentClient(Entity): + pass + + +class DeploymentClient(Collection): + """This class represents a collection of deployment clients.""" + def __init__(self, service): + Collection.__init__(self, service, PATH_DEPLOYMENT_CLIENTS, item=ServerClass) + + class Indexes(Collection): """This class contains the collection of indexes in this Splunk instance. @@ -3302,6 +3346,16 @@ def update(self, **kwargs): return self +class ServerClass(Entity): + pass + + +class ServerClasses(Collection): + """This class represents a collection of server classes.""" + def __init__(self, service): + Collection.__init__(self, service, PATH_DEPLOYMENT_SERVERCLASSES, item=ServerClass) + + class User(Entity): """This class represents a Splunk user. """