Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding more deployment endpoint code to Service #158

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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
*.observed

# virtualenv files
/bin/
/include/
/lib/
/local/
56 changes: 55 additions & 1 deletion splunklib/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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/"
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you meant item= DeploymentApp


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)
Copy link
Contributor

@fantavlik fantavlik Jan 19, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You'll want to change the name of the collection to DeploymentClients (plural) and this line to item=DeploymentClient




class Indexes(Collection):
"""This class contains the collection of indexes in this Splunk instance.
Expand Down Expand Up @@ -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.
"""
Expand Down