Skip to content

Commit

Permalink
Refactor code with generic classes and adding get methods
Browse files Browse the repository at this point in the history
  • Loading branch information
alfespa17 committed May 18, 2021
1 parent 7ed28b6 commit 88af3cf
Show file tree
Hide file tree
Showing 11 changed files with 38 additions and 31 deletions.
2 changes: 1 addition & 1 deletion api-client-spring-boot-autoconfigure/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<gson.version>2.8.6</gson.version>
<feign.version>11.1</feign.version>
<okhttp.version>4.9.1</okhttp.version>
<revision>0.0.2</revision>
<revision>0.0.3</revision>
<maven.deploy.skip>false</maven.deploy.skip>
</properties>

Expand Down
2 changes: 1 addition & 1 deletion api-client-spring-boot-starter-sample/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<description>Demo project for Spring Boot</description>
<properties>
<java.version>11</java.version>
<revision>0.0.2</revision>
<revision>0.0.3</revision>
<maven.deploy.skip>true</maven.deploy.skip>
</properties>
<dependencies>
Expand Down
2 changes: 1 addition & 1 deletion api-client-spring-boot-starter/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<revision>0.0.2</revision>
<revision>0.0.3</revision>
<maven.deploy.skip>false</maven.deploy.skip>
</properties>

Expand Down
2 changes: 1 addition & 1 deletion api-client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<description>Demo project for Spring Boot</description>
<properties>
<java.version>11</java.version>
<revision>0.0.2</revision>
<revision>0.0.3</revision>
<feign.version>11.1</feign.version>
<maven.deploy.skip>false</maven.deploy.skip>
</properties>
Expand Down
32 changes: 20 additions & 12 deletions api-client/src/main/java/org/azbuilder/api/client/RestClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,49 +2,57 @@

import feign.Param;
import feign.RequestLine;
import org.azbuilder.api.client.model.organization.Organization;
import org.azbuilder.api.client.model.organization.OrganizationResponse;
import org.azbuilder.api.client.model.organization.job.Job;
import org.azbuilder.api.client.model.organization.module.definition.Definition;
import org.azbuilder.api.client.model.organization.module.definition.parameter.Parameter;
import org.azbuilder.api.client.model.organization.module.definition.parameter.ParameterResponse;
import org.azbuilder.api.client.model.organization.workspace.Workspace;
import org.azbuilder.api.client.model.organization.workspace.WorkspaceResponse;
import org.azbuilder.api.client.model.organization.workspace.environment.Environment;
import org.azbuilder.api.client.model.organization.workspace.environment.EnvironmentResponse;
import org.azbuilder.api.client.model.organization.workspace.secret.Secret;
import org.azbuilder.api.client.model.organization.workspace.secret.SecretResponse;
import org.azbuilder.api.client.model.organization.workspace.variable.Variable;
import org.azbuilder.api.client.model.organization.workspace.variable.VariableResponse;

public interface RestClient{
import java.util.List;

public interface RestClient {

@RequestLine("GET /api/v1/organization")
OrganizationResponse<Void> getAllOrganizations();
OrganizationResponse<List<Organization>, Void> getAllOrganizations();

@RequestLine("GET /api/v1/organization?filter[job]=status=={jobStatus}&include=job")
OrganizationResponse<Job> getAllOrganizationsWithJobStatus(@Param("jobStatus") String jobStatus);
OrganizationResponse<List<Organization>, Job> getAllOrganizationsWithJobStatus(@Param("jobStatus") String jobStatus);

@RequestLine("GET /api/v1/organization/{organizationId}/module/{moduleId}/definition/{definitionId}/parameter")
ParameterResponse getAllDefinitions(@Param("organizationId") String organizationId, @Param("moduleId") String moduleId, @Param("definitionId") String definitionId);
ParameterResponse<List<Parameter>> getAllParameters(@Param("organizationId") String organizationId, @Param("moduleId") String moduleId, @Param("definitionId") String definitionId);

@RequestLine("GET /api/v1/organization/{organizationId}/workspace/{workspaceId}/secret")
SecretResponse getAllSecrets(@Param("organizationId") String organizationId, @Param("workspaceId") String workspaceId);
SecretResponse<List<Secret>> getAllSecrets(@Param("organizationId") String organizationId, @Param("workspaceId") String workspaceId);

@RequestLine("GET /api/v1/organization/{organizationId}/workspace/{workspaceId}/variable")
VariableResponse getAllVariables(@Param("organizationId") String organizationId, @Param("workspaceId") String workspaceId);
VariableResponse<List<Variable>> getAllVariables(@Param("organizationId") String organizationId, @Param("workspaceId") String workspaceId);

@RequestLine("GET /api/v1/organization/{organizationId}/workspace/{workspaceId}/environment")
EnvironmentResponse<List<Environment>> getAllEnvironmentVariables(@Param("organizationId") String organizationId, @Param("workspaceId") String workspaceId);

@RequestLine("GET /api/v1/organization/{organizationId}/workspace")
WorkspaceResponse<Void> getAllWorkspaces(@Param("organizationId") String organizationId);
WorkspaceResponse<List<Workspace>, Void> getAllWorkspaces(@Param("organizationId") String organizationId);

@RequestLine("GET /api/v1/organization/{organizationId}/workspace/{workspaceId}?include=definition")
WorkspaceResponse<Definition> getWorkspaceByIdWithModuleDefinition(@Param("organizationId") String organizationId, @Param("workspaceId") String workspaceId);
WorkspaceResponse<Workspace,Definition> getWorkspaceByIdWithModuleDefinition(@Param("organizationId") String organizationId, @Param("workspaceId") String workspaceId);

@RequestLine("GET /api/v1/organization/{organizationId}/workspace/{workspaceId}?include=variable")
WorkspaceResponse<Variable> getWorkspaceByIdWithVariables(@Param("organizationId") String organizationId, @Param("workspaceId") String workspaceId);
WorkspaceResponse<Workspace, Variable> getWorkspaceByIdWithVariables(@Param("organizationId") String organizationId, @Param("workspaceId") String workspaceId);

@RequestLine("GET /api/v1/organization/{organizationId}/workspace/{workspaceId}?include=secret")
WorkspaceResponse<Secret> getWorkspaceByIdWithSecrets(@Param("organizationId") String organizationId, @Param("workspaceId") String workspaceId);
WorkspaceResponse<Workspace, Secret> getWorkspaceByIdWithSecrets(@Param("organizationId") String organizationId, @Param("workspaceId") String workspaceId);

@RequestLine("GET /api/v1/organization/{organizationId}/workspace/{workspaceId}?include=environment")
WorkspaceResponse<Environment> getWorkspaceByWithEnvironmentVariables(@Param("organizationId") String organizationId, @Param("workspaceId") String workspaceId);

WorkspaceResponse<Workspace, Environment> getWorkspaceByIdWithEnvironmentVariables(@Param("organizationId") String organizationId, @Param("workspaceId") String workspaceId);


}
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@

@Getter
@Setter
public class OrganizationResponse<T> {

List<Organization> data;
List<T> included;
public class OrganizationResponse<T1,T2> {
T1 data;
List<T2> included;
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@

@Getter
@Setter
public class ParameterResponse {
List<Parameter> data;
public class ParameterResponse<T1> {
T1 data;
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

@Getter
@Setter
public class WorkspaceResponse<T> {
List<Workspace> data;
List<T> included;
public class WorkspaceResponse<T1,T2> {
T1 data;
List<T2> included;
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@

@Getter
@Setter
public class EnvironmentResponse {
List<Environment> data;
public class EnvironmentResponse<T1> {
T1 data;
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@

@Getter
@Setter
public class SecretResponse {
List<Secret> data;
public class SecretResponse<T1> {
T1 data;
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@

@Getter
@Setter
public class VariableResponse {
List<Variable> data;
public class VariableResponse<T1> {
T1 data;
}

0 comments on commit 88af3cf

Please sign in to comment.