Skip to content
This repository has been archived by the owner on Dec 2, 2022. It is now read-only.

add generated code for task lifecycle hooks #48

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions sdk/src/main/java/com/hashicorp/nomad/apimodel/Task.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public final class Task extends ApiObject {
private String name;
private String driver;
private String user;
private TaskLifecycle lifecycle;
private Map<String, Object> config;
private List<Constraint> constraints;
private List<Affinity> affinities;
Expand Down Expand Up @@ -66,6 +67,16 @@ public Task setUser(String user) {
return this;
}

@JsonProperty("Lifecycle")
public TaskLifecycle getLifecycle() {
return lifecycle;
}

public Task setLifecycle(TaskLifecycle lifecycle) {
this.lifecycle = lifecycle;
return this;
}

@JsonProperty("Config")
public Map<String, Object> getConfig() {
return config;
Expand Down
51 changes: 51 additions & 0 deletions sdk/src/main/java/com/hashicorp/nomad/apimodel/TaskLifecycle.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package com.hashicorp.nomad.apimodel;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.hashicorp.nomad.javasdk.ApiObject;
import com.hashicorp.nomad.javasdk.NomadJson;

import java.io.IOException;
import java.util.List;

/**
* This is a generated JavaBean representing a request or response structure.
*
* @see <a href="https://www.nomadproject.io/docs/http/index.html">Nomad HTTP API</a> documentation associated with the endpoint you are using.
*/
public final class TaskLifecycle extends ApiObject {
private String hook;
private boolean sidecar;

@JsonProperty("Hook")
public String getHook() {
return hook;
}

public TaskLifecycle setHook(String hook) {
this.hook = hook;
return this;
}

@JsonProperty("Sidecar")
public boolean getSidecar() {
return sidecar;
}

public TaskLifecycle setSidecar(boolean sidecar) {
this.sidecar = sidecar;
return this;
}

@Override
public String toString() {
return NomadJson.serialize(this);
}

public static TaskLifecycle fromJson(String json) throws IOException {
return NomadJson.deserialize(json, TaskLifecycle.class);
}

public static List<TaskLifecycle> fromJsonArray(String json) throws IOException {
return NomadJson.deserializeList(json, TaskLifecycle.class);
}
}