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

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 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 getter(Function g) { return obj -> g.apply((CreateSolutionRequest) obj); } private static BiConsumer setter(BiConsumer s) { return (obj, val) -> s.accept((Builder) obj, val); } public interface Builder extends PersonalizeRequest.Builder, SdkPojo, CopyableBuilder { /** *

* The name for the solution. *

* * @param name * The name for the solution. * @return Returns a reference to this object so that method calls can be chained together. */ Builder name(String 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. *

* * @param performHPO * 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 Returns a reference to this object so that method calls can be chained together. */ Builder performHPO(Boolean 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. *

* * @param performAutoML * 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 Returns a reference to this object so that method calls can be chained together. */ Builder performAutoML(Boolean performAutoML); /** *

* The ARN of the recipe to use for model training. Only specified when performAutoML is false. *

* * @param recipeArn * The ARN of the recipe to use for model training. Only specified when performAutoML is * false. * @return Returns a reference to this object so that method calls can be chained together. */ Builder recipeArn(String recipeArn); /** *

* The Amazon Resource Name (ARN) of the dataset group that provides the training data. *

* * @param datasetGroupArn * The Amazon Resource Name (ARN) of the dataset group that provides the training data. * @return Returns a reference to this object so that method calls can be chained together. */ Builder datasetGroupArn(String 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. *

* * @param eventType * 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 Returns a reference to this object so that method calls can be chained together. */ Builder eventType(String 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. *

*
* * @param solutionConfig * 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 Returns a reference to this object so that method calls can be chained together. */ Builder solutionConfig(SolutionConfig solutionConfig); /** *

* 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. *

*
This is a convenience method that creates an instance of the {@link SolutionConfig.Builder} avoiding * the need to create one manually via {@link SolutionConfig#builder()}. * * When the {@link Consumer} completes, {@link SolutionConfig.Builder#build()} is called immediately and its * result is passed to {@link #solutionConfig(SolutionConfig)}. * * @param solutionConfig * a consumer that will call methods on {@link SolutionConfig.Builder} * @return Returns a reference to this object so that method calls can be chained together. * @see #solutionConfig(SolutionConfig) */ default Builder solutionConfig(Consumer solutionConfig) { return solutionConfig(SolutionConfig.builder().applyMutation(solutionConfig).build()); } /** *

* A list of tags to * apply to the solution. *

* * @param tags * A list of tags * to apply to the solution. * @return Returns a reference to this object so that method calls can be chained together. */ Builder tags(Collection tags); /** *

* A list of tags to * apply to the solution. *

* * @param tags * A list of tags * to apply to the solution. * @return Returns a reference to this object so that method calls can be chained together. */ Builder tags(Tag... tags); /** *

* A list of tags to * apply to the solution. *

* This is a convenience method that creates an instance of the {@link List.Builder} avoiding the need to * create one manually via {@link List#builder()}. * * When the {@link Consumer} completes, {@link List.Builder#build()} is called immediately and its result * is passed to {@link #tags(List)}. * * @param tags * a consumer that will call methods on {@link List.Builder} * @return Returns a reference to this object so that method calls can be chained together. * @see #tags(List) */ Builder tags(Consumer... tags); @Override Builder overrideConfiguration(AwsRequestOverrideConfiguration overrideConfiguration); @Override Builder overrideConfiguration(Consumer builderConsumer); } static final class BuilderImpl extends PersonalizeRequest.BuilderImpl implements Builder { private String name; private Boolean performHPO; private Boolean performAutoML; private String recipeArn; private String datasetGroupArn; private String eventType; private SolutionConfig solutionConfig; private List tags = DefaultSdkAutoConstructList.getInstance(); private BuilderImpl() { } private BuilderImpl(CreateSolutionRequest model) { super(model); name(model.name); performHPO(model.performHPO); performAutoML(model.performAutoML); recipeArn(model.recipeArn); datasetGroupArn(model.datasetGroupArn); eventType(model.eventType); solutionConfig(model.solutionConfig); tags(model.tags); } public final String getName() { return name; } public final void setName(String name) { this.name = name; } @Override public final Builder name(String name) { this.name = name; return this; } public final Boolean getPerformHPO() { return performHPO; } public final void setPerformHPO(Boolean performHPO) { this.performHPO = performHPO; } @Override public final Builder performHPO(Boolean performHPO) { this.performHPO = performHPO; return this; } public final Boolean getPerformAutoML() { return performAutoML; } public final void setPerformAutoML(Boolean performAutoML) { this.performAutoML = performAutoML; } @Override public final Builder performAutoML(Boolean performAutoML) { this.performAutoML = performAutoML; return this; } public final String getRecipeArn() { return recipeArn; } public final void setRecipeArn(String recipeArn) { this.recipeArn = recipeArn; } @Override public final Builder recipeArn(String recipeArn) { this.recipeArn = recipeArn; return this; } public final String getDatasetGroupArn() { return datasetGroupArn; } public final void setDatasetGroupArn(String datasetGroupArn) { this.datasetGroupArn = datasetGroupArn; } @Override public final Builder datasetGroupArn(String datasetGroupArn) { this.datasetGroupArn = datasetGroupArn; return this; } public final String getEventType() { return eventType; } public final void setEventType(String eventType) { this.eventType = eventType; } @Override public final Builder eventType(String eventType) { this.eventType = eventType; return this; } public final SolutionConfig.Builder getSolutionConfig() { return solutionConfig != null ? solutionConfig.toBuilder() : null; } public final void setSolutionConfig(SolutionConfig.BuilderImpl solutionConfig) { this.solutionConfig = solutionConfig != null ? solutionConfig.build() : null; } @Override public final Builder solutionConfig(SolutionConfig solutionConfig) { this.solutionConfig = solutionConfig; return this; } public final List getTags() { List result = TagsCopier.copyToBuilder(this.tags); if (result instanceof SdkAutoConstructList) { return null; } return result; } public final void setTags(Collection tags) { this.tags = TagsCopier.copyFromBuilder(tags); } @Override public final Builder tags(Collection tags) { this.tags = TagsCopier.copy(tags); return this; } @Override @SafeVarargs public final Builder tags(Tag... tags) { tags(Arrays.asList(tags)); return this; } @Override @SafeVarargs public final Builder tags(Consumer... tags) { tags(Stream.of(tags).map(c -> Tag.builder().applyMutation(c).build()).collect(Collectors.toList())); return this; } @Override public Builder overrideConfiguration(AwsRequestOverrideConfiguration overrideConfiguration) { super.overrideConfiguration(overrideConfiguration); return this; } @Override public Builder overrideConfiguration(Consumer builderConsumer) { super.overrideConfiguration(builderConsumer); return this; } @Override public CreateSolutionRequest build() { return new CreateSolutionRequest(this); } @Override public List> sdkFields() { return SDK_FIELDS; } } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy