moira-python-client 4.3.0__tar.gz → 4.3.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.3.0 → moira_python_client-4.3.1}/CHANGELOG.md +4 -0
- {moira_python_client-4.3.0/moira_python_client.egg-info → moira_python_client-4.3.1}/PKG-INFO +1 -1
- moira_python_client-4.3.1/VERSION.txt +1 -0
- moira_python_client-4.3.1/moira_client/models/team/__init__.py +8 -0
- moira_python_client-4.3.1/moira_client/models/team/_managers.py +96 -0
- moira_python_client-4.3.1/moira_client/models/team/_models.py +19 -0
- moira_python_client-4.3.1/moira_client/models/team/contact/__init__.py +5 -0
- moira_python_client-4.3.1/moira_client/models/team/contact/_managers.py +24 -0
- moira_python_client-4.3.1/moira_client/models/team/settings/__init__.py +7 -0
- moira_python_client-4.3.1/moira_client/models/team/settings/_managers.py +23 -0
- moira_python_client-4.3.1/moira_client/models/team/settings/_models.py +11 -0
- moira_python_client-4.3.1/moira_client/models/team/subscription/__init__.py +5 -0
- moira_python_client-4.3.1/moira_client/models/team/subscription/_managers.py +30 -0
- moira_python_client-4.3.1/moira_client/models/team/user/__init__.py +7 -0
- moira_python_client-4.3.1/moira_client/models/team/user/_managers.py +43 -0
- moira_python_client-4.3.1/moira_client/models/team/user/_models.py +6 -0
- {moira_python_client-4.3.0 → moira_python_client-4.3.1/moira_python_client.egg-info}/PKG-INFO +1 -1
- {moira_python_client-4.3.0 → moira_python_client-4.3.1}/moira_python_client.egg-info/SOURCES.txt +13 -0
- {moira_python_client-4.3.0 → moira_python_client-4.3.1}/setup.py +6 -1
- moira_python_client-4.3.0/VERSION.txt +0 -1
- {moira_python_client-4.3.0 → moira_python_client-4.3.1}/LICENSE +0 -0
- {moira_python_client-4.3.0 → moira_python_client-4.3.1}/MANIFEST.in +0 -0
- {moira_python_client-4.3.0 → moira_python_client-4.3.1}/README.md +0 -0
- {moira_python_client-4.3.0 → moira_python_client-4.3.1}/moira_client/__init__.py +0 -0
- {moira_python_client-4.3.0 → moira_python_client-4.3.1}/moira_client/client.py +0 -0
- {moira_python_client-4.3.0 → moira_python_client-4.3.1}/moira_client/models/__init__.py +0 -0
- {moira_python_client-4.3.0 → moira_python_client-4.3.1}/moira_client/models/base.py +0 -0
- {moira_python_client-4.3.0 → moira_python_client-4.3.1}/moira_client/models/config.py +0 -0
- {moira_python_client-4.3.0 → moira_python_client-4.3.1}/moira_client/models/contact.py +0 -0
- {moira_python_client-4.3.0 → moira_python_client-4.3.1}/moira_client/models/event.py +0 -0
- {moira_python_client-4.3.0 → moira_python_client-4.3.1}/moira_client/models/health.py +0 -0
- {moira_python_client-4.3.0 → moira_python_client-4.3.1}/moira_client/models/notification.py +0 -0
- {moira_python_client-4.3.0 → moira_python_client-4.3.1}/moira_client/models/pattern.py +0 -0
- {moira_python_client-4.3.0 → moira_python_client-4.3.1}/moira_client/models/subscription.py +0 -0
- {moira_python_client-4.3.0 → moira_python_client-4.3.1}/moira_client/models/tag.py +0 -0
- {moira_python_client-4.3.0 → moira_python_client-4.3.1}/moira_client/models/trigger.py +0 -0
- {moira_python_client-4.3.0 → moira_python_client-4.3.1}/moira_client/models/user.py +0 -0
- {moira_python_client-4.3.0 → moira_python_client-4.3.1}/moira_client/moira.py +0 -0
- {moira_python_client-4.3.0 → moira_python_client-4.3.1}/moira_python_client.egg-info/dependency_links.txt +0 -0
- {moira_python_client-4.3.0 → moira_python_client-4.3.1}/moira_python_client.egg-info/requires.txt +0 -0
- {moira_python_client-4.3.0 → moira_python_client-4.3.1}/moira_python_client.egg-info/top_level.txt +0 -0
- {moira_python_client-4.3.0 → moira_python_client-4.3.1}/requirements.txt +0 -0
- {moira_python_client-4.3.0 → moira_python_client-4.3.1}/setup.cfg +0 -0
- {moira_python_client-4.3.0 → moira_python_client-4.3.1}/test-requirements.txt +0 -0
- {moira_python_client-4.3.0 → moira_python_client-4.3.1}/tests/test_client.py +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
4.3.1
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
from typing import Optional
|
|
2
|
+
|
|
3
|
+
from ._models import TeamModel, UserTeams, SaveTeamResponse
|
|
4
|
+
from .contact import TeamContactManager
|
|
5
|
+
from .settings import TeamSettingsManager
|
|
6
|
+
from .subscription import TeamSubscriptionManager
|
|
7
|
+
from .user import TeamUserManager
|
|
8
|
+
from ...client import Client
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class TeamManager:
|
|
12
|
+
def __init__(self, client: Client) -> None:
|
|
13
|
+
self._client = client
|
|
14
|
+
self._user = None # type: Optional[TeamUserManager]
|
|
15
|
+
self._settings = None # type: Optional[TeamSettingsManager]
|
|
16
|
+
self._subscription = None # type: Optional[TeamSubscriptionManager]
|
|
17
|
+
self._contact = None # type: Optional[TeamContactManager]
|
|
18
|
+
|
|
19
|
+
def get_all(self) -> UserTeams:
|
|
20
|
+
"""Get all teams"""
|
|
21
|
+
response = self._client.get(self._full_path())
|
|
22
|
+
|
|
23
|
+
return UserTeams(teams=[TeamModel(**team) for team in response["teams"]])
|
|
24
|
+
|
|
25
|
+
def create(self, team: TeamModel) -> SaveTeamResponse:
|
|
26
|
+
"""Create a new team"""
|
|
27
|
+
payload = {
|
|
28
|
+
"name": team.name,
|
|
29
|
+
"description": team.description,
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
response = self._client.post(self._full_path(), json=payload)
|
|
33
|
+
|
|
34
|
+
return SaveTeamResponse(**response)
|
|
35
|
+
|
|
36
|
+
def delete(self, team_id: str) -> SaveTeamResponse:
|
|
37
|
+
"""Delete a team"""
|
|
38
|
+
response = self._client.delete(self._full_path(team_id))
|
|
39
|
+
|
|
40
|
+
return SaveTeamResponse(**response)
|
|
41
|
+
|
|
42
|
+
def get(self, team_id: str) -> TeamModel:
|
|
43
|
+
"""Get a team by ID"""
|
|
44
|
+
response = self._client.get(self._full_path(team_id))
|
|
45
|
+
|
|
46
|
+
return TeamModel(**response)
|
|
47
|
+
|
|
48
|
+
def update(self, team_id: str, team: TeamModel) -> SaveTeamResponse:
|
|
49
|
+
"""Update existing team"""
|
|
50
|
+
payload = {
|
|
51
|
+
"name": team.name,
|
|
52
|
+
"description": team.description,
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
response = self._client.put(self._full_path(team_id), json=payload)
|
|
56
|
+
|
|
57
|
+
return SaveTeamResponse(**response)
|
|
58
|
+
|
|
59
|
+
@property
|
|
60
|
+
def user(self) -> TeamUserManager:
|
|
61
|
+
"""Get team user manager"""
|
|
62
|
+
if self._user is None:
|
|
63
|
+
self._user = TeamUserManager(self._client)
|
|
64
|
+
|
|
65
|
+
return self._user
|
|
66
|
+
|
|
67
|
+
@property
|
|
68
|
+
def settings(self) -> TeamSettingsManager:
|
|
69
|
+
"""Get team settings manager"""
|
|
70
|
+
if self._settings is None:
|
|
71
|
+
self._settings = TeamSettingsManager(self._client)
|
|
72
|
+
|
|
73
|
+
return self._settings
|
|
74
|
+
|
|
75
|
+
@property
|
|
76
|
+
def subscription(self) -> TeamSubscriptionManager:
|
|
77
|
+
"""Get team subscription manager"""
|
|
78
|
+
if self._subscription is None:
|
|
79
|
+
self._subscription = TeamSubscriptionManager(self._client)
|
|
80
|
+
|
|
81
|
+
return self._subscription
|
|
82
|
+
|
|
83
|
+
@property
|
|
84
|
+
def contact(self) -> TeamContactManager:
|
|
85
|
+
"""Get team contact manager"""
|
|
86
|
+
if self._contact is None:
|
|
87
|
+
self._contact = TeamContactManager(self._client)
|
|
88
|
+
|
|
89
|
+
return self._contact
|
|
90
|
+
|
|
91
|
+
@staticmethod
|
|
92
|
+
def _full_path(team_id: Optional[str] = None) -> str:
|
|
93
|
+
if team_id is None:
|
|
94
|
+
return "teams"
|
|
95
|
+
|
|
96
|
+
return "teams/{team_id}".format(team_id=team_id)
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
from ..base import Base
|
|
2
|
+
from typing import List
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class TeamModel(Base):
|
|
6
|
+
def __init__(self, description: str, name: str, **kwargs):
|
|
7
|
+
self.description = description
|
|
8
|
+
self.name = name
|
|
9
|
+
self._id = kwargs.get("id", None)
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class UserTeams:
|
|
13
|
+
def __init__(self, teams: List[TeamModel]):
|
|
14
|
+
self.teams = teams
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class SaveTeamResponse(Base):
|
|
18
|
+
def __init__(self, **kwargs):
|
|
19
|
+
self._id = kwargs.get("id")
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
from ...contact import Contact
|
|
2
|
+
from ....client import Client
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class TeamContactManager:
|
|
6
|
+
def __init__(self, client: Client) -> None:
|
|
7
|
+
self._client = client
|
|
8
|
+
|
|
9
|
+
def create(self, team_id: str, contact: Contact) -> Contact:
|
|
10
|
+
"""Create a new team contact"""
|
|
11
|
+
payload = {
|
|
12
|
+
"team_id": team_id,
|
|
13
|
+
"name": contact.name,
|
|
14
|
+
"type": contact.type,
|
|
15
|
+
"value": contact.value,
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
response = self._client.post(self._full_path(team_id), json=payload)
|
|
19
|
+
|
|
20
|
+
return Contact(**response)
|
|
21
|
+
|
|
22
|
+
@staticmethod
|
|
23
|
+
def _full_path(team_id: str) -> str:
|
|
24
|
+
return "teams/{team_id}/contacts".format(team_id=team_id)
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
from ._models import TeamSettings
|
|
2
|
+
from ...contact import Contact
|
|
3
|
+
from ...subscription import Subscription
|
|
4
|
+
from ....client import Client
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class TeamSettingsManager:
|
|
8
|
+
def __init__(self, client: Client) -> None:
|
|
9
|
+
self._client = client
|
|
10
|
+
|
|
11
|
+
def get(self, team_id: str) -> TeamSettings:
|
|
12
|
+
"""Get team settings"""
|
|
13
|
+
response = self._client.get(self._full_path(team_id))
|
|
14
|
+
|
|
15
|
+
return TeamSettings(
|
|
16
|
+
contacts=[Contact(**contact) for contact in response["contacts"]],
|
|
17
|
+
subscriptions=[Subscription(self._client, **subscription) for subscription in response["subscriptions"]],
|
|
18
|
+
team_id=response["team_id"],
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
@staticmethod
|
|
22
|
+
def _full_path(team_id: str) -> str:
|
|
23
|
+
return "teams/{team_id}/settings".format(team_id=team_id)
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
from typing import List
|
|
2
|
+
|
|
3
|
+
from ...contact import Contact
|
|
4
|
+
from ...subscription import Subscription
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class TeamSettings:
|
|
8
|
+
def __init__(self, contacts: List[Contact], subscriptions: List[Subscription], team_id: str) -> None:
|
|
9
|
+
self.contacts = contacts
|
|
10
|
+
self.subscriptions = subscriptions
|
|
11
|
+
self.team_id = team_id
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
from ...subscription import SubscriptionModel, Subscription
|
|
2
|
+
from ....client import Client
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class TeamSubscriptionManager:
|
|
6
|
+
def __init__(self, client: Client) -> None:
|
|
7
|
+
self._client = client
|
|
8
|
+
|
|
9
|
+
def create(self, team_id: str, subscription: SubscriptionModel) -> Subscription:
|
|
10
|
+
"""Create a new team subscription"""
|
|
11
|
+
payload = {
|
|
12
|
+
"team_id": team_id,
|
|
13
|
+
"contacts": subscription.contacts,
|
|
14
|
+
"tags": subscription.tags,
|
|
15
|
+
"enabled": subscription.enabled,
|
|
16
|
+
"any_tags": subscription.any_tags,
|
|
17
|
+
"throttling": subscription.throttling,
|
|
18
|
+
"sched": subscription.sched,
|
|
19
|
+
"ignore_warnings": subscription.ignore_warnings,
|
|
20
|
+
"ignore_recoverings": subscription.ignore_recoverings,
|
|
21
|
+
"plotting": subscription.plotting,
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
response = self._client.post(self._full_path(team_id), json=payload)
|
|
25
|
+
|
|
26
|
+
return Subscription(self._client, **response)
|
|
27
|
+
|
|
28
|
+
@staticmethod
|
|
29
|
+
def _full_path(team_id: str) -> str:
|
|
30
|
+
return "teams/{team_id}/subscriptions".format(team_id=team_id)
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
from ._models import TeamMembers
|
|
2
|
+
from ....client import Client
|
|
3
|
+
from typing import Optional
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class TeamUserManager:
|
|
7
|
+
def __init__(self, client: Client) -> None:
|
|
8
|
+
self._client = client
|
|
9
|
+
|
|
10
|
+
def get(self, team_id: str) -> TeamMembers:
|
|
11
|
+
"""Get users of a team"""
|
|
12
|
+
response = self._client.get(self._full_path(team_id))
|
|
13
|
+
|
|
14
|
+
return TeamMembers(**response)
|
|
15
|
+
|
|
16
|
+
def add(self, team_id: str, members: TeamMembers) -> TeamMembers:
|
|
17
|
+
"""Add users to a team"""
|
|
18
|
+
payload = {"usernames": members.usernames}
|
|
19
|
+
|
|
20
|
+
response = self._client.post(self._full_path(team_id), json=payload)
|
|
21
|
+
|
|
22
|
+
return TeamMembers(**response)
|
|
23
|
+
|
|
24
|
+
def set(self, team_id: str, members: TeamMembers) -> TeamMembers:
|
|
25
|
+
"""Set users of a team"""
|
|
26
|
+
payload = {"usernames": members.usernames}
|
|
27
|
+
|
|
28
|
+
response = self._client.put(self._full_path(team_id), json=payload)
|
|
29
|
+
|
|
30
|
+
return TeamMembers(**response)
|
|
31
|
+
|
|
32
|
+
def delete(self, team_id: str, team_user_id: str) -> TeamMembers:
|
|
33
|
+
"""Delete a user from a team"""
|
|
34
|
+
response = self._client.delete(self._full_path(team_id, team_user_id))
|
|
35
|
+
|
|
36
|
+
return TeamMembers(**response)
|
|
37
|
+
|
|
38
|
+
@staticmethod
|
|
39
|
+
def _full_path(team_id: str, team_user_id: Optional[str] = None) -> str:
|
|
40
|
+
if team_user_id is None:
|
|
41
|
+
return "teams/{team_id}/users".format(team_id=team_id)
|
|
42
|
+
|
|
43
|
+
return "teams/{team_id}/users/{team_user_id}".format(team_id=team_id, team_user_id=team_user_id)
|
{moira_python_client-4.3.0 → moira_python_client-4.3.1}/moira_python_client.egg-info/SOURCES.txt
RENAMED
|
@@ -22,6 +22,19 @@ moira_client/models/subscription.py
|
|
|
22
22
|
moira_client/models/tag.py
|
|
23
23
|
moira_client/models/trigger.py
|
|
24
24
|
moira_client/models/user.py
|
|
25
|
+
moira_client/models/team/__init__.py
|
|
26
|
+
moira_client/models/team/_managers.py
|
|
27
|
+
moira_client/models/team/_models.py
|
|
28
|
+
moira_client/models/team/contact/__init__.py
|
|
29
|
+
moira_client/models/team/contact/_managers.py
|
|
30
|
+
moira_client/models/team/settings/__init__.py
|
|
31
|
+
moira_client/models/team/settings/_managers.py
|
|
32
|
+
moira_client/models/team/settings/_models.py
|
|
33
|
+
moira_client/models/team/subscription/__init__.py
|
|
34
|
+
moira_client/models/team/subscription/_managers.py
|
|
35
|
+
moira_client/models/team/user/__init__.py
|
|
36
|
+
moira_client/models/team/user/_managers.py
|
|
37
|
+
moira_client/models/team/user/_models.py
|
|
25
38
|
moira_python_client.egg-info/PKG-INFO
|
|
26
39
|
moira_python_client.egg-info/SOURCES.txt
|
|
27
40
|
moira_python_client.egg-info/dependency_links.txt
|
|
@@ -23,7 +23,12 @@ setup(
|
|
|
23
23
|
author_email = 'al.lukyanchenko@gmail.com',
|
|
24
24
|
packages=[
|
|
25
25
|
'moira_client',
|
|
26
|
-
'moira_client.models'
|
|
26
|
+
'moira_client.models',
|
|
27
|
+
'moira_client.models.team',
|
|
28
|
+
'moira_client.models.team.contact',
|
|
29
|
+
'moira_client.models.team.settings',
|
|
30
|
+
'moira_client.models.team.subscription',
|
|
31
|
+
'moira_client.models.team.user',
|
|
27
32
|
],
|
|
28
33
|
classifiers=[
|
|
29
34
|
'Development Status :: 4 - Beta',
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
4.3.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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{moira_python_client-4.3.0 → moira_python_client-4.3.1}/moira_python_client.egg-info/requires.txt
RENAMED
|
File without changes
|
{moira_python_client-4.3.0 → moira_python_client-4.3.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
|