Skip to content

Possible fix for #207? #235

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

Closed
wants to merge 6 commits into from
Closed
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
2 changes: 2 additions & 0 deletions splunklib/binding.py
Original file line number Diff line number Diff line change
Expand Up @@ -746,6 +746,8 @@ def post(self, path_segment, owner=None, app=None, sharing=None, headers=None, *
if headers is None:
headers = []

query = { key.replace('_dup__', ''): val for key, val in query.items() }

path = self.authority + self._abspath(path_segment, owner=owner, app=app, sharing=sharing)
logging.debug("POST request to %s (body: %s)", path, repr(query))
all_headers = headers + self.additional_headers + self._auth_headers
Expand Down
23 changes: 23 additions & 0 deletions splunklib/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1040,6 +1040,29 @@ def access(self):
``owner``, ``app``, and ``sharing``.
"""
return self.state.access

def access_update(self, **kwargs):
"""Updates the server with the ACL along arguments you specify.

:param kwargs: ACL specific arguments (optional).
:type kwargs: ``dict``

:return: The entity this method is called on.
:rtype: class:`Entity`

**Example**::

import splunklib.client as client
s = client.connect(...)
search = s.apps['search']
search.access_update(**{'owner': 'new_owner', 'perms.read': 'admin, power', perms.write: '*'})
"""
kwargs = {'_dup__' + key if key == 'owner' or key == 'app' or key == 'sharing' else key: val for key, val in kwargs.items()}
kwargs['_dup__owner'] = kwargs.get('_dup__owner', self.access.get('owner'))
kwargs['_dup__app'] = kwargs.get('_dup__app', self.access.get('app'))
kwargs['_dup__sharing'] = kwargs.get('_dup__sharing', self.access.get('sharing'))
self.service.post(self.path + 'acl', **kwargs)
return self

@property
def content(self):
Expand Down