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

software.amazon.awssdk.services.ssm.model.StartSessionRequest 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.ssm.model;

import java.util.Arrays;
import java.util.Collection;
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.Consumer;
import java.util.function.Function;
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.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;

/**
 */
@Generated("software.amazon.awssdk:codegen")
public final class StartSessionRequest extends SsmRequest implements
        ToCopyableBuilder {
    private static final SdkField TARGET_FIELD = SdkField. builder(MarshallingType.STRING).memberName("Target")
            .getter(getter(StartSessionRequest::target)).setter(setter(Builder::target))
            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Target").build()).build();

    private static final SdkField DOCUMENT_NAME_FIELD = SdkField. builder(MarshallingType.STRING)
            .memberName("DocumentName").getter(getter(StartSessionRequest::documentName)).setter(setter(Builder::documentName))
            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("DocumentName").build()).build();

    private static final SdkField>> PARAMETERS_FIELD = SdkField
            .>> builder(MarshallingType.MAP)
            .memberName("Parameters")
            .getter(getter(StartSessionRequest::parameters))
            .setter(setter(Builder::parameters))
            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Parameters").build(),
                    MapTrait.builder()
                            .keyLocationName("key")
                            .valueLocationName("value")
                            .valueFieldInfo(
                                    SdkField.> builder(MarshallingType.LIST)
                                            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
                                                    .locationName("value").build(),
                                                    ListTrait
                                                            .builder()
                                                            .memberLocationName(null)
                                                            .memberFieldInfo(
                                                                    SdkField. builder(MarshallingType.STRING)
                                                                            .traits(LocationTrait.builder()
                                                                                    .location(MarshallLocation.PAYLOAD)
                                                                                    .locationName("member").build()).build())
                                                            .build()).build()).build()).build();

    private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(TARGET_FIELD,
            DOCUMENT_NAME_FIELD, PARAMETERS_FIELD));

    private final String target;

    private final String documentName;

    private final Map> parameters;

    private StartSessionRequest(BuilderImpl builder) {
        super(builder);
        this.target = builder.target;
        this.documentName = builder.documentName;
        this.parameters = builder.parameters;
    }

    /**
     * 

* The instance to connect to for the session. *

* * @return The instance to connect to for the session. */ public String target() { return target; } /** *

* The name of the SSM document to define the parameters and plugin settings for the session. For example, * SSM-SessionManagerRunShell. You can call the GetDocument API to verify the document exists * before attempting to start a session. If no document name is provided, a shell to the instance is launched by * default. *

* * @return The name of the SSM document to define the parameters and plugin settings for the session. For example, * SSM-SessionManagerRunShell. You can call the GetDocument API to verify the document * exists before attempting to start a session. If no document name is provided, a shell to the instance is * launched by default. */ public String documentName() { return documentName; } /** * Returns true if the Parameters 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 hasParameters() { return parameters != null && !(parameters instanceof SdkAutoConstructMap); } /** *

* Reserved for future use. *

*

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

*

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

* * @return Reserved for future use. */ public Map> parameters() { return parameters; } @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(target()); hashCode = 31 * hashCode + Objects.hashCode(documentName()); hashCode = 31 * hashCode + Objects.hashCode(parameters()); 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 StartSessionRequest)) { return false; } StartSessionRequest other = (StartSessionRequest) obj; return Objects.equals(target(), other.target()) && Objects.equals(documentName(), other.documentName()) && Objects.equals(parameters(), other.parameters()); } /** * 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("StartSessionRequest").add("Target", target()).add("DocumentName", documentName()) .add("Parameters", parameters()).build(); } public Optional getValueForField(String fieldName, Class clazz) { switch (fieldName) { case "Target": return Optional.ofNullable(clazz.cast(target())); case "DocumentName": return Optional.ofNullable(clazz.cast(documentName())); case "Parameters": return Optional.ofNullable(clazz.cast(parameters())); default: return Optional.empty(); } } @Override public List> sdkFields() { return SDK_FIELDS; } private static Function getter(Function g) { return obj -> g.apply((StartSessionRequest) obj); } private static BiConsumer setter(BiConsumer s) { return (obj, val) -> s.accept((Builder) obj, val); } public interface Builder extends SsmRequest.Builder, SdkPojo, CopyableBuilder { /** *

* The instance to connect to for the session. *

* * @param target * The instance to connect to for the session. * @return Returns a reference to this object so that method calls can be chained together. */ Builder target(String target); /** *

* The name of the SSM document to define the parameters and plugin settings for the session. For example, * SSM-SessionManagerRunShell. You can call the GetDocument API to verify the document * exists before attempting to start a session. If no document name is provided, a shell to the instance is * launched by default. *

* * @param documentName * The name of the SSM document to define the parameters and plugin settings for the session. For * example, SSM-SessionManagerRunShell. You can call the GetDocument API to verify * the document exists before attempting to start a session. If no document name is provided, a shell to * the instance is launched by default. * @return Returns a reference to this object so that method calls can be chained together. */ Builder documentName(String documentName); /** *

* Reserved for future use. *

* * @param parameters * Reserved for future use. * @return Returns a reference to this object so that method calls can be chained together. */ Builder parameters(Map> parameters); @Override Builder overrideConfiguration(AwsRequestOverrideConfiguration overrideConfiguration); @Override Builder overrideConfiguration(Consumer builderConsumer); } static final class BuilderImpl extends SsmRequest.BuilderImpl implements Builder { private String target; private String documentName; private Map> parameters = DefaultSdkAutoConstructMap.getInstance(); private BuilderImpl() { } private BuilderImpl(StartSessionRequest model) { super(model); target(model.target); documentName(model.documentName); parameters(model.parameters); } public final String getTarget() { return target; } @Override public final Builder target(String target) { this.target = target; return this; } public final void setTarget(String target) { this.target = target; } public final String getDocumentName() { return documentName; } @Override public final Builder documentName(String documentName) { this.documentName = documentName; return this; } public final void setDocumentName(String documentName) { this.documentName = documentName; } public final Map> getParameters() { return parameters; } @Override public final Builder parameters(Map> parameters) { this.parameters = SessionManagerParametersCopier.copy(parameters); return this; } public final void setParameters(Map> parameters) { this.parameters = SessionManagerParametersCopier.copy(parameters); } @Override public Builder overrideConfiguration(AwsRequestOverrideConfiguration overrideConfiguration) { super.overrideConfiguration(overrideConfiguration); return this; } @Override public Builder overrideConfiguration(Consumer builderConsumer) { super.overrideConfiguration(builderConsumer); return this; } @Override public StartSessionRequest build() { return new StartSessionRequest(this); } @Override public List> sdkFields() { return SDK_FIELDS; } } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy