Skip to content

Commit

Permalink
fix(github): Use new github teams api as old one is deprecated (#907) (
Browse files Browse the repository at this point in the history
…#910)

* fix(github): Use new github teams api

https://github.blog/changelog/2022-02-22-sunset-notice-deprecated-teams-api-endpoints/

* refactor(github): Remove unused function

* chore(gradle): spotless apply

Co-authored-by: David Constenla <1520001+daconstenla@users.noreply.github.com>

* refactor(github): clean up unused functions

* refactor(github): delete unused model

Co-authored-by: David Constenla <1520001+daconstenla@users.noreply.github.com>
(cherry picked from commit 665b5fe)

Co-authored-by: Thomas Schaaf <schaaf@komola.de>
  • Loading branch information
mergify[bot] and thomaschaaf committed Mar 1, 2022
1 parent 9010e21 commit a881f98
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 44 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,9 @@ public Set<String> load(Long key) {
int page = 1;
boolean hasMorePages = true;
do {
List<Member> members = getMembersInTeamPaginated(key, page++);
List<Member> members =
getMembersInTeamPaginated(
gitHubProperties.getOrganization(), key, page++);
members.forEach(m -> memberships.add(m.getLogin().toLowerCase()));
if (members.size() != gitHubProperties.paginationValue) {
hasMorePages = false;
Expand Down Expand Up @@ -295,11 +297,13 @@ private List<Member> getMembersInOrgPaginated(String organization, int page) {
return members;
}

private List<Member> getMembersInTeamPaginated(Long teamId, int page) {
private List<Member> getMembersInTeamPaginated(String organization, Long teamId, int page) {
List<Member> members = new ArrayList<>();
try {
log.debug("Requesting page " + page + " of members team " + teamId + ".");
members = gitHubClient.getMembersOfTeam(teamId, page, gitHubProperties.paginationValue);
members =
gitHubClient.getMembersOfTeam(
organization, teamId, page, gitHubProperties.paginationValue);
} catch (RetrofitError e) {
if (e.getResponse().getStatus() != 404) {
handleNon404s(e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,14 @@

import com.netflix.spinnaker.fiat.roles.github.model.Member;
import com.netflix.spinnaker.fiat.roles.github.model.Team;
import com.netflix.spinnaker.fiat.roles.github.model.TeamMembership;
import java.util.List;
import retrofit.client.Response;
import retrofit.http.GET;
import retrofit.http.Path;
import retrofit.http.Query;

/** Retrofit interface for interacting with a GitHub REST API. */
public interface GitHubClient {

@GET("/orgs/{org}/members/{username}")
Response isMemberOfOrganization(@Path("org") String org, @Path("username") String username);

/** This one should use the Current User credentials */
@GET("/user/teams")
List<Team> getUserTeams();

@GET("/orgs/{org}/teams")
List<Team> getOrgTeams(
@Path("org") String org, @Query("page") int page, @Query("per_page") int paginationValue);
Expand All @@ -43,10 +34,10 @@ List<Team> getOrgTeams(
List<Member> getOrgMembers(
@Path("org") String org, @Query("page") int page, @Query("per_page") int paginationValue);

@GET("/teams/{idTeam}/members")
@GET("/orgs/{org}/teams/{idTeam}/members")
List<Member> getMembersOfTeam(
@Path("idTeam") Long idTeam, @Query("page") int page, @Query("per_page") int paginationValue);

@GET("/teams/{idTeam}/memberships/{username}")
TeamMembership isMemberOfTeam(@Path("idTeam") Long idTeam, @Path("username") String username);
@Path("org") String org,
@Path("idTeam") Long idTeam,
@Query("page") int page,
@Query("per_page") int paginationValue);
}

This file was deleted.

0 comments on commit a881f98

Please sign in to comment.