Skip to content

Commit

Permalink
feat: Add support for cluster_id field for trigger creation (#38)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tetrergeru authored Feb 29, 2024
1 parent 15319ea commit dd6fead
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
# 4.2.0

Add support for multiple clusters in trigger creation

Now you can use `cluster_id` field in api to set non-default cluster for remote triggers. List of available clusters can be seen in api at `https://your-moira-url/api/config`

# 4.1.0

Add support for prometheus trigger creation.

Now you canuse `trigger_source` field in api that overrides `is_remote` field
Now you can use `trigger_source` field in api that overrides `is_remote` field

# 4.0.2

Expand Down
2 changes: 1 addition & 1 deletion VERSION.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4.1.4
4.2.0
8 changes: 8 additions & 0 deletions moira_client/models/trigger.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ def __init__(
mute_new_metrics=False,
alone_metrics=None,
trigger_source=None,
cluster_id=None,
**kwargs):
"""
Expand All @@ -57,6 +58,7 @@ def __init__(
:param alone_metrics: dict with targets of alone metrics
:param kwargs: additional parameters
:param trigger_source: str specify trigger source, overrides is_remote
:param cluster_id: str specify cluster id
"""
self._client = client

Expand All @@ -75,6 +77,7 @@ def __init__(

self.is_remote = is_remote
self.trigger_source = trigger_source
self.cluster_id = cluster_id
self.mute_new_metrics = mute_new_metrics
self.alone_metrics = alone_metrics

Expand Down Expand Up @@ -153,6 +156,8 @@ def _send_request(self, trigger_id=None):

if self.trigger_source:
data['trigger_source'] = self.trigger_source
if self.cluster_id:
data['cluster_id'] = self.cluster_id

if trigger_id:
data['id'] = trigger_id
Expand Down Expand Up @@ -529,6 +534,7 @@ def create(
mute_new_metrics=False,
alone_metrics=None,
trigger_source=None,
cluster_id=None,
**kwargs
):
"""
Expand All @@ -549,6 +555,7 @@ def create(
:param alone_metrics: dict with targets of alone metrics
:param kwargs: additional trigger params
:param trigger_source: str specify trigger source, overrides is_remote
:param cluster_id: str specify cluster id
:return: Trigger
"""
return Trigger(
Expand All @@ -568,6 +575,7 @@ def create(
mute_new_metrics=mute_new_metrics,
alone_metrics=alone_metrics,
trigger_source=trigger_source,
cluster_id=cluster_id,
**kwargs
)

Expand Down

0 comments on commit dd6fead

Please sign in to comment.