def get_team(team_id): """Return a specific team. .. :quickref: GET; Return a specific team. **Example request**: .. sourcecode:: http GET /teams/76b96ead-a7ed-447b-8fa6-26b57bc571e5 HTTP/1.1 Host: example.com Accept: application/json **Example response**: .. sourcecode:: http HTTP/1.1 200 OK { 'createdAt': '2019-01-15T11:44:23Z', 'id': '76b96ead-a7ed-447b-8fa6-26b57bc571e5', 'name': 'My team', 'updatedAt': '2019-01-15T11:44:23Z' } :resheader Content-Type: application/json :status 200: the team """ team = TeamController.get(filters={"Team": {"id": team_id}}) return jsonify(format_team(team)), 200
def list_team_checks(cls, team_id): from depc.controllers.teams import TeamController _ = TeamController.get({"Team": {"id": team_id}}) checks = ( db.session.query(Check) .join(Source, Source.id == Check.source_id) .join(Team, Team.id == Source.team_id) .filter(Team.id == team_id) .all() ) return [cls.resource_to_dict(c) for c in checks]
def list_teams(): """Return the list of teams. .. :quickref: GET; Return the list of teams. **Example request**: .. sourcecode:: http GET /teams HTTP/1.1 Host: example.com Accept: application/json **Example response**: .. sourcecode:: http HTTP/1.1 200 OK { 'teams': [{ 'createdAt': '2019-01-15T10:24:35Z', 'id': '5b513051-74b4-4eea-9739-5c5053c3d37c', 'name': 'My team', 'updatedAt': '2019-01-15T10:24:35Z' }] } :resheader Content-Type: application/json :status 200: list of teams """ name = request.args.get("name", None) # Search team by name if name: team = TeamController.get(filters={"Team": {"name": name}}) return jsonify(format_team(team)), 200 # Otherwise list of the teams teams = TeamController.list() return jsonify({"teams": [format_team(s) for s in teams]}), 200