All Downloads are FREE. Search and download functionalities are using the official Maven repository.

software.amazon.awssdk.services.ecs.model.LoadBalancer Maven / Gradle / Ivy

/*
 * Copyright 2014-2019 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.ecs.model;

import java.io.Serializable;
import java.util.Arrays;
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.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.utils.ToString;
import software.amazon.awssdk.utils.builder.CopyableBuilder;
import software.amazon.awssdk.utils.builder.ToCopyableBuilder;

/**
 * 

* Details on a load balancer to be used with a service or task set. *

*

* If the service is using the ECS deployment controller, you are limited to one load balancer or target * group. *

*

* If the service is using the CODE_DEPLOY deployment controller, the service is required to use either an * Application Load Balancer or Network Load Balancer. When you are creating an AWS CodeDeploy deployment group, you * specify two target groups (referred to as a targetGroupPair). Each target group binds to a separate task * set in the deployment. The load balancer can also have up to two listeners, a required listener for production * traffic and an optional listener that allows you to test new revisions of the service before routing production * traffic to it. *

*

* Services with tasks that use the awsvpc network mode (for example, those with the Fargate launch type) * only support Application Load Balancers and Network Load Balancers. Classic Load Balancers are not supported. Also, * when you create any target groups for these services, you must choose ip as the target type, not * instance. Tasks that use the awsvpc network mode are associated with an elastic network * interface, not an Amazon EC2 instance. *

*/ @Generated("software.amazon.awssdk:codegen") public final class LoadBalancer implements SdkPojo, Serializable, ToCopyableBuilder { private static final SdkField TARGET_GROUP_ARN_FIELD = SdkField. builder(MarshallingType.STRING) .getter(getter(LoadBalancer::targetGroupArn)).setter(setter(Builder::targetGroupArn)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("targetGroupArn").build()).build(); private static final SdkField LOAD_BALANCER_NAME_FIELD = SdkField. builder(MarshallingType.STRING) .getter(getter(LoadBalancer::loadBalancerName)).setter(setter(Builder::loadBalancerName)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("loadBalancerName").build()).build(); private static final SdkField CONTAINER_NAME_FIELD = SdkField. builder(MarshallingType.STRING) .getter(getter(LoadBalancer::containerName)).setter(setter(Builder::containerName)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("containerName").build()).build(); private static final SdkField CONTAINER_PORT_FIELD = SdkField. builder(MarshallingType.INTEGER) .getter(getter(LoadBalancer::containerPort)).setter(setter(Builder::containerPort)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("containerPort").build()).build(); private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(TARGET_GROUP_ARN_FIELD, LOAD_BALANCER_NAME_FIELD, CONTAINER_NAME_FIELD, CONTAINER_PORT_FIELD)); private static final long serialVersionUID = 1L; private final String targetGroupArn; private final String loadBalancerName; private final String containerName; private final Integer containerPort; private LoadBalancer(BuilderImpl builder) { this.targetGroupArn = builder.targetGroupArn; this.loadBalancerName = builder.loadBalancerName; this.containerName = builder.containerName; this.containerPort = builder.containerPort; } /** *

* The full Amazon Resource Name (ARN) of the Elastic Load Balancing target group or groups associated with a * service or task set. *

*

* A target group ARN is only specified when using an application load balancer or a network load balancer. If you * are using a classic load balancer this should be omitted. *

*

* For services using the ECS deployment controller, you are limited to one target group. For services * using the CODE_DEPLOY deployment controller, you are required to define two target groups for the * load balancer. *

* *

* If your service's task definition uses the awsvpc network mode (which is required for the Fargate * launch type), you must choose ip as the target type, not instance, because tasks that * use the awsvpc network mode are associated with an elastic network interface, not an Amazon EC2 * instance. *

*
* * @return The full Amazon Resource Name (ARN) of the Elastic Load Balancing target group or groups associated with * a service or task set.

*

* A target group ARN is only specified when using an application load balancer or a network load balancer. * If you are using a classic load balancer this should be omitted. *

*

* For services using the ECS deployment controller, you are limited to one target group. For * services using the CODE_DEPLOY deployment controller, you are required to define two target * groups for the load balancer. *

* *

* If your service's task definition uses the awsvpc network mode (which is required for the * Fargate launch type), you must choose ip as the target type, not instance, * because tasks that use the awsvpc network mode are associated with an elastic network * interface, not an Amazon EC2 instance. *

*/ public String targetGroupArn() { return targetGroupArn; } /** *

* The name of the load balancer to associate with the Amazon ECS service or task set. *

*

* A load balancer name is only specified when using a classic load balancer. If you are using an application load * balancer or a network load balancer this should be omitted. *

* * @return The name of the load balancer to associate with the Amazon ECS service or task set.

*

* A load balancer name is only specified when using a classic load balancer. If you are using an * application load balancer or a network load balancer this should be omitted. */ public String loadBalancerName() { return loadBalancerName; } /** *

* The name of the container (as it appears in a container definition) to associate with the load balancer. *

* * @return The name of the container (as it appears in a container definition) to associate with the load balancer. */ public String containerName() { return containerName; } /** *

* The port on the container to associate with the load balancer. This port must correspond to a * containerPort in the service's task definition. Your container instances must allow ingress traffic * on the hostPort of the port mapping. *

* * @return The port on the container to associate with the load balancer. This port must correspond to a * containerPort in the service's task definition. Your container instances must allow ingress * traffic on the hostPort of the port mapping. */ public Integer containerPort() { return containerPort; } @Override public Builder toBuilder() { return new BuilderImpl(this); } public static Builder builder() { return new BuilderImpl(); } public static Class serializableBuilderClass() { return BuilderImpl.class; } @Override public int hashCode() { int hashCode = 1; hashCode = 31 * hashCode + Objects.hashCode(targetGroupArn()); hashCode = 31 * hashCode + Objects.hashCode(loadBalancerName()); hashCode = 31 * hashCode + Objects.hashCode(containerName()); hashCode = 31 * hashCode + Objects.hashCode(containerPort()); return hashCode; } @Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (!(obj instanceof LoadBalancer)) { return false; } LoadBalancer other = (LoadBalancer) obj; return Objects.equals(targetGroupArn(), other.targetGroupArn()) && Objects.equals(loadBalancerName(), other.loadBalancerName()) && Objects.equals(containerName(), other.containerName()) && Objects.equals(containerPort(), other.containerPort()); } /** * 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 String toString() { return ToString.builder("LoadBalancer").add("TargetGroupArn", targetGroupArn()) .add("LoadBalancerName", loadBalancerName()).add("ContainerName", containerName()) .add("ContainerPort", containerPort()).build(); } public Optional getValueForField(String fieldName, Class clazz) { switch (fieldName) { case "targetGroupArn": return Optional.ofNullable(clazz.cast(targetGroupArn())); case "loadBalancerName": return Optional.ofNullable(clazz.cast(loadBalancerName())); case "containerName": return Optional.ofNullable(clazz.cast(containerName())); case "containerPort": return Optional.ofNullable(clazz.cast(containerPort())); default: return Optional.empty(); } } @Override public List> sdkFields() { return SDK_FIELDS; } private static Function getter(Function g) { return obj -> g.apply((LoadBalancer) obj); } private static BiConsumer setter(BiConsumer s) { return (obj, val) -> s.accept((Builder) obj, val); } public interface Builder extends SdkPojo, CopyableBuilder { /** *

* The full Amazon Resource Name (ARN) of the Elastic Load Balancing target group or groups associated with a * service or task set. *

*

* A target group ARN is only specified when using an application load balancer or a network load balancer. If * you are using a classic load balancer this should be omitted. *

*

* For services using the ECS deployment controller, you are limited to one target group. For * services using the CODE_DEPLOY deployment controller, you are required to define two target * groups for the load balancer. *

* *

* If your service's task definition uses the awsvpc network mode (which is required for the * Fargate launch type), you must choose ip as the target type, not instance, because * tasks that use the awsvpc network mode are associated with an elastic network interface, not an * Amazon EC2 instance. *

*
* * @param targetGroupArn * The full Amazon Resource Name (ARN) of the Elastic Load Balancing target group or groups associated * with a service or task set.

*

* A target group ARN is only specified when using an application load balancer or a network load * balancer. If you are using a classic load balancer this should be omitted. *

*

* For services using the ECS deployment controller, you are limited to one target group. * For services using the CODE_DEPLOY deployment controller, you are required to define two * target groups for the load balancer. *

* *

* If your service's task definition uses the awsvpc network mode (which is required for the * Fargate launch type), you must choose ip as the target type, not instance, * because tasks that use the awsvpc network mode are associated with an elastic network * interface, not an Amazon EC2 instance. *

* @return Returns a reference to this object so that method calls can be chained together. */ Builder targetGroupArn(String targetGroupArn); /** *

* The name of the load balancer to associate with the Amazon ECS service or task set. *

*

* A load balancer name is only specified when using a classic load balancer. If you are using an application * load balancer or a network load balancer this should be omitted. *

* * @param loadBalancerName * The name of the load balancer to associate with the Amazon ECS service or task set.

*

* A load balancer name is only specified when using a classic load balancer. If you are using an * application load balancer or a network load balancer this should be omitted. * @return Returns a reference to this object so that method calls can be chained together. */ Builder loadBalancerName(String loadBalancerName); /** *

* The name of the container (as it appears in a container definition) to associate with the load balancer. *

* * @param containerName * The name of the container (as it appears in a container definition) to associate with the load * balancer. * @return Returns a reference to this object so that method calls can be chained together. */ Builder containerName(String containerName); /** *

* The port on the container to associate with the load balancer. This port must correspond to a * containerPort in the service's task definition. Your container instances must allow ingress * traffic on the hostPort of the port mapping. *

* * @param containerPort * The port on the container to associate with the load balancer. This port must correspond to a * containerPort in the service's task definition. Your container instances must allow * ingress traffic on the hostPort of the port mapping. * @return Returns a reference to this object so that method calls can be chained together. */ Builder containerPort(Integer containerPort); } static final class BuilderImpl implements Builder { private String targetGroupArn; private String loadBalancerName; private String containerName; private Integer containerPort; private BuilderImpl() { } private BuilderImpl(LoadBalancer model) { targetGroupArn(model.targetGroupArn); loadBalancerName(model.loadBalancerName); containerName(model.containerName); containerPort(model.containerPort); } public final String getTargetGroupArn() { return targetGroupArn; } @Override public final Builder targetGroupArn(String targetGroupArn) { this.targetGroupArn = targetGroupArn; return this; } public final void setTargetGroupArn(String targetGroupArn) { this.targetGroupArn = targetGroupArn; } public final String getLoadBalancerName() { return loadBalancerName; } @Override public final Builder loadBalancerName(String loadBalancerName) { this.loadBalancerName = loadBalancerName; return this; } public final void setLoadBalancerName(String loadBalancerName) { this.loadBalancerName = loadBalancerName; } public final String getContainerName() { return containerName; } @Override public final Builder containerName(String containerName) { this.containerName = containerName; return this; } public final void setContainerName(String containerName) { this.containerName = containerName; } public final Integer getContainerPort() { return containerPort; } @Override public final Builder containerPort(Integer containerPort) { this.containerPort = containerPort; return this; } public final void setContainerPort(Integer containerPort) { this.containerPort = containerPort; } @Override public LoadBalancer build() { return new LoadBalancer(this); } @Override public List> sdkFields() { return SDK_FIELDS; } } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy