Skip to content

Add Dashboard entity and Dashboards collection - #820

Open
dannyota wants to merge 1 commit into
splunk:developfrom
dannyota:feature/dashboard-entity
Open

Add Dashboard entity and Dashboards collection#820
dannyota wants to merge 1 commit into
splunk:developfrom
dannyota:feature/dashboard-entity

Conversation

@dannyota

Copy link
Copy Markdown

Description of PR

Adds a Dashboard entity and Dashboards collection to splunklib.client, wrapping the data/ui/views/ REST endpoint.

The SDK already provides entity classes for most Splunk resources (indexes, saved searches, inputs, apps, etc.), but dashboards are missing — users currently have to use raw service.get()/service.post() calls. This PR follows the same Entity/Collection pattern used by SavedSearch, Index, Application, and others.

Changes:

  • Dashboard(Entity) — with an export() method that returns the XML definition via eai:data
  • Dashboards(Collection) — with a create(name, xml) method that passes XML as eai:data
  • Service.dashboards property to access the collection
  • PATH_DASHBOARDS constant (data/ui/views/)

Usage:

for dash in service.dashboards:
    print(dash.name, dash.export()[:80])

service.dashboards.create("my_dashboard", "<dashboard><label>Test</label></dashboard>")

Testing the changes

Unit tests added in tests/unit/test_dashboard.py (7 tests):

  • Entity/Collection subclass checks
  • export() returns eai:data content (and empty string when missing)
  • create() passes XML as eai:data to the underlying Collection
  • create() raises TypeError when XML is omitted

Tested with Python 3.13, Splunk Enterprise 10.4.0. Passes ruff check, ruff format, and basedpyright.

Documentation

Docstrings follow the existing SDK conventions (:return:, :rtype:, :param:). The Service.dashboards property is documented consistently with Service.saved_searches, Service.indexes, etc.

Dependencies and other resources

No external dependencies. Follows the same Entity/Collection pattern as the existing SavedSearch, Index, Application, and Macro classes in client.py.

@Ickerday

Copy link
Copy Markdown
Collaborator

Hi, please take a look at this: https://github.com/splunk/splunk-sdk-python/blob/develop/CONTRIBUTING.md

@dannyota

Copy link
Copy Markdown
Author

Thanks for the pointer — here's where this PR stands against CONTRIBUTING.md:

  • 1. Individual Contributor Agreement — submitted via the contributions form on 2026-08-19.
  • 2. Fork the repositorydannyota/splunk-sdk-python, branch feature/dashboard-entity.
  • 3. Make changes to the develop branch, preferably with testssplunklib/client.py plus tests/unit/test_dashboard.py (107 added lines, no existing lines modified).
  • 4. Create a pull request against the develop branch — this PR targets develop.

Let me know if anything else is needed to move this forward.

@dannyota
dannyota force-pushed the feature/dashboard-entity branch from 59e9e59 to bacb577 Compare August 19, 2026 04:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants