Class GithubTeamService
java.lang.Object
edu.ucsb.cs156.frontiers.services.GithubTeamService
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordstatic final record -
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.createOrGetTeamInfo(Team team, Course course) Creates a team on GitHub if it doesn't exist, or returns the existing team info.createTeam(String teamName, Course course) Creates a new team on GitHub.createTeamInfo(String teamName, Course course) Creates a new team on GitHub.voiddeleteGithubTeam(Integer orgId, Integer teamId, Course course) Deletes a team on GitHub.getAllTeams(Course course) Returns all teams for an organization, following pagination links when present.Get the org id, given the org name.Gets the team ID for a team slug, returns null if team doesn't exist.getTeamInfo(String teamSlug, Course course) Gets the team info for a team slug, returns null if team doesn't exist.getTeamInfoById(Integer orgId, Integer teamId, Course course) Gets the team info for a team ID, returns null if team doesn't exist.getTeamInfoByName(String teamName, Course course) Finds team info by display name by searching the organization's teams.getTeamMemberships(String teamSlug, Course course) Returns all team members for a GitHub team.getTeamMembershipStatus(String githubLogin, Integer teamId, Course course, Integer orgId) Gets the current team membership status for a user.voidremoveMemberFromGithubTeam(Integer orgId, String githubLogin, Integer teamId, Course course) Removes a member from a GitHub team
-
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
-
createOrGetTeamInfo
public GithubTeamService.GithubTeamInfo createOrGetTeamInfo(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 info.- Parameters:
team- The team to createcourse- The course containing the organization- Returns:
- The GitHub team info
- 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.JsonProcessingExceptionNoSuchAlgorithmExceptionInvalidKeySpecException
-
getTeamId
public Integer getTeamId(String teamSlug, Course course) throws com.fasterxml.jackson.core.JsonProcessingException, NoSuchAlgorithmException, InvalidKeySpecException Gets the team ID for a team slug, returns null if team doesn't exist.- Parameters:
teamSlug- The slug 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
-
getTeamInfo
public GithubTeamService.GithubTeamInfo getTeamInfo(String teamSlug, Course course) throws com.fasterxml.jackson.core.JsonProcessingException, NoSuchAlgorithmException, InvalidKeySpecException Gets the team info for a team slug, returns null if team doesn't exist.- Parameters:
teamSlug- The slug of the teamcourse- The course containing the organization- Returns:
- The GitHub team info 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
-
getTeamInfoById
public GithubTeamService.GithubTeamInfo getTeamInfoById(Integer orgId, Integer teamId, Course course) throws com.fasterxml.jackson.core.JsonProcessingException, NoSuchAlgorithmException, InvalidKeySpecException Gets the team info for a team ID, returns null if team doesn't exist.- Parameters:
orgId- The GitHub organization IDteamId- The GitHub team IDcourse- The course containing the organization- Returns:
- The GitHub team info 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
-
getTeamInfoByName
public GithubTeamService.GithubTeamInfo getTeamInfoByName(String teamName, Course course) throws com.fasterxml.jackson.core.JsonProcessingException, NoSuchAlgorithmException, InvalidKeySpecException Finds team info by display name by searching the organization's teams.- Parameters:
teamName- The display name of the teamcourse- The course containing the organization- Returns:
- The GitHub team info 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
-
createTeam
public Integer createTeam(String teamName, Course course) throws com.fasterxml.jackson.core.JsonProcessingException, NoSuchAlgorithmException, InvalidKeySpecException Creates a new team on GitHub.- Parameters:
teamName- The name of 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
-
createTeamInfo
public GithubTeamService.GithubTeamInfo createTeamInfo(String teamName, Course course) throws com.fasterxml.jackson.core.JsonProcessingException, NoSuchAlgorithmException, InvalidKeySpecException Creates a new team on GitHub.- Parameters:
teamName- The name of the team to createcourse- The course containing the organization- Returns:
- The GitHub team info
- 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
-
deleteGithubTeam
public void deleteGithubTeam(Integer orgId, Integer teamId, Course course) throws com.fasterxml.jackson.core.JsonProcessingException, NoSuchAlgorithmException, InvalidKeySpecException Deletes a team on GitHub.- Parameters:
orgId- The ID of the organizationcourse- The course containing the organizationgithubTeamId- The ID of the team to delete- 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, Integer orgId) 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 organizationorgId- The GitHub organization ID- 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 addteamId- The GitHub team IDrole- The role to assign ("member" or "maintainer")course- The course containing the organization- 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
-
removeMemberFromGithubTeam
public void removeMemberFromGithubTeam(Integer orgId, String githubLogin, Integer teamId, Course course) throws NoSuchAlgorithmException, InvalidKeySpecException, com.fasterxml.jackson.core.JsonProcessingException Removes a member from a GitHub team- Parameters:
orgId-githubLogin-teamId-course-- Throws:
NoSuchAlgorithmExceptionInvalidKeySpecExceptioncom.fasterxml.jackson.core.JsonProcessingException
-
getTeamMemberships
public Map<String,TeamStatus> getTeamMemberships(String teamSlug, Course course) throws NoSuchAlgorithmException, InvalidKeySpecException, com.fasterxml.jackson.core.JsonProcessingException Returns all team members for a GitHub team.- Parameters:
teamSlug- The GitHub team slugcourse- The course containing the organization- Returns:
- A map of github login to TeamStatus
- Throws:
NoSuchAlgorithmException- if there is an algorithm errorInvalidKeySpecException- if there is a key specification errorcom.fasterxml.jackson.core.JsonProcessingException- if there is an error processing JSON
-
getAllTeams
public List<GithubTeamService.GithubTeamInfo> getAllTeams(Course course) throws NoSuchAlgorithmException, InvalidKeySpecException, com.fasterxml.jackson.core.JsonProcessingException Returns all teams for an organization, following pagination links when present.- Parameters:
course- The course containing the organization- Returns:
- A list of GitHub teams with id and name
- Throws:
NoSuchAlgorithmException- if there is an algorithm errorInvalidKeySpecException- if there is a key specification errorcom.fasterxml.jackson.core.JsonProcessingException- if there is an error processing JSON
-