From 88af3cf910a43266f15b79d0dcaf0e54b37a6fac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alfredo=20Espa=C3=B1a?= Date: Tue, 18 May 2021 17:18:41 -0600 Subject: [PATCH] Refactor code with generic classes and adding get methods --- api-client-spring-boot-autoconfigure/pom.xml | 2 +- api-client-spring-boot-starter-sample/pom.xml | 2 +- api-client-spring-boot-starter/pom.xml | 2 +- api-client/pom.xml | 2 +- .../org/azbuilder/api/client/RestClient.java | 32 ++++++++++++------- .../organization/OrganizationResponse.java | 7 ++-- .../parameter/ParameterResponse.java | 4 +-- .../workspace/WorkspaceResponse.java | 6 ++-- .../environment/EnvironmentResponse.java | 4 +-- .../workspace/secret/SecretResponse.java | 4 +-- .../workspace/variable/VariableResponse.java | 4 +-- 11 files changed, 38 insertions(+), 31 deletions(-) diff --git a/api-client-spring-boot-autoconfigure/pom.xml b/api-client-spring-boot-autoconfigure/pom.xml index 8d802c0..84720d2 100644 --- a/api-client-spring-boot-autoconfigure/pom.xml +++ b/api-client-spring-boot-autoconfigure/pom.xml @@ -19,7 +19,7 @@ 2.8.6 11.1 4.9.1 - 0.0.2 + 0.0.3 false diff --git a/api-client-spring-boot-starter-sample/pom.xml b/api-client-spring-boot-starter-sample/pom.xml index 213b379..f4285c4 100644 --- a/api-client-spring-boot-starter-sample/pom.xml +++ b/api-client-spring-boot-starter-sample/pom.xml @@ -15,7 +15,7 @@ Demo project for Spring Boot 11 - 0.0.2 + 0.0.3 true diff --git a/api-client-spring-boot-starter/pom.xml b/api-client-spring-boot-starter/pom.xml index a4543c4..9724628 100644 --- a/api-client-spring-boot-starter/pom.xml +++ b/api-client-spring-boot-starter/pom.xml @@ -13,7 +13,7 @@ UTF-8 - 0.0.2 + 0.0.3 false diff --git a/api-client/pom.xml b/api-client/pom.xml index c83203e..0c21640 100644 --- a/api-client/pom.xml +++ b/api-client/pom.xml @@ -15,7 +15,7 @@ Demo project for Spring Boot 11 - 0.0.2 + 0.0.3 11.1 false diff --git a/api-client/src/main/java/org/azbuilder/api/client/RestClient.java b/api-client/src/main/java/org/azbuilder/api/client/RestClient.java index 4f85f8c..8e13823 100644 --- a/api-client/src/main/java/org/azbuilder/api/client/RestClient.java +++ b/api-client/src/main/java/org/azbuilder/api/client/RestClient.java @@ -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 getAllOrganizations(); + OrganizationResponse, Void> getAllOrganizations(); @RequestLine("GET /api/v1/organization?filter[job]=status=={jobStatus}&include=job") - OrganizationResponse getAllOrganizationsWithJobStatus(@Param("jobStatus") String jobStatus); + OrganizationResponse, 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> 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> 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> getAllVariables(@Param("organizationId") String organizationId, @Param("workspaceId") String workspaceId); + + @RequestLine("GET /api/v1/organization/{organizationId}/workspace/{workspaceId}/environment") + EnvironmentResponse> getAllEnvironmentVariables(@Param("organizationId") String organizationId, @Param("workspaceId") String workspaceId); @RequestLine("GET /api/v1/organization/{organizationId}/workspace") - WorkspaceResponse getAllWorkspaces(@Param("organizationId") String organizationId); + WorkspaceResponse, Void> getAllWorkspaces(@Param("organizationId") String organizationId); @RequestLine("GET /api/v1/organization/{organizationId}/workspace/{workspaceId}?include=definition") - WorkspaceResponse getWorkspaceByIdWithModuleDefinition(@Param("organizationId") String organizationId, @Param("workspaceId") String workspaceId); + WorkspaceResponse getWorkspaceByIdWithModuleDefinition(@Param("organizationId") String organizationId, @Param("workspaceId") String workspaceId); @RequestLine("GET /api/v1/organization/{organizationId}/workspace/{workspaceId}?include=variable") - WorkspaceResponse getWorkspaceByIdWithVariables(@Param("organizationId") String organizationId, @Param("workspaceId") String workspaceId); + WorkspaceResponse getWorkspaceByIdWithVariables(@Param("organizationId") String organizationId, @Param("workspaceId") String workspaceId); @RequestLine("GET /api/v1/organization/{organizationId}/workspace/{workspaceId}?include=secret") - WorkspaceResponse getWorkspaceByIdWithSecrets(@Param("organizationId") String organizationId, @Param("workspaceId") String workspaceId); + WorkspaceResponse getWorkspaceByIdWithSecrets(@Param("organizationId") String organizationId, @Param("workspaceId") String workspaceId); @RequestLine("GET /api/v1/organization/{organizationId}/workspace/{workspaceId}?include=environment") - WorkspaceResponse getWorkspaceByWithEnvironmentVariables(@Param("organizationId") String organizationId, @Param("workspaceId") String workspaceId); - + WorkspaceResponse getWorkspaceByIdWithEnvironmentVariables(@Param("organizationId") String organizationId, @Param("workspaceId") String workspaceId); } diff --git a/api-client/src/main/java/org/azbuilder/api/client/model/organization/OrganizationResponse.java b/api-client/src/main/java/org/azbuilder/api/client/model/organization/OrganizationResponse.java index 134ccfe..35ccf94 100644 --- a/api-client/src/main/java/org/azbuilder/api/client/model/organization/OrganizationResponse.java +++ b/api-client/src/main/java/org/azbuilder/api/client/model/organization/OrganizationResponse.java @@ -7,8 +7,7 @@ @Getter @Setter -public class OrganizationResponse { - - List data; - List included; +public class OrganizationResponse { + T1 data; + List included; } diff --git a/api-client/src/main/java/org/azbuilder/api/client/model/organization/module/definition/parameter/ParameterResponse.java b/api-client/src/main/java/org/azbuilder/api/client/model/organization/module/definition/parameter/ParameterResponse.java index c5e29ea..f4f7417 100644 --- a/api-client/src/main/java/org/azbuilder/api/client/model/organization/module/definition/parameter/ParameterResponse.java +++ b/api-client/src/main/java/org/azbuilder/api/client/model/organization/module/definition/parameter/ParameterResponse.java @@ -7,6 +7,6 @@ @Getter @Setter -public class ParameterResponse { - List data; +public class ParameterResponse { + T1 data; } diff --git a/api-client/src/main/java/org/azbuilder/api/client/model/organization/workspace/WorkspaceResponse.java b/api-client/src/main/java/org/azbuilder/api/client/model/organization/workspace/WorkspaceResponse.java index 13c4d2b..c999d13 100644 --- a/api-client/src/main/java/org/azbuilder/api/client/model/organization/workspace/WorkspaceResponse.java +++ b/api-client/src/main/java/org/azbuilder/api/client/model/organization/workspace/WorkspaceResponse.java @@ -7,7 +7,7 @@ @Getter @Setter -public class WorkspaceResponse { - List data; - List included; +public class WorkspaceResponse { + T1 data; + List included; } diff --git a/api-client/src/main/java/org/azbuilder/api/client/model/organization/workspace/environment/EnvironmentResponse.java b/api-client/src/main/java/org/azbuilder/api/client/model/organization/workspace/environment/EnvironmentResponse.java index ffd8d0e..e4bb8ba 100644 --- a/api-client/src/main/java/org/azbuilder/api/client/model/organization/workspace/environment/EnvironmentResponse.java +++ b/api-client/src/main/java/org/azbuilder/api/client/model/organization/workspace/environment/EnvironmentResponse.java @@ -7,6 +7,6 @@ @Getter @Setter -public class EnvironmentResponse { - List data; +public class EnvironmentResponse { + T1 data; } diff --git a/api-client/src/main/java/org/azbuilder/api/client/model/organization/workspace/secret/SecretResponse.java b/api-client/src/main/java/org/azbuilder/api/client/model/organization/workspace/secret/SecretResponse.java index 7257131..24b2bb5 100644 --- a/api-client/src/main/java/org/azbuilder/api/client/model/organization/workspace/secret/SecretResponse.java +++ b/api-client/src/main/java/org/azbuilder/api/client/model/organization/workspace/secret/SecretResponse.java @@ -7,6 +7,6 @@ @Getter @Setter -public class SecretResponse { - List data; +public class SecretResponse { + T1 data; } diff --git a/api-client/src/main/java/org/azbuilder/api/client/model/organization/workspace/variable/VariableResponse.java b/api-client/src/main/java/org/azbuilder/api/client/model/organization/workspace/variable/VariableResponse.java index d65d1bd..e620a59 100644 --- a/api-client/src/main/java/org/azbuilder/api/client/model/organization/workspace/variable/VariableResponse.java +++ b/api-client/src/main/java/org/azbuilder/api/client/model/organization/workspace/variable/VariableResponse.java @@ -7,6 +7,6 @@ @Getter @Setter -public class VariableResponse { - List data; +public class VariableResponse { + T1 data; }