moira-python-client 4.2.1__py3-none-any.whl → 4.3.0__py3-none-any.whl
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_client/models/contact.py +1 -0
- moira_client/models/subscription.py +82 -52
- moira_client/moira.py +11 -0
- {moira_python_client-4.2.1.dist-info → moira_python_client-4.3.0.dist-info}/METADATA +1 -1
- {moira_python_client-4.2.1.dist-info → moira_python_client-4.3.0.dist-info}/RECORD +8 -8
- {moira_python_client-4.2.1.dist-info → moira_python_client-4.3.0.dist-info}/WHEEL +1 -1
- {moira_python_client-4.2.1.dist-info → moira_python_client-4.3.0.dist-info}/LICENSE +0 -0
- {moira_python_client-4.2.1.dist-info → moira_python_client-4.3.0.dist-info}/top_level.txt +0 -0
moira_client/models/contact.py
CHANGED
|
@@ -2,12 +2,10 @@ from ..client import InvalidJSONError
|
|
|
2
2
|
from ..client import ResponseStructureError
|
|
3
3
|
from .base import Base
|
|
4
4
|
|
|
5
|
-
class
|
|
6
|
-
def __init__(self,
|
|
5
|
+
class SubscriptionModel(Base):
|
|
6
|
+
def __init__(self, tags, contacts=None, enabled=None, throttling=None, sched=None,
|
|
7
7
|
ignore_warnings=False, ignore_recoverings=False, plotting=None, any_tags=False, **kwargs):
|
|
8
8
|
"""
|
|
9
|
-
|
|
10
|
-
:param client: api client
|
|
11
9
|
:param tags: list of str tags
|
|
12
10
|
:param contacts: list of contact id's
|
|
13
11
|
:param enabled: bool is enabled
|
|
@@ -19,8 +17,6 @@ class Subscription(Base):
|
|
|
19
17
|
:param any_tags: bool any tags
|
|
20
18
|
:param kwargs: additional parameters
|
|
21
19
|
"""
|
|
22
|
-
self._client = client
|
|
23
|
-
|
|
24
20
|
self._id = kwargs.get('id', None)
|
|
25
21
|
self.tags = tags if not any_tags else []
|
|
26
22
|
if not contacts:
|
|
@@ -38,32 +34,7 @@ class Subscription(Base):
|
|
|
38
34
|
if not plotting:
|
|
39
35
|
plotting = {'enabled': False, 'theme': 'light'}
|
|
40
36
|
self.plotting = plotting
|
|
41
|
-
|
|
42
|
-
def _send_request(self, subscription_id=None):
|
|
43
|
-
data = {
|
|
44
|
-
'contacts': self.contacts,
|
|
45
|
-
'tags': self.tags,
|
|
46
|
-
'enabled': self.enabled,
|
|
47
|
-
'any_tags': self.any_tags,
|
|
48
|
-
'throttling': self.throttling,
|
|
49
|
-
'sched': self.sched,
|
|
50
|
-
'ignore_warnings': self.ignore_warnings,
|
|
51
|
-
'ignore_recoverings': self.ignore_recoverings,
|
|
52
|
-
'plotting': self.plotting
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
if subscription_id:
|
|
56
|
-
data['id'] = subscription_id
|
|
57
|
-
|
|
58
|
-
if subscription_id:
|
|
59
|
-
result = self._client.put('subscription/{id}'.format(id=subscription_id), json=data)
|
|
60
|
-
else:
|
|
61
|
-
result = self._client.put('subscription', json=data)
|
|
62
|
-
if 'id' not in result:
|
|
63
|
-
raise ResponseStructureError("id doesn't exist in response", result)
|
|
64
|
-
|
|
65
|
-
self._id = result['id']
|
|
66
|
-
return self._id
|
|
37
|
+
self.team_id = kwargs.get('team_id', None)
|
|
67
38
|
|
|
68
39
|
def disable_day(self, day):
|
|
69
40
|
"""
|
|
@@ -124,26 +95,6 @@ class Subscription(Base):
|
|
|
124
95
|
'theme': 'light'
|
|
125
96
|
}
|
|
126
97
|
|
|
127
|
-
def save(self):
|
|
128
|
-
"""
|
|
129
|
-
Save subscription
|
|
130
|
-
|
|
131
|
-
:return: subscription id
|
|
132
|
-
"""
|
|
133
|
-
if self._id:
|
|
134
|
-
return self.update()
|
|
135
|
-
self._send_request()
|
|
136
|
-
|
|
137
|
-
def update(self):
|
|
138
|
-
"""
|
|
139
|
-
Update subscription
|
|
140
|
-
|
|
141
|
-
:return: subscription id
|
|
142
|
-
"""
|
|
143
|
-
if not self._id:
|
|
144
|
-
return self.save()
|
|
145
|
-
self._send_request(self._id)
|
|
146
|
-
|
|
147
98
|
def set_start_hour(self, hour):
|
|
148
99
|
"""
|
|
149
100
|
Set start hour
|
|
@@ -185,6 +136,85 @@ class Subscription(Base):
|
|
|
185
136
|
self._end_minute = minute
|
|
186
137
|
|
|
187
138
|
|
|
139
|
+
class Subscription(SubscriptionModel):
|
|
140
|
+
def __init__(self, client, tags, contacts=None, enabled=None, throttling=None, sched=None,
|
|
141
|
+
ignore_warnings=False, ignore_recoverings=False, plotting=None, any_tags=False, **kwargs):
|
|
142
|
+
"""
|
|
143
|
+
:param client: api client
|
|
144
|
+
:param tags: list of str tags
|
|
145
|
+
:param contacts: list of contact id's
|
|
146
|
+
:param enabled: bool is enabled
|
|
147
|
+
:param throttling: bool throttling
|
|
148
|
+
:param sched: dict schedule
|
|
149
|
+
:param ignore_warnings: bool ignore warnings
|
|
150
|
+
:param ignore_recoverings: bool ignore recoverings
|
|
151
|
+
:param plotting: dict plotting settings
|
|
152
|
+
:param any_tags: bool any tags
|
|
153
|
+
:param kwargs: additional parameters
|
|
154
|
+
"""
|
|
155
|
+
self._client = client
|
|
156
|
+
|
|
157
|
+
super().__init__(
|
|
158
|
+
tags=tags,
|
|
159
|
+
contacts=contacts,
|
|
160
|
+
enabled=enabled,
|
|
161
|
+
throttling=throttling,
|
|
162
|
+
sched=sched,
|
|
163
|
+
ignore_warnings=ignore_warnings,
|
|
164
|
+
ignore_recoverings=ignore_recoverings,
|
|
165
|
+
plotting=plotting,
|
|
166
|
+
any_tags=any_tags,
|
|
167
|
+
**kwargs,
|
|
168
|
+
)
|
|
169
|
+
|
|
170
|
+
def _send_request(self, subscription_id=None):
|
|
171
|
+
data = {
|
|
172
|
+
'contacts': self.contacts,
|
|
173
|
+
'tags': self.tags,
|
|
174
|
+
'enabled': self.enabled,
|
|
175
|
+
'any_tags': self.any_tags,
|
|
176
|
+
'throttling': self.throttling,
|
|
177
|
+
'sched': self.sched,
|
|
178
|
+
'ignore_warnings': self.ignore_warnings,
|
|
179
|
+
'ignore_recoverings': self.ignore_recoverings,
|
|
180
|
+
'plotting': self.plotting,
|
|
181
|
+
'team_id': self.team_id,
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
if subscription_id:
|
|
185
|
+
data['id'] = subscription_id
|
|
186
|
+
|
|
187
|
+
if subscription_id:
|
|
188
|
+
result = self._client.put('subscription/{id}'.format(id=subscription_id), json=data)
|
|
189
|
+
else:
|
|
190
|
+
result = self._client.put('subscription', json=data)
|
|
191
|
+
if 'id' not in result:
|
|
192
|
+
raise ResponseStructureError("id doesn't exist in response", result)
|
|
193
|
+
|
|
194
|
+
self._id = result['id']
|
|
195
|
+
return self._id
|
|
196
|
+
|
|
197
|
+
def save(self):
|
|
198
|
+
"""
|
|
199
|
+
Save subscription
|
|
200
|
+
|
|
201
|
+
:return: subscription id
|
|
202
|
+
"""
|
|
203
|
+
if self._id:
|
|
204
|
+
return self.update()
|
|
205
|
+
self._send_request()
|
|
206
|
+
|
|
207
|
+
def update(self):
|
|
208
|
+
"""
|
|
209
|
+
Update subscription
|
|
210
|
+
|
|
211
|
+
:return: subscription id
|
|
212
|
+
"""
|
|
213
|
+
if not self._id:
|
|
214
|
+
return self.save()
|
|
215
|
+
self._send_request(self._id)
|
|
216
|
+
|
|
217
|
+
|
|
188
218
|
class SubscriptionManager:
|
|
189
219
|
def __init__(self, client):
|
|
190
220
|
self._client = client
|
moira_client/moira.py
CHANGED
|
@@ -9,6 +9,7 @@ from .models.trigger import TriggerManager
|
|
|
9
9
|
from .models.health import HealthManager
|
|
10
10
|
from .models.config import ConfigManager
|
|
11
11
|
from .models.user import UserManager
|
|
12
|
+
from .models.team import TeamManager
|
|
12
13
|
|
|
13
14
|
|
|
14
15
|
class Moira:
|
|
@@ -34,6 +35,7 @@ class Moira:
|
|
|
34
35
|
self._health = None
|
|
35
36
|
self._config = None
|
|
36
37
|
self._user = None
|
|
38
|
+
self._team = None
|
|
37
39
|
|
|
38
40
|
@property
|
|
39
41
|
def trigger(self):
|
|
@@ -145,3 +147,12 @@ class Moira:
|
|
|
145
147
|
if not self._user:
|
|
146
148
|
self._user = UserManager(self._client)
|
|
147
149
|
return self._user
|
|
150
|
+
|
|
151
|
+
@property
|
|
152
|
+
def team(self) -> TeamManager:
|
|
153
|
+
"""Get team manager
|
|
154
|
+
"""
|
|
155
|
+
if not self._team:
|
|
156
|
+
self._team = TeamManager(self._client)
|
|
157
|
+
|
|
158
|
+
return self._team
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
moira_client/__init__.py,sha256=BUWUwGU1V5wvdi5-mUXd8AJlsGyrAvFKOjs8-vkUV4o,67
|
|
2
2
|
moira_client/client.py,sha256=SGakaO2SB2EjsZPlfD1Dv2naIgwBr5F5QufYKm-Ro1w,4106
|
|
3
|
-
moira_client/moira.py,sha256=
|
|
3
|
+
moira_client/moira.py,sha256=Pa3grEVhGu2gcPxWR8sdu7GGowNF3AXBYvK1nmRiZi8,3859
|
|
4
4
|
moira_client/models/__init__.py,sha256=K3Kcjh8F_jV703ii-QMeN9cMwqcCfbfeNF7e9MfCD1c,126
|
|
5
5
|
moira_client/models/base.py,sha256=cYVLxnc5PGjmUcoZRZ7AFx5f0Ij96HypJpOjpwr_D-Q,385
|
|
6
6
|
moira_client/models/config.py,sha256=BbsShuKhe5H0DTXkIeOndHyXbi2xW2BRP0pwoIQl4Ok,2178
|
|
7
|
-
moira_client/models/contact.py,sha256
|
|
7
|
+
moira_client/models/contact.py,sha256=-z8p32EIUfG9x8KRbUPeJR3DroOuPHfBN9pv8yq4lgI,4987
|
|
8
8
|
moira_client/models/event.py,sha256=pXsuU-X3i3DX89rs1wBaB7SBvw_q5dgJwLJgQFrp7vg,1375
|
|
9
9
|
moira_client/models/health.py,sha256=a2bGgHVVbcIJCraArjI9V-gqpwdRZ1B5SnNrsLqR6mI,1708
|
|
10
10
|
moira_client/models/notification.py,sha256=stk78RW0lENkBX7FHm9cTskHkz8SxdXmpcXP72XwWio,1946
|
|
11
11
|
moira_client/models/pattern.py,sha256=Ef8Roupkjrs8gb41vrgBwvgpgTmJU4igsU58z19LHcg,1619
|
|
12
|
-
moira_client/models/subscription.py,sha256=
|
|
12
|
+
moira_client/models/subscription.py,sha256=vAGuxrcTkGLtrj8D_cC_lo3EMGtAnClOXdmFfMl45E0,9050
|
|
13
13
|
moira_client/models/tag.py,sha256=2sDmf9CKAzzZRqQykBdR3-jKgcfo62hGO7eivI1X_sc,4336
|
|
14
14
|
moira_client/models/trigger.py,sha256=61Gs4blN0pcPrCEnOzpaKkA_UgeChz3Kv2qV-zXySYE,17868
|
|
15
15
|
moira_client/models/user.py,sha256=9zG7pbmEA9ESUWFMzvqfyLP0lqcjz1pc0n8U7mL1UMk,1767
|
|
16
|
-
moira_python_client-4.
|
|
17
|
-
moira_python_client-4.
|
|
18
|
-
moira_python_client-4.
|
|
19
|
-
moira_python_client-4.
|
|
20
|
-
moira_python_client-4.
|
|
16
|
+
moira_python_client-4.3.0.dist-info/LICENSE,sha256=HJk93uYDrJpwAa6G3ufYfC4ZgCKH2flOtdgOv1esxgI,1062
|
|
17
|
+
moira_python_client-4.3.0.dist-info/METADATA,sha256=_OsSWx_61kPxAoKt0oIaH1h90ZT_fCyA40liA2i3SdY,1243
|
|
18
|
+
moira_python_client-4.3.0.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
|
|
19
|
+
moira_python_client-4.3.0.dist-info/top_level.txt,sha256=zBB6_FP28feugBNn2cLmi5nCniRPnuChI6HuXUqFdIA,13
|
|
20
|
+
moira_python_client-4.3.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|