software.amazon.awssdk.services.securityhub.model.AwsCodeBuildProjectEnvironment Maven / Gradle / Ivy
/*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
* the License. A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
* CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
* and limitations under the License.
*/
package software.amazon.awssdk.services.securityhub.model;
import java.io.Serializable;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.function.BiConsumer;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import software.amazon.awssdk.annotations.Generated;
import software.amazon.awssdk.core.SdkField;
import software.amazon.awssdk.core.SdkPojo;
import software.amazon.awssdk.core.protocol.MarshallLocation;
import software.amazon.awssdk.core.protocol.MarshallingType;
import software.amazon.awssdk.core.traits.ListTrait;
import software.amazon.awssdk.core.traits.LocationTrait;
import software.amazon.awssdk.core.util.DefaultSdkAutoConstructList;
import software.amazon.awssdk.core.util.SdkAutoConstructList;
import software.amazon.awssdk.utils.ToString;
import software.amazon.awssdk.utils.builder.CopyableBuilder;
import software.amazon.awssdk.utils.builder.ToCopyableBuilder;
/**
*
* Information about the build environment for this build project.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class AwsCodeBuildProjectEnvironment implements SdkPojo, Serializable,
ToCopyableBuilder {
private static final SdkField CERTIFICATE_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("Certificate").getter(getter(AwsCodeBuildProjectEnvironment::certificate))
.setter(setter(Builder::certificate))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Certificate").build()).build();
private static final SdkField> ENVIRONMENT_VARIABLES_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("EnvironmentVariables")
.getter(getter(AwsCodeBuildProjectEnvironment::environmentVariables))
.setter(setter(Builder::environmentVariables))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("EnvironmentVariables").build(),
ListTrait
.builder()
.memberLocationName(null)
.memberFieldInfo(
SdkField. builder(
MarshallingType.SDK_POJO)
.constructor(AwsCodeBuildProjectEnvironmentEnvironmentVariablesDetails::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("member").build()).build()).build()).build();
private static final SdkField PRIVILEGED_MODE_FIELD = SdkField. builder(MarshallingType.BOOLEAN)
.memberName("PrivilegedMode").getter(getter(AwsCodeBuildProjectEnvironment::privilegedMode))
.setter(setter(Builder::privilegedMode))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("PrivilegedMode").build()).build();
private static final SdkField IMAGE_PULL_CREDENTIALS_TYPE_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("ImagePullCredentialsType").getter(getter(AwsCodeBuildProjectEnvironment::imagePullCredentialsType))
.setter(setter(Builder::imagePullCredentialsType))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ImagePullCredentialsType").build())
.build();
private static final SdkField REGISTRY_CREDENTIAL_FIELD = SdkField
. builder(MarshallingType.SDK_POJO)
.memberName("RegistryCredential").getter(getter(AwsCodeBuildProjectEnvironment::registryCredential))
.setter(setter(Builder::registryCredential)).constructor(AwsCodeBuildProjectEnvironmentRegistryCredential::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("RegistryCredential").build())
.build();
private static final SdkField TYPE_FIELD = SdkField. builder(MarshallingType.STRING).memberName("Type")
.getter(getter(AwsCodeBuildProjectEnvironment::type)).setter(setter(Builder::type))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Type").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(CERTIFICATE_FIELD,
ENVIRONMENT_VARIABLES_FIELD, PRIVILEGED_MODE_FIELD, IMAGE_PULL_CREDENTIALS_TYPE_FIELD, REGISTRY_CREDENTIAL_FIELD,
TYPE_FIELD));
private static final long serialVersionUID = 1L;
private final String certificate;
private final List environmentVariables;
private final Boolean privilegedMode;
private final String imagePullCredentialsType;
private final AwsCodeBuildProjectEnvironmentRegistryCredential registryCredential;
private final String type;
private AwsCodeBuildProjectEnvironment(BuilderImpl builder) {
this.certificate = builder.certificate;
this.environmentVariables = builder.environmentVariables;
this.privilegedMode = builder.privilegedMode;
this.imagePullCredentialsType = builder.imagePullCredentialsType;
this.registryCredential = builder.registryCredential;
this.type = builder.type;
}
/**
*
* The certificate to use with this build project.
*
*
* @return The certificate to use with this build project.
*/
public final String certificate() {
return certificate;
}
/**
* For responses, this returns true if the service returned a value for the EnvironmentVariables property. This DOES
* NOT check that the value is non-empty (for which, you should check the {@code isEmpty()} method on the property).
* This is useful because the SDK will never return a null collection or map, but you may need to differentiate
* between the service returning nothing (or null) and the service returning an empty collection or map. For
* requests, this returns true if a value for the property was specified in the request builder, and false if a
* value was not specified.
*/
public final boolean hasEnvironmentVariables() {
return environmentVariables != null && !(environmentVariables instanceof SdkAutoConstructList);
}
/**
*
* A set of environment variables to make available to builds for the build project.
*
*
* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException.
*
*
* This method will never return null. If you would like to know whether the service returned this field (so that
* you can differentiate between null and empty), you can use the {@link #hasEnvironmentVariables} method.
*
*
* @return A set of environment variables to make available to builds for the build project.
*/
public final List environmentVariables() {
return environmentVariables;
}
/**
*
* Whether to allow the Docker daemon to run inside a Docker container. Set to true if the build
* project is used to build Docker images.
*
*
* @return Whether to allow the Docker daemon to run inside a Docker container. Set to true if the
* build project is used to build Docker images.
*/
public final Boolean privilegedMode() {
return privilegedMode;
}
/**
*
* The type of credentials CodeBuild uses to pull images in your build.
*
*
* Valid values:
*
*
* -
*
* CODEBUILD specifies that CodeBuild uses its own credentials. This requires that you modify your ECR
* repository policy to trust the CodeBuild service principal.
*
*
* -
*
* SERVICE_ROLE specifies that CodeBuild uses your build project's service role.
*
*
*
*
* When you use a cross-account or private registry image, you must use SERVICE_ROLE credentials. When
* you use an CodeBuild curated image, you must use CODEBUILD credentials.
*
*
* @return The type of credentials CodeBuild uses to pull images in your build.
*
* Valid values:
*
*
* -
*
* CODEBUILD specifies that CodeBuild uses its own credentials. This requires that you modify
* your ECR repository policy to trust the CodeBuild service principal.
*
*
* -
*
* SERVICE_ROLE specifies that CodeBuild uses your build project's service role.
*
*
*
*
* When you use a cross-account or private registry image, you must use SERVICE_ROLE
* credentials. When you use an CodeBuild curated image, you must use CODEBUILD credentials.
*/
public final String imagePullCredentialsType() {
return imagePullCredentialsType;
}
/**
*
* The credentials for access to a private registry.
*
*
* @return The credentials for access to a private registry.
*/
public final AwsCodeBuildProjectEnvironmentRegistryCredential registryCredential() {
return registryCredential;
}
/**
*
* The type of build environment to use for related builds.
*
*
* The environment type ARM_CONTAINER is available only in Regions US East (N. Virginia), US East
* (Ohio), US West (Oregon), Europe (Ireland), Asia Pacific (Mumbai), Asia Pacific (Tokyo), Asia Pacific (Sydney),
* and Europe (Frankfurt).
*
*
* The environment type LINUX_CONTAINER with compute type build.general1.2xlarge is available only in
* Regions US East (N. Virginia), US East (N. Virginia), US West (Oregon), Canada (Central), Europe (Ireland),
* Europe (London), Europe (Frankfurt), Asia Pacific (Tokyo), Asia Pacific (Seoul), Asia Pacific (Singapore), Asia
* Pacific (Sydney), China (Beijing), and China (Ningxia).
*
*
* The environment type LINUX_GPU_CONTAINER is available only in Regions US East (N. Virginia), US East
* (N. Virginia), US West (Oregon), Canada (Central), Europe (Ireland), Europe (London), Europe (Frankfurt), Asia
* Pacific (Tokyo), Asia Pacific (Seoul), Asia Pacific (Singapore), Asia Pacific (Sydney), China (Beijing), and
* China (Ningxia).
*
*
* Valid values: WINDOWS_CONTAINER | LINUX_CONTAINER | LINUX_GPU_CONTAINER |
* ARM_CONTAINER
*
*
* @return The type of build environment to use for related builds.
*
* The environment type ARM_CONTAINER is available only in Regions US East (N. Virginia), US
* East (Ohio), US West (Oregon), Europe (Ireland), Asia Pacific (Mumbai), Asia Pacific (Tokyo), Asia
* Pacific (Sydney), and Europe (Frankfurt).
*
*
* The environment type LINUX_CONTAINER with compute type build.general1.2xlarge is available
* only in Regions US East (N. Virginia), US East (N. Virginia), US West (Oregon), Canada (Central), Europe
* (Ireland), Europe (London), Europe (Frankfurt), Asia Pacific (Tokyo), Asia Pacific (Seoul), Asia Pacific
* (Singapore), Asia Pacific (Sydney), China (Beijing), and China (Ningxia).
*
*
* The environment type LINUX_GPU_CONTAINER is available only in Regions US East (N. Virginia),
* US East (N. Virginia), US West (Oregon), Canada (Central), Europe (Ireland), Europe (London), Europe
* (Frankfurt), Asia Pacific (Tokyo), Asia Pacific (Seoul), Asia Pacific (Singapore), Asia Pacific (Sydney),
* China (Beijing), and China (Ningxia).
*
*
* Valid values: WINDOWS_CONTAINER | LINUX_CONTAINER |
* LINUX_GPU_CONTAINER | ARM_CONTAINER
*/
public final String type() {
return type;
}
@Override
public Builder toBuilder() {
return new BuilderImpl(this);
}
public static Builder builder() {
return new BuilderImpl();
}
public static Class extends Builder> serializableBuilderClass() {
return BuilderImpl.class;
}
@Override
public final int hashCode() {
int hashCode = 1;
hashCode = 31 * hashCode + Objects.hashCode(certificate());
hashCode = 31 * hashCode + Objects.hashCode(hasEnvironmentVariables() ? environmentVariables() : null);
hashCode = 31 * hashCode + Objects.hashCode(privilegedMode());
hashCode = 31 * hashCode + Objects.hashCode(imagePullCredentialsType());
hashCode = 31 * hashCode + Objects.hashCode(registryCredential());
hashCode = 31 * hashCode + Objects.hashCode(type());
return hashCode;
}
@Override
public final boolean equals(Object obj) {
return equalsBySdkFields(obj);
}
@Override
public final boolean equalsBySdkFields(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof AwsCodeBuildProjectEnvironment)) {
return false;
}
AwsCodeBuildProjectEnvironment other = (AwsCodeBuildProjectEnvironment) obj;
return Objects.equals(certificate(), other.certificate()) && hasEnvironmentVariables() == other.hasEnvironmentVariables()
&& Objects.equals(environmentVariables(), other.environmentVariables())
&& Objects.equals(privilegedMode(), other.privilegedMode())
&& Objects.equals(imagePullCredentialsType(), other.imagePullCredentialsType())
&& Objects.equals(registryCredential(), other.registryCredential()) && Objects.equals(type(), other.type());
}
/**
* Returns a string representation of this object. This is useful for testing and debugging. Sensitive data will be
* redacted from this string using a placeholder value.
*/
@Override
public final String toString() {
return ToString.builder("AwsCodeBuildProjectEnvironment").add("Certificate", certificate())
.add("EnvironmentVariables", hasEnvironmentVariables() ? environmentVariables() : null)
.add("PrivilegedMode", privilegedMode()).add("ImagePullCredentialsType", imagePullCredentialsType())
.add("RegistryCredential", registryCredential()).add("Type", type()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "Certificate":
return Optional.ofNullable(clazz.cast(certificate()));
case "EnvironmentVariables":
return Optional.ofNullable(clazz.cast(environmentVariables()));
case "PrivilegedMode":
return Optional.ofNullable(clazz.cast(privilegedMode()));
case "ImagePullCredentialsType":
return Optional.ofNullable(clazz.cast(imagePullCredentialsType()));
case "RegistryCredential":
return Optional.ofNullable(clazz.cast(registryCredential()));
case "Type":
return Optional.ofNullable(clazz.cast(type()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function