
software.amazon.awssdk.services.ssm.model.Session 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.io.Serializable;
import java.time.Instant;
import java.util.Arrays;
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 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.utils.ToString;
import software.amazon.awssdk.utils.builder.CopyableBuilder;
import software.amazon.awssdk.utils.builder.ToCopyableBuilder;
/**
*
* Information about a Session Manager connection to an instance.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class Session implements SdkPojo, Serializable, ToCopyableBuilder {
private static final SdkField SESSION_ID_FIELD = SdkField. builder(MarshallingType.STRING)
.getter(getter(Session::sessionId)).setter(setter(Builder::sessionId))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("SessionId").build()).build();
private static final SdkField TARGET_FIELD = SdkField. builder(MarshallingType.STRING)
.getter(getter(Session::target)).setter(setter(Builder::target))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Target").build()).build();
private static final SdkField STATUS_FIELD = SdkField. builder(MarshallingType.STRING)
.getter(getter(Session::statusAsString)).setter(setter(Builder::status))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Status").build()).build();
private static final SdkField START_DATE_FIELD = SdkField. builder(MarshallingType.INSTANT)
.getter(getter(Session::startDate)).setter(setter(Builder::startDate))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("StartDate").build()).build();
private static final SdkField END_DATE_FIELD = SdkField. builder(MarshallingType.INSTANT)
.getter(getter(Session::endDate)).setter(setter(Builder::endDate))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("EndDate").build()).build();
private static final SdkField DOCUMENT_NAME_FIELD = SdkField. builder(MarshallingType.STRING)
.getter(getter(Session::documentName)).setter(setter(Builder::documentName))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("DocumentName").build()).build();
private static final SdkField OWNER_FIELD = SdkField. builder(MarshallingType.STRING)
.getter(getter(Session::owner)).setter(setter(Builder::owner))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Owner").build()).build();
private static final SdkField DETAILS_FIELD = SdkField. builder(MarshallingType.STRING)
.getter(getter(Session::details)).setter(setter(Builder::details))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Details").build()).build();
private static final SdkField OUTPUT_URL_FIELD = SdkField
. builder(MarshallingType.SDK_POJO).getter(getter(Session::outputUrl))
.setter(setter(Builder::outputUrl)).constructor(SessionManagerOutputUrl::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("OutputUrl").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(SESSION_ID_FIELD,
TARGET_FIELD, STATUS_FIELD, START_DATE_FIELD, END_DATE_FIELD, DOCUMENT_NAME_FIELD, OWNER_FIELD, DETAILS_FIELD,
OUTPUT_URL_FIELD));
private static final long serialVersionUID = 1L;
private final String sessionId;
private final String target;
private final String status;
private final Instant startDate;
private final Instant endDate;
private final String documentName;
private final String owner;
private final String details;
private final SessionManagerOutputUrl outputUrl;
private Session(BuilderImpl builder) {
this.sessionId = builder.sessionId;
this.target = builder.target;
this.status = builder.status;
this.startDate = builder.startDate;
this.endDate = builder.endDate;
this.documentName = builder.documentName;
this.owner = builder.owner;
this.details = builder.details;
this.outputUrl = builder.outputUrl;
}
/**
*
* The ID of the session.
*
*
* @return The ID of the session.
*/
public String sessionId() {
return sessionId;
}
/**
*
* The instance that the Session Manager session connected to.
*
*
* @return The instance that the Session Manager session connected to.
*/
public String target() {
return target;
}
/**
*
* The status of the session. For example, "Connected" or "Terminated".
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #status} will
* return {@link SessionStatus#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #statusAsString}.
*
*
* @return The status of the session. For example, "Connected" or "Terminated".
* @see SessionStatus
*/
public SessionStatus status() {
return SessionStatus.fromValue(status);
}
/**
*
* The status of the session. For example, "Connected" or "Terminated".
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #status} will
* return {@link SessionStatus#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #statusAsString}.
*
*
* @return The status of the session. For example, "Connected" or "Terminated".
* @see SessionStatus
*/
public String statusAsString() {
return status;
}
/**
*
* The date and time, in ISO-8601 Extended format, when the session began.
*
*
* @return The date and time, in ISO-8601 Extended format, when the session began.
*/
public Instant startDate() {
return startDate;
}
/**
*
* The date and time, in ISO-8601 Extended format, when the session was terminated.
*
*
* @return The date and time, in ISO-8601 Extended format, when the session was terminated.
*/
public Instant endDate() {
return endDate;
}
/**
*
* The name of the Session Manager SSM document used to define the parameters and plugin settings for the session.
* For example, SSM-SessionManagerRunShell
.
*
*
* @return The name of the Session Manager SSM document used to define the parameters and plugin settings for the
* session. For example, SSM-SessionManagerRunShell
.
*/
public String documentName() {
return documentName;
}
/**
*
* The ID of the AWS user account that started the session.
*
*
* @return The ID of the AWS user account that started the session.
*/
public String owner() {
return owner;
}
/**
*
* Reserved for future use.
*
*
* @return Reserved for future use.
*/
public String details() {
return details;
}
/**
*
* Reserved for future use.
*
*
* @return Reserved for future use.
*/
public SessionManagerOutputUrl outputUrl() {
return outputUrl;
}
@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 int hashCode() {
int hashCode = 1;
hashCode = 31 * hashCode + Objects.hashCode(sessionId());
hashCode = 31 * hashCode + Objects.hashCode(target());
hashCode = 31 * hashCode + Objects.hashCode(statusAsString());
hashCode = 31 * hashCode + Objects.hashCode(startDate());
hashCode = 31 * hashCode + Objects.hashCode(endDate());
hashCode = 31 * hashCode + Objects.hashCode(documentName());
hashCode = 31 * hashCode + Objects.hashCode(owner());
hashCode = 31 * hashCode + Objects.hashCode(details());
hashCode = 31 * hashCode + Objects.hashCode(outputUrl());
return hashCode;
}
@Override
public boolean equals(Object obj) {
return equalsBySdkFields(obj);
}
@Override
public boolean equalsBySdkFields(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof Session)) {
return false;
}
Session other = (Session) obj;
return Objects.equals(sessionId(), other.sessionId()) && Objects.equals(target(), other.target())
&& Objects.equals(statusAsString(), other.statusAsString()) && Objects.equals(startDate(), other.startDate())
&& Objects.equals(endDate(), other.endDate()) && Objects.equals(documentName(), other.documentName())
&& Objects.equals(owner(), other.owner()) && Objects.equals(details(), other.details())
&& Objects.equals(outputUrl(), other.outputUrl());
}
/**
* 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("Session").add("SessionId", sessionId()).add("Target", target()).add("Status", statusAsString())
.add("StartDate", startDate()).add("EndDate", endDate()).add("DocumentName", documentName())
.add("Owner", owner()).add("Details", details()).add("OutputUrl", outputUrl()).build();
}
public Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "SessionId":
return Optional.ofNullable(clazz.cast(sessionId()));
case "Target":
return Optional.ofNullable(clazz.cast(target()));
case "Status":
return Optional.ofNullable(clazz.cast(statusAsString()));
case "StartDate":
return Optional.ofNullable(clazz.cast(startDate()));
case "EndDate":
return Optional.ofNullable(clazz.cast(endDate()));
case "DocumentName":
return Optional.ofNullable(clazz.cast(documentName()));
case "Owner":
return Optional.ofNullable(clazz.cast(owner()));
case "Details":
return Optional.ofNullable(clazz.cast(details()));
case "OutputUrl":
return Optional.ofNullable(clazz.cast(outputUrl()));
default:
return Optional.empty();
}
}
@Override
public List> sdkFields() {
return SDK_FIELDS;
}
private static Function