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

software.amazon.awssdk.services.sagemaker.model.CreateNotebookInstanceLifecycleConfigRequest 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.sagemaker.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 CreateNotebookInstanceLifecycleConfigRequest extends SageMakerRequest implements
        ToCopyableBuilder {
    private static final SdkField NOTEBOOK_INSTANCE_LIFECYCLE_CONFIG_NAME_FIELD = SdkField
            . builder(MarshallingType.STRING)
            .getter(getter(CreateNotebookInstanceLifecycleConfigRequest::notebookInstanceLifecycleConfigName))
            .setter(setter(Builder::notebookInstanceLifecycleConfigName))
            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
                    .locationName("NotebookInstanceLifecycleConfigName").build()).build();

    private static final SdkField> ON_CREATE_FIELD = SdkField
            .> builder(MarshallingType.LIST)
            .getter(getter(CreateNotebookInstanceLifecycleConfigRequest::onCreate))
            .setter(setter(Builder::onCreate))
            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("OnCreate").build(),
                    ListTrait
                            .builder()
                            .memberLocationName(null)
                            .memberFieldInfo(
                                    SdkField. builder(MarshallingType.SDK_POJO)
                                            .constructor(NotebookInstanceLifecycleHook::builder)
                                            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
                                                    .locationName("member").build()).build()).build()).build();

    private static final SdkField> ON_START_FIELD = SdkField
            .> builder(MarshallingType.LIST)
            .getter(getter(CreateNotebookInstanceLifecycleConfigRequest::onStart))
            .setter(setter(Builder::onStart))
            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("OnStart").build(),
                    ListTrait
                            .builder()
                            .memberLocationName(null)
                            .memberFieldInfo(
                                    SdkField. builder(MarshallingType.SDK_POJO)
                                            .constructor(NotebookInstanceLifecycleHook::builder)
                                            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
                                                    .locationName("member").build()).build()).build()).build();

    private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(
            NOTEBOOK_INSTANCE_LIFECYCLE_CONFIG_NAME_FIELD, ON_CREATE_FIELD, ON_START_FIELD));

    private final String notebookInstanceLifecycleConfigName;

    private final List onCreate;

    private final List onStart;

    private CreateNotebookInstanceLifecycleConfigRequest(BuilderImpl builder) {
        super(builder);
        this.notebookInstanceLifecycleConfigName = builder.notebookInstanceLifecycleConfigName;
        this.onCreate = builder.onCreate;
        this.onStart = builder.onStart;
    }

    /**
     * 

* The name of the lifecycle configuration. *

* * @return The name of the lifecycle configuration. */ public String notebookInstanceLifecycleConfigName() { return notebookInstanceLifecycleConfigName; } /** * Returns true if the OnCreate 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 boolean hasOnCreate() { return onCreate != null && !(onCreate instanceof SdkAutoConstructList); } /** *

* A shell script that runs only once, when you create a notebook instance. The shell script must be a * base64-encoded string. *

*

* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException. *

*

* You can use {@link #hasOnCreate()} to see if a value was sent in this field. *

* * @return A shell script that runs only once, when you create a notebook instance. The shell script must be a * base64-encoded string. */ public List onCreate() { return onCreate; } /** * Returns true if the OnStart 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 boolean hasOnStart() { return onStart != null && !(onStart instanceof SdkAutoConstructList); } /** *

* A shell script that runs every time you start a notebook instance, including when you create the notebook * instance. The shell script must be a base64-encoded string. *

*

* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException. *

*

* You can use {@link #hasOnStart()} to see if a value was sent in this field. *

* * @return A shell script that runs every time you start a notebook instance, including when you create the notebook * instance. The shell script must be a base64-encoded string. */ public List onStart() { return onStart; } @Override public Builder toBuilder() { return new BuilderImpl(this); } public static Builder builder() { return new BuilderImpl(); } public static Class serializableBuilderClass() { return BuilderImpl.class; } @Override public int hashCode() { int hashCode = 1; hashCode = 31 * hashCode + super.hashCode(); hashCode = 31 * hashCode + Objects.hashCode(notebookInstanceLifecycleConfigName()); hashCode = 31 * hashCode + Objects.hashCode(onCreate()); hashCode = 31 * hashCode + Objects.hashCode(onStart()); return hashCode; } @Override public boolean equals(Object obj) { return super.equals(obj) && equalsBySdkFields(obj); } @Override public boolean equalsBySdkFields(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (!(obj instanceof CreateNotebookInstanceLifecycleConfigRequest)) { return false; } CreateNotebookInstanceLifecycleConfigRequest other = (CreateNotebookInstanceLifecycleConfigRequest) obj; return Objects.equals(notebookInstanceLifecycleConfigName(), other.notebookInstanceLifecycleConfigName()) && Objects.equals(onCreate(), other.onCreate()) && Objects.equals(onStart(), other.onStart()); } /** * 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 String toString() { return ToString.builder("CreateNotebookInstanceLifecycleConfigRequest") .add("NotebookInstanceLifecycleConfigName", notebookInstanceLifecycleConfigName()).add("OnCreate", onCreate()) .add("OnStart", onStart()).build(); } public Optional getValueForField(String fieldName, Class clazz) { switch (fieldName) { case "NotebookInstanceLifecycleConfigName": return Optional.ofNullable(clazz.cast(notebookInstanceLifecycleConfigName())); case "OnCreate": return Optional.ofNullable(clazz.cast(onCreate())); case "OnStart": return Optional.ofNullable(clazz.cast(onStart())); default: return Optional.empty(); } } @Override public List> sdkFields() { return SDK_FIELDS; } private static Function getter(Function g) { return obj -> g.apply((CreateNotebookInstanceLifecycleConfigRequest) obj); } private static BiConsumer setter(BiConsumer s) { return (obj, val) -> s.accept((Builder) obj, val); } public interface Builder extends SageMakerRequest.Builder, SdkPojo, CopyableBuilder { /** *

* The name of the lifecycle configuration. *

* * @param notebookInstanceLifecycleConfigName * The name of the lifecycle configuration. * @return Returns a reference to this object so that method calls can be chained together. */ Builder notebookInstanceLifecycleConfigName(String notebookInstanceLifecycleConfigName); /** *

* A shell script that runs only once, when you create a notebook instance. The shell script must be a * base64-encoded string. *

* * @param onCreate * A shell script that runs only once, when you create a notebook instance. The shell script must be a * base64-encoded string. * @return Returns a reference to this object so that method calls can be chained together. */ Builder onCreate(Collection onCreate); /** *

* A shell script that runs only once, when you create a notebook instance. The shell script must be a * base64-encoded string. *

* * @param onCreate * A shell script that runs only once, when you create a notebook instance. The shell script must be a * base64-encoded string. * @return Returns a reference to this object so that method calls can be chained together. */ Builder onCreate(NotebookInstanceLifecycleHook... onCreate); /** *

* A shell script that runs only once, when you create a notebook instance. The shell script must be a * base64-encoded string. *

* This is a convenience 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 #onCreate(List)}. * * @param onCreate * 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 #onCreate(List) */ Builder onCreate(Consumer... onCreate); /** *

* A shell script that runs every time you start a notebook instance, including when you create the notebook * instance. The shell script must be a base64-encoded string. *

* * @param onStart * A shell script that runs every time you start a notebook instance, including when you create the * notebook instance. The shell script must be a base64-encoded string. * @return Returns a reference to this object so that method calls can be chained together. */ Builder onStart(Collection onStart); /** *

* A shell script that runs every time you start a notebook instance, including when you create the notebook * instance. The shell script must be a base64-encoded string. *

* * @param onStart * A shell script that runs every time you start a notebook instance, including when you create the * notebook instance. The shell script must be a base64-encoded string. * @return Returns a reference to this object so that method calls can be chained together. */ Builder onStart(NotebookInstanceLifecycleHook... onStart); /** *

* A shell script that runs every time you start a notebook instance, including when you create the notebook * instance. The shell script must be a base64-encoded string. *

* This is a convenience 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 #onStart(List)}. * * @param onStart * 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 #onStart(List) */ Builder onStart(Consumer... onStart); @Override Builder overrideConfiguration(AwsRequestOverrideConfiguration overrideConfiguration); @Override Builder overrideConfiguration(Consumer builderConsumer); } static final class BuilderImpl extends SageMakerRequest.BuilderImpl implements Builder { private String notebookInstanceLifecycleConfigName; private List onCreate = DefaultSdkAutoConstructList.getInstance(); private List onStart = DefaultSdkAutoConstructList.getInstance(); private BuilderImpl() { } private BuilderImpl(CreateNotebookInstanceLifecycleConfigRequest model) { super(model); notebookInstanceLifecycleConfigName(model.notebookInstanceLifecycleConfigName); onCreate(model.onCreate); onStart(model.onStart); } public final String getNotebookInstanceLifecycleConfigName() { return notebookInstanceLifecycleConfigName; } @Override public final Builder notebookInstanceLifecycleConfigName(String notebookInstanceLifecycleConfigName) { this.notebookInstanceLifecycleConfigName = notebookInstanceLifecycleConfigName; return this; } public final void setNotebookInstanceLifecycleConfigName(String notebookInstanceLifecycleConfigName) { this.notebookInstanceLifecycleConfigName = notebookInstanceLifecycleConfigName; } public final Collection getOnCreate() { return onCreate != null ? onCreate.stream().map(NotebookInstanceLifecycleHook::toBuilder) .collect(Collectors.toList()) : null; } @Override public final Builder onCreate(Collection onCreate) { this.onCreate = NotebookInstanceLifecycleConfigListCopier.copy(onCreate); return this; } @Override @SafeVarargs public final Builder onCreate(NotebookInstanceLifecycleHook... onCreate) { onCreate(Arrays.asList(onCreate)); return this; } @Override @SafeVarargs public final Builder onCreate(Consumer... onCreate) { onCreate(Stream.of(onCreate).map(c -> NotebookInstanceLifecycleHook.builder().applyMutation(c).build()) .collect(Collectors.toList())); return this; } public final void setOnCreate(Collection onCreate) { this.onCreate = NotebookInstanceLifecycleConfigListCopier.copyFromBuilder(onCreate); } public final Collection getOnStart() { return onStart != null ? onStart.stream().map(NotebookInstanceLifecycleHook::toBuilder).collect(Collectors.toList()) : null; } @Override public final Builder onStart(Collection onStart) { this.onStart = NotebookInstanceLifecycleConfigListCopier.copy(onStart); return this; } @Override @SafeVarargs public final Builder onStart(NotebookInstanceLifecycleHook... onStart) { onStart(Arrays.asList(onStart)); return this; } @Override @SafeVarargs public final Builder onStart(Consumer... onStart) { onStart(Stream.of(onStart).map(c -> NotebookInstanceLifecycleHook.builder().applyMutation(c).build()) .collect(Collectors.toList())); return this; } public final void setOnStart(Collection onStart) { this.onStart = NotebookInstanceLifecycleConfigListCopier.copyFromBuilder(onStart); } @Override public Builder overrideConfiguration(AwsRequestOverrideConfiguration overrideConfiguration) { super.overrideConfiguration(overrideConfiguration); return this; } @Override public Builder overrideConfiguration(Consumer builderConsumer) { super.overrideConfiguration(builderConsumer); return this; } @Override public CreateNotebookInstanceLifecycleConfigRequest build() { return new CreateNotebookInstanceLifecycleConfigRequest(this); } @Override public List> sdkFields() { return SDK_FIELDS; } } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy