software.amazon.awssdk.services.opsworks.model.Recipes Maven / Gradle / Ivy
Show all versions of opsworks 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.opsworks.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.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.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;
/**
*
* AWS OpsWorks Stacks supports five lifecycle events: setup, configuration, deploy,
* undeploy, and shutdown. For each layer, AWS OpsWorks Stacks runs a set of standard recipes for each
* event. In addition, you can provide custom recipes for any or all layers and events. AWS OpsWorks Stacks runs custom
* event recipes after the standard recipes. LayerCustomRecipes
specifies the custom recipes for a
* particular layer to be run in response to each of the five events.
*
*
* To specify a recipe, use the cookbook's directory name in the repository followed by two colons and the recipe name,
* which is the recipe's file name without the .rb extension. For example: phpapp2::dbsetup specifies the dbsetup.rb
* recipe in the repository's phpapp2 folder.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class Recipes implements SdkPojo, Serializable, ToCopyableBuilder {
private static final SdkField> SETUP_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("Setup")
.getter(getter(Recipes::setup))
.setter(setter(Builder::setup))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Setup").build(),
ListTrait
.builder()
.memberLocationName(null)
.memberFieldInfo(
SdkField. builder(MarshallingType.STRING)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("member").build()).build()).build()).build();
private static final SdkField> CONFIGURE_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("Configure")
.getter(getter(Recipes::configure))
.setter(setter(Builder::configure))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Configure").build(),
ListTrait
.builder()
.memberLocationName(null)
.memberFieldInfo(
SdkField. builder(MarshallingType.STRING)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("member").build()).build()).build()).build();
private static final SdkField> DEPLOY_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("Deploy")
.getter(getter(Recipes::deploy))
.setter(setter(Builder::deploy))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Deploy").build(),
ListTrait
.builder()
.memberLocationName(null)
.memberFieldInfo(
SdkField. builder(MarshallingType.STRING)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("member").build()).build()).build()).build();
private static final SdkField> UNDEPLOY_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("Undeploy")
.getter(getter(Recipes::undeploy))
.setter(setter(Builder::undeploy))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Undeploy").build(),
ListTrait
.builder()
.memberLocationName(null)
.memberFieldInfo(
SdkField. builder(MarshallingType.STRING)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("member").build()).build()).build()).build();
private static final SdkField> SHUTDOWN_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("Shutdown")
.getter(getter(Recipes::shutdown))
.setter(setter(Builder::shutdown))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Shutdown").build(),
ListTrait
.builder()
.memberLocationName(null)
.memberFieldInfo(
SdkField. builder(MarshallingType.STRING)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("member").build()).build()).build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(SETUP_FIELD, CONFIGURE_FIELD,
DEPLOY_FIELD, UNDEPLOY_FIELD, SHUTDOWN_FIELD));
private static final long serialVersionUID = 1L;
private final List setup;
private final List configure;
private final List deploy;
private final List undeploy;
private final List shutdown;
private Recipes(BuilderImpl builder) {
this.setup = builder.setup;
this.configure = builder.configure;
this.deploy = builder.deploy;
this.undeploy = builder.undeploy;
this.shutdown = builder.shutdown;
}
/**
* Returns true if the Setup property was specified by the sender (it may be empty), or false if the sender did not
* specify the value (it will be empty). For responses returned by the SDK, the sender is the AWS service.
*/
public final boolean hasSetup() {
return setup != null && !(setup instanceof SdkAutoConstructList);
}
/**
*
* An array of custom recipe names to be run following a setup
event.
*
*
* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException.
*
*
* You can use {@link #hasSetup()} to see if a value was sent in this field.
*
*
* @return An array of custom recipe names to be run following a setup
event.
*/
public final List setup() {
return setup;
}
/**
* Returns true if the Configure property was specified by the sender (it may be empty), or false if the sender did
* not specify the value (it will be empty). For responses returned by the SDK, the sender is the AWS service.
*/
public final boolean hasConfigure() {
return configure != null && !(configure instanceof SdkAutoConstructList);
}
/**
*
* An array of custom recipe names to be run following a configure
event.
*
*
* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException.
*
*
* You can use {@link #hasConfigure()} to see if a value was sent in this field.
*
*
* @return An array of custom recipe names to be run following a configure
event.
*/
public final List configure() {
return configure;
}
/**
* Returns true if the Deploy property was specified by the sender (it may be empty), or false if the sender did not
* specify the value (it will be empty). For responses returned by the SDK, the sender is the AWS service.
*/
public final boolean hasDeploy() {
return deploy != null && !(deploy instanceof SdkAutoConstructList);
}
/**
*
* An array of custom recipe names to be run following a deploy
event.
*
*
* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException.
*
*
* You can use {@link #hasDeploy()} to see if a value was sent in this field.
*
*
* @return An array of custom recipe names to be run following a deploy
event.
*/
public final List deploy() {
return deploy;
}
/**
* Returns true if the Undeploy property was specified by the sender (it may be empty), or false if the sender did
* not specify the value (it will be empty). For responses returned by the SDK, the sender is the AWS service.
*/
public final boolean hasUndeploy() {
return undeploy != null && !(undeploy instanceof SdkAutoConstructList);
}
/**
*
* An array of custom recipe names to be run following a undeploy
event.
*
*
* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException.
*
*
* You can use {@link #hasUndeploy()} to see if a value was sent in this field.
*
*
* @return An array of custom recipe names to be run following a undeploy
event.
*/
public final List undeploy() {
return undeploy;
}
/**
* Returns true if the Shutdown property was specified by the sender (it may be empty), or false if the sender did
* not specify the value (it will be empty). For responses returned by the SDK, the sender is the AWS service.
*/
public final boolean hasShutdown() {
return shutdown != null && !(shutdown instanceof SdkAutoConstructList);
}
/**
*
* An array of custom recipe names to be run following a shutdown
event.
*
*
* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException.
*
*
* You can use {@link #hasShutdown()} to see if a value was sent in this field.
*
*
* @return An array of custom recipe names to be run following a shutdown
event.
*/
public final List shutdown() {
return shutdown;
}
@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(hasSetup() ? setup() : null);
hashCode = 31 * hashCode + Objects.hashCode(hasConfigure() ? configure() : null);
hashCode = 31 * hashCode + Objects.hashCode(hasDeploy() ? deploy() : null);
hashCode = 31 * hashCode + Objects.hashCode(hasUndeploy() ? undeploy() : null);
hashCode = 31 * hashCode + Objects.hashCode(hasShutdown() ? shutdown() : 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 Recipes)) {
return false;
}
Recipes other = (Recipes) obj;
return hasSetup() == other.hasSetup() && Objects.equals(setup(), other.setup()) && hasConfigure() == other.hasConfigure()
&& Objects.equals(configure(), other.configure()) && hasDeploy() == other.hasDeploy()
&& Objects.equals(deploy(), other.deploy()) && hasUndeploy() == other.hasUndeploy()
&& Objects.equals(undeploy(), other.undeploy()) && hasShutdown() == other.hasShutdown()
&& Objects.equals(shutdown(), other.shutdown());
}
/**
* 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("Recipes").add("Setup", hasSetup() ? setup() : null)
.add("Configure", hasConfigure() ? configure() : null).add("Deploy", hasDeploy() ? deploy() : null)
.add("Undeploy", hasUndeploy() ? undeploy() : null).add("Shutdown", hasShutdown() ? shutdown() : null).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "Setup":
return Optional.ofNullable(clazz.cast(setup()));
case "Configure":
return Optional.ofNullable(clazz.cast(configure()));
case "Deploy":
return Optional.ofNullable(clazz.cast(deploy()));
case "Undeploy":
return Optional.ofNullable(clazz.cast(undeploy()));
case "Shutdown":
return Optional.ofNullable(clazz.cast(shutdown()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function