moira-python-client 4.2.0__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.2.0 → moira_python_client-4.2.1}/CHANGELOG.md +4 -0
- {moira-python-client-4.2.0/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.2.0 → moira_python_client-4.2.1}/moira_client/client.py +32 -4
- {moira-python-client-4.2.0 → moira_python_client-4.2.1}/moira_client/models/contact.py +16 -5
- {moira-python-client-4.2.0 → moira_python_client-4.2.1/moira_python_client.egg-info}/PKG-INFO +1 -1
- moira-python-client-4.2.0/VERSION.txt +0 -1
- {moira-python-client-4.2.0 → moira_python_client-4.2.1}/LICENSE +0 -0
- {moira-python-client-4.2.0 → moira_python_client-4.2.1}/MANIFEST.in +0 -0
- {moira-python-client-4.2.0 → moira_python_client-4.2.1}/README.md +0 -0
- {moira-python-client-4.2.0 → moira_python_client-4.2.1}/moira_client/__init__.py +0 -0
- {moira-python-client-4.2.0 → moira_python_client-4.2.1}/moira_client/models/__init__.py +0 -0
- {moira-python-client-4.2.0 → moira_python_client-4.2.1}/moira_client/models/base.py +0 -0
- {moira-python-client-4.2.0 → moira_python_client-4.2.1}/moira_client/models/config.py +0 -0
- {moira-python-client-4.2.0 → moira_python_client-4.2.1}/moira_client/models/event.py +0 -0
- {moira-python-client-4.2.0 → moira_python_client-4.2.1}/moira_client/models/health.py +0 -0
- {moira-python-client-4.2.0 → moira_python_client-4.2.1}/moira_client/models/notification.py +0 -0
- {moira-python-client-4.2.0 → moira_python_client-4.2.1}/moira_client/models/pattern.py +0 -0
- {moira-python-client-4.2.0 → moira_python_client-4.2.1}/moira_client/models/subscription.py +0 -0
- {moira-python-client-4.2.0 → moira_python_client-4.2.1}/moira_client/models/tag.py +0 -0
- {moira-python-client-4.2.0 → moira_python_client-4.2.1}/moira_client/models/trigger.py +0 -0
- {moira-python-client-4.2.0 → moira_python_client-4.2.1}/moira_client/models/user.py +0 -0
- {moira-python-client-4.2.0 → moira_python_client-4.2.1}/moira_client/moira.py +0 -0
- {moira-python-client-4.2.0 → moira_python_client-4.2.1}/moira_python_client.egg-info/SOURCES.txt +0 -0
- {moira-python-client-4.2.0 → moira_python_client-4.2.1}/moira_python_client.egg-info/dependency_links.txt +0 -0
- {moira-python-client-4.2.0 → moira_python_client-4.2.1}/moira_python_client.egg-info/requires.txt +0 -0
- {moira-python-client-4.2.0 → moira_python_client-4.2.1}/moira_python_client.egg-info/top_level.txt +0 -0
- {moira-python-client-4.2.0 → moira_python_client-4.2.1}/requirements.txt +0 -0
- {moira-python-client-4.2.0 → moira_python_client-4.2.1}/setup.cfg +0 -0
- {moira-python-client-4.2.0 → moira_python_client-4.2.1}/setup.py +0 -0
- {moira-python-client-4.2.0 → moira_python_client-4.2.1}/test-requirements.txt +0 -0
- {moira-python-client-4.2.0 → moira_python_client-4.2.1}/tests/test_client.py +0 -0
|
@@ -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)
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
4.2.0
|
|
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
|
|
File without changes
|
{moira-python-client-4.2.0 → moira_python_client-4.2.1}/moira_python_client.egg-info/SOURCES.txt
RENAMED
|
File without changes
|
|
File without changes
|
{moira-python-client-4.2.0 → moira_python_client-4.2.1}/moira_python_client.egg-info/requires.txt
RENAMED
|
File without changes
|
{moira-python-client-4.2.0 → 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
|