Class GithubTeamService
java.lang.Object
edu.ucsb.cs156.frontiers.services.GithubTeamService
-
Constructor Summary
ConstructorsConstructorDescriptionGithubTeamService
(JwtService jwtService, com.fasterxml.jackson.databind.ObjectMapper objectMapper, org.springframework.boot.web.client.RestTemplateBuilder builder) -
Method Summary
Modifier and TypeMethodDescriptionaddMemberToGithubTeam
(String githubLogin, Integer teamId, String role, Course course, Integer orgId) Adds a member to a GitHub team.createOrGetTeamId
(Team team, Course course) Creates a team on GitHub if it doesn't exist, or returns the existing team ID.Get the org id, given the org name.Gets the team ID for a team name, returns null if team doesn't exist.getTeamMembershipStatus
(String githubLogin, Integer teamId, Course course) Gets the current team membership status for a user.
-
Constructor Details
-
GithubTeamService
public GithubTeamService(JwtService jwtService, com.fasterxml.jackson.databind.ObjectMapper objectMapper, org.springframework.boot.web.client.RestTemplateBuilder builder)
-
-
Method Details
-
createOrGetTeamId
public Integer createOrGetTeamId(Team team, Course course) throws com.fasterxml.jackson.core.JsonProcessingException, NoSuchAlgorithmException, InvalidKeySpecException Creates a team on GitHub if it doesn't exist, or returns the existing team ID.- Parameters:
team
- The team to createcourse
- The course containing the organization- Returns:
- The GitHub team ID
- Throws:
com.fasterxml.jackson.core.JsonProcessingException
- if there is an error processing JSONNoSuchAlgorithmException
- if there is an algorithm errorInvalidKeySpecException
- if there is a key specification error
-
getOrgId
public Integer getOrgId(String orgName, Course course) throws com.fasterxml.jackson.core.JsonProcessingException, NoSuchAlgorithmException, InvalidKeySpecException Get the org id, given the org name.Note: in the future, it would be better to cache this value in the Course row in the database at the time the Github App is linked to the org, since it doesn't change.
- Parameters:
orgName
-course
-- Returns:
- Throws:
com.fasterxml.jackson.core.JsonProcessingException
NoSuchAlgorithmException
InvalidKeySpecException
-
getTeamId
public Integer getTeamId(String teamName, Course course) throws com.fasterxml.jackson.core.JsonProcessingException, NoSuchAlgorithmException, InvalidKeySpecException Gets the team ID for a team name, returns null if team doesn't exist.- Parameters:
teamName
- The name of the teamcourse
- The course containing the organization- Returns:
- The GitHub team ID or null if not found
- Throws:
com.fasterxml.jackson.core.JsonProcessingException
- if there is an error processing JSONNoSuchAlgorithmException
- if there is an algorithm errorInvalidKeySpecException
- if there is a key specification error
-
getTeamMembershipStatus
public TeamStatus getTeamMembershipStatus(String githubLogin, Integer teamId, Course course) throws com.fasterxml.jackson.core.JsonProcessingException, NoSuchAlgorithmException, InvalidKeySpecException Gets the current team membership status for a user.- Parameters:
githubLogin
- The GitHub login of the userteamId
- The GitHub team IDcourse
- The course containing the organization- Returns:
- The team status of the user
- Throws:
com.fasterxml.jackson.core.JsonProcessingException
- if there is an error processing JSONNoSuchAlgorithmException
- if there is an algorithm errorInvalidKeySpecException
- if there is a key specification error
-
addMemberToGithubTeam
public TeamStatus addMemberToGithubTeam(String githubLogin, Integer teamId, String role, Course course, Integer orgId) throws com.fasterxml.jackson.core.JsonProcessingException, NoSuchAlgorithmException, InvalidKeySpecException Adds a member to a GitHub team.- Parameters:
githubLogin
- The GitHub login of the user to addrole
- The role to assign ("member" or "maintainer")course
- The course containing the organizationteamSlug
- The GitHub team slug (name)- Returns:
- The resulting team status
- Throws:
com.fasterxml.jackson.core.JsonProcessingException
- if there is an error processing JSONNoSuchAlgorithmException
- if there is an algorithm errorInvalidKeySpecException
- if there is a key specification error
-