
software.amazon.awssdk.services.timestreamquery.model.ScheduledQueryRunSummary 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.timestreamquery.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.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;
/**
*
* Run summary for the scheduled query
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class ScheduledQueryRunSummary implements SdkPojo, Serializable,
ToCopyableBuilder {
private static final SdkField INVOCATION_TIME_FIELD = SdkField. builder(MarshallingType.INSTANT)
.memberName("InvocationTime").getter(getter(ScheduledQueryRunSummary::invocationTime))
.setter(setter(Builder::invocationTime))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("InvocationTime").build()).build();
private static final SdkField TRIGGER_TIME_FIELD = SdkField. builder(MarshallingType.INSTANT)
.memberName("TriggerTime").getter(getter(ScheduledQueryRunSummary::triggerTime)).setter(setter(Builder::triggerTime))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("TriggerTime").build()).build();
private static final SdkField RUN_STATUS_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("RunStatus").getter(getter(ScheduledQueryRunSummary::runStatusAsString))
.setter(setter(Builder::runStatus))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("RunStatus").build()).build();
private static final SdkField EXECUTION_STATS_FIELD = SdkField
. builder(MarshallingType.SDK_POJO).memberName("ExecutionStats")
.getter(getter(ScheduledQueryRunSummary::executionStats)).setter(setter(Builder::executionStats))
.constructor(ExecutionStats::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ExecutionStats").build()).build();
private static final SdkField QUERY_INSIGHTS_RESPONSE_FIELD = SdkField
. builder(MarshallingType.SDK_POJO).memberName("QueryInsightsResponse")
.getter(getter(ScheduledQueryRunSummary::queryInsightsResponse)).setter(setter(Builder::queryInsightsResponse))
.constructor(ScheduledQueryInsightsResponse::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("QueryInsightsResponse").build())
.build();
private static final SdkField ERROR_REPORT_LOCATION_FIELD = SdkField
. builder(MarshallingType.SDK_POJO).memberName("ErrorReportLocation")
.getter(getter(ScheduledQueryRunSummary::errorReportLocation)).setter(setter(Builder::errorReportLocation))
.constructor(ErrorReportLocation::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ErrorReportLocation").build())
.build();
private static final SdkField FAILURE_REASON_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("FailureReason").getter(getter(ScheduledQueryRunSummary::failureReason))
.setter(setter(Builder::failureReason))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("FailureReason").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(INVOCATION_TIME_FIELD,
TRIGGER_TIME_FIELD, RUN_STATUS_FIELD, EXECUTION_STATS_FIELD, QUERY_INSIGHTS_RESPONSE_FIELD,
ERROR_REPORT_LOCATION_FIELD, FAILURE_REASON_FIELD));
private static final Map> SDK_NAME_TO_FIELD = memberNameToFieldInitializer();
private static final long serialVersionUID = 1L;
private final Instant invocationTime;
private final Instant triggerTime;
private final String runStatus;
private final ExecutionStats executionStats;
private final ScheduledQueryInsightsResponse queryInsightsResponse;
private final ErrorReportLocation errorReportLocation;
private final String failureReason;
private ScheduledQueryRunSummary(BuilderImpl builder) {
this.invocationTime = builder.invocationTime;
this.triggerTime = builder.triggerTime;
this.runStatus = builder.runStatus;
this.executionStats = builder.executionStats;
this.queryInsightsResponse = builder.queryInsightsResponse;
this.errorReportLocation = builder.errorReportLocation;
this.failureReason = builder.failureReason;
}
/**
*
* InvocationTime for this run. This is the time at which the query is scheduled to run. Parameter
* @scheduled_runtime
can be used in the query to get the value.
*
*
* @return InvocationTime for this run. This is the time at which the query is scheduled to run. Parameter
* @scheduled_runtime
can be used in the query to get the value.
*/
public final Instant invocationTime() {
return invocationTime;
}
/**
*
* The actual time when the query was run.
*
*
* @return The actual time when the query was run.
*/
public final Instant triggerTime() {
return triggerTime;
}
/**
*
* The status of a scheduled query run.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #runStatus} will
* return {@link ScheduledQueryRunStatus#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available
* from {@link #runStatusAsString}.
*
*
* @return The status of a scheduled query run.
* @see ScheduledQueryRunStatus
*/
public final ScheduledQueryRunStatus runStatus() {
return ScheduledQueryRunStatus.fromValue(runStatus);
}
/**
*
* The status of a scheduled query run.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #runStatus} will
* return {@link ScheduledQueryRunStatus#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available
* from {@link #runStatusAsString}.
*
*
* @return The status of a scheduled query run.
* @see ScheduledQueryRunStatus
*/
public final String runStatusAsString() {
return runStatus;
}
/**
*
* Runtime statistics for a scheduled run.
*
*
* @return Runtime statistics for a scheduled run.
*/
public final ExecutionStats executionStats() {
return executionStats;
}
/**
*
* Provides various insights and metrics related to the run summary of the scheduled query.
*
*
* @return Provides various insights and metrics related to the run summary of the scheduled query.
*/
public final ScheduledQueryInsightsResponse queryInsightsResponse() {
return queryInsightsResponse;
}
/**
*
* S3 location for error report.
*
*
* @return S3 location for error report.
*/
public final ErrorReportLocation errorReportLocation() {
return errorReportLocation;
}
/**
*
* Error message for the scheduled query in case of failure. You might have to look at the error report to get more
* detailed error reasons.
*
*
* @return Error message for the scheduled query in case of failure. You might have to look at the error report to
* get more detailed error reasons.
*/
public final String failureReason() {
return failureReason;
}
@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(invocationTime());
hashCode = 31 * hashCode + Objects.hashCode(triggerTime());
hashCode = 31 * hashCode + Objects.hashCode(runStatusAsString());
hashCode = 31 * hashCode + Objects.hashCode(executionStats());
hashCode = 31 * hashCode + Objects.hashCode(queryInsightsResponse());
hashCode = 31 * hashCode + Objects.hashCode(errorReportLocation());
hashCode = 31 * hashCode + Objects.hashCode(failureReason());
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 ScheduledQueryRunSummary)) {
return false;
}
ScheduledQueryRunSummary other = (ScheduledQueryRunSummary) obj;
return Objects.equals(invocationTime(), other.invocationTime()) && Objects.equals(triggerTime(), other.triggerTime())
&& Objects.equals(runStatusAsString(), other.runStatusAsString())
&& Objects.equals(executionStats(), other.executionStats())
&& Objects.equals(queryInsightsResponse(), other.queryInsightsResponse())
&& Objects.equals(errorReportLocation(), other.errorReportLocation())
&& Objects.equals(failureReason(), other.failureReason());
}
/**
* 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("ScheduledQueryRunSummary").add("InvocationTime", invocationTime())
.add("TriggerTime", triggerTime()).add("RunStatus", runStatusAsString()).add("ExecutionStats", executionStats())
.add("QueryInsightsResponse", queryInsightsResponse()).add("ErrorReportLocation", errorReportLocation())
.add("FailureReason", failureReason()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "InvocationTime":
return Optional.ofNullable(clazz.cast(invocationTime()));
case "TriggerTime":
return Optional.ofNullable(clazz.cast(triggerTime()));
case "RunStatus":
return Optional.ofNullable(clazz.cast(runStatusAsString()));
case "ExecutionStats":
return Optional.ofNullable(clazz.cast(executionStats()));
case "QueryInsightsResponse":
return Optional.ofNullable(clazz.cast(queryInsightsResponse()));
case "ErrorReportLocation":
return Optional.ofNullable(clazz.cast(errorReportLocation()));
case "FailureReason":
return Optional.ofNullable(clazz.cast(failureReason()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
@Override
public final Map> sdkFieldNameToField() {
return SDK_NAME_TO_FIELD;
}
private static Map> memberNameToFieldInitializer() {
Map> map = new HashMap<>();
map.put("InvocationTime", INVOCATION_TIME_FIELD);
map.put("TriggerTime", TRIGGER_TIME_FIELD);
map.put("RunStatus", RUN_STATUS_FIELD);
map.put("ExecutionStats", EXECUTION_STATS_FIELD);
map.put("QueryInsightsResponse", QUERY_INSIGHTS_RESPONSE_FIELD);
map.put("ErrorReportLocation", ERROR_REPORT_LOCATION_FIELD);
map.put("FailureReason", FAILURE_REASON_FIELD);
return Collections.unmodifiableMap(map);
}
private static Function