software.amazon.awssdk.services.apprunner.model.CreateServiceRequest Maven / Gradle / Ivy
Show all versions of apprunner Show documentation
/*
* 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.util.Arrays;
import java.util.Collection;
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.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.awscore.AwsRequestOverrideConfiguration;
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;
/**
*/
@Generated("software.amazon.awssdk:codegen")
public final class CreateServiceRequest extends AppRunnerRequest implements
ToCopyableBuilder {
private static final SdkField SERVICE_NAME_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("ServiceName").getter(getter(CreateServiceRequest::serviceName)).setter(setter(Builder::serviceName))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ServiceName").build()).build();
private static final SdkField SOURCE_CONFIGURATION_FIELD = SdkField
. builder(MarshallingType.SDK_POJO).memberName("SourceConfiguration")
.getter(getter(CreateServiceRequest::sourceConfiguration)).setter(setter(Builder::sourceConfiguration))
.constructor(SourceConfiguration::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("SourceConfiguration").build())
.build();
private static final SdkField INSTANCE_CONFIGURATION_FIELD = SdkField
. builder(MarshallingType.SDK_POJO).memberName("InstanceConfiguration")
.getter(getter(CreateServiceRequest::instanceConfiguration)).setter(setter(Builder::instanceConfiguration))
.constructor(InstanceConfiguration::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("InstanceConfiguration").build())
.build();
private static final SdkField> TAGS_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("Tags")
.getter(getter(CreateServiceRequest::tags))
.setter(setter(Builder::tags))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Tags").build(),
ListTrait
.builder()
.memberLocationName(null)
.memberFieldInfo(
SdkField. builder(MarshallingType.SDK_POJO)
.constructor(Tag::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("member").build()).build()).build()).build();
private static final SdkField ENCRYPTION_CONFIGURATION_FIELD = SdkField
. builder(MarshallingType.SDK_POJO).memberName("EncryptionConfiguration")
.getter(getter(CreateServiceRequest::encryptionConfiguration)).setter(setter(Builder::encryptionConfiguration))
.constructor(EncryptionConfiguration::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("EncryptionConfiguration").build())
.build();
private static final SdkField HEALTH_CHECK_CONFIGURATION_FIELD = SdkField
. builder(MarshallingType.SDK_POJO).memberName("HealthCheckConfiguration")
.getter(getter(CreateServiceRequest::healthCheckConfiguration)).setter(setter(Builder::healthCheckConfiguration))
.constructor(HealthCheckConfiguration::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("HealthCheckConfiguration").build())
.build();
private static final SdkField AUTO_SCALING_CONFIGURATION_ARN_FIELD = SdkField
. builder(MarshallingType.STRING)
.memberName("AutoScalingConfigurationArn")
.getter(getter(CreateServiceRequest::autoScalingConfigurationArn))
.setter(setter(Builder::autoScalingConfigurationArn))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("AutoScalingConfigurationArn")
.build()).build();
private static final SdkField NETWORK_CONFIGURATION_FIELD = SdkField
. builder(MarshallingType.SDK_POJO).memberName("NetworkConfiguration")
.getter(getter(CreateServiceRequest::networkConfiguration)).setter(setter(Builder::networkConfiguration))
.constructor(NetworkConfiguration::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("NetworkConfiguration").build())
.build();
private static final SdkField OBSERVABILITY_CONFIGURATION_FIELD = SdkField
. builder(MarshallingType.SDK_POJO)
.memberName("ObservabilityConfiguration")
.getter(getter(CreateServiceRequest::observabilityConfiguration))
.setter(setter(Builder::observabilityConfiguration))
.constructor(ServiceObservabilityConfiguration::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ObservabilityConfiguration").build())
.build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(SERVICE_NAME_FIELD,
SOURCE_CONFIGURATION_FIELD, INSTANCE_CONFIGURATION_FIELD, TAGS_FIELD, ENCRYPTION_CONFIGURATION_FIELD,
HEALTH_CHECK_CONFIGURATION_FIELD, AUTO_SCALING_CONFIGURATION_ARN_FIELD, NETWORK_CONFIGURATION_FIELD,
OBSERVABILITY_CONFIGURATION_FIELD));
private static final Map> SDK_NAME_TO_FIELD = memberNameToFieldInitializer();
private final String serviceName;
private final SourceConfiguration sourceConfiguration;
private final InstanceConfiguration instanceConfiguration;
private final List tags;
private final EncryptionConfiguration encryptionConfiguration;
private final HealthCheckConfiguration healthCheckConfiguration;
private final String autoScalingConfigurationArn;
private final NetworkConfiguration networkConfiguration;
private final ServiceObservabilityConfiguration observabilityConfiguration;
private CreateServiceRequest(BuilderImpl builder) {
super(builder);
this.serviceName = builder.serviceName;
this.sourceConfiguration = builder.sourceConfiguration;
this.instanceConfiguration = builder.instanceConfiguration;
this.tags = builder.tags;
this.encryptionConfiguration = builder.encryptionConfiguration;
this.healthCheckConfiguration = builder.healthCheckConfiguration;
this.autoScalingConfigurationArn = builder.autoScalingConfigurationArn;
this.networkConfiguration = builder.networkConfiguration;
this.observabilityConfiguration = builder.observabilityConfiguration;
}
/**
*
* A name for the App Runner service. It must be unique across all the running App Runner services in your Amazon
* Web Services account in the Amazon Web Services Region.
*
*
* @return A name for the App Runner service. It must be unique across all the running App Runner services in your
* Amazon Web Services account in the Amazon Web Services Region.
*/
public final String serviceName() {
return serviceName;
}
/**
*
* The source to deploy to the App Runner service. It can be a code or an image repository.
*
*
* @return The source to deploy to the App Runner service. It can be a code or an image repository.
*/
public final SourceConfiguration sourceConfiguration() {
return sourceConfiguration;
}
/**
*
* The runtime configuration of instances (scaling units) of your service.
*
*
* @return The runtime configuration of instances (scaling units) of your service.
*/
public final InstanceConfiguration instanceConfiguration() {
return instanceConfiguration;
}
/**
* For responses, this returns true if the service returned a value for the Tags 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 hasTags() {
return tags != null && !(tags instanceof SdkAutoConstructList);
}
/**
*
* An optional list of metadata items that you can associate with the App Runner service resource. A tag is a
* key-value pair.
*
*
* 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 #hasTags} method.
*
*
* @return An optional list of metadata items that you can associate with the App Runner service resource. A tag is
* a key-value pair.
*/
public final List tags() {
return tags;
}
/**
*
* An optional custom encryption key that App Runner uses to encrypt the copy of your source repository that it
* maintains and your service logs. By default, App Runner uses an Amazon Web Services managed key.
*
*
* @return An optional custom encryption key that App Runner uses to encrypt the copy of your source repository that
* it maintains and your service logs. By default, App Runner uses an Amazon Web Services managed key.
*/
public final EncryptionConfiguration encryptionConfiguration() {
return encryptionConfiguration;
}
/**
*
* The settings for the health check that App Runner performs to monitor the health of the App Runner service.
*
*
* @return The settings for the health check that App Runner performs to monitor the health of the App Runner
* service.
*/
public final HealthCheckConfiguration healthCheckConfiguration() {
return healthCheckConfiguration;
}
/**
*
* The Amazon Resource Name (ARN) of an App Runner automatic scaling configuration resource that you want to
* associate with your service. If not provided, App Runner associates the latest revision of a default auto scaling
* configuration.
*
*
* Specify an ARN with a name and a revision number to associate that revision. For example:
* arn:aws:apprunner:us-east-1:123456789012:autoscalingconfiguration/high-availability/3
*
*
* Specify just the name to associate the latest revision. For example:
* arn:aws:apprunner:us-east-1:123456789012:autoscalingconfiguration/high-availability
*
*
* @return The Amazon Resource Name (ARN) of an App Runner automatic scaling configuration resource that you want to
* associate with your service. If not provided, App Runner associates the latest revision of a default auto
* scaling configuration.
*
* Specify an ARN with a name and a revision number to associate that revision. For example:
* arn:aws:apprunner:us-east-1:123456789012:autoscalingconfiguration/high-availability/3
*
*
* Specify just the name to associate the latest revision. For example:
* arn:aws:apprunner:us-east-1:123456789012:autoscalingconfiguration/high-availability
*/
public final String autoScalingConfigurationArn() {
return autoScalingConfigurationArn;
}
/**
*
* Configuration settings related to network traffic of the web application that the App Runner service runs.
*
*
* @return Configuration settings related to network traffic of the web application that the App Runner service
* runs.
*/
public final NetworkConfiguration networkConfiguration() {
return networkConfiguration;
}
/**
*
* The observability configuration of your service.
*
*
* @return The observability configuration of your service.
*/
public final ServiceObservabilityConfiguration observabilityConfiguration() {
return observabilityConfiguration;
}
@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 + super.hashCode();
hashCode = 31 * hashCode + Objects.hashCode(serviceName());
hashCode = 31 * hashCode + Objects.hashCode(sourceConfiguration());
hashCode = 31 * hashCode + Objects.hashCode(instanceConfiguration());
hashCode = 31 * hashCode + Objects.hashCode(hasTags() ? tags() : null);
hashCode = 31 * hashCode + Objects.hashCode(encryptionConfiguration());
hashCode = 31 * hashCode + Objects.hashCode(healthCheckConfiguration());
hashCode = 31 * hashCode + Objects.hashCode(autoScalingConfigurationArn());
hashCode = 31 * hashCode + Objects.hashCode(networkConfiguration());
hashCode = 31 * hashCode + Objects.hashCode(observabilityConfiguration());
return hashCode;
}
@Override
public final boolean equals(Object obj) {
return super.equals(obj) && equalsBySdkFields(obj);
}
@Override
public final boolean equalsBySdkFields(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof CreateServiceRequest)) {
return false;
}
CreateServiceRequest other = (CreateServiceRequest) obj;
return Objects.equals(serviceName(), other.serviceName())
&& Objects.equals(sourceConfiguration(), other.sourceConfiguration())
&& Objects.equals(instanceConfiguration(), other.instanceConfiguration()) && hasTags() == other.hasTags()
&& Objects.equals(tags(), other.tags())
&& Objects.equals(encryptionConfiguration(), other.encryptionConfiguration())
&& Objects.equals(healthCheckConfiguration(), other.healthCheckConfiguration())
&& Objects.equals(autoScalingConfigurationArn(), other.autoScalingConfigurationArn())
&& Objects.equals(networkConfiguration(), other.networkConfiguration())
&& Objects.equals(observabilityConfiguration(), other.observabilityConfiguration());
}
/**
* 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("CreateServiceRequest").add("ServiceName", serviceName())
.add("SourceConfiguration", sourceConfiguration()).add("InstanceConfiguration", instanceConfiguration())
.add("Tags", hasTags() ? tags() : null).add("EncryptionConfiguration", encryptionConfiguration())
.add("HealthCheckConfiguration", healthCheckConfiguration())
.add("AutoScalingConfigurationArn", autoScalingConfigurationArn())
.add("NetworkConfiguration", networkConfiguration())
.add("ObservabilityConfiguration", observabilityConfiguration()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "ServiceName":
return Optional.ofNullable(clazz.cast(serviceName()));
case "SourceConfiguration":
return Optional.ofNullable(clazz.cast(sourceConfiguration()));
case "InstanceConfiguration":
return Optional.ofNullable(clazz.cast(instanceConfiguration()));
case "Tags":
return Optional.ofNullable(clazz.cast(tags()));
case "EncryptionConfiguration":
return Optional.ofNullable(clazz.cast(encryptionConfiguration()));
case "HealthCheckConfiguration":
return Optional.ofNullable(clazz.cast(healthCheckConfiguration()));
case "AutoScalingConfigurationArn":
return Optional.ofNullable(clazz.cast(autoScalingConfigurationArn()));
case "NetworkConfiguration":
return Optional.ofNullable(clazz.cast(networkConfiguration()));
case "ObservabilityConfiguration":
return Optional.ofNullable(clazz.cast(observabilityConfiguration()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
@Override
public final Map> sdkFieldNameToField() {
return SDK_NAME_TO_FIELD;
}
private static Map> memberNameToFieldInitializer() {
Map> map = new HashMap<>();
map.put("ServiceName", SERVICE_NAME_FIELD);
map.put("SourceConfiguration", SOURCE_CONFIGURATION_FIELD);
map.put("InstanceConfiguration", INSTANCE_CONFIGURATION_FIELD);
map.put("Tags", TAGS_FIELD);
map.put("EncryptionConfiguration", ENCRYPTION_CONFIGURATION_FIELD);
map.put("HealthCheckConfiguration", HEALTH_CHECK_CONFIGURATION_FIELD);
map.put("AutoScalingConfigurationArn", AUTO_SCALING_CONFIGURATION_ARN_FIELD);
map.put("NetworkConfiguration", NETWORK_CONFIGURATION_FIELD);
map.put("ObservabilityConfiguration", OBSERVABILITY_CONFIGURATION_FIELD);
return Collections.unmodifiableMap(map);
}
private static Function