software.amazon.awscdk.services.codebuild.BuildEnvironmentVariable Maven / Gradle / Ivy
Show all versions of codebuild Show documentation
package software.amazon.awscdk.services.codebuild;
/**
* Example:
*
*
* // later:
* PipelineProject project;
* Artifact sourceOutput = new Artifact();
* CodeBuildAction buildAction = CodeBuildAction.Builder.create()
* .actionName("Build1")
* .input(sourceOutput)
* .project(PipelineProject.Builder.create(this, "Project")
* .buildSpec(BuildSpec.fromObject(Map.of(
* "version", "0.2",
* "env", Map.of(
* "exported-variables", List.of("MY_VAR")),
* "phases", Map.of(
* "build", Map.of(
* "commands", "export MY_VAR=\"some value\"")))))
* .build())
* .variablesNamespace("MyNamespace")
* .build();
* CodeBuildAction.Builder.create()
* .actionName("CodeBuild")
* .project(project)
* .input(sourceOutput)
* .environmentVariables(Map.of(
* "MyVar", BuildEnvironmentVariable.builder()
* .value(buildAction.variable("MY_VAR"))
* .build()))
* .build();
*
*/
@javax.annotation.Generated(value = "jsii-pacmak/1.52.1 (build 5ccc8f6)", date = "2022-01-20T19:50:01.473Z")
@software.amazon.jsii.Jsii(module = software.amazon.awscdk.services.codebuild.$Module.class, fqn = "@aws-cdk/aws-codebuild.BuildEnvironmentVariable")
@software.amazon.jsii.Jsii.Proxy(BuildEnvironmentVariable.Jsii$Proxy.class)
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable)
public interface BuildEnvironmentVariable extends software.amazon.jsii.JsiiSerializable {
/**
* The value of the environment variable.
*
* For plain-text variables (the default), this is the literal value of variable.
* For SSM parameter variables, pass the name of the parameter here (parameterName
property of IParameter
).
* For SecretsManager variables secrets, pass either the secret name (secretName
property of ISecret
)
* or the secret ARN (secretArn
property of ISecret
) here,
* along with optional SecretsManager qualifiers separated by ':', like the JSON key, or the version or stage
* (see https://docs.aws.amazon.com/codebuild/latest/userguide/build-spec-ref.html#build-spec.env.secrets-manager for details).
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable)
@org.jetbrains.annotations.NotNull java.lang.Object getValue();
/**
* The type of environment variable.
*
* Default: PlainText
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable)
default @org.jetbrains.annotations.Nullable software.amazon.awscdk.services.codebuild.BuildEnvironmentVariableType getType() {
return null;
}
/**
* @return a {@link Builder} of {@link BuildEnvironmentVariable}
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable)
static Builder builder() {
return new Builder();
}
/**
* A builder for {@link BuildEnvironmentVariable}
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable)
public static final class Builder implements software.amazon.jsii.Builder {
java.lang.Object value;
software.amazon.awscdk.services.codebuild.BuildEnvironmentVariableType type;
/**
* Sets the value of {@link BuildEnvironmentVariable#getValue}
* @param value The value of the environment variable. This parameter is required.
* For plain-text variables (the default), this is the literal value of variable.
* For SSM parameter variables, pass the name of the parameter here (parameterName
property of IParameter
).
* For SecretsManager variables secrets, pass either the secret name (secretName
property of ISecret
)
* or the secret ARN (secretArn
property of ISecret
) here,
* along with optional SecretsManager qualifiers separated by ':', like the JSON key, or the version or stage
* (see https://docs.aws.amazon.com/codebuild/latest/userguide/build-spec-ref.html#build-spec.env.secrets-manager for details).
* @return {@code this}
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable)
public Builder value(java.lang.Object value) {
this.value = value;
return this;
}
/**
* Sets the value of {@link BuildEnvironmentVariable#getType}
* @param type The type of environment variable.
* @return {@code this}
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable)
public Builder type(software.amazon.awscdk.services.codebuild.BuildEnvironmentVariableType type) {
this.type = type;
return this;
}
/**
* Builds the configured instance.
* @return a new instance of {@link BuildEnvironmentVariable}
* @throws NullPointerException if any required attribute was not provided
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable)
@Override
public BuildEnvironmentVariable build() {
return new Jsii$Proxy(this);
}
}
/**
* An implementation for {@link BuildEnvironmentVariable}
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable)
@software.amazon.jsii.Internal
final class Jsii$Proxy extends software.amazon.jsii.JsiiObject implements BuildEnvironmentVariable {
private final java.lang.Object value;
private final software.amazon.awscdk.services.codebuild.BuildEnvironmentVariableType type;
/**
* Constructor that initializes the object based on values retrieved from the JsiiObject.
* @param objRef Reference to the JSII managed object.
*/
protected Jsii$Proxy(final software.amazon.jsii.JsiiObjectRef objRef) {
super(objRef);
this.value = software.amazon.jsii.Kernel.get(this, "value", software.amazon.jsii.NativeType.forClass(java.lang.Object.class));
this.type = software.amazon.jsii.Kernel.get(this, "type", software.amazon.jsii.NativeType.forClass(software.amazon.awscdk.services.codebuild.BuildEnvironmentVariableType.class));
}
/**
* Constructor that initializes the object based on literal property values passed by the {@link Builder}.
*/
protected Jsii$Proxy(final Builder builder) {
super(software.amazon.jsii.JsiiObject.InitializationMode.JSII);
this.value = java.util.Objects.requireNonNull(builder.value, "value is required");
this.type = builder.type;
}
@Override
public final java.lang.Object getValue() {
return this.value;
}
@Override
public final software.amazon.awscdk.services.codebuild.BuildEnvironmentVariableType getType() {
return this.type;
}
@Override
@software.amazon.jsii.Internal
public com.fasterxml.jackson.databind.JsonNode $jsii$toJson() {
final com.fasterxml.jackson.databind.ObjectMapper om = software.amazon.jsii.JsiiObjectMapper.INSTANCE;
final com.fasterxml.jackson.databind.node.ObjectNode data = com.fasterxml.jackson.databind.node.JsonNodeFactory.instance.objectNode();
data.set("value", om.valueToTree(this.getValue()));
if (this.getType() != null) {
data.set("type", om.valueToTree(this.getType()));
}
final com.fasterxml.jackson.databind.node.ObjectNode struct = com.fasterxml.jackson.databind.node.JsonNodeFactory.instance.objectNode();
struct.set("fqn", om.valueToTree("@aws-cdk/aws-codebuild.BuildEnvironmentVariable"));
struct.set("data", data);
final com.fasterxml.jackson.databind.node.ObjectNode obj = com.fasterxml.jackson.databind.node.JsonNodeFactory.instance.objectNode();
obj.set("$jsii.struct", struct);
return obj;
}
@Override
public final boolean equals(final Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
BuildEnvironmentVariable.Jsii$Proxy that = (BuildEnvironmentVariable.Jsii$Proxy) o;
if (!value.equals(that.value)) return false;
return this.type != null ? this.type.equals(that.type) : that.type == null;
}
@Override
public final int hashCode() {
int result = this.value.hashCode();
result = 31 * result + (this.type != null ? this.type.hashCode() : 0);
return result;
}
}
}