/* * Copyright 2018-2023 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 com.amazonaws.services.lightsail.model; import java.io.Serializable; import javax.annotation.Generated; import com.amazonaws.protocol.StructuredPojo; import com.amazonaws.protocol.ProtocolMarshaller; /** *

* Describes the settings of a container that will be launched, or that is launched, to an Amazon Lightsail container * service. *

* * @see AWS API * Documentation */ @Generated("com.amazonaws:aws-java-sdk-code-generator") public class Container implements Serializable, Cloneable, StructuredPojo { /** *

* The name of the image used for the container. *

*

* Container images sourced from your Lightsail container service, that are registered and stored on your service, * start with a colon (:). For example, if your container service name is * container-service-1, the container image label is mystaticsite, and you want to use the * third (3) version of the registered container image, then you should specify * :container-service-1.mystaticsite.3. To use the latest version of a container image, specify * latest instead of a version number (for example, * :container-service-1.mystaticsite.latest). Lightsail will automatically use the highest numbered * version of the registered container image. *

*

* Container images sourced from a public registry like Docker Hub don't start with a colon. For example, * nginx:latest or nginx. *

*/ private String image; /** *

* The launch command for the container. *

*/ private java.util.List command; /** *

* The environment variables of the container. *

*/ private java.util.Map environment; /** *

* The open firewall ports of the container. *

*/ private java.util.Map ports; /** *

* The name of the image used for the container. *

*

* Container images sourced from your Lightsail container service, that are registered and stored on your service, * start with a colon (:). For example, if your container service name is * container-service-1, the container image label is mystaticsite, and you want to use the * third (3) version of the registered container image, then you should specify * :container-service-1.mystaticsite.3. To use the latest version of a container image, specify * latest instead of a version number (for example, * :container-service-1.mystaticsite.latest). Lightsail will automatically use the highest numbered * version of the registered container image. *

*

* Container images sourced from a public registry like Docker Hub don't start with a colon. For example, * nginx:latest or nginx. *

* * @param image * The name of the image used for the container.

*

* Container images sourced from your Lightsail container service, that are registered and stored on your * service, start with a colon (:). For example, if your container service name is * container-service-1, the container image label is mystaticsite, and you want to * use the third (3) version of the registered container image, then you should specify * :container-service-1.mystaticsite.3. To use the latest version of a container image, specify * latest instead of a version number (for example, * :container-service-1.mystaticsite.latest). Lightsail will automatically use the highest * numbered version of the registered container image. *

*

* Container images sourced from a public registry like Docker Hub don't start with a colon. For example, * nginx:latest or nginx. */ public void setImage(String image) { this.image = image; } /** *

* The name of the image used for the container. *

*

* Container images sourced from your Lightsail container service, that are registered and stored on your service, * start with a colon (:). For example, if your container service name is * container-service-1, the container image label is mystaticsite, and you want to use the * third (3) version of the registered container image, then you should specify * :container-service-1.mystaticsite.3. To use the latest version of a container image, specify * latest instead of a version number (for example, * :container-service-1.mystaticsite.latest). Lightsail will automatically use the highest numbered * version of the registered container image. *

*

* Container images sourced from a public registry like Docker Hub don't start with a colon. For example, * nginx:latest or nginx. *

* * @return The name of the image used for the container.

*

* Container images sourced from your Lightsail container service, that are registered and stored on your * service, start with a colon (:). For example, if your container service name is * container-service-1, the container image label is mystaticsite, and you want to * use the third (3) version of the registered container image, then you should specify * :container-service-1.mystaticsite.3. To use the latest version of a container image, specify * latest instead of a version number (for example, * :container-service-1.mystaticsite.latest). Lightsail will automatically use the highest * numbered version of the registered container image. *

*

* Container images sourced from a public registry like Docker Hub don't start with a colon. For example, * nginx:latest or nginx. */ public String getImage() { return this.image; } /** *

* The name of the image used for the container. *

*

* Container images sourced from your Lightsail container service, that are registered and stored on your service, * start with a colon (:). For example, if your container service name is * container-service-1, the container image label is mystaticsite, and you want to use the * third (3) version of the registered container image, then you should specify * :container-service-1.mystaticsite.3. To use the latest version of a container image, specify * latest instead of a version number (for example, * :container-service-1.mystaticsite.latest). Lightsail will automatically use the highest numbered * version of the registered container image. *

*

* Container images sourced from a public registry like Docker Hub don't start with a colon. For example, * nginx:latest or nginx. *

* * @param image * The name of the image used for the container.

*

* Container images sourced from your Lightsail container service, that are registered and stored on your * service, start with a colon (:). For example, if your container service name is * container-service-1, the container image label is mystaticsite, and you want to * use the third (3) version of the registered container image, then you should specify * :container-service-1.mystaticsite.3. To use the latest version of a container image, specify * latest instead of a version number (for example, * :container-service-1.mystaticsite.latest). Lightsail will automatically use the highest * numbered version of the registered container image. *

*

* Container images sourced from a public registry like Docker Hub don't start with a colon. For example, * nginx:latest or nginx. * @return Returns a reference to this object so that method calls can be chained together. */ public Container withImage(String image) { setImage(image); return this; } /** *

* The launch command for the container. *

* * @return The launch command for the container. */ public java.util.List getCommand() { return command; } /** *

* The launch command for the container. *

* * @param command * The launch command for the container. */ public void setCommand(java.util.Collection command) { if (command == null) { this.command = null; return; } this.command = new java.util.ArrayList(command); } /** *

* The launch command for the container. *

*

* NOTE: This method appends the values to the existing list (if any). Use * {@link #setCommand(java.util.Collection)} or {@link #withCommand(java.util.Collection)} if you want to override * the existing values. *

* * @param command * The launch command for the container. * @return Returns a reference to this object so that method calls can be chained together. */ public Container withCommand(String... command) { if (this.command == null) { setCommand(new java.util.ArrayList(command.length)); } for (String ele : command) { this.command.add(ele); } return this; } /** *

* The launch command for the container. *

* * @param command * The launch command for the container. * @return Returns a reference to this object so that method calls can be chained together. */ public Container withCommand(java.util.Collection command) { setCommand(command); return this; } /** *

* The environment variables of the container. *

* * @return The environment variables of the container. */ public java.util.Map getEnvironment() { return environment; } /** *

* The environment variables of the container. *

* * @param environment * The environment variables of the container. */ public void setEnvironment(java.util.Map environment) { this.environment = environment; } /** *

* The environment variables of the container. *

* * @param environment * The environment variables of the container. * @return Returns a reference to this object so that method calls can be chained together. */ public Container withEnvironment(java.util.Map environment) { setEnvironment(environment); return this; } /** * Add a single Environment entry * * @see Container#withEnvironment * @returns a reference to this object so that method calls can be chained together. */ public Container addEnvironmentEntry(String key, String value) { if (null == this.environment) { this.environment = new java.util.HashMap(); } if (this.environment.containsKey(key)) throw new IllegalArgumentException("Duplicated keys (" + key.toString() + ") are provided."); this.environment.put(key, value); return this; } /** * Removes all the entries added into Environment. * * @return Returns a reference to this object so that method calls can be chained together. */ public Container clearEnvironmentEntries() { this.environment = null; return this; } /** *

* The open firewall ports of the container. *

* * @return The open firewall ports of the container. */ public java.util.Map getPorts() { return ports; } /** *

* The open firewall ports of the container. *

* * @param ports * The open firewall ports of the container. */ public void setPorts(java.util.Map ports) { this.ports = ports; } /** *

* The open firewall ports of the container. *

* * @param ports * The open firewall ports of the container. * @return Returns a reference to this object so that method calls can be chained together. */ public Container withPorts(java.util.Map ports) { setPorts(ports); return this; } /** * Add a single Ports entry * * @see Container#withPorts * @returns a reference to this object so that method calls can be chained together. */ public Container addPortsEntry(String key, String value) { if (null == this.ports) { this.ports = new java.util.HashMap(); } if (this.ports.containsKey(key)) throw new IllegalArgumentException("Duplicated keys (" + key.toString() + ") are provided."); this.ports.put(key, value); return this; } /** * Removes all the entries added into Ports. * * @return Returns a reference to this object so that method calls can be chained together. */ public Container clearPortsEntries() { this.ports = null; return this; } /** * 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. * * @return A string representation of this object. * * @see java.lang.Object#toString() */ @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("{"); if (getImage() != null) sb.append("Image: ").append(getImage()).append(","); if (getCommand() != null) sb.append("Command: ").append(getCommand()).append(","); if (getEnvironment() != null) sb.append("Environment: ").append(getEnvironment()).append(","); if (getPorts() != null) sb.append("Ports: ").append(getPorts()); sb.append("}"); return sb.toString(); } @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (obj instanceof Container == false) return false; Container other = (Container) obj; if (other.getImage() == null ^ this.getImage() == null) return false; if (other.getImage() != null && other.getImage().equals(this.getImage()) == false) return false; if (other.getCommand() == null ^ this.getCommand() == null) return false; if (other.getCommand() != null && other.getCommand().equals(this.getCommand()) == false) return false; if (other.getEnvironment() == null ^ this.getEnvironment() == null) return false; if (other.getEnvironment() != null && other.getEnvironment().equals(this.getEnvironment()) == false) return false; if (other.getPorts() == null ^ this.getPorts() == null) return false; if (other.getPorts() != null && other.getPorts().equals(this.getPorts()) == false) return false; return true; } @Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getImage() == null) ? 0 : getImage().hashCode()); hashCode = prime * hashCode + ((getCommand() == null) ? 0 : getCommand().hashCode()); hashCode = prime * hashCode + ((getEnvironment() == null) ? 0 : getEnvironment().hashCode()); hashCode = prime * hashCode + ((getPorts() == null) ? 0 : getPorts().hashCode()); return hashCode; } @Override public Container clone() { try { return (Container) super.clone(); } catch (CloneNotSupportedException e) { throw new IllegalStateException("Got a CloneNotSupportedException from Object.clone() " + "even though we're Cloneable!", e); } } @com.amazonaws.annotation.SdkInternalApi @Override public void marshall(ProtocolMarshaller protocolMarshaller) { com.amazonaws.services.lightsail.model.transform.ContainerMarshaller.getInstance().marshall(this, protocolMarshaller); } }