moira-python-client 4.1.4__tar.gz → 4.2.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {moira-python-client-4.1.4 → moira_python_client-4.2.1}/CHANGELOG.md +11 -1
- {moira-python-client-4.1.4/moira_python_client.egg-info → moira_python_client-4.2.1}/PKG-INFO +1 -1
- moira_python_client-4.2.1/VERSION.txt +1 -0
- {moira-python-client-4.1.4 → moira_python_client-4.2.1}/moira_client/client.py +32 -4
- {moira-python-client-4.1.4 → moira_python_client-4.2.1}/moira_client/models/contact.py +16 -5
- {moira-python-client-4.1.4 → moira_python_client-4.2.1}/moira_client/models/trigger.py +8 -0
- {moira-python-client-4.1.4 → moira_python_client-4.2.1/moira_python_client.egg-info}/PKG-INFO +1 -1
- moira-python-client-4.1.4/VERSION.txt +0 -1
- {moira-python-client-4.1.4 → moira_python_client-4.2.1}/LICENSE +0 -0
- {moira-python-client-4.1.4 → moira_python_client-4.2.1}/MANIFEST.in +0 -0
- {moira-python-client-4.1.4 → moira_python_client-4.2.1}/README.md +0 -0
- {moira-python-client-4.1.4 → moira_python_client-4.2.1}/moira_client/__init__.py +0 -0
- {moira-python-client-4.1.4 → moira_python_client-4.2.1}/moira_client/models/__init__.py +0 -0
- {moira-python-client-4.1.4 → moira_python_client-4.2.1}/moira_client/models/base.py +0 -0
- {moira-python-client-4.1.4 → moira_python_client-4.2.1}/moira_client/models/config.py +0 -0
- {moira-python-client-4.1.4 → moira_python_client-4.2.1}/moira_client/models/event.py +0 -0
- {moira-python-client-4.1.4 → moira_python_client-4.2.1}/moira_client/models/health.py +0 -0
- {moira-python-client-4.1.4 → moira_python_client-4.2.1}/moira_client/models/notification.py +0 -0
- {moira-python-client-4.1.4 → moira_python_client-4.2.1}/moira_client/models/pattern.py +0 -0
- {moira-python-client-4.1.4 → moira_python_client-4.2.1}/moira_client/models/subscription.py +0 -0
- {moira-python-client-4.1.4 → moira_python_client-4.2.1}/moira_client/models/tag.py +0 -0
- {moira-python-client-4.1.4 → moira_python_client-4.2.1}/moira_client/models/user.py +0 -0
- {moira-python-client-4.1.4 → moira_python_client-4.2.1}/moira_client/moira.py +0 -0
- {moira-python-client-4.1.4 → moira_python_client-4.2.1}/moira_python_client.egg-info/SOURCES.txt +0 -0
- {moira-python-client-4.1.4 → moira_python_client-4.2.1}/moira_python_client.egg-info/dependency_links.txt +0 -0
- {moira-python-client-4.1.4 → moira_python_client-4.2.1}/moira_python_client.egg-info/requires.txt +0 -0
- {moira-python-client-4.1.4 → moira_python_client-4.2.1}/moira_python_client.egg-info/top_level.txt +0 -0
- {moira-python-client-4.1.4 → moira_python_client-4.2.1}/requirements.txt +0 -0
- {moira-python-client-4.1.4 → moira_python_client-4.2.1}/setup.cfg +0 -0
- {moira-python-client-4.1.4 → moira_python_client-4.2.1}/setup.py +0 -0
- {moira-python-client-4.1.4 → moira_python_client-4.2.1}/test-requirements.txt +0 -0
- {moira-python-client-4.1.4 → moira_python_client-4.2.1}/tests/test_client.py +0 -0
|
@@ -1,8 +1,18 @@
|
|
|
1
|
+
# 4.2.1
|
|
2
|
+
|
|
3
|
+
Add support for name field in contacts
|
|
4
|
+
|
|
5
|
+
# 4.2.0
|
|
6
|
+
|
|
7
|
+
Add support for multiple clusters in trigger creation
|
|
8
|
+
|
|
9
|
+
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`
|
|
10
|
+
|
|
1
11
|
# 4.1.0
|
|
2
12
|
|
|
3
13
|
Add support for prometheus trigger creation.
|
|
4
14
|
|
|
5
|
-
Now you
|
|
15
|
+
Now you can use `trigger_source` field in api that overrides `is_remote` field
|
|
6
16
|
|
|
7
17
|
# 4.0.2
|
|
8
18
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
4.2.1
|
|
@@ -21,6 +21,14 @@ class InvalidJSONError(Exception):
|
|
|
21
21
|
"""
|
|
22
22
|
self.content = content
|
|
23
23
|
|
|
24
|
+
class MoiraApiError(Exception):
|
|
25
|
+
def __init__(self, body):
|
|
26
|
+
"""
|
|
27
|
+
|
|
28
|
+
:param body: response body
|
|
29
|
+
"""
|
|
30
|
+
self.body = body
|
|
31
|
+
|
|
24
32
|
|
|
25
33
|
class Client:
|
|
26
34
|
def __init__(self, api_url, auth_custom=None, auth_user=None, auth_pass=None, login=None):
|
|
@@ -64,7 +72,12 @@ class Client:
|
|
|
64
72
|
:raises: InvalidJSONError
|
|
65
73
|
"""
|
|
66
74
|
r = requests.get(self._path_join(path), headers=self.headers, auth=self.auth, **kwargs)
|
|
67
|
-
|
|
75
|
+
|
|
76
|
+
try:
|
|
77
|
+
r.raise_for_status()
|
|
78
|
+
except requests.exceptions.HTTPError as err:
|
|
79
|
+
raise MoiraApiError(r.content)
|
|
80
|
+
|
|
68
81
|
try:
|
|
69
82
|
return r.json()
|
|
70
83
|
except ValueError:
|
|
@@ -81,7 +94,12 @@ class Client:
|
|
|
81
94
|
:raises: InvalidJSONError
|
|
82
95
|
"""
|
|
83
96
|
r = requests.delete(self._path_join(path), headers=self.headers, auth=self.auth, **kwargs)
|
|
84
|
-
|
|
97
|
+
|
|
98
|
+
try:
|
|
99
|
+
r.raise_for_status()
|
|
100
|
+
except requests.exceptions.HTTPError as err:
|
|
101
|
+
raise MoiraApiError(r.content)
|
|
102
|
+
|
|
85
103
|
try:
|
|
86
104
|
return r.json()
|
|
87
105
|
except ValueError:
|
|
@@ -98,7 +116,12 @@ class Client:
|
|
|
98
116
|
:raises: InvalidJSONError
|
|
99
117
|
"""
|
|
100
118
|
r = requests.put(self._path_join(path), headers=self.headers, auth=self.auth, **kwargs)
|
|
101
|
-
|
|
119
|
+
|
|
120
|
+
try:
|
|
121
|
+
r.raise_for_status()
|
|
122
|
+
except requests.exceptions.HTTPError as err:
|
|
123
|
+
raise MoiraApiError(r.content)
|
|
124
|
+
|
|
102
125
|
try:
|
|
103
126
|
return r.json()
|
|
104
127
|
except ValueError:
|
|
@@ -115,7 +138,12 @@ class Client:
|
|
|
115
138
|
:raises: InvalidJSONError
|
|
116
139
|
"""
|
|
117
140
|
r = requests.post(self._path_join(path), headers=self.headers, auth=self.auth, **kwargs)
|
|
118
|
-
|
|
141
|
+
|
|
142
|
+
try:
|
|
143
|
+
r.raise_for_status()
|
|
144
|
+
except requests.exceptions.HTTPError as err:
|
|
145
|
+
raise MoiraApiError(r.content)
|
|
146
|
+
|
|
119
147
|
try:
|
|
120
148
|
return r.json()
|
|
121
149
|
except ValueError:
|
|
@@ -21,6 +21,7 @@ class Contact(Base):
|
|
|
21
21
|
self.type = type
|
|
22
22
|
self.value = value
|
|
23
23
|
self.user = kwargs.get('user', None)
|
|
24
|
+
self.name = kwargs.get('name', None)
|
|
24
25
|
self._id = kwargs.get('id', None)
|
|
25
26
|
|
|
26
27
|
|
|
@@ -28,26 +29,34 @@ class ContactManager:
|
|
|
28
29
|
def __init__(self, client):
|
|
29
30
|
self._client = client
|
|
30
31
|
|
|
31
|
-
def add(self, value, contact_type):
|
|
32
|
+
def add(self, value, contact_type, name=None):
|
|
32
33
|
"""
|
|
33
34
|
Add new contact
|
|
34
35
|
|
|
35
36
|
:param value: str contact value
|
|
36
37
|
:param contact_type: str contact type (one of CONTACT_* constants)
|
|
38
|
+
:param name: str contact name
|
|
37
39
|
:return: Contact
|
|
38
40
|
|
|
39
41
|
:raises: ResponseStructureError
|
|
40
42
|
"""
|
|
41
|
-
data = {
|
|
42
|
-
'value': value,
|
|
43
|
-
'type': contact_type
|
|
44
|
-
}
|
|
45
43
|
|
|
46
44
|
contacts = self.fetch_by_current_user()
|
|
47
45
|
for contact in contacts:
|
|
48
46
|
if contact.value == value and contact.type == contact_type:
|
|
47
|
+
if name and contact.name != name:
|
|
48
|
+
contact.name = name
|
|
49
|
+
self.update(contact)
|
|
50
|
+
return contact
|
|
49
51
|
return contact
|
|
50
52
|
|
|
53
|
+
data = {
|
|
54
|
+
'value': value,
|
|
55
|
+
'type': contact_type
|
|
56
|
+
}
|
|
57
|
+
if name:
|
|
58
|
+
data['name'] = name
|
|
59
|
+
|
|
51
60
|
result = self._client.put(self._full_path(), json=data)
|
|
52
61
|
if 'id' not in result:
|
|
53
62
|
raise ResponseStructureError('No id in response', result)
|
|
@@ -135,6 +144,8 @@ class ContactManager:
|
|
|
135
144
|
'type': contact.type,
|
|
136
145
|
'value': contact.value,
|
|
137
146
|
}
|
|
147
|
+
if contact.name:
|
|
148
|
+
data['name'] = contact.name
|
|
138
149
|
|
|
139
150
|
try:
|
|
140
151
|
self._client.put(self._full_path(contact.id), json=data)
|
|
@@ -37,6 +37,7 @@ class Trigger(Base):
|
|
|
37
37
|
mute_new_metrics=False,
|
|
38
38
|
alone_metrics=None,
|
|
39
39
|
trigger_source=None,
|
|
40
|
+
cluster_id=None,
|
|
40
41
|
**kwargs):
|
|
41
42
|
"""
|
|
42
43
|
|
|
@@ -57,6 +58,7 @@ class Trigger(Base):
|
|
|
57
58
|
:param alone_metrics: dict with targets of alone metrics
|
|
58
59
|
:param kwargs: additional parameters
|
|
59
60
|
:param trigger_source: str specify trigger source, overrides is_remote
|
|
61
|
+
:param cluster_id: str specify cluster id
|
|
60
62
|
"""
|
|
61
63
|
self._client = client
|
|
62
64
|
|
|
@@ -75,6 +77,7 @@ class Trigger(Base):
|
|
|
75
77
|
|
|
76
78
|
self.is_remote = is_remote
|
|
77
79
|
self.trigger_source = trigger_source
|
|
80
|
+
self.cluster_id = cluster_id
|
|
78
81
|
self.mute_new_metrics = mute_new_metrics
|
|
79
82
|
self.alone_metrics = alone_metrics
|
|
80
83
|
|
|
@@ -153,6 +156,8 @@ class Trigger(Base):
|
|
|
153
156
|
|
|
154
157
|
if self.trigger_source:
|
|
155
158
|
data['trigger_source'] = self.trigger_source
|
|
159
|
+
if self.cluster_id:
|
|
160
|
+
data['cluster_id'] = self.cluster_id
|
|
156
161
|
|
|
157
162
|
if trigger_id:
|
|
158
163
|
data['id'] = trigger_id
|
|
@@ -529,6 +534,7 @@ class TriggerManager:
|
|
|
529
534
|
mute_new_metrics=False,
|
|
530
535
|
alone_metrics=None,
|
|
531
536
|
trigger_source=None,
|
|
537
|
+
cluster_id=None,
|
|
532
538
|
**kwargs
|
|
533
539
|
):
|
|
534
540
|
"""
|
|
@@ -549,6 +555,7 @@ class TriggerManager:
|
|
|
549
555
|
:param alone_metrics: dict with targets of alone metrics
|
|
550
556
|
:param kwargs: additional trigger params
|
|
551
557
|
:param trigger_source: str specify trigger source, overrides is_remote
|
|
558
|
+
:param cluster_id: str specify cluster id
|
|
552
559
|
:return: Trigger
|
|
553
560
|
"""
|
|
554
561
|
return Trigger(
|
|
@@ -568,6 +575,7 @@ class TriggerManager:
|
|
|
568
575
|
mute_new_metrics=mute_new_metrics,
|
|
569
576
|
alone_metrics=alone_metrics,
|
|
570
577
|
trigger_source=trigger_source,
|
|
578
|
+
cluster_id=cluster_id,
|
|
571
579
|
**kwargs
|
|
572
580
|
)
|
|
573
581
|
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
4.1.4
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{moira-python-client-4.1.4 → moira_python_client-4.2.1}/moira_python_client.egg-info/SOURCES.txt
RENAMED
|
File without changes
|
|
File without changes
|
{moira-python-client-4.1.4 → moira_python_client-4.2.1}/moira_python_client.egg-info/requires.txt
RENAMED
|
File without changes
|
{moira-python-client-4.1.4 → moira_python_client-4.2.1}/moira_python_client.egg-info/top_level.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|