
software.amazon.awssdk.services.personalize.model.CreateSolutionRequest 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.personalize.model;
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.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 CreateSolutionRequest extends PersonalizeRequest implements
ToCopyableBuilder {
private static final SdkField NAME_FIELD = SdkField. builder(MarshallingType.STRING).memberName("name")
.getter(getter(CreateSolutionRequest::name)).setter(setter(Builder::name))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("name").build()).build();
private static final SdkField PERFORM_HPO_FIELD = SdkField. builder(MarshallingType.BOOLEAN)
.memberName("performHPO").getter(getter(CreateSolutionRequest::performHPO)).setter(setter(Builder::performHPO))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("performHPO").build()).build();
private static final SdkField PERFORM_AUTO_ML_FIELD = SdkField. builder(MarshallingType.BOOLEAN)
.memberName("performAutoML").getter(getter(CreateSolutionRequest::performAutoML))
.setter(setter(Builder::performAutoML))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("performAutoML").build()).build();
private static final SdkField RECIPE_ARN_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("recipeArn").getter(getter(CreateSolutionRequest::recipeArn)).setter(setter(Builder::recipeArn))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("recipeArn").build()).build();
private static final SdkField DATASET_GROUP_ARN_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("datasetGroupArn").getter(getter(CreateSolutionRequest::datasetGroupArn))
.setter(setter(Builder::datasetGroupArn))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("datasetGroupArn").build()).build();
private static final SdkField EVENT_TYPE_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("eventType").getter(getter(CreateSolutionRequest::eventType)).setter(setter(Builder::eventType))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("eventType").build()).build();
private static final SdkField SOLUTION_CONFIG_FIELD = SdkField
. builder(MarshallingType.SDK_POJO).memberName("solutionConfig")
.getter(getter(CreateSolutionRequest::solutionConfig)).setter(setter(Builder::solutionConfig))
.constructor(SolutionConfig::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("solutionConfig").build()).build();
private static final SdkField> TAGS_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("tags")
.getter(getter(CreateSolutionRequest::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 List> SDK_FIELDS = Collections.unmodifiableList(Arrays
.asList(NAME_FIELD, PERFORM_HPO_FIELD, PERFORM_AUTO_ML_FIELD, RECIPE_ARN_FIELD, DATASET_GROUP_ARN_FIELD,
EVENT_TYPE_FIELD, SOLUTION_CONFIG_FIELD, TAGS_FIELD));
private final String name;
private final Boolean performHPO;
private final Boolean performAutoML;
private final String recipeArn;
private final String datasetGroupArn;
private final String eventType;
private final SolutionConfig solutionConfig;
private final List tags;
private CreateSolutionRequest(BuilderImpl builder) {
super(builder);
this.name = builder.name;
this.performHPO = builder.performHPO;
this.performAutoML = builder.performAutoML;
this.recipeArn = builder.recipeArn;
this.datasetGroupArn = builder.datasetGroupArn;
this.eventType = builder.eventType;
this.solutionConfig = builder.solutionConfig;
this.tags = builder.tags;
}
/**
*
* The name for the solution.
*
*
* @return The name for the solution.
*/
public final String name() {
return name;
}
/**
*
* Whether to perform hyperparameter optimization (HPO) on the specified or selected recipe. The default is
* false
.
*
*
* When performing AutoML, this parameter is always true
and you should not set it to
* false
.
*
*
* @return Whether to perform hyperparameter optimization (HPO) on the specified or selected recipe. The default is
* false
.
*
* When performing AutoML, this parameter is always true
and you should not set it to
* false
.
*/
public final Boolean performHPO() {
return performHPO;
}
/**
*
* Whether to perform automated machine learning (AutoML). The default is false
. For this case, you
* must specify recipeArn
.
*
*
* When set to true
, Amazon Personalize analyzes your training data and selects the optimal
* USER_PERSONALIZATION recipe and hyperparameters. In this case, you must omit recipeArn
. Amazon
* Personalize determines the optimal recipe by running tests with different values for the hyperparameters. AutoML
* lengthens the training process as compared to selecting a specific recipe.
*
*
* @return Whether to perform automated machine learning (AutoML). The default is false
. For this case,
* you must specify recipeArn
.
*
* When set to true
, Amazon Personalize analyzes your training data and selects the optimal
* USER_PERSONALIZATION recipe and hyperparameters. In this case, you must omit recipeArn
.
* Amazon Personalize determines the optimal recipe by running tests with different values for the
* hyperparameters. AutoML lengthens the training process as compared to selecting a specific recipe.
*/
public final Boolean performAutoML() {
return performAutoML;
}
/**
*
* The ARN of the recipe to use for model training. Only specified when performAutoML
is false.
*
*
* @return The ARN of the recipe to use for model training. Only specified when performAutoML
is false.
*/
public final String recipeArn() {
return recipeArn;
}
/**
*
* The Amazon Resource Name (ARN) of the dataset group that provides the training data.
*
*
* @return The Amazon Resource Name (ARN) of the dataset group that provides the training data.
*/
public final String datasetGroupArn() {
return datasetGroupArn;
}
/**
*
* When your have multiple event types (using an EVENT_TYPE
schema field), this parameter specifies
* which event type (for example, 'click' or 'like') is used for training the model.
*
*
* If you do not provide an eventType
, Amazon Personalize will use all interactions for training with
* equal weight regardless of type.
*
*
* @return When your have multiple event types (using an EVENT_TYPE
schema field), this parameter
* specifies which event type (for example, 'click' or 'like') is used for training the model.
*
* If you do not provide an eventType
, Amazon Personalize will use all interactions for
* training with equal weight regardless of type.
*/
public final String eventType() {
return eventType;
}
/**
*
* The configuration to use with the solution. When performAutoML
is set to true, Amazon Personalize
* only evaluates the autoMLConfig
section of the solution configuration.
*
*
*
* Amazon Personalize doesn't support configuring the hpoObjective
at this time.
*
*
*
* @return The configuration to use with the solution. When performAutoML
is set to true, Amazon
* Personalize only evaluates the autoMLConfig
section of the solution configuration.
*
*
* Amazon Personalize doesn't support configuring the hpoObjective
at this time.
*
*/
public final SolutionConfig solutionConfig() {
return solutionConfig;
}
/**
* 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);
}
/**
*
* A list of tags to apply
* to the solution.
*
*
* 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 A list of tags to
* apply to the solution.
*/
public final List tags() {
return tags;
}
@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(name());
hashCode = 31 * hashCode + Objects.hashCode(performHPO());
hashCode = 31 * hashCode + Objects.hashCode(performAutoML());
hashCode = 31 * hashCode + Objects.hashCode(recipeArn());
hashCode = 31 * hashCode + Objects.hashCode(datasetGroupArn());
hashCode = 31 * hashCode + Objects.hashCode(eventType());
hashCode = 31 * hashCode + Objects.hashCode(solutionConfig());
hashCode = 31 * hashCode + Objects.hashCode(hasTags() ? tags() : null);
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 CreateSolutionRequest)) {
return false;
}
CreateSolutionRequest other = (CreateSolutionRequest) obj;
return Objects.equals(name(), other.name()) && Objects.equals(performHPO(), other.performHPO())
&& Objects.equals(performAutoML(), other.performAutoML()) && Objects.equals(recipeArn(), other.recipeArn())
&& Objects.equals(datasetGroupArn(), other.datasetGroupArn()) && Objects.equals(eventType(), other.eventType())
&& Objects.equals(solutionConfig(), other.solutionConfig()) && hasTags() == other.hasTags()
&& Objects.equals(tags(), other.tags());
}
/**
* 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("CreateSolutionRequest").add("Name", name()).add("PerformHPO", performHPO())
.add("PerformAutoML", performAutoML()).add("RecipeArn", recipeArn()).add("DatasetGroupArn", datasetGroupArn())
.add("EventType", eventType()).add("SolutionConfig", solutionConfig()).add("Tags", hasTags() ? tags() : null)
.build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "name":
return Optional.ofNullable(clazz.cast(name()));
case "performHPO":
return Optional.ofNullable(clazz.cast(performHPO()));
case "performAutoML":
return Optional.ofNullable(clazz.cast(performAutoML()));
case "recipeArn":
return Optional.ofNullable(clazz.cast(recipeArn()));
case "datasetGroupArn":
return Optional.ofNullable(clazz.cast(datasetGroupArn()));
case "eventType":
return Optional.ofNullable(clazz.cast(eventType()));
case "solutionConfig":
return Optional.ofNullable(clazz.cast(solutionConfig()));
case "tags":
return Optional.ofNullable(clazz.cast(tags()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function