Add Dashboard entity and Dashboards collection#820
Open
dannyota wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description of PR
Adds a
Dashboardentity andDashboardscollection tosplunklib.client, wrapping thedata/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 bySavedSearch,Index,Application, and others.Changes:
Dashboard(Entity)— with anexport()method that returns the XML definition viaeai:dataDashboards(Collection)— with acreate(name, xml)method that passes XML aseai:dataService.dashboardsproperty to access the collectionPATH_DASHBOARDSconstant (data/ui/views/)Usage:
Testing the changes
Unit tests added in
tests/unit/test_dashboard.py(7 tests):export()returnseai:datacontent (and empty string when missing)create()passes XML aseai:datato the underlying Collectioncreate()raisesTypeErrorwhen XML is omittedTested with Python 3.13, Splunk Enterprise 10.4.0. Passes
ruff check,ruff format, andbasedpyright.Documentation
Docstrings follow the existing SDK conventions (
:return:,:rtype:,:param:). TheService.dashboardsproperty is documented consistently withService.saved_searches,Service.indexes, etc.Dependencies and other resources
No external dependencies. Follows the same Entity/Collection pattern as the existing
SavedSearch,Index,Application, andMacroclasses inclient.py.