Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
software.amazon.awssdk.services.apprunner.model.ImageConfiguration 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.apprunner.model;
import java.io.Serializable;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.function.BiConsumer;
import java.util.function.Function;
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.LocationTrait;
import software.amazon.awssdk.core.traits.MapTrait;
import software.amazon.awssdk.core.util.DefaultSdkAutoConstructMap;
import software.amazon.awssdk.core.util.SdkAutoConstructMap;
import software.amazon.awssdk.utils.ToString;
import software.amazon.awssdk.utils.builder.CopyableBuilder;
import software.amazon.awssdk.utils.builder.ToCopyableBuilder;
/**
*
* Describes the configuration that App Runner uses to run an App Runner service using an image pulled from a source
* image repository.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class ImageConfiguration implements SdkPojo, Serializable,
ToCopyableBuilder {
private static final SdkField> RUNTIME_ENVIRONMENT_VARIABLES_FIELD = SdkField
.> builder(MarshallingType.MAP)
.memberName("RuntimeEnvironmentVariables")
.getter(getter(ImageConfiguration::runtimeEnvironmentVariables))
.setter(setter(Builder::runtimeEnvironmentVariables))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("RuntimeEnvironmentVariables")
.build(),
MapTrait.builder()
.keyLocationName("key")
.valueLocationName("value")
.valueFieldInfo(
SdkField. builder(MarshallingType.STRING)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("value").build()).build()).build()).build();
private static final SdkField START_COMMAND_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("StartCommand").getter(getter(ImageConfiguration::startCommand)).setter(setter(Builder::startCommand))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("StartCommand").build()).build();
private static final SdkField PORT_FIELD = SdkField. builder(MarshallingType.STRING).memberName("Port")
.getter(getter(ImageConfiguration::port)).setter(setter(Builder::port))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Port").build()).build();
private static final SdkField> RUNTIME_ENVIRONMENT_SECRETS_FIELD = SdkField
.> builder(MarshallingType.MAP)
.memberName("RuntimeEnvironmentSecrets")
.getter(getter(ImageConfiguration::runtimeEnvironmentSecrets))
.setter(setter(Builder::runtimeEnvironmentSecrets))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("RuntimeEnvironmentSecrets").build(),
MapTrait.builder()
.keyLocationName("key")
.valueLocationName("value")
.valueFieldInfo(
SdkField. builder(MarshallingType.STRING)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("value").build()).build()).build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(
RUNTIME_ENVIRONMENT_VARIABLES_FIELD, START_COMMAND_FIELD, PORT_FIELD, RUNTIME_ENVIRONMENT_SECRETS_FIELD));
private static final Map> SDK_NAME_TO_FIELD = Collections
.unmodifiableMap(new HashMap>() {
{
put("RuntimeEnvironmentVariables", RUNTIME_ENVIRONMENT_VARIABLES_FIELD);
put("StartCommand", START_COMMAND_FIELD);
put("Port", PORT_FIELD);
put("RuntimeEnvironmentSecrets", RUNTIME_ENVIRONMENT_SECRETS_FIELD);
}
});
private static final long serialVersionUID = 1L;
private final Map runtimeEnvironmentVariables;
private final String startCommand;
private final String port;
private final Map runtimeEnvironmentSecrets;
private ImageConfiguration(BuilderImpl builder) {
this.runtimeEnvironmentVariables = builder.runtimeEnvironmentVariables;
this.startCommand = builder.startCommand;
this.port = builder.port;
this.runtimeEnvironmentSecrets = builder.runtimeEnvironmentSecrets;
}
/**
* For responses, this returns true if the service returned a value for the RuntimeEnvironmentVariables 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 hasRuntimeEnvironmentVariables() {
return runtimeEnvironmentVariables != null && !(runtimeEnvironmentVariables instanceof SdkAutoConstructMap);
}
/**
*
* Environment variables that are available to your running App Runner service. An array of key-value pairs.
*
*
* 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 #hasRuntimeEnvironmentVariables} method.
*
*
* @return Environment variables that are available to your running App Runner service. An array of key-value pairs.
*/
public final Map runtimeEnvironmentVariables() {
return runtimeEnvironmentVariables;
}
/**
*
* An optional command that App Runner runs to start the application in the source image. If specified, this command
* overrides the Docker image’s default start command.
*
*
* @return An optional command that App Runner runs to start the application in the source image. If specified, this
* command overrides the Docker image’s default start command.
*/
public final String startCommand() {
return startCommand;
}
/**
*
* The port that your application listens to in the container.
*
*
* Default: 8080
*
*
* @return The port that your application listens to in the container.
*
* Default: 8080
*/
public final String port() {
return port;
}
/**
* For responses, this returns true if the service returned a value for the RuntimeEnvironmentSecrets 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 hasRuntimeEnvironmentSecrets() {
return runtimeEnvironmentSecrets != null && !(runtimeEnvironmentSecrets instanceof SdkAutoConstructMap);
}
/**
*
* An array of key-value pairs representing the secrets and parameters that get referenced to your service as an
* environment variable. The supported values are either the full Amazon Resource Name (ARN) of the Secrets Manager
* secret or the full ARN of the parameter in the Amazon Web Services Systems Manager Parameter Store.
*
*
*
*
*
* If the Amazon Web Services Systems Manager Parameter Store parameter exists in the same Amazon Web Services
* Region as the service that you're launching, you can use either the full ARN or name of the secret. If the
* parameter exists in a different Region, then the full ARN must be specified.
*
*
*
*
* Currently, cross account referencing of Amazon Web Services Systems Manager Parameter Store parameter is not
* supported.
*
*
*
*
*
* 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 #hasRuntimeEnvironmentSecrets} method.
*
*
* @return An array of key-value pairs representing the secrets and parameters that get referenced to your service
* as an environment variable. The supported values are either the full Amazon Resource Name (ARN) of the
* Secrets Manager secret or the full ARN of the parameter in the Amazon Web Services Systems Manager
* Parameter Store.
*
*
*
* If the Amazon Web Services Systems Manager Parameter Store parameter exists in the same Amazon Web
* Services Region as the service that you're launching, you can use either the full ARN or name of the
* secret. If the parameter exists in a different Region, then the full ARN must be specified.
*
*
*
*
* Currently, cross account referencing of Amazon Web Services Systems Manager Parameter Store parameter is
* not supported.
*
*
*
*/
public final Map runtimeEnvironmentSecrets() {
return runtimeEnvironmentSecrets;
}
@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(hasRuntimeEnvironmentVariables() ? runtimeEnvironmentVariables() : null);
hashCode = 31 * hashCode + Objects.hashCode(startCommand());
hashCode = 31 * hashCode + Objects.hashCode(port());
hashCode = 31 * hashCode + Objects.hashCode(hasRuntimeEnvironmentSecrets() ? runtimeEnvironmentSecrets() : null);
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 ImageConfiguration)) {
return false;
}
ImageConfiguration other = (ImageConfiguration) obj;
return hasRuntimeEnvironmentVariables() == other.hasRuntimeEnvironmentVariables()
&& Objects.equals(runtimeEnvironmentVariables(), other.runtimeEnvironmentVariables())
&& Objects.equals(startCommand(), other.startCommand()) && Objects.equals(port(), other.port())
&& hasRuntimeEnvironmentSecrets() == other.hasRuntimeEnvironmentSecrets()
&& Objects.equals(runtimeEnvironmentSecrets(), other.runtimeEnvironmentSecrets());
}
/**
* 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("ImageConfiguration")
.add("RuntimeEnvironmentVariables",
runtimeEnvironmentVariables() == null ? null : "*** Sensitive Data Redacted ***")
.add("StartCommand", startCommand() == null ? null : "*** Sensitive Data Redacted ***").add("Port", port())
.add("RuntimeEnvironmentSecrets", runtimeEnvironmentSecrets() == null ? null : "*** Sensitive Data Redacted ***")
.build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "RuntimeEnvironmentVariables":
return Optional.ofNullable(clazz.cast(runtimeEnvironmentVariables()));
case "StartCommand":
return Optional.ofNullable(clazz.cast(startCommand()));
case "Port":
return Optional.ofNullable(clazz.cast(port()));
case "RuntimeEnvironmentSecrets":
return Optional.ofNullable(clazz.cast(runtimeEnvironmentSecrets()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
@Override
public final Map> sdkFieldNameToField() {
return SDK_NAME_TO_FIELD;
}
private static Function getter(Function g) {
return obj -> g.apply((ImageConfiguration) obj);
}
private static BiConsumer setter(BiConsumer s) {
return (obj, val) -> s.accept((Builder) obj, val);
}
public interface Builder extends SdkPojo, CopyableBuilder {
/**
*
* Environment variables that are available to your running App Runner service. An array of key-value pairs.
*
*
* @param runtimeEnvironmentVariables
* Environment variables that are available to your running App Runner service. An array of key-value
* pairs.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder runtimeEnvironmentVariables(Map runtimeEnvironmentVariables);
/**
*
* An optional command that App Runner runs to start the application in the source image. If specified, this
* command overrides the Docker image’s default start command.
*
*
* @param startCommand
* An optional command that App Runner runs to start the application in the source image. If specified,
* this command overrides the Docker image’s default start command.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder startCommand(String startCommand);
/**
*
* The port that your application listens to in the container.
*
*
* Default: 8080
*
*
* @param port
* The port that your application listens to in the container.
*
* Default: 8080
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder port(String port);
/**
*
* An array of key-value pairs representing the secrets and parameters that get referenced to your service as an
* environment variable. The supported values are either the full Amazon Resource Name (ARN) of the Secrets
* Manager secret or the full ARN of the parameter in the Amazon Web Services Systems Manager Parameter Store.
*
*
*
*
*
* If the Amazon Web Services Systems Manager Parameter Store parameter exists in the same Amazon Web Services
* Region as the service that you're launching, you can use either the full ARN or name of the secret. If the
* parameter exists in a different Region, then the full ARN must be specified.
*
*
*
*
* Currently, cross account referencing of Amazon Web Services Systems Manager Parameter Store parameter is not
* supported.
*
*
*
*
*
* @param runtimeEnvironmentSecrets
* An array of key-value pairs representing the secrets and parameters that get referenced to your
* service as an environment variable. The supported values are either the full Amazon Resource Name
* (ARN) of the Secrets Manager secret or the full ARN of the parameter in the Amazon Web Services
* Systems Manager Parameter Store.
*
*
*
* If the Amazon Web Services Systems Manager Parameter Store parameter exists in the same Amazon Web
* Services Region as the service that you're launching, you can use either the full ARN or name of the
* secret. If the parameter exists in a different Region, then the full ARN must be specified.
*
*
*
*
* Currently, cross account referencing of Amazon Web Services Systems Manager Parameter Store parameter
* is not supported.
*
*
*
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder runtimeEnvironmentSecrets(Map runtimeEnvironmentSecrets);
}
static final class BuilderImpl implements Builder {
private Map runtimeEnvironmentVariables = DefaultSdkAutoConstructMap.getInstance();
private String startCommand;
private String port;
private Map runtimeEnvironmentSecrets = DefaultSdkAutoConstructMap.getInstance();
private BuilderImpl() {
}
private BuilderImpl(ImageConfiguration model) {
runtimeEnvironmentVariables(model.runtimeEnvironmentVariables);
startCommand(model.startCommand);
port(model.port);
runtimeEnvironmentSecrets(model.runtimeEnvironmentSecrets);
}
public final Map getRuntimeEnvironmentVariables() {
if (runtimeEnvironmentVariables instanceof SdkAutoConstructMap) {
return null;
}
return runtimeEnvironmentVariables;
}
public final void setRuntimeEnvironmentVariables(Map runtimeEnvironmentVariables) {
this.runtimeEnvironmentVariables = RuntimeEnvironmentVariablesCopier.copy(runtimeEnvironmentVariables);
}
@Override
public final Builder runtimeEnvironmentVariables(Map runtimeEnvironmentVariables) {
this.runtimeEnvironmentVariables = RuntimeEnvironmentVariablesCopier.copy(runtimeEnvironmentVariables);
return this;
}
public final String getStartCommand() {
return startCommand;
}
public final void setStartCommand(String startCommand) {
this.startCommand = startCommand;
}
@Override
public final Builder startCommand(String startCommand) {
this.startCommand = startCommand;
return this;
}
public final String getPort() {
return port;
}
public final void setPort(String port) {
this.port = port;
}
@Override
public final Builder port(String port) {
this.port = port;
return this;
}
public final Map getRuntimeEnvironmentSecrets() {
if (runtimeEnvironmentSecrets instanceof SdkAutoConstructMap) {
return null;
}
return runtimeEnvironmentSecrets;
}
public final void setRuntimeEnvironmentSecrets(Map runtimeEnvironmentSecrets) {
this.runtimeEnvironmentSecrets = RuntimeEnvironmentSecretsCopier.copy(runtimeEnvironmentSecrets);
}
@Override
public final Builder runtimeEnvironmentSecrets(Map runtimeEnvironmentSecrets) {
this.runtimeEnvironmentSecrets = RuntimeEnvironmentSecretsCopier.copy(runtimeEnvironmentSecrets);
return this;
}
@Override
public ImageConfiguration build() {
return new ImageConfiguration(this);
}
@Override
public List> sdkFields() {
return SDK_FIELDS;
}
@Override
public Map> sdkFieldNameToField() {
return SDK_NAME_TO_FIELD;
}
}
}