-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add support for Team APIs (#42)
- Loading branch information
Showing
31 changed files
with
1,106 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
# 4.3.0 | ||
|
||
Add support for Team APIs | ||
|
||
# 4.2.1 | ||
|
||
Add support for name field in contacts | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -126,3 +126,160 @@ for contact in contacts: | |
contact_id = moira.contact.get_id(type='slack', value='#err') | ||
print(contact_id) | ||
``` | ||
|
||
## Team | ||
|
||
### Get all teams | ||
```python | ||
teams = moira.team.get_all() | ||
``` | ||
|
||
### Create a new team | ||
```python | ||
from moira_client.models.team import TeamModel | ||
|
||
team = TeamModel( | ||
description="Team that holds all members of infrastructure division", | ||
name="Infrastructure Team", | ||
) | ||
|
||
saved_team = moira.team.create(team) | ||
``` | ||
|
||
### Delete a team | ||
```python | ||
team_id = "d5d98eb3-ee18-4f75-9364-244f67e23b54" | ||
|
||
deleted_team = moira.team.delete(team_id) | ||
``` | ||
|
||
### Get a team by ID | ||
```python | ||
team_id = "d5d98eb3-ee18-4f75-9364-244f67e23b54" | ||
|
||
team = moira.team.get(team_id) | ||
``` | ||
|
||
### Update existing team | ||
```python | ||
from moira_client.models.team import TeamModel | ||
|
||
team_id = "d5d98eb3-ee18-4f75-9364-244f67e23b54" | ||
team = TeamModel( | ||
description="Team that holds all members of infrastructure division", | ||
name="Infrastructure Team", | ||
) | ||
|
||
updated_team = moira.team.update(team_id, team) | ||
``` | ||
|
||
### Team Settings | ||
|
||
#### Get team settings | ||
```python | ||
team_id = "d5d98eb3-ee18-4f75-9364-244f67e23b54" | ||
|
||
settings = moira.team.settings.get(team_id) | ||
``` | ||
|
||
### Team User | ||
|
||
#### Get users of a team | ||
|
||
```python | ||
team_id = "d5d98eb3-ee18-4f75-9364-244f67e23b54" | ||
|
||
users = moira.team.user.get(team_id) | ||
``` | ||
|
||
#### Add users to a team | ||
|
||
```python | ||
from moira_client.models.team.user import TeamMembers | ||
|
||
team_id = "d5d98eb3-ee18-4f75-9364-244f67e23b54" | ||
users_to_add = TeamMembers(usernames=["anonymous", ]) | ||
|
||
users = moira.team.user.add(team_id, users_to_add) | ||
``` | ||
|
||
#### Set users of a team | ||
|
||
```python | ||
from moira_client.models.team.user import TeamMembers | ||
|
||
team_id = "d5d98eb3-ee18-4f75-9364-244f67e23b54" | ||
users_to_set = TeamMembers(usernames=["anonymous", ]) | ||
|
||
users = moira.team.user.set(team_id, users_to_set) | ||
``` | ||
|
||
#### Delete a user from a team | ||
|
||
```python | ||
team_id = "d5d98eb3-ee18-4f75-9364-244f67e23b54" | ||
team_user_id = "anonymous" | ||
|
||
users = moira.team.user.delete(team_id, team_user_id) | ||
``` | ||
|
||
### Team Subscription | ||
|
||
#### Create a new team subscription | ||
|
||
```python | ||
from moira_client.models.subscription import SubscriptionModel | ||
|
||
team_id = "d5d98eb3-ee18-4f75-9364-244f67e23b54" | ||
subscription_to_create = SubscriptionModel( | ||
any_tags=False, | ||
contacts=[ | ||
"acd2db98-1659-4a2f-b227-52d71f6e3ba1" | ||
], | ||
enabled=True, | ||
ignore_recoverings=False, | ||
ignore_warnings=False, | ||
plotting={ | ||
"enabled": True, | ||
"theme": "dark" | ||
}, | ||
sched={ | ||
"days": [ | ||
{ | ||
"enabled": True, | ||
"name": "Mon" | ||
} | ||
], | ||
"endOffset": 1439, | ||
"startOffset": 0, | ||
"tzOffset": -60 | ||
}, | ||
tags=[ | ||
"server", | ||
"cpu" | ||
], | ||
throttling=False, | ||
user="", | ||
) | ||
|
||
subscription = moira.team.subscription.create(team_id, subscription_to_create) | ||
``` | ||
|
||
### Team Contact | ||
|
||
#### Create a new team contact | ||
|
||
```python | ||
from moira_client.models.contact import Contact | ||
|
||
team_id = "d5d98eb3-ee18-4f75-9364-244f67e23b54" | ||
contact_to_create = Contact( | ||
name="Mail Alerts", | ||
team_id=team_id, | ||
type="mail", | ||
user="", | ||
value="[email protected]", | ||
) | ||
|
||
contact = moira.team.contact.create(team_id, contact_to_create) | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
4.2.1 | ||
4.3.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
from ._managers import TeamManager | ||
from ._models import TeamModel | ||
|
||
|
||
__all__ = [ | ||
"TeamManager", | ||
"TeamModel", | ||
] |
Oops, something went wrong.