// Path: fiat-github/src/main/java/com/netflix/spinnaker/fiat/roles/github/GitHubProperties.java
// @Configuration
// @ConditionalOnProperty(value = "auth.group-membership.service", havingValue = "github")
// @ConfigurationProperties(prefix = "auth.group-membership.github")
// @Data
// public class GitHubProperties {
//   @NotEmpty private String baseUrl;
//   @NotEmpty private String accessToken;
//   @NotEmpty private String organization;
// 
//   @NotNull
//   @Max(100L)
//   @Min(1L)
//   Integer paginationValue = 100;
// 
//   @NotNull Integer membershipCacheTTLSeconds = 60 * 10; // 10 min time to refresh
//   @NotNull Integer membershipCacheTeamsSize = 1000; // 1000 github teams
// }
// 
// Path: fiat-github/src/main/java/com/netflix/spinnaker/fiat/roles/github/client/GitHubClient.java
// 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);
// 
//   @GET("/orgs/{org}/members")
//   List<Member> getOrgMembers(
//       @Path("org") String org, @Query("page") int page, @Query("per_page") int paginationValue);
// 
//   @GET("/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);
// }


import com.jakewharton.retrofit.Ok3Client;
import com.netflix.spinnaker.config.DefaultServiceEndpoint;
import com.netflix.spinnaker.config.okhttp3.OkHttpClientProvider;
import com.netflix.spinnaker.fiat.roles.github.GitHubProperties;
import com.netflix.spinnaker.fiat.roles.github.client.GitHubClient;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import retrofit.Endpoints;
import retrofit.RequestInterceptor;
import retrofit.RestAdapter;
import retrofit.converter.JacksonConverter;
package com.netflix.spinnaker.fiat.config;


/**
 * Converts the list of GitHub Configuration properties a collection of clients to access the GitHub
 * hosts
 */
@Configuration
@ConditionalOnProperty(value = "auth.group-membership.service", havingValue = "github")
@Slf4j
public class GitHubConfig {

  @Autowired @Setter private RestAdapter.LogLevel retrofitLogLevel;

  @Autowired @Setter private GitHubProperties gitHubProperties;

  @Bean
  public GitHubClient gitHubClient(OkHttpClientProvider clientProvider) {
    BasicAuthRequestInterceptor interceptor =
        new BasicAuthRequestInterceptor().setAccessToken(gitHubProperties.getAccessToken());

    return new RestAdapter.Builder()
        .setEndpoint(Endpoints.newFixedEndpoint(gitHubProperties.getBaseUrl()))
        .setRequestInterceptor(interceptor)
        .setClient(
// Path: fiat-github/src/main/java/com/netflix/spinnaker/fiat/roles/github/GitHubProperties.java
// @Configuration
// @ConditionalOnProperty(value = "auth.group-membership.service", havingValue = "github")
// @ConfigurationProperties(prefix = "auth.group-membership.github")
// @Data
// public class GitHubProperties {
//   @NotEmpty private String baseUrl;
//   @NotEmpty private String accessToken;
//   @NotEmpty private String organization;
// 
//   @NotNull
//   @Max(100L)
//   @Min(1L)
//   Integer paginationValue = 100;
// 
//   @NotNull Integer membershipCacheTTLSeconds = 60 * 10; // 10 min time to refresh
//   @NotNull Integer membershipCacheTeamsSize = 1000; // 1000 github teams
// }
// 
// Path: fiat-github/src/main/java/com/netflix/spinnaker/fiat/roles/github/client/GitHubClient.java
// 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);
// 
//   @GET("/orgs/{org}/members")
//   List<Member> getOrgMembers(
//       @Path("org") String org, @Query("page") int page, @Query("per_page") int paginationValue);
// 
//   @GET("/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: fiat-github/src/main/java/com/netflix/spinnaker/fiat/config/GitHubConfig.java
import com.jakewharton.retrofit.Ok3Client;
import com.netflix.spinnaker.config.DefaultServiceEndpoint;
import com.netflix.spinnaker.config.okhttp3.OkHttpClientProvider;
import com.netflix.spinnaker.fiat.roles.github.GitHubProperties;
import com.netflix.spinnaker.fiat.roles.github.client.GitHubClient;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import retrofit.Endpoints;
import retrofit.RequestInterceptor;
import retrofit.RestAdapter;
import retrofit.converter.JacksonConverter;

package com.netflix.spinnaker.fiat.config;


/**
 * Converts the list of GitHub Configuration properties a collection of clients to access the GitHub
 * hosts
 */
@Configuration
@ConditionalOnProperty(value = "auth.group-membership.service", havingValue = "github")
@Slf4j
public class GitHubConfig {

  @Autowired @Setter private RestAdapter.LogLevel retrofitLogLevel;

  @Autowired @Setter private GitHubProperties gitHubProperties;

  @Bean
  public GitHubClient gitHubClient(OkHttpClientProvider clientProvider) {
    BasicAuthRequestInterceptor interceptor =
        new BasicAuthRequestInterceptor().setAccessToken(gitHubProperties.getAccessToken());

    return new RestAdapter.Builder()
        .setEndpoint(Endpoints.newFixedEndpoint(gitHubProperties.getBaseUrl()))
        .setRequestInterceptor(interceptor)
        .setClient(
            new Ok3Client(