All Downloads are FREE. Search and download functionalities are using the official Maven repository.
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.apigateway.model.CanarySettings 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.apigateway.model;
import java.io.Serializable;
import java.util.Arrays;
import java.util.Collections;
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;
/**
*
* Configuration settings of a canary deployment.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class CanarySettings implements SdkPojo, Serializable, ToCopyableBuilder {
private static final SdkField PERCENT_TRAFFIC_FIELD = SdkField. builder(MarshallingType.DOUBLE)
.memberName("percentTraffic").getter(getter(CanarySettings::percentTraffic)).setter(setter(Builder::percentTraffic))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("percentTraffic").build()).build();
private static final SdkField DEPLOYMENT_ID_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("deploymentId").getter(getter(CanarySettings::deploymentId)).setter(setter(Builder::deploymentId))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("deploymentId").build()).build();
private static final SdkField> STAGE_VARIABLE_OVERRIDES_FIELD = SdkField
.> builder(MarshallingType.MAP)
.memberName("stageVariableOverrides")
.getter(getter(CanarySettings::stageVariableOverrides))
.setter(setter(Builder::stageVariableOverrides))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("stageVariableOverrides").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 USE_STAGE_CACHE_FIELD = SdkField. builder(MarshallingType.BOOLEAN)
.memberName("useStageCache").getter(getter(CanarySettings::useStageCache)).setter(setter(Builder::useStageCache))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("useStageCache").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(PERCENT_TRAFFIC_FIELD,
DEPLOYMENT_ID_FIELD, STAGE_VARIABLE_OVERRIDES_FIELD, USE_STAGE_CACHE_FIELD));
private static final long serialVersionUID = 1L;
private final Double percentTraffic;
private final String deploymentId;
private final Map stageVariableOverrides;
private final Boolean useStageCache;
private CanarySettings(BuilderImpl builder) {
this.percentTraffic = builder.percentTraffic;
this.deploymentId = builder.deploymentId;
this.stageVariableOverrides = builder.stageVariableOverrides;
this.useStageCache = builder.useStageCache;
}
/**
*
* The percent (0-100) of traffic diverted to a canary deployment.
*
*
* @return The percent (0-100) of traffic diverted to a canary deployment.
*/
public final Double percentTraffic() {
return percentTraffic;
}
/**
*
* The ID of the canary deployment.
*
*
* @return The ID of the canary deployment.
*/
public final String deploymentId() {
return deploymentId;
}
/**
* For responses, this returns true if the service returned a value for the StageVariableOverrides 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 hasStageVariableOverrides() {
return stageVariableOverrides != null && !(stageVariableOverrides instanceof SdkAutoConstructMap);
}
/**
*
* Stage variables overridden for a canary release deployment, including new stage variables introduced in the
* canary. These stage variables are represented as a string-to-string map between stage variable names and their
* values.
*
*
* 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 #hasStageVariableOverrides} method.
*
*
* @return Stage variables overridden for a canary release deployment, including new stage variables introduced in
* the canary. These stage variables are represented as a string-to-string map between stage variable names
* and their values.
*/
public final Map stageVariableOverrides() {
return stageVariableOverrides;
}
/**
*
* A Boolean flag to indicate whether the canary deployment uses the stage cache or not.
*
*
* @return A Boolean flag to indicate whether the canary deployment uses the stage cache or not.
*/
public final Boolean useStageCache() {
return useStageCache;
}
@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(percentTraffic());
hashCode = 31 * hashCode + Objects.hashCode(deploymentId());
hashCode = 31 * hashCode + Objects.hashCode(hasStageVariableOverrides() ? stageVariableOverrides() : null);
hashCode = 31 * hashCode + Objects.hashCode(useStageCache());
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 CanarySettings)) {
return false;
}
CanarySettings other = (CanarySettings) obj;
return Objects.equals(percentTraffic(), other.percentTraffic()) && Objects.equals(deploymentId(), other.deploymentId())
&& hasStageVariableOverrides() == other.hasStageVariableOverrides()
&& Objects.equals(stageVariableOverrides(), other.stageVariableOverrides())
&& Objects.equals(useStageCache(), other.useStageCache());
}
/**
* 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("CanarySettings").add("PercentTraffic", percentTraffic()).add("DeploymentId", deploymentId())
.add("StageVariableOverrides", hasStageVariableOverrides() ? stageVariableOverrides() : null)
.add("UseStageCache", useStageCache()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "percentTraffic":
return Optional.ofNullable(clazz.cast(percentTraffic()));
case "deploymentId":
return Optional.ofNullable(clazz.cast(deploymentId()));
case "stageVariableOverrides":
return Optional.ofNullable(clazz.cast(stageVariableOverrides()));
case "useStageCache":
return Optional.ofNullable(clazz.cast(useStageCache()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function getter(Function g) {
return obj -> g.apply((CanarySettings) obj);
}
private static BiConsumer setter(BiConsumer s) {
return (obj, val) -> s.accept((Builder) obj, val);
}
public interface Builder extends SdkPojo, CopyableBuilder {
/**
*
* The percent (0-100) of traffic diverted to a canary deployment.
*
*
* @param percentTraffic
* The percent (0-100) of traffic diverted to a canary deployment.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder percentTraffic(Double percentTraffic);
/**
*
* The ID of the canary deployment.
*
*
* @param deploymentId
* The ID of the canary deployment.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder deploymentId(String deploymentId);
/**
*
* Stage variables overridden for a canary release deployment, including new stage variables introduced in the
* canary. These stage variables are represented as a string-to-string map between stage variable names and
* their values.
*
*
* @param stageVariableOverrides
* Stage variables overridden for a canary release deployment, including new stage variables introduced
* in the canary. These stage variables are represented as a string-to-string map between stage variable
* names and their values.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder stageVariableOverrides(Map stageVariableOverrides);
/**
*
* A Boolean flag to indicate whether the canary deployment uses the stage cache or not.
*
*
* @param useStageCache
* A Boolean flag to indicate whether the canary deployment uses the stage cache or not.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder useStageCache(Boolean useStageCache);
}
static final class BuilderImpl implements Builder {
private Double percentTraffic;
private String deploymentId;
private Map stageVariableOverrides = DefaultSdkAutoConstructMap.getInstance();
private Boolean useStageCache;
private BuilderImpl() {
}
private BuilderImpl(CanarySettings model) {
percentTraffic(model.percentTraffic);
deploymentId(model.deploymentId);
stageVariableOverrides(model.stageVariableOverrides);
useStageCache(model.useStageCache);
}
public final Double getPercentTraffic() {
return percentTraffic;
}
public final void setPercentTraffic(Double percentTraffic) {
this.percentTraffic = percentTraffic;
}
@Override
public final Builder percentTraffic(Double percentTraffic) {
this.percentTraffic = percentTraffic;
return this;
}
public final String getDeploymentId() {
return deploymentId;
}
public final void setDeploymentId(String deploymentId) {
this.deploymentId = deploymentId;
}
@Override
public final Builder deploymentId(String deploymentId) {
this.deploymentId = deploymentId;
return this;
}
public final Map getStageVariableOverrides() {
if (stageVariableOverrides instanceof SdkAutoConstructMap) {
return null;
}
return stageVariableOverrides;
}
public final void setStageVariableOverrides(Map stageVariableOverrides) {
this.stageVariableOverrides = MapOfStringToStringCopier.copy(stageVariableOverrides);
}
@Override
public final Builder stageVariableOverrides(Map stageVariableOverrides) {
this.stageVariableOverrides = MapOfStringToStringCopier.copy(stageVariableOverrides);
return this;
}
public final Boolean getUseStageCache() {
return useStageCache;
}
public final void setUseStageCache(Boolean useStageCache) {
this.useStageCache = useStageCache;
}
@Override
public final Builder useStageCache(Boolean useStageCache) {
this.useStageCache = useStageCache;
return this;
}
@Override
public CanarySettings build() {
return new CanarySettings(this);
}
@Override
public List> sdkFields() {
return SDK_FIELDS;
}
}
}