Skip to content
This repository has been archived by the owner on Apr 14, 2021. It is now read-only.

Commit

Permalink
Add support to Team resource
Browse files Browse the repository at this point in the history
  • Loading branch information
joaodaher committed Jun 28, 2019
1 parent e930e0f commit 60e098f
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
2 changes: 2 additions & 0 deletions tsuru/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
Log,
Plan,
Platform,
Team,
)
from tsuru.exceptions import (
DoesNotExist,
Expand All @@ -25,6 +26,7 @@
'Log',
'Plan',
'Platform',
'Team',
'DoesNotExist',
'UnexpectedDataFormat',
'UnsupportedModelException',
Expand Down
2 changes: 2 additions & 0 deletions tsuru/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from tsuru.models.log import Log
from tsuru.models.plan import Plan
from tsuru.models.platform import Platform
from tsuru.models.team import Team
__all__ = (
'App',
'Deploy',
Expand All @@ -13,4 +14,5 @@
'Log',
'Plan',
'Platform',
'Team',
)
25 changes: 25 additions & 0 deletions tsuru/models/team.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
from tsuru import exceptions
from tsuru.models.base import BaseModel


class Team(BaseModel):
_RESOURCE_NAME = 'teams'
_PK_FIELD = 'name'

@classmethod
def get(cls, pk):
# Since /teams endpoint does not support detail,
# we fetch-all-and-match
all_teams = cls.list()
for team in all_teams:
if team.pk == pk:
return team
raise exceptions.DoesNotExist()

@property
def name(self):
return self._get('name')

@property
def permissions(self):
return self._get('permissions')

0 comments on commit 60e098f

Please sign in to comment.