From d8df408eaf4f7dc3293771eda356a4bb66e2e28d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alfredo=20Espa=C3=B1a?= Date: Tue, 26 Oct 2021 14:43:05 -0600 Subject: [PATCH] Add support for history endpoint (#15) --- api-client-spring-boot-autoconfigure/pom.xml | 2 +- api-client-spring-boot-starter-sample/pom.xml | 2 +- .../ApiClientStarterSampleApplicationTests.java | 13 +++++++++++++ api-client-spring-boot-starter/pom.xml | 2 +- api-client/pom.xml | 2 +- .../org/azbuilder/api/client/TerrakubeClient.java | 5 +++++ .../model/organization/workspace/HistoryData.java | 13 +++++++++++++ .../organization/workspace/Relationships.java | 2 +- .../organization/workspace/history/History.java | 12 ++++++++++++ .../workspace/history/HistoryAttributes.java | 14 ++++++++++++++ .../workspace/history/HistoryRequest.java | 10 ++++++++++ .../workspace/history/Relationships.java | 11 +++++++++++ .../workspace/history/WorkspaceData.java | 11 +++++++++++ 13 files changed, 94 insertions(+), 5 deletions(-) create mode 100644 api-client/src/main/java/org/azbuilder/api/client/model/organization/workspace/HistoryData.java create mode 100644 api-client/src/main/java/org/azbuilder/api/client/model/organization/workspace/history/History.java create mode 100644 api-client/src/main/java/org/azbuilder/api/client/model/organization/workspace/history/HistoryAttributes.java create mode 100644 api-client/src/main/java/org/azbuilder/api/client/model/organization/workspace/history/HistoryRequest.java create mode 100644 api-client/src/main/java/org/azbuilder/api/client/model/organization/workspace/history/Relationships.java create mode 100644 api-client/src/main/java/org/azbuilder/api/client/model/organization/workspace/history/WorkspaceData.java diff --git a/api-client-spring-boot-autoconfigure/pom.xml b/api-client-spring-boot-autoconfigure/pom.xml index 232c44e..e54a842 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.6 4.9.1 - 0.7.0-beta.1 + 0.7.0-beta.2 false 1.18.20 diff --git a/api-client-spring-boot-starter-sample/pom.xml b/api-client-spring-boot-starter-sample/pom.xml index 1a4dcf4..f729a69 100644 --- a/api-client-spring-boot-starter-sample/pom.xml +++ b/api-client-spring-boot-starter-sample/pom.xml @@ -15,7 +15,7 @@ Terrakube Spring Boot Starter sample 11 - 0.7.0-beta.1 + 0.7.0-beta.2 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 31cac83..8bae1fd 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 @@ -11,6 +11,9 @@ import org.azbuilder.api.client.model.organization.provider.version.implementation.Implementation; import org.azbuilder.api.client.model.organization.vcs.Vcs; import org.azbuilder.api.client.model.organization.workspace.Workspace; +import org.azbuilder.api.client.model.organization.workspace.history.History; +import org.azbuilder.api.client.model.organization.workspace.history.HistoryAttributes; +import org.azbuilder.api.client.model.organization.workspace.history.HistoryRequest; import org.azbuilder.api.client.model.organization.workspace.variable.Variable; import org.azbuilder.api.client.model.response.Response; import org.junit.jupiter.api.Test; @@ -29,6 +32,16 @@ class ApiClientStarterSampleApplicationTests { @Test void contextLoads() { assertNotNull(restClient); +/* + HistoryRequest historyRequest = new HistoryRequest(); + History newHistory = new History(); + newHistory.setType("history"); + HistoryAttributes historyAttributes = new HistoryAttributes(); + historyAttributes.setOutput("HolaMundo333333"); + newHistory.setAttributes(historyAttributes); + historyRequest.setData(newHistory); + + restClient.createHistory(historyRequest,"4918ee6f-ffaf-4532-a370-d8c06e45eb4d", "21bb4721-4760-49f0-a7c7-bd6072081be9" ); /* restClient.getAllOrganizations().getData().size(); diff --git a/api-client-spring-boot-starter/pom.xml b/api-client-spring-boot-starter/pom.xml index d19f228..41cef38 100644 --- a/api-client-spring-boot-starter/pom.xml +++ b/api-client-spring-boot-starter/pom.xml @@ -13,7 +13,7 @@ UTF-8 - 0.7.0-beta.1 + 0.7.0-beta.2 false diff --git a/api-client/pom.xml b/api-client/pom.xml index 7260a03..d9d4ba2 100644 --- a/api-client/pom.xml +++ b/api-client/pom.xml @@ -15,7 +15,7 @@ Java Terrakube client 11 - 0.7.0-beta.1 + 0.7.0-beta.2 11.6 3.8.0 false diff --git a/api-client/src/main/java/org/azbuilder/api/client/TerrakubeClient.java b/api-client/src/main/java/org/azbuilder/api/client/TerrakubeClient.java index 7f2471a..99c5f2b 100644 --- a/api-client/src/main/java/org/azbuilder/api/client/TerrakubeClient.java +++ b/api-client/src/main/java/org/azbuilder/api/client/TerrakubeClient.java @@ -14,6 +14,7 @@ import org.azbuilder.api.client.model.organization.template.Template; import org.azbuilder.api.client.model.organization.vcs.Vcs; import org.azbuilder.api.client.model.organization.workspace.Workspace; +import org.azbuilder.api.client.model.organization.workspace.history.HistoryRequest; import org.azbuilder.api.client.model.organization.workspace.variable.Variable; import org.azbuilder.api.client.model.response.Response; import org.azbuilder.api.client.model.response.ResponseWithInclude; @@ -57,6 +58,10 @@ public interface TerrakubeClient { @Headers("Content-Type: application/vnd.api+json") void createStep(StepRequest stepRequest, @Param("organizationId") String organizationId, @Param("jobId") String jobId); + @RequestLine("POST /api/v1/organization/{organizationId}/workspace/{workspaceId}/history") + @Headers("Content-Type: application/vnd.api+json") + void createHistory(HistoryRequest historyRequest, @Param("organizationId") String organizationId, @Param("workspaceId") String workspaceId); + @RequestLine("PATCH /api/v1/organization/{organizationId}/job/{jobId}/step/{stepId}") @Headers("Content-Type: application/vnd.api+json") void updateStep(StepRequest stepRequest, @Param("organizationId") String organizationId, @Param("jobId") String jobId, @Param("stepId") String stepId); diff --git a/api-client/src/main/java/org/azbuilder/api/client/model/organization/workspace/HistoryData.java b/api-client/src/main/java/org/azbuilder/api/client/model/organization/workspace/HistoryData.java new file mode 100644 index 0000000..6dba8fb --- /dev/null +++ b/api-client/src/main/java/org/azbuilder/api/client/model/organization/workspace/HistoryData.java @@ -0,0 +1,13 @@ +package org.azbuilder.api.client.model.organization.workspace; + +import lombok.Getter; +import lombok.Setter; +import org.azbuilder.api.client.model.generic.Resource; + +import java.util.List; + +@Getter +@Setter +public class HistoryData { + List data; +} diff --git a/api-client/src/main/java/org/azbuilder/api/client/model/organization/workspace/Relationships.java b/api-client/src/main/java/org/azbuilder/api/client/model/organization/workspace/Relationships.java index b39ff0b..0a9ed09 100644 --- a/api-client/src/main/java/org/azbuilder/api/client/model/organization/workspace/Relationships.java +++ b/api-client/src/main/java/org/azbuilder/api/client/model/organization/workspace/Relationships.java @@ -6,9 +6,9 @@ @Getter @Setter public class Relationships { - JobData job; OrganizationData organization; VariableData variable; VcsData vcs; + HistoryData history; } diff --git a/api-client/src/main/java/org/azbuilder/api/client/model/organization/workspace/history/History.java b/api-client/src/main/java/org/azbuilder/api/client/model/organization/workspace/history/History.java new file mode 100644 index 0000000..f3d285e --- /dev/null +++ b/api-client/src/main/java/org/azbuilder/api/client/model/organization/workspace/history/History.java @@ -0,0 +1,12 @@ +package org.azbuilder.api.client.model.organization.workspace.history; + +import lombok.Getter; +import lombok.Setter; +import org.azbuilder.api.client.model.generic.Resource; + +@Getter +@Setter +public class History extends Resource { + HistoryAttributes attributes; + Relationships relationships; +} diff --git a/api-client/src/main/java/org/azbuilder/api/client/model/organization/workspace/history/HistoryAttributes.java b/api-client/src/main/java/org/azbuilder/api/client/model/organization/workspace/history/HistoryAttributes.java new file mode 100644 index 0000000..fe4ea40 --- /dev/null +++ b/api-client/src/main/java/org/azbuilder/api/client/model/organization/workspace/history/HistoryAttributes.java @@ -0,0 +1,14 @@ +package org.azbuilder.api.client.model.organization.workspace.history; + +import lombok.Getter; +import lombok.Setter; + +@Getter +@Setter +public class HistoryAttributes { + private String createdBy; + private String createdDate; + private String output; + private String updatedBy; + private String updatedDate; +} diff --git a/api-client/src/main/java/org/azbuilder/api/client/model/organization/workspace/history/HistoryRequest.java b/api-client/src/main/java/org/azbuilder/api/client/model/organization/workspace/history/HistoryRequest.java new file mode 100644 index 0000000..7c268e7 --- /dev/null +++ b/api-client/src/main/java/org/azbuilder/api/client/model/organization/workspace/history/HistoryRequest.java @@ -0,0 +1,10 @@ +package org.azbuilder.api.client.model.organization.workspace.history; + +import lombok.Getter; +import lombok.Setter; + +@Getter +@Setter +public class HistoryRequest { + History data; +} diff --git a/api-client/src/main/java/org/azbuilder/api/client/model/organization/workspace/history/Relationships.java b/api-client/src/main/java/org/azbuilder/api/client/model/organization/workspace/history/Relationships.java new file mode 100644 index 0000000..8f630d2 --- /dev/null +++ b/api-client/src/main/java/org/azbuilder/api/client/model/organization/workspace/history/Relationships.java @@ -0,0 +1,11 @@ +package org.azbuilder.api.client.model.organization.workspace.history; + +import lombok.Getter; +import lombok.Setter; +import org.azbuilder.api.client.model.organization.workspace.variable.WorkspaceData; + +@Getter +@Setter +public class Relationships { + WorkspaceData workspace; +} diff --git a/api-client/src/main/java/org/azbuilder/api/client/model/organization/workspace/history/WorkspaceData.java b/api-client/src/main/java/org/azbuilder/api/client/model/organization/workspace/history/WorkspaceData.java new file mode 100644 index 0000000..d091ba4 --- /dev/null +++ b/api-client/src/main/java/org/azbuilder/api/client/model/organization/workspace/history/WorkspaceData.java @@ -0,0 +1,11 @@ +package org.azbuilder.api.client.model.organization.workspace.history; + +import lombok.Getter; +import lombok.Setter; +import org.azbuilder.api.client.model.generic.Resource; + +@Getter +@Setter +public class WorkspaceData { + Resource data; +}