Repository navigation
Expand file tree
/
Copy pathDeploymentCreateParams.java
More file actions
128 lines (99 loc) · 3.5 KB
/
Copy pathDeploymentCreateParams.java
File metadata and controls
128 lines (99 loc) · 3.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
package com.qoder.cloudagents.managed;
import com.qoder.cloudagents.core.*;
import com.qoder.cloudagents.errors.ConfigurationException;
import java.util.*;
/** Immutable JSON configuration; unknown fields are preserved. */
public final class DeploymentCreateParams extends JsonObject {
private DeploymentCreateParams(JsonValue value) {
super(value);
}
public static DeploymentCreateParams fromJson(JsonValue value) {
return new DeploymentCreateParams(value);
}
public String name() {
return optional("name", JsonValue::asString);
}
public String description() {
return optional("description", JsonValue::asString);
}
public AgentReference agent() {
return optional("agent", AgentReference::fromJson);
}
public String environmentId() {
return optional("environment_id", JsonValue::asString);
}
/** BYOC tunnel bound to the deployment, when configured. */
public String tunnelId() {
return optional("tunnel_id", JsonValue::asString);
}
public DeploymentSchedule schedule() {
return optional("schedule", DeploymentSchedule::fromJson);
}
public List<SessionEventParam> initialEvents() {
return optionalList("initial_events", SessionEventParam::fromJson);
}
public List<SessionResourceSpec> resources() {
return optionalList("resources", SessionResourceSpec::fromJson);
}
public List<String> vaultIds() {
return optionalList("vault_ids", JsonValue::asString);
}
public Map<String, String> metadata() {
return optionalNullableMap("metadata", JsonValue::asString);
}
public String environmentVariables() {
return optional("environment_variables", JsonValue::asString);
}
public static Builder builder() {
return new Builder();
}
public static final class Builder extends JsonObjectBuilder<Builder> {
private Builder() {}
public Builder name(String value) {
return put("name", value);
}
public Builder description(String value) {
return put("description", value);
}
public Builder agent(AgentReference value) {
return put("agent", value);
}
public Builder agent(String value) {
return put("agent", value == null ? null : AgentReference.of(value));
}
public Builder environmentId(String value) {
return put("environment_id", value);
}
/** Bind sessions created by this deployment to the specified BYOC tunnel. */
public Builder tunnelId(String value) {
return put("tunnel_id", value);
}
public Builder schedule(DeploymentSchedule value) {
return put("schedule", value);
}
public Builder initialEvents(List<SessionEventParam> value) {
return put("initial_events", value);
}
public Builder resources(List<SessionResourceSpec> value) {
return put("resources", value);
}
public Builder vaultIds(List<String> value) {
return put("vault_ids", value);
}
public Builder metadata(Map<String, String> value) {
return put("metadata", value);
}
public Builder environmentVariables(String value) {
return put("environment_variables", value);
}
public DeploymentCreateParams build() {
require("name", "agent", "environment_id", "initial_events");
JsonValue events = json().get("initial_events");
if (!events.isMissing()
&& !events.isNull()
&& (events.asArray().isEmpty() || events.asArray().size() > 50))
throw new ConfigurationException("initialEvents requires 1-50 events");
return new DeploymentCreateParams(json());
}
}
}