Skip to content

Commit

Permalink
Add TeamRepo put API
Browse files Browse the repository at this point in the history
  • Loading branch information
samad-yar-khan committed Apr 23, 2024
1 parent 6450d0c commit 0e0270e
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions backend/analytics_server/mhq/api/teams.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
from flask import Blueprint
from typing import List
from voluptuous import Required, Schema, Optional
from typing import Any, Dict, List
from voluptuous import Required, Schema, Optional, All, Coerce
from mhq.service.code.models.org_repo import RawOrgRepo
from mhq.api.resources.code_resouces import adapt_org_repo
from mhq.service.code.repository_service import get_repository_service
from mhq.api.resources.core_resources import adapt_team
from mhq.store.models.core.teams import Team
from mhq.service.core.teams import get_team_service

from mhq.api.request_utils import dataschema
from mhq.api.request_utils import coerce_org_repos, dataschema
from mhq.service.query_validator import get_query_validator

app = Blueprint("teams", __name__)
Expand Down Expand Up @@ -90,3 +91,21 @@ def fetch_team_repos(team_id: str):
team_repos = get_repository_service().get_team_repos(team)

return [adapt_org_repo(repo) for repo in team_repos]


@app.route("/teams/<team_id>/repos", methods={"PUT"})
@dataschema(
Schema(
{
Required("repos"): All(list, Coerce(coerce_org_repos)),
}
),
)
def update_team_repos(team_id: str, repos: List[RawOrgRepo]):

query_validator = get_query_validator()
team: Team = query_validator.team_validator(team_id)

team_repos = get_repository_service().update_team_repos(team, repos)

return [adapt_org_repo(repo) for repo in team_repos]

0 comments on commit 0e0270e

Please sign in to comment.