Skip to content

Commit d946b78

Browse files
committed
fixed formatting errors using python black
1 parent 55a3bc6 commit d946b78

File tree

4 files changed

+41
-20
lines changed

4 files changed

+41
-20
lines changed

linode_api4/groups/monitor.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ def create_alert_definition(
268268
if entity_ids is not None:
269269
params["entity_ids"] = entity_ids
270270

271-
#API will handle check for service_type return error if missing
271+
# API will handle check for service_type return error if missing
272272
result = self.client.post(
273273
f"/monitor/services/{service_type}/alert-definitions", data=params
274274
)
@@ -279,4 +279,4 @@ def create_alert_definition(
279279
json=result,
280280
)
281281

282-
return AlertDefinition(self.client, result["id"],service_type, result)
282+
return AlertDefinition(self.client, result["id"], service_type, result)

linode_api4/objects/monitor.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ class MetricType(StrEnum):
6969
histogram = "histogram"
7070
summary = "summary"
7171

72+
7273
class CriteriaCondition(StrEnum):
7374
"""
7475
Enum for supported CriteriaCondition
@@ -220,6 +221,7 @@ class TriggerConditions(JSONObject):
220221
- polling_interval_seconds: how often metrics are sampled (seconds)
221222
- trigger_occurrences: how many consecutive evaluation periods must match to trigger
222223
"""
224+
223225
criteria_condition: CriteriaCondition = CriteriaCondition.all
224226
evaluation_period_seconds: int = 0
225227
polling_interval_seconds: int = 0
@@ -239,6 +241,7 @@ class DimensionFilter(JSONObject):
239241
"value": "primary"
240242
}
241243
"""
244+
242245
dimension_label: str = ""
243246
label: str = ""
244247
operator: str = ""
@@ -260,6 +263,7 @@ class Rule(JSONObject):
260263
"unit": "percent"
261264
}
262265
"""
266+
263267
aggregate_function: Union[AggregateFunction, str] = ""
264268
dimension_filters: Optional[List[DimensionFilter]] = None
265269
label: str = ""
@@ -275,6 +279,7 @@ class RuleCriteria(JSONObject):
275279
Container for a list of Rule objects, matching the JSON shape:
276280
"rule_criteria": { "rules": [ { ... }, ... ] }
277281
"""
282+
278283
rules: List[Rule] = field(default_factory=list)
279284

280285

@@ -295,11 +300,13 @@ class AlertChannelEnvelope(JSONObject):
295300
- type: str - Channel type (e.g. 'webhook', 'email', 'pagerduty').
296301
- url: str - Destination URL or address associated with the channel.
297302
"""
303+
298304
id: int = 0
299305
label: str = ""
300306
type: str = ""
301307
url: str = ""
302308

309+
303310
class AlertType(StrEnum):
304311
"""
305312
Enumeration of alert origin types used by alert definitions.
@@ -312,6 +319,7 @@ class AlertType(StrEnum):
312319
This enum can be used to compare or validate the `type` value when
313320
processing alert definitions.
314321
"""
322+
315323
system = "system"
316324
user = "user"
317325

@@ -354,6 +362,7 @@ class EmailChannelContent(JSONObject):
354362
"""
355363
Represents the content for an email alert channel.
356364
"""
365+
357366
email_addresses: List[str] = None
358367

359368

@@ -362,9 +371,11 @@ class ChannelContent(JSONObject):
362371
"""
363372
Represents the content block for an AlertChannel, which varies by channel type.
364373
"""
374+
365375
email: EmailChannelContent = None
366376
# Other channel types like 'webhook', 'slack' could be added here as Optional fields.
367-
377+
378+
368379
class AlertChannel(Base):
369380
"""
370381
Represents an alert channel used to deliver notifications when alerts

test/integration/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -678,4 +678,4 @@ def test_monitor_client(get_monitor_token_for_db_entities):
678678
ca_path=api_ca_file,
679679
)
680680

681-
return client, entity_ids
681+
return client, entity_ids

test/integration/models/monitor/test_monitor.py

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -132,12 +132,12 @@ def test_integration_create_get_update_delete_alert_definition(
132132
"operator": "eq",
133133
"value": "primary",
134134
}
135-
],
136-
"label": "Memory Usage",
137-
"metric": "memory_usage",
138-
"operator": "gt",
139-
"threshold": 90,
140-
"unit": "percent",
135+
],
136+
"label": "Memory Usage",
137+
"metric": "memory_usage",
138+
"operator": "gt",
139+
"threshold": 90,
140+
"unit": "percent",
141141
} # <-- Close the rule dictionary here
142142
]
143143
}
@@ -155,7 +155,9 @@ def test_integration_create_get_update_delete_alert_definition(
155155
# Pick an existing alert channel to attach to the definition; skip if none
156156
channels = list(client.monitor.alert_channels())
157157
if not channels:
158-
pytest.skip("No alert channels available on account for creating alert definitions")
158+
pytest.skip(
159+
"No alert channels available on account for creating alert definitions"
160+
)
159161

160162
created = None
161163
try:
@@ -177,23 +179,29 @@ def test_integration_create_get_update_delete_alert_definition(
177179
timeout = 120
178180
interval = 10
179181
start = time.time()
180-
while getattr(created, "status", None) == "in progress" and (time.time() - start) < timeout:
182+
while (
183+
getattr(created, "status", None) == "in progress"
184+
and (time.time() - start) < timeout
185+
):
181186
time.sleep(interval)
182187
try:
183-
created = client.load(AlertDefinition,created.id,service_type)
188+
created = client.load(AlertDefinition, created.id, service_type)
184189
except Exception:
185190
# transient errors while polling; continue until timeout
186191
pass
187192

188-
update_alert= client.load(AlertDefinition, created.id, service_type)
193+
update_alert = client.load(AlertDefinition, created.id, service_type)
189194
update_alert.label = f"{label}-updated"
190195
update_alert.save()
191196

192197
updated = client.load(AlertDefinition, update_alert.id, service_type)
193-
while getattr(updated, "status", None) == "in progress" and (time.time() - start) < timeout:
198+
while (
199+
getattr(updated, "status", None) == "in progress"
200+
and (time.time() - start) < timeout
201+
):
194202
time.sleep(interval)
195203
try:
196-
updated = client.load(AlertDefinition,updated.id,service_type)
204+
updated = client.load(AlertDefinition, updated.id, service_type)
197205
except Exception:
198206
# transient errors while polling; continue until timeout
199207
pass
@@ -204,21 +212,23 @@ def test_integration_create_get_update_delete_alert_definition(
204212
finally:
205213
if created:
206214
# Best-effort cleanup; allow transient errors.
207-
# max time alert should take to update
215+
# max time alert should take to update
208216
try:
209-
delete_alert = client.load(AlertDefinition, created.id, service_type)
217+
delete_alert = client.load(
218+
AlertDefinition, created.id, service_type
219+
)
210220
delete_alert.delete()
211221
except Exception:
212222
pass
213223

214224
# confirm it's gone (if API returns 404 or raises)
215225
try:
216-
client.load(AlertDefinition,created.id,service_type)
226+
client.load(AlertDefinition, created.id, service_type)
217227
# If no exception, fail explicitly
218228
assert False, "Alert definition still retrievable after delete"
219229
except ApiError:
220230
# Expected: alert definition is deleted and API returns 404 or similar error
221231
pass
222232
except Exception:
223233
# Any other exception is acceptable here, as the resource should be gone
224-
pass
234+
pass

0 commit comments

Comments
 (0)