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.

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.

1 participant