From 9cc60640202730a8175dfa9b67fce3a77476f939 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alfredo=20Espa=C3=B1a?= Date: Thu, 15 Jul 2021 15:22:24 -0600 Subject: [PATCH] Adding search organization by name and search module by name and provider --- api-client-spring-boot-autoconfigure/pom.xml | 9 ++++++++- api-client-spring-boot-starter-sample/pom.xml | 2 +- .../ApiClientStarterSampleApplicationTests.java | 14 ++++++++++++++ api-client-spring-boot-starter/pom.xml | 2 +- api-client/pom.xml | 9 ++++++++- .../java/org/azbuilder/api/client/RestClient.java | 12 ++++++++++-- .../model/organization/module/ModuleResponse.java | 5 +++-- 7 files changed, 45 insertions(+), 8 deletions(-) diff --git a/api-client-spring-boot-autoconfigure/pom.xml b/api-client-spring-boot-autoconfigure/pom.xml index 2a71714..1c56b29 100644 --- a/api-client-spring-boot-autoconfigure/pom.xml +++ b/api-client-spring-boot-autoconfigure/pom.xml @@ -19,8 +19,9 @@ 2.8.6 11.1 4.9.1 - 0.1.0 + 0.2.0 false + 1.18.20 @@ -66,6 +67,12 @@ feign-okhttp ${feign.version} + + org.projectlombok + lombok + ${lombok.version} + provided + diff --git a/api-client-spring-boot-starter-sample/pom.xml b/api-client-spring-boot-starter-sample/pom.xml index e238033..05c3000 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.1.0 + 0.2.0 true diff --git a/api-client-spring-boot-starter-sample/src/test/java/org/azbuilder/api/client/sample/ApiClientStarterSampleApplicationTests.java b/api-client-spring-boot-starter-sample/src/test/java/org/azbuilder/api/client/sample/ApiClientStarterSampleApplicationTests.java index a9a82c0..b310e90 100644 --- a/api-client-spring-boot-starter-sample/src/test/java/org/azbuilder/api/client/sample/ApiClientStarterSampleApplicationTests.java +++ b/api-client-spring-boot-starter-sample/src/test/java/org/azbuilder/api/client/sample/ApiClientStarterSampleApplicationTests.java @@ -1,11 +1,16 @@ package org.azbuilder.api.client.sample; +import org.azbuilder.api.client.model.generic.Resource; +import org.azbuilder.api.client.model.organization.Organization; +import org.azbuilder.api.client.model.organization.OrganizationResponse; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import static org.junit.jupiter.api.Assertions.assertNotNull; import org.azbuilder.api.client.RestClient; +import java.util.List; + @SpringBootTest class ApiClientStarterSampleApplicationTests { @@ -15,7 +20,16 @@ class ApiClientStarterSampleApplicationTests { @Test void contextLoads() { assertNotNull(restClient); + //restClient.getAllOrganizations(); + //OrganizationResponse, Resource> organizationResponse = restClient.getOrganizationByName("organization1"); + + //System.out.println(organizationResponse.getData().size()); + //System.out.println(organizationResponse.getData().get(0).getId()); + + + //System.out.println(restClient.getModuleByNameAndProviderWithModuleDefinition(organizationResponse.getData().get(0).getId(),"Azure","azurerm").getIncluded().size()); + //restClient.getModuleByNameAndProviderWithModuleDefinition(organizationResponse.getData().get(0).getId(),"Google","gcp").getIncluded().forEach(k->System.out.println(k.getAttributes().get("terraformVersion"))); } } diff --git a/api-client-spring-boot-starter/pom.xml b/api-client-spring-boot-starter/pom.xml index c748268..86da6c2 100644 --- a/api-client-spring-boot-starter/pom.xml +++ b/api-client-spring-boot-starter/pom.xml @@ -13,7 +13,7 @@ UTF-8 - 0.1.0 + 0.2.0 false diff --git a/api-client/pom.xml b/api-client/pom.xml index 0490fb4..d88b9cc 100644 --- a/api-client/pom.xml +++ b/api-client/pom.xml @@ -15,10 +15,11 @@ Demo project for Spring Boot 11 - 0.1.0 + 0.2.0 11.1 3.8.0 false + 1.18.20 @@ -59,6 +60,12 @@ feign-gson ${feign.version} + + org.projectlombok + lombok + ${lombok.version} + provided + org.springframework.boot spring-boot-starter-test 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 7e6d517..776cf36 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 @@ -3,11 +3,13 @@ import feign.Headers; import feign.Param; import feign.RequestLine; +import org.azbuilder.api.client.model.generic.Resource; 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.job.JobRequest; import org.azbuilder.api.client.model.organization.job.JobResponse; +import org.azbuilder.api.client.model.organization.module.ModuleResponse; 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; @@ -25,7 +27,7 @@ public interface RestClient { @RequestLine("GET /api/v1/organization") - OrganizationResponse, Void> getAllOrganizations(); + OrganizationResponse, Resource> getAllOrganizations(); @RequestLine("GET /api/v1/organization?filter[job]=status=={jobStatus}&include=job") OrganizationResponse, Job> getAllOrganizationsWithJobStatus(@Param("jobStatus") String jobStatus); @@ -43,7 +45,7 @@ public interface RestClient { EnvironmentResponse> getAllEnvironmentVariables(@Param("organizationId") String organizationId, @Param("workspaceId") String workspaceId); @RequestLine("GET /api/v1/organization/{organizationId}/workspace") - WorkspaceResponse, Void> getAllWorkspaces(@Param("organizationId") String organizationId); + WorkspaceResponse, Resource> 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); @@ -64,4 +66,10 @@ public interface RestClient { @RequestLine("GET /api/v1/organization/{organizationId}/job/{jobId}") JobResponse getJobById(@Param("organizationId") String organizationId, @Param("jobId") String jobId); + @RequestLine("GET /api/v1/organization?filter[organization]=name=={organizationName}") + OrganizationResponse, Resource> getOrganizationByName(@Param("organizationName") String organizationName); + + @RequestLine("GET /api/v1/organization/{organizationId}/module?include=definition&filter[module]=name=={moduleName};provider=={providerName}") + ModuleResponse, Definition> getModuleByNameAndProviderWithModuleDefinition(@Param("organizationId") String organizationId, @Param("moduleName") String moduleName, @Param("providerName") String providerName); + } diff --git a/api-client/src/main/java/org/azbuilder/api/client/model/organization/module/ModuleResponse.java b/api-client/src/main/java/org/azbuilder/api/client/model/organization/module/ModuleResponse.java index 7fc9047..744228b 100644 --- a/api-client/src/main/java/org/azbuilder/api/client/model/organization/module/ModuleResponse.java +++ b/api-client/src/main/java/org/azbuilder/api/client/model/organization/module/ModuleResponse.java @@ -7,6 +7,7 @@ @Getter @Setter -public class ModuleResponse { - List data; +public class ModuleResponse { + T1 data; + List included; }