Skip to content
Merged
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: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.35.3] - 2026-03-03
### Updated
- Dashboard methods to use centralized `chronicle_request` helper function for improved code consistency and maintainability

### Added
- Helper functions for formatting dashboard resources
- Pagination helper for `list_dashboards` method

## [0.35.2] - 2026-03-02
### Added
- `parse_statedump` parameter to `run_parser()` method for converting
Expand Down
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2951,9 +2951,13 @@ dashboard = chronicle.get_dashboard(
print(f"Dashboard Details: {dashboard}")
```

### List Dashboards with pagination
### List Dashboards
```python
# List dashboards (first page)
dashboards = chronicle.list_dashboards()
for dashboard in dashboards.get("nativeDashboards", []):
print(f"- {dashboard.get('displayName')}")

# List dashboards with pagination(first page)
dashboards = chronicle.list_dashboards(page_size=10)
for dashboard in dashboards.get("nativeDashboards", []):
print(f"- {dashboard.get('displayName')}")
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "hatchling.build"

[project]
name = "secops"
version = "0.35.2"
version = "0.35.3"
description = "Python SDK for wrapping the Google SecOps API for common use cases"
readme = "README.md"
requires-python = ">=3.10"
Expand Down
116 changes: 96 additions & 20 deletions src/secops/chronicle/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -4095,6 +4095,7 @@ def create_dashboard(
description: str | None = None,
filters: list[dict[str, Any]] | str | None = None,
charts: list[dict[str, Any]] | str | None = None,
api_version: APIVersion | None = APIVersion.V1ALPHA,
) -> dict[str, Any]:
"""Create a new native dashboard.

Expand All @@ -4106,6 +4107,7 @@ def create_dashboard(
(JSON or JSON string)
charts: List of charts to include in the dashboard
(JSON or JSON string)
api_version: Preferred API version to use. Defaults to V1ALPHA

Returns:
Dictionary containing the created dashboard details
Expand All @@ -4125,73 +4127,102 @@ def create_dashboard(
description=description,
filters=filters,
charts=charts,
api_version=api_version,
)

def import_dashboard(self, dashboard: dict[str, Any]) -> dict[str, Any]:
def import_dashboard(
self,
dashboard: dict[str, Any],
api_version: APIVersion | None = APIVersion.V1ALPHA,
) -> dict[str, Any]:
"""Create a new native dashboard.

Args:
dashboard: ImportNativeDashboardsInlineSource
api_version: Preferred API version to use. Defaults to V1ALPHA

Returns:
Dictionary containing the created dashboard details

Raises:
APIError: If the API request fails
"""
return _import_dashboard(
self, dashboard=dashboard, api_version=api_version
)

return _import_dashboard(self, dashboard=dashboard)

def export_dashboard(self, dashboard_names: list[str]) -> dict[str, Any]:
def export_dashboard(
self,
dashboard_names: list[str],
api_version: APIVersion | None = APIVersion.V1ALPHA,
) -> dict[str, Any]:
"""Export native dashboards.
It supports single dashboard export operation only.

Args:
dashboard_names: List of dashboard resource names to export.
api_version: Preferred API version to use. Defaults to V1ALPHA

Returns:
Dictionary containing the exported dashboards.

Raises:
APIError: If the API request fails
"""

return _export_dashboard(self, dashboard_names=dashboard_names)
return _export_dashboard(
self, dashboard_names=dashboard_names, api_version=api_version
)

def list_dashboards(
self,
page_size: int | None = None,
page_token: str | None = None,
api_version: APIVersion | None = APIVersion.V1ALPHA,
as_list: bool = False,
) -> dict[str, Any]:
"""List all available dashboards.
"""List all available dashboards in Basic View.

Args:
page_size: Maximum number of results to return
page_token: Token for pagination
api_version: Preferred API version to use. Defaults to V1ALPHA
as_list: Whether to return results as a list or dictionary

Returns:
Dictionary containing dashboard list and pagination info
If as_list is True: List of dashboards.
If as_list is False: Dictionary containing list of dashboards
and pagination info.

Raises:
APIError: If the API request fails
"""
return _list_dashboards(
self,
page_size=page_size,
page_token=page_token,
api_version=api_version,
as_list=as_list,
)

def get_dashboard(
self,
dashboard_id: str,
view: str | None = None,
api_version: APIVersion | None = APIVersion.V1ALPHA,
) -> dict[str, Any]:
"""Get information about a specific dashboard.

Args:
dashboard_id: ID of the dashboard to retrieve
view: Level of detail to include in the response
Defaults to BASIC
api_version: Preferred API version to use. Defaults to V1ALPHA

Returns:
Dictionary containing dashboard details

Raises:
APIError: If the API request fails
"""
if view:
try:
Expand All @@ -4203,6 +4234,7 @@ def get_dashboard(
self,
dashboard_id=dashboard_id,
view=view,
api_version=api_version,
)

def update_dashboard(
Expand All @@ -4212,6 +4244,7 @@ def update_dashboard(
description: str | None = None,
filters: list[dict[str, Any]] | str | None = None,
charts: list[dict[str, Any]] | str | None = None,
api_version: APIVersion | None = APIVersion.V1ALPHA,
) -> dict[str, Any]:
"""Update an existing dashboard.

Expand All @@ -4221,6 +4254,7 @@ def update_dashboard(
description: New description for the dashboard (optional)
filters: New filters for the dashboard (optional)
charts: New charts for the dashboard (optional)
api_version: Preferred API version to use. Defaults to V1ALPHA

Returns:
Dictionary containing the updated dashboard details
Expand All @@ -4232,15 +4266,29 @@ def update_dashboard(
description=description,
filters=filters,
charts=charts,
api_version=api_version,
)

def delete_dashboard(self, dashboard_id: str) -> dict[str, Any]:
def delete_dashboard(
self,
dashboard_id: str,
api_version: APIVersion | None = APIVersion.V1ALPHA,
) -> dict[str, Any]:
"""Delete an existing dashboard.

Args:
dashboard_id: ID of the dashboard to delete
api_version: Preferred API version to use. Defaults to V1ALPHA

Returns:
Empty dictionary if deletion is successful

Raises:
APIError: If the API request fails
"""
return _delete_dashboard(self, dashboard_id=dashboard_id)
return _delete_dashboard(
self, dashboard_id=dashboard_id, api_version=api_version
)

def add_chart(
self,
Expand All @@ -4254,6 +4302,7 @@ def add_chart(
description: str | None = None,
query: str | None = None,
interval: InputInterval | dict[str, Any] | str | None = None,
api_version: APIVersion | None = APIVersion.V1ALPHA,
**kwargs,
) -> dict[str, Any]:
"""Add a chart to an existing dashboard.
Expand All @@ -4272,6 +4321,7 @@ def add_chart(
description: Description for the chart
query: Query for the chart
interval: Query input interval for the chart
api_version: Preferred API version to use. Defaults to V1ALPHA
**kwargs: Additional keyword arguments
(Will be added to request payload)

Expand All @@ -4296,6 +4346,7 @@ def add_chart(
description=description,
query=query,
interval=interval,
api_version=api_version,
**kwargs,
)

Expand All @@ -4305,17 +4356,23 @@ def duplicate_dashboard(
display_name: str,
access_type: str,
description: str | None = None,
api_version: APIVersion | None = APIVersion.V1ALPHA,
) -> dict[str, Any]:
"""Duplicate an existing dashboard.

Args:
dashboard_id: Id of the dashboard to duplicate
display_name: Display name for the new dashboard
access_type: Access type for the new dashboard (PRIVATE or PUBLIC)
description: Description for the new dashboard
dashboard_id: ID of the dashboard to duplicate
display_name: New name for the duplicated dashboard
access_type: Access type for the duplicated dashboard
(DashboardAccessType.PRIVATE or DashboardAccessType.PUBLIC)
description: Description for the duplicated dashboard
api_version: Preferred API version to use. Defaults to V1ALPHA

Returns:
Dictionary containing the updated dashboard details
Dictionary containing the duplicated dashboard details

Raises:
APIError: If the API request fails
"""
try:
access_type = DashboardAccessType[access_type.upper()]
Expand All @@ -4328,18 +4385,21 @@ def duplicate_dashboard(
display_name=display_name,
access_type=access_type,
description=description,
api_version=api_version,
)

def remove_chart(
self,
dashboard_id: str,
chart_id: str,
api_version: APIVersion | None = APIVersion.V1ALPHA,
) -> dict[str, Any]:
"""Remove a chart from a dashboard.

Args:
dashboard_id: ID of the dashboard containing the chart
chart_id: ID of the chart to remove
api_version: Preferred API version to use. Defaults to V1ALPHA

Returns:
Dictionary containing the updated dashboard
Expand All @@ -4351,24 +4411,34 @@ def remove_chart(
self,
dashboard_id=dashboard_id,
chart_id=chart_id,
api_version=api_version,
)

def get_chart(self, chart_id: str) -> dict[str, Any]:
"""Get information about a specific chart.
def get_chart(
self,
chart_id: str,
api_version: APIVersion | None = APIVersion.V1ALPHA,
) -> dict[str, Any]:
"""Get detail for dashboard chart.

Args:
chart_id: ID of the chart to retrieve
chart_id: ID of the chart
api_version: Preferred API version to use. Defaults to V1ALPHA

Returns:
Dictionary containing chart details
Dict[str, Any]: Dictionary containing chart details

Raises:
APIError: If the API request fails
"""
return _get_chart(self, chart_id)
return _get_chart(self, chart_id, api_version)

def edit_chart(
self,
dashboard_id: str,
dashboard_chart: None | (dict[str, Any] | DashboardChart | str) = None,
dashboard_query: None | (dict[str, Any] | DashboardQuery | str) = None,
api_version: APIVersion | None = APIVersion.V1ALPHA,
) -> dict[str, Any]:
"""Edit an existing chart in a dashboard.

Expand All @@ -4391,15 +4461,21 @@ def edit_chart(
"input": {},
"etag":"123131231321321"
}
api_version: Preferred API version to use. Defaults to V1ALPHA

Returns:
Dictionary containing the updated dashboard with edited chart

Raises:
APIError: If the API request fails
"""

return _edit_chart(
self,
dashboard_id=dashboard_id,
dashboard_chart=dashboard_chart,
dashboard_query=dashboard_query,
api_version=api_version,
)

def execute_dashboard_query(
Expand Down
Loading
Loading