software.amazon.awssdk.services.athena.model.SessionStatus Maven / Gradle / Ivy
Show all versions of athena Show documentation
/*
* 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.athena.model;
import java.io.Serializable;
import java.time.Instant;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
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.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;
/**
*
* Contains information about the status of a session.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class SessionStatus implements SdkPojo, Serializable, ToCopyableBuilder {
private static final SdkField START_DATE_TIME_FIELD = SdkField. builder(MarshallingType.INSTANT)
.memberName("StartDateTime").getter(getter(SessionStatus::startDateTime)).setter(setter(Builder::startDateTime))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("StartDateTime").build()).build();
private static final SdkField LAST_MODIFIED_DATE_TIME_FIELD = SdkField. builder(MarshallingType.INSTANT)
.memberName("LastModifiedDateTime").getter(getter(SessionStatus::lastModifiedDateTime))
.setter(setter(Builder::lastModifiedDateTime))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("LastModifiedDateTime").build())
.build();
private static final SdkField END_DATE_TIME_FIELD = SdkField. builder(MarshallingType.INSTANT)
.memberName("EndDateTime").getter(getter(SessionStatus::endDateTime)).setter(setter(Builder::endDateTime))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("EndDateTime").build()).build();
private static final SdkField IDLE_SINCE_DATE_TIME_FIELD = SdkField. builder(MarshallingType.INSTANT)
.memberName("IdleSinceDateTime").getter(getter(SessionStatus::idleSinceDateTime))
.setter(setter(Builder::idleSinceDateTime))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("IdleSinceDateTime").build()).build();
private static final SdkField STATE_FIELD = SdkField. builder(MarshallingType.STRING).memberName("State")
.getter(getter(SessionStatus::stateAsString)).setter(setter(Builder::state))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("State").build()).build();
private static final SdkField STATE_CHANGE_REASON_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("StateChangeReason").getter(getter(SessionStatus::stateChangeReason))
.setter(setter(Builder::stateChangeReason))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("StateChangeReason").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(START_DATE_TIME_FIELD,
LAST_MODIFIED_DATE_TIME_FIELD, END_DATE_TIME_FIELD, IDLE_SINCE_DATE_TIME_FIELD, STATE_FIELD,
STATE_CHANGE_REASON_FIELD));
private static final Map> SDK_NAME_TO_FIELD = Collections
.unmodifiableMap(new HashMap>() {
{
put("StartDateTime", START_DATE_TIME_FIELD);
put("LastModifiedDateTime", LAST_MODIFIED_DATE_TIME_FIELD);
put("EndDateTime", END_DATE_TIME_FIELD);
put("IdleSinceDateTime", IDLE_SINCE_DATE_TIME_FIELD);
put("State", STATE_FIELD);
put("StateChangeReason", STATE_CHANGE_REASON_FIELD);
}
});
private static final long serialVersionUID = 1L;
private final Instant startDateTime;
private final Instant lastModifiedDateTime;
private final Instant endDateTime;
private final Instant idleSinceDateTime;
private final String state;
private final String stateChangeReason;
private SessionStatus(BuilderImpl builder) {
this.startDateTime = builder.startDateTime;
this.lastModifiedDateTime = builder.lastModifiedDateTime;
this.endDateTime = builder.endDateTime;
this.idleSinceDateTime = builder.idleSinceDateTime;
this.state = builder.state;
this.stateChangeReason = builder.stateChangeReason;
}
/**
*
* The date and time that the session started.
*
*
* @return The date and time that the session started.
*/
public final Instant startDateTime() {
return startDateTime;
}
/**
*
* The most recent date and time that the session was modified.
*
*
* @return The most recent date and time that the session was modified.
*/
public final Instant lastModifiedDateTime() {
return lastModifiedDateTime;
}
/**
*
* The date and time that the session ended.
*
*
* @return The date and time that the session ended.
*/
public final Instant endDateTime() {
return endDateTime;
}
/**
*
* The date and time starting at which the session became idle. Can be empty if the session is not currently idle.
*
*
* @return The date and time starting at which the session became idle. Can be empty if the session is not currently
* idle.
*/
public final Instant idleSinceDateTime() {
return idleSinceDateTime;
}
/**
*
* The state of the session. A description of each state follows.
*
*
* CREATING
- The session is being started, including acquiring resources.
*
*
* CREATED
- The session has been started.
*
*
* IDLE
- The session is able to accept a calculation.
*
*
* BUSY
- The session is processing another task and is unable to accept a calculation.
*
*
* TERMINATING
- The session is in the process of shutting down.
*
*
* TERMINATED
- The session and its resources are no longer running.
*
*
* DEGRADED
- The session has no healthy coordinators.
*
*
* FAILED
- Due to a failure, the session and its resources are no longer running.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #state} will return
* {@link SessionState#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #stateAsString}.
*
*
* @return The state of the session. A description of each state follows.
*
* CREATING
- The session is being started, including acquiring resources.
*
*
* CREATED
- The session has been started.
*
*
* IDLE
- The session is able to accept a calculation.
*
*
* BUSY
- The session is processing another task and is unable to accept a calculation.
*
*
* TERMINATING
- The session is in the process of shutting down.
*
*
* TERMINATED
- The session and its resources are no longer running.
*
*
* DEGRADED
- The session has no healthy coordinators.
*
*
* FAILED
- Due to a failure, the session and its resources are no longer running.
* @see SessionState
*/
public final SessionState state() {
return SessionState.fromValue(state);
}
/**
*
* The state of the session. A description of each state follows.
*
*
* CREATING
- The session is being started, including acquiring resources.
*
*
* CREATED
- The session has been started.
*
*
* IDLE
- The session is able to accept a calculation.
*
*
* BUSY
- The session is processing another task and is unable to accept a calculation.
*
*
* TERMINATING
- The session is in the process of shutting down.
*
*
* TERMINATED
- The session and its resources are no longer running.
*
*
* DEGRADED
- The session has no healthy coordinators.
*
*
* FAILED
- Due to a failure, the session and its resources are no longer running.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #state} will return
* {@link SessionState#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #stateAsString}.
*
*
* @return The state of the session. A description of each state follows.
*
* CREATING
- The session is being started, including acquiring resources.
*
*
* CREATED
- The session has been started.
*
*
* IDLE
- The session is able to accept a calculation.
*
*
* BUSY
- The session is processing another task and is unable to accept a calculation.
*
*
* TERMINATING
- The session is in the process of shutting down.
*
*
* TERMINATED
- The session and its resources are no longer running.
*
*
* DEGRADED
- The session has no healthy coordinators.
*
*
* FAILED
- Due to a failure, the session and its resources are no longer running.
* @see SessionState
*/
public final String stateAsString() {
return state;
}
/**
*
* The reason for the session state change (for example, canceled because the session was terminated).
*
*
* @return The reason for the session state change (for example, canceled because the session was terminated).
*/
public final String stateChangeReason() {
return stateChangeReason;
}
@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 + Objects.hashCode(startDateTime());
hashCode = 31 * hashCode + Objects.hashCode(lastModifiedDateTime());
hashCode = 31 * hashCode + Objects.hashCode(endDateTime());
hashCode = 31 * hashCode + Objects.hashCode(idleSinceDateTime());
hashCode = 31 * hashCode + Objects.hashCode(stateAsString());
hashCode = 31 * hashCode + Objects.hashCode(stateChangeReason());
return hashCode;
}
@Override
public final boolean equals(Object obj) {
return equalsBySdkFields(obj);
}
@Override
public final boolean equalsBySdkFields(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof SessionStatus)) {
return false;
}
SessionStatus other = (SessionStatus) obj;
return Objects.equals(startDateTime(), other.startDateTime())
&& Objects.equals(lastModifiedDateTime(), other.lastModifiedDateTime())
&& Objects.equals(endDateTime(), other.endDateTime())
&& Objects.equals(idleSinceDateTime(), other.idleSinceDateTime())
&& Objects.equals(stateAsString(), other.stateAsString())
&& Objects.equals(stateChangeReason(), other.stateChangeReason());
}
/**
* 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("SessionStatus").add("StartDateTime", startDateTime())
.add("LastModifiedDateTime", lastModifiedDateTime()).add("EndDateTime", endDateTime())
.add("IdleSinceDateTime", idleSinceDateTime()).add("State", stateAsString())
.add("StateChangeReason", stateChangeReason()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "StartDateTime":
return Optional.ofNullable(clazz.cast(startDateTime()));
case "LastModifiedDateTime":
return Optional.ofNullable(clazz.cast(lastModifiedDateTime()));
case "EndDateTime":
return Optional.ofNullable(clazz.cast(endDateTime()));
case "IdleSinceDateTime":
return Optional.ofNullable(clazz.cast(idleSinceDateTime()));
case "State":
return Optional.ofNullable(clazz.cast(stateAsString()));
case "StateChangeReason":
return Optional.ofNullable(clazz.cast(stateChangeReason()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
@Override
public final Map> sdkFieldNameToField() {
return SDK_NAME_TO_FIELD;
}
private static Function