software.amazon.awssdk.services.cloudwatchlogs.model.QueryInfo Maven / Gradle / Ivy
Show all versions of cloudwatchlogs Show documentation
/*
* Copyright 2014-2019 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.cloudwatchlogs.model;
import java.io.Serializable;
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.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 one CloudWatch Logs Insights query that matches the request in a DescribeQueries
* operation.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class QueryInfo implements SdkPojo, Serializable, ToCopyableBuilder {
private static final SdkField QUERY_ID_FIELD = SdkField. builder(MarshallingType.STRING)
.getter(getter(QueryInfo::queryId)).setter(setter(Builder::queryId))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("queryId").build()).build();
private static final SdkField QUERY_STRING_FIELD = SdkField. builder(MarshallingType.STRING)
.getter(getter(QueryInfo::queryString)).setter(setter(Builder::queryString))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("queryString").build()).build();
private static final SdkField STATUS_FIELD = SdkField. builder(MarshallingType.STRING)
.getter(getter(QueryInfo::statusAsString)).setter(setter(Builder::status))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("status").build()).build();
private static final SdkField CREATE_TIME_FIELD = SdkField. builder(MarshallingType.LONG)
.getter(getter(QueryInfo::createTime)).setter(setter(Builder::createTime))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("createTime").build()).build();
private static final SdkField LOG_GROUP_NAME_FIELD = SdkField. builder(MarshallingType.STRING)
.getter(getter(QueryInfo::logGroupName)).setter(setter(Builder::logGroupName))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("logGroupName").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(QUERY_ID_FIELD,
QUERY_STRING_FIELD, STATUS_FIELD, CREATE_TIME_FIELD, LOG_GROUP_NAME_FIELD));
private static final long serialVersionUID = 1L;
private final String queryId;
private final String queryString;
private final String status;
private final Long createTime;
private final String logGroupName;
private QueryInfo(BuilderImpl builder) {
this.queryId = builder.queryId;
this.queryString = builder.queryString;
this.status = builder.status;
this.createTime = builder.createTime;
this.logGroupName = builder.logGroupName;
}
/**
*
* The unique ID number of this query.
*
*
* @return The unique ID number of this query.
*/
public String queryId() {
return queryId;
}
/**
*
* The query string used in this query.
*
*
* @return The query string used in this query.
*/
public String queryString() {
return queryString;
}
/**
*
* The status of this query. Possible values are Cancelled
, Complete
, Failed
,
* Running
, Scheduled
, and Unknown
.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #status} will
* return {@link QueryStatus#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #statusAsString}.
*
*
* @return The status of this query. Possible values are Cancelled
, Complete
,
* Failed
, Running
, Scheduled
, and Unknown
.
* @see QueryStatus
*/
public QueryStatus status() {
return QueryStatus.fromValue(status);
}
/**
*
* The status of this query. Possible values are Cancelled
, Complete
, Failed
,
* Running
, Scheduled
, and Unknown
.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #status} will
* return {@link QueryStatus#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #statusAsString}.
*
*
* @return The status of this query. Possible values are Cancelled
, Complete
,
* Failed
, Running
, Scheduled
, and Unknown
.
* @see QueryStatus
*/
public String statusAsString() {
return status;
}
/**
*
* The date and time that this query was created.
*
*
* @return The date and time that this query was created.
*/
public Long createTime() {
return createTime;
}
/**
*
* The name of the log group scanned by this query.
*
*
* @return The name of the log group scanned by this query.
*/
public String logGroupName() {
return logGroupName;
}
@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(queryId());
hashCode = 31 * hashCode + Objects.hashCode(queryString());
hashCode = 31 * hashCode + Objects.hashCode(statusAsString());
hashCode = 31 * hashCode + Objects.hashCode(createTime());
hashCode = 31 * hashCode + Objects.hashCode(logGroupName());
return hashCode;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof QueryInfo)) {
return false;
}
QueryInfo other = (QueryInfo) obj;
return Objects.equals(queryId(), other.queryId()) && Objects.equals(queryString(), other.queryString())
&& Objects.equals(statusAsString(), other.statusAsString()) && Objects.equals(createTime(), other.createTime())
&& Objects.equals(logGroupName(), other.logGroupName());
}
/**
* 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("QueryInfo").add("QueryId", queryId()).add("QueryString", queryString())
.add("Status", statusAsString()).add("CreateTime", createTime()).add("LogGroupName", logGroupName()).build();
}
public Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "queryId":
return Optional.ofNullable(clazz.cast(queryId()));
case "queryString":
return Optional.ofNullable(clazz.cast(queryString()));
case "status":
return Optional.ofNullable(clazz.cast(statusAsString()));
case "createTime":
return Optional.ofNullable(clazz.cast(createTime()));
case "logGroupName":
return Optional.ofNullable(clazz.cast(logGroupName()));
default:
return Optional.empty();
}
}
@Override
public List> sdkFields() {
return SDK_FIELDS;
}
private static Function