Skip to content

Commit

Permalink
Merge pull request #2 from AzBuilder/searchByOrganizationModule
Browse files Browse the repository at this point in the history
Adding search organization and module options
  • Loading branch information
alfespa17 authored Jul 15, 2021
2 parents 4fd8375 + 9cc6064 commit a067c4b
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 8 deletions.
9 changes: 8 additions & 1 deletion api-client-spring-boot-autoconfigure/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@
<gson.version>2.8.6</gson.version>
<feign.version>11.1</feign.version>
<okhttp.version>4.9.1</okhttp.version>
<revision>0.1.0</revision>
<revision>0.2.0</revision>
<maven.deploy.skip>false</maven.deploy.skip>
<lombok.version>1.18.20</lombok.version>
</properties>

<distributionManagement>
Expand Down Expand Up @@ -66,6 +67,12 @@
<artifactId>feign-okhttp</artifactId>
<version>${feign.version}</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
<scope>provided</scope>
</dependency>
</dependencies>

</project>
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.1.0</revision>
<revision>0.2.0</revision>
<maven.deploy.skip>true</maven.deploy.skip>
</properties>
<dependencies>
Expand Down
Original file line number Diff line number Diff line change
@@ -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 {

Expand All @@ -15,7 +20,16 @@ class ApiClientStarterSampleApplicationTests {
@Test
void contextLoads() {
assertNotNull(restClient);
//restClient.getAllOrganizations();
//OrganizationResponse<List<Organization>, 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")));
}

}
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.1.0</revision>
<revision>0.2.0</revision>
<maven.deploy.skip>false</maven.deploy.skip>
</properties>

Expand Down
9 changes: 8 additions & 1 deletion api-client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@
<description>Demo project for Spring Boot</description>
<properties>
<java.version>11</java.version>
<revision>0.1.0</revision>
<revision>0.2.0</revision>
<feign.version>11.1</feign.version>
<feign-form.version>3.8.0</feign-form.version>
<maven.deploy.skip>false</maven.deploy.skip>
<lombok.version>1.18.20</lombok.version>
</properties>

<distributionManagement>
Expand Down Expand Up @@ -59,6 +60,12 @@
<artifactId>feign-gson</artifactId>
<version>${feign.version}</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
Expand Down
12 changes: 10 additions & 2 deletions api-client/src/main/java/org/azbuilder/api/client/RestClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -25,7 +27,7 @@
public interface RestClient {

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

@RequestLine("GET /api/v1/organization?filter[job]=status=={jobStatus}&include=job")
OrganizationResponse<List<Organization>, Job> getAllOrganizationsWithJobStatus(@Param("jobStatus") String jobStatus);
Expand All @@ -43,7 +45,7 @@ public interface RestClient {
EnvironmentResponse<List<Environment>> getAllEnvironmentVariables(@Param("organizationId") String organizationId, @Param("workspaceId") String workspaceId);

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

@RequestLine("GET /api/v1/organization/{organizationId}/workspace/{workspaceId}?include=definition")
WorkspaceResponse<Workspace, Definition> getWorkspaceByIdWithModuleDefinition(@Param("organizationId") String organizationId, @Param("workspaceId") String workspaceId);
Expand All @@ -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<List<Organization>, Resource> getOrganizationByName(@Param("organizationName") String organizationName);

@RequestLine("GET /api/v1/organization/{organizationId}/module?include=definition&filter[module]=name=={moduleName};provider=={providerName}")
ModuleResponse<List<Organization>, Definition> getModuleByNameAndProviderWithModuleDefinition(@Param("organizationId") String organizationId, @Param("moduleName") String moduleName, @Param("providerName") String providerName);

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

@Getter
@Setter
public class ModuleResponse {
List<Module> data;
public class ModuleResponse<T1,T2> {
T1 data;
List<T2> included;
}

0 comments on commit a067c4b

Please sign in to comment.