Skip to content

Commit faf6b22

Browse files
Merge pull request #714 from linode/dev
v5.46.0
2 parents 76d6341 + 6f4c991 commit faf6b22

32 files changed

Lines changed: 557 additions & 87 deletions

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ jobs:
4242
GITHUB_TOKEN: ${{ github.token }}
4343

4444
- name: checkout repo
45-
uses: actions/checkout@v6
45+
uses: actions/checkout@v7
4646

4747
- name: setup python 3
4848
uses: actions/setup-python@v6
@@ -61,7 +61,7 @@ jobs:
6161
matrix:
6262
python-version: ['3.10', '3.11', '3.12', '3.13', '3.14']
6363
steps:
64-
- uses: actions/checkout@v6
64+
- uses: actions/checkout@v7
6565
- uses: actions/setup-python@v6
6666
with:
6767
python-version: ${{ matrix.python-version }}

.github/workflows/codeql.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
build-mode: none
2424
steps:
2525
- name: Checkout repository
26-
uses: actions/checkout@v6
26+
uses: actions/checkout@v7
2727

2828
- name: Initialize CodeQL
2929
uses: github/codeql-action/init@v4

.github/workflows/dependency-review.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
runs-on: ubuntu-latest
1212
steps:
1313
- name: 'Checkout repository'
14-
uses: actions/checkout@v6
14+
uses: actions/checkout@v7
1515
- name: 'Dependency Review'
1616
uses: actions/dependency-review-action@v5
1717
with:

.github/workflows/e2e-test-pr.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ jobs:
6464

6565
# Check out merge commit
6666
- name: Checkout PR
67-
uses: actions/checkout@v6
67+
uses: actions/checkout@v7
6868
with:
6969
ref: ${{ inputs.sha }}
7070
fetch-depth: 0
@@ -166,7 +166,7 @@ jobs:
166166

167167
steps:
168168
- name: Checkout code
169-
uses: actions/checkout@v6
169+
uses: actions/checkout@v7
170170
with:
171171
fetch-depth: 0
172172
submodules: 'recursive'

.github/workflows/e2e-test.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,15 +73,15 @@ jobs:
7373
steps:
7474
- name: Clone Repository with SHA
7575
if: ${{ inputs.sha != '' }}
76-
uses: actions/checkout@v6
76+
uses: actions/checkout@v7
7777
with:
7878
fetch-depth: 0
7979
submodules: 'recursive'
8080
ref: ${{ inputs.sha }}
8181

8282
- name: Clone Repository without SHA
8383
if: ${{ inputs.sha == '' }}
84-
uses: actions/checkout@v6
84+
uses: actions/checkout@v7
8585
with:
8686
fetch-depth: 0
8787
submodules: 'recursive'
@@ -127,7 +127,7 @@ jobs:
127127

128128
steps:
129129
- name: Checkout code
130-
uses: actions/checkout@v6
130+
uses: actions/checkout@v7
131131
with:
132132
fetch-depth: 0
133133
submodules: 'recursive'
@@ -195,7 +195,7 @@ jobs:
195195

196196
steps:
197197
- name: Checkout code
198-
uses: actions/checkout@v6
198+
uses: actions/checkout@v7
199199
with:
200200
fetch-depth: 0
201201
submodules: 'recursive'

.github/workflows/labeler.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
steps:
1919
-
2020
name: Checkout
21-
uses: actions/checkout@v6
21+
uses: actions/checkout@v7
2222
-
2323
name: Run Labeler
2424
uses: crazy-max/ghaction-github-labeler@548a7c3603594ec17c819e1239f281a3b801ab4d

.github/workflows/nightly-smoke-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919

2020
steps:
2121
- name: Checkout code
22-
uses: actions/checkout@v6
22+
uses: actions/checkout@v7
2323
with:
2424
ref: dev
2525

.github/workflows/publish-pypi.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
environment: pypi-release
1313
steps:
1414
- name: Checkout
15-
uses: actions/checkout@v6
15+
uses: actions/checkout@v7
1616

1717
- name: Setup Python
1818
uses: actions/setup-python@v6

.github/workflows/release-cross-repo-test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
runs-on: ubuntu-latest
1414
steps:
1515
- name: Checkout linode_api4 repository
16-
uses: actions/checkout@v6
16+
uses: actions/checkout@v7
1717
with:
1818
fetch-depth: 0
1919
submodules: 'recursive'
@@ -30,7 +30,7 @@ jobs:
3030
python-version: '3.10'
3131

3232
- name: Checkout ansible repo
33-
uses: actions/checkout@v6
33+
uses: actions/checkout@v7
3434
with:
3535
repository: linode/ansible_linode
3636
path: .ansible/collections/ansible_collections/linode/cloud

linode_api4/groups/monitor.py

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,7 @@ def create_alert_definition(
225225
description: Optional[str] = None,
226226
scope: Optional[Union[AlertScope, str]] = None,
227227
regions: Optional[list[str]] = None,
228+
group_by: Optional[list[str]] = None,
228229
) -> AlertDefinition:
229230
"""
230231
Create a new alert definition for a given service type.
@@ -258,6 +259,8 @@ def create_alert_definition(
258259
:type scope: Optional[Union[AlertScope, str]]
259260
:param regions: (Optional) Regions to monitor.
260261
:type regions: Optional[list[str]]
262+
:param group_by: (Optional) Aggregates metric data by dimension so that alert conditions are evaluated independently for each dimension value.
263+
:type group_by: Optional[list[str]]
261264
262265
:returns: The newly created :class:`AlertDefinition`.
263266
:rtype: AlertDefinition
@@ -282,6 +285,8 @@ def create_alert_definition(
282285
params["scope"] = scope
283286
if regions is not None:
284287
params["regions"] = regions
288+
if group_by is not None:
289+
params["group_by"] = group_by
285290

286291
# API will validate service_type and return an error if missing
287292
result = self.client.post(
@@ -296,6 +301,95 @@ def create_alert_definition(
296301

297302
return AlertDefinition(self.client, result["id"], service_type, result)
298303

304+
def clone_alert_definition(
305+
self,
306+
service_type: str,
307+
id: int,
308+
label: str,
309+
description: Optional[str] = None,
310+
scope: Optional[Union[AlertScope, str]] = None,
311+
regions: Optional[list[str]] = None,
312+
entity_ids: Optional[list[str]] = None,
313+
severity: Optional[int] = None,
314+
rule_criteria: Optional[dict] = None,
315+
trigger_conditions: Optional[dict] = None,
316+
channel_ids: Optional[list[int]] = None,
317+
group_by: Optional[list[str]] = None,
318+
) -> AlertDefinition:
319+
"""
320+
Clone an existing alert definition for a given service type.
321+
The clone request creates a new alert definition based on the source
322+
definition identified by ``id``.
323+
324+
API Documentation: TODO
325+
326+
:param service_type: Service type for the source alert definition
327+
(e.g. ``"dbaas"``).
328+
:type service_type: str
329+
:param id: Source alert definition identifier.
330+
:type id: int (Alert identifier)
331+
:param label: Human-readable label for the cloned alert definition.
332+
This value is mandatory and must be unique.
333+
:type label: str
334+
:param description: (Optional) Longer description for the cloned alert definition.
335+
:type description: Optional[str]
336+
:param scope: (Optional) Alert scope provided in the clone request.
337+
Scope is inherited from the source alert and is immutable.
338+
:type scope: Optional[Union[AlertScope, str]]
339+
:param regions: (Optional) Regions to monitor.
340+
:type regions: Optional[list[str]]
341+
:param entity_ids: (Optional) Restrict the alert to a subset of entity IDs.
342+
:type entity_ids: Optional[list[str]]
343+
:param severity: (Optional) Severity level for the alert.
344+
:type severity: Optional[int]
345+
:param rule_criteria: (Optional) Rule criteria used to evaluate the alert.
346+
:type rule_criteria: Optional[dict]
347+
:param trigger_conditions: (Optional) Trigger conditions for alert state transitions.
348+
:type trigger_conditions: Optional[dict]
349+
:param channel_ids: (Optional) List of alert channel IDs to notify.
350+
:type channel_ids: Optional[list[int]]
351+
:param group_by: (Optional) Aggregates metric data by dimension so that alert conditions are evaluated independently for each dimension value.
352+
:type group_by: Optional[list[str]]
353+
354+
:returns: The newly created cloned :class:`AlertDefinition`.
355+
:rtype: AlertDefinition
356+
"""
357+
params = {
358+
"label": label,
359+
}
360+
361+
if description is not None:
362+
params["description"] = description
363+
if scope is not None:
364+
params["scope"] = scope
365+
if regions is not None:
366+
params["regions"] = regions
367+
if entity_ids is not None:
368+
params["entity_ids"] = entity_ids
369+
if severity is not None:
370+
params["severity"] = severity
371+
if rule_criteria is not None:
372+
params["rule_criteria"] = rule_criteria
373+
if trigger_conditions is not None:
374+
params["trigger_conditions"] = trigger_conditions
375+
if channel_ids is not None:
376+
params["channel_ids"] = channel_ids
377+
if group_by is not None:
378+
params["group_by"] = group_by
379+
380+
result = self.client.post(
381+
f"/monitor/services/{service_type}/alert-definitions/{id}/clone",
382+
data=params,
383+
)
384+
385+
if "id" not in result:
386+
raise UnexpectedResponseError(
387+
"Unexpected response when cloning alert definition!",
388+
json=result,
389+
)
390+
391+
return AlertDefinition(self.client, result["id"], service_type, result)
392+
299393
def alert_definition_entities(
300394
self,
301395
service_type: str,

0 commit comments

Comments
 (0)