Skip to content

Commit 0336dbb

Browse files
committed
chore: lint fix and formatting.
1 parent 3be2936 commit 0336dbb

4 files changed

Lines changed: 36 additions & 15 deletions

File tree

src/secops/chronicle/client.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4186,7 +4186,8 @@ def list_dashboards(
41864186
41874187
Returns:
41884188
If as_list is True: List of dashboards.
4189-
If as_list is False: Dictionary containing list of dashboards and pagination info.
4189+
If as_list is False: Dictionary containing list of dashboards
4190+
and pagination info.
41904191
41914192
Raises:
41924193
APIError: If the API request fails
@@ -4360,7 +4361,7 @@ def duplicate_dashboard(
43604361
dashboard_id: ID of the dashboard to duplicate
43614362
display_name: New name for the duplicated dashboard
43624363
access_type: Access type for the duplicated dashboard
4363-
(DashboardAccessType.PRIVATE or DashboardAccessType.PUBLIC)
4364+
(DashboardAccessType.PRIVATE or DashboardAccessType.PUBLIC)
43644365
description: Description for the duplicated dashboard
43654366
api_version: Preferred API version to use. Defaults to V1ALPHA
43664367
@@ -4407,7 +4408,7 @@ def remove_chart(
44074408
self,
44084409
dashboard_id=dashboard_id,
44094410
chart_id=chart_id,
4410-
api_version=api_version
4411+
api_version=api_version,
44114412
)
44124413

44134414
def get_chart(

src/secops/chronicle/dashboard.py

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,8 @@ def import_dashboard(
153153
"""
154154
if not any(key in dashboard for key in _VALID_DASHBOARD_KEYS):
155155
raise SecOpsError(
156-
f'Dashboard must contain at least one of: {", ".join(_VALID_DASHBOARD_KEYS)}'
156+
"Dashboard must contain at least one "
157+
f'of: {", ".join(_VALID_DASHBOARD_KEYS)}'
157158
)
158159

159160
payload = {"source": {"dashboards": [dashboard]}}
@@ -224,7 +225,8 @@ def list_dashboards(
224225
225226
Returns:
226227
If as_list is True: List of dashboards.
227-
If as_list is False: Dictionary containing list of dashboards and pagination info.
228+
If as_list is False: Dictionary containing list of dashboards
229+
and pagination info.
228230
229231
Raises:
230232
APIError: If the API request fails
@@ -275,6 +277,7 @@ def get_dashboard(
275277
error_message=f"Failed to get dashboard with ID {dashboard_id}",
276278
)
277279

280+
278281
def update_dashboard(
279282
client: "ChronicleClient",
280283
dashboard_id: str,
@@ -300,7 +303,8 @@ def update_dashboard(
300303
301304
Raises:
302305
ValueError: If no fields are provided to update
303-
APIError: If filters or charts JSON is invalid, or if the API request fails
306+
APIError: If filters or charts JSON is invalid,
307+
or if the API request fails
304308
"""
305309
dashboard_id = format_resource_id(dashboard_id)
306310

@@ -524,7 +528,9 @@ def add_chart(
524528
endpoint_path=f"nativeDashboards/{dashboard_id}:addChart",
525529
api_version=api_version,
526530
json=payload,
527-
error_message=f"Failed to add chart to dashboard with ID {dashboard_id}",
531+
error_message=(
532+
f"Failed to add chart to dashboard with ID {dashboard_id}"
533+
),
528534
)
529535

530536

@@ -585,7 +591,10 @@ def remove_chart(
585591
endpoint_path=f"nativeDashboards/{dashboard_id}:removeChart",
586592
api_version=api_version,
587593
json={"dashboardChart": chart_id},
588-
error_message=f"Failed to remove chart with ID {chart_id} from dashboard with ID {dashboard_id}",
594+
error_message=(
595+
f"Failed to remove chart with ID {chart_id} "
596+
f"from dashboard with ID {dashboard_id}"
597+
),
589598
)
590599

591600

@@ -674,5 +683,7 @@ def edit_chart(
674683
endpoint_path=f"nativeDashboards/{dashboard_id}:editChart",
675684
api_version=api_version,
676685
json=payload,
677-
error_message=f"Failed to edit chart in dashboard with ID {dashboard_id}",
686+
error_message=(
687+
f"Failed to edit chart in dashboard with ID {dashboard_id}"
688+
),
678689
)

src/secops/chronicle/utils/format_utils.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ def format_resource_id(resource_id: str) -> str:
3333
resource_id: The full resource string or just the ID.
3434
3535
Returns:
36-
The extracted ID from the resource string, or the original string if it doesn't match the expected format.
36+
The extracted ID from the resource string,
37+
or the original string if it doesn't match the expected format.
3738
"""
3839
if resource_id.startswith("projects/"):
3940
return resource_id.split("/")[-1]
@@ -46,11 +47,13 @@ def parse_json_list(
4647
"""Parse a JSON string into a list, or return the list as-is.
4748
4849
Args:
49-
value: A list of dictionaries or a JSON string representing a list of dictionaries.
50+
value: A list of dictionaries or
51+
a JSON string representing a list of dictionaries.
5052
field_name: The name of the field being parsed, used for error messages.
5153
5254
Returns:
53-
A list of dictionaries parsed from the JSON string, or the original list if it was already a list.
55+
A list of dictionaries parsed from the JSON string,
56+
or the original list if it was already a list.
5457
5558
Raises:
5659
APIError: If the input is a string but cannot be parsed as valid JSON.

tests/chronicle/utils/test_format_utils.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@
1717

1818
import pytest
1919

20-
from secops.chronicle.utils.format_utils import format_resource_id, parse_json_list
20+
from secops.chronicle.utils.format_utils import (
21+
format_resource_id,
22+
parse_json_list,
23+
)
2124
from secops.exceptions import APIError
2225

2326

@@ -39,7 +42,10 @@ def test_format_resource_id_handles_minimal_projects_prefix() -> None:
3942

4043
def test_format_resource_id_does_not_alter_non_projects_paths() -> None:
4144
# Paths that don't start with "projects/" should be returned as-is
42-
assert format_resource_id("instances/my-instance/dashboards/abc") == "instances/my-instance/dashboards/abc"
45+
assert (
46+
format_resource_id("instances/my-instance/dashboards/abc")
47+
== "instances/my-instance/dashboards/abc"
48+
)
4349

4450

4551
def test_format_resource_id_empty_string_returns_empty_string() -> None:
@@ -91,4 +97,4 @@ def test_parse_json_list_handles_empty_json_array() -> None:
9197

9298
def test_parse_json_list_handles_empty_list_input() -> None:
9399
result = parse_json_list([], "filters")
94-
assert result == []
100+
assert result == []

0 commit comments

Comments
 (0)