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

software.amazon.awssdk.services.cloudwatchlogs.model.GetQueryResultsResponse 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.cloudwatchlogs.model;

import java.util.Arrays;
import java.util.Collection;
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.ListTrait;
import software.amazon.awssdk.core.traits.LocationTrait;
import software.amazon.awssdk.core.util.DefaultSdkAutoConstructList;
import software.amazon.awssdk.core.util.SdkAutoConstructList;
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 GetQueryResultsResponse extends CloudWatchLogsResponse implements
        ToCopyableBuilder {
    private static final SdkField>> RESULTS_FIELD = SdkField
            .>> builder(MarshallingType.LIST)
            .memberName("results")
            .getter(getter(GetQueryResultsResponse::results))
            .setter(setter(Builder::results))
            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("results").build(),
                    ListTrait
                            .builder()
                            .memberLocationName(null)
                            .memberFieldInfo(
                                    SdkField.> builder(MarshallingType.LIST)
                                            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
                                                    .locationName("member").build(),
                                                    ListTrait
                                                            .builder()
                                                            .memberLocationName(null)
                                                            .memberFieldInfo(
                                                                    SdkField. builder(MarshallingType.SDK_POJO)
                                                                            .constructor(ResultField::builder)
                                                                            .traits(LocationTrait.builder()
                                                                                    .location(MarshallLocation.PAYLOAD)
                                                                                    .locationName("member").build()).build())
                                                            .build()).build()).build()).build();

    private static final SdkField STATISTICS_FIELD = SdkField
            . builder(MarshallingType.SDK_POJO).memberName("statistics")
            .getter(getter(GetQueryResultsResponse::statistics)).setter(setter(Builder::statistics))
            .constructor(QueryStatistics::builder)
            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("statistics").build()).build();

    private static final SdkField STATUS_FIELD = SdkField. builder(MarshallingType.STRING).memberName("status")
            .getter(getter(GetQueryResultsResponse::statusAsString)).setter(setter(Builder::status))
            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("status").build()).build();

    private static final SdkField ENCRYPTION_KEY_FIELD = SdkField. builder(MarshallingType.STRING)
            .memberName("encryptionKey").getter(getter(GetQueryResultsResponse::encryptionKey))
            .setter(setter(Builder::encryptionKey))
            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("encryptionKey").build()).build();

    private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(RESULTS_FIELD,
            STATISTICS_FIELD, STATUS_FIELD, ENCRYPTION_KEY_FIELD));

    private final List> results;

    private final QueryStatistics statistics;

    private final String status;

    private final String encryptionKey;

    private GetQueryResultsResponse(BuilderImpl builder) {
        super(builder);
        this.results = builder.results;
        this.statistics = builder.statistics;
        this.status = builder.status;
        this.encryptionKey = builder.encryptionKey;
    }

    /**
     * For responses, this returns true if the service returned a value for the Results property. This DOES NOT check
     * that the value is non-empty (for which, you should check the {@code isEmpty()} method on the property). This is
     * useful because the SDK will never return a null collection or map, but you may need to differentiate between the
     * service returning nothing (or null) and the service returning an empty collection or map. For requests, this
     * returns true if a value for the property was specified in the request builder, and false if a value was not
     * specified.
     */
    public final boolean hasResults() {
        return results != null && !(results instanceof SdkAutoConstructList);
    }

    /**
     * 

* The log events that matched the query criteria during the most recent time it ran. *

*

* The results value is an array of arrays. Each log event is one object in the top-level array. Each * of these log event objects is an array of field/value pairs. *

*

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

*

* This method will never return null. If you would like to know whether the service returned this field (so that * you can differentiate between null and empty), you can use the {@link #hasResults} method. *

* * @return The log events that matched the query criteria during the most recent time it ran.

*

* The results value is an array of arrays. Each log event is one object in the top-level * array. Each of these log event objects is an array of field/value pairs. */ public final List> results() { return results; } /** *

* Includes the number of log events scanned by the query, the number of log events that matched the query criteria, * and the total number of bytes in the scanned log events. These values reflect the full raw results of the query. *

* * @return Includes the number of log events scanned by the query, the number of log events that matched the query * criteria, and the total number of bytes in the scanned log events. These values reflect the full raw * results of the query. */ public final QueryStatistics statistics() { return statistics; } /** *

* The status of the most recent running of the query. Possible values are Cancelled, * Complete, Failed, Running, Scheduled, Timeout, * and Unknown. *

*

* Queries time out after 60 minutes of runtime. To avoid having your queries time out, reduce the time range being * searched or partition your query into a number of queries. *

*

* 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 the most recent running of the query. Possible values are Cancelled, * Complete, Failed, Running, Scheduled, * Timeout, and Unknown.

*

* Queries time out after 60 minutes of runtime. To avoid having your queries time out, reduce the time * range being searched or partition your query into a number of queries. * @see QueryStatus */ public final QueryStatus status() { return QueryStatus.fromValue(status); } /** *

* The status of the most recent running of the query. Possible values are Cancelled, * Complete, Failed, Running, Scheduled, Timeout, * and Unknown. *

*

* Queries time out after 60 minutes of runtime. To avoid having your queries time out, reduce the time range being * searched or partition your query into a number of queries. *

*

* 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 the most recent running of the query. Possible values are Cancelled, * Complete, Failed, Running, Scheduled, * Timeout, and Unknown.

*

* Queries time out after 60 minutes of runtime. To avoid having your queries time out, reduce the time * range being searched or partition your query into a number of queries. * @see QueryStatus */ public final String statusAsString() { return status; } /** *

* If you associated an KMS key with the CloudWatch Logs Insights query results in this account, this field displays * the ARN of the key that's used to encrypt the query results when StartQuery * stores them. *

* * @return If you associated an KMS key with the CloudWatch Logs Insights query results in this account, this field * displays the ARN of the key that's used to encrypt the query results when StartQuery stores them. */ public final String encryptionKey() { return encryptionKey; } @Override public Builder toBuilder() { return new BuilderImpl(this); } public static Builder builder() { return new BuilderImpl(); } public static Class serializableBuilderClass() { return BuilderImpl.class; } @Override public final int hashCode() { int hashCode = 1; hashCode = 31 * hashCode + super.hashCode(); hashCode = 31 * hashCode + Objects.hashCode(hasResults() ? results() : null); hashCode = 31 * hashCode + Objects.hashCode(statistics()); hashCode = 31 * hashCode + Objects.hashCode(statusAsString()); hashCode = 31 * hashCode + Objects.hashCode(encryptionKey()); return hashCode; } @Override public final boolean equals(Object obj) { return super.equals(obj) && equalsBySdkFields(obj); } @Override public final boolean equalsBySdkFields(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (!(obj instanceof GetQueryResultsResponse)) { return false; } GetQueryResultsResponse other = (GetQueryResultsResponse) obj; return hasResults() == other.hasResults() && Objects.equals(results(), other.results()) && Objects.equals(statistics(), other.statistics()) && Objects.equals(statusAsString(), other.statusAsString()) && Objects.equals(encryptionKey(), other.encryptionKey()); } /** * 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("GetQueryResultsResponse").add("Results", hasResults() ? results() : null) .add("Statistics", statistics()).add("Status", statusAsString()).add("EncryptionKey", encryptionKey()).build(); } public final Optional getValueForField(String fieldName, Class clazz) { switch (fieldName) { case "results": return Optional.ofNullable(clazz.cast(results())); case "statistics": return Optional.ofNullable(clazz.cast(statistics())); case "status": return Optional.ofNullable(clazz.cast(statusAsString())); case "encryptionKey": return Optional.ofNullable(clazz.cast(encryptionKey())); default: return Optional.empty(); } } @Override public final List> sdkFields() { return SDK_FIELDS; } private static Function getter(Function g) { return obj -> g.apply((GetQueryResultsResponse) obj); } private static BiConsumer setter(BiConsumer s) { return (obj, val) -> s.accept((Builder) obj, val); } public interface Builder extends CloudWatchLogsResponse.Builder, SdkPojo, CopyableBuilder { /** *

* The log events that matched the query criteria during the most recent time it ran. *

*

* The results value is an array of arrays. Each log event is one object in the top-level array. * Each of these log event objects is an array of field/value pairs. *

* * @param results * The log events that matched the query criteria during the most recent time it ran.

*

* The results value is an array of arrays. Each log event is one object in the top-level * array. Each of these log event objects is an array of field/value pairs. * @return Returns a reference to this object so that method calls can be chained together. */ Builder results(Collection> results); /** *

* The log events that matched the query criteria during the most recent time it ran. *

*

* The results value is an array of arrays. Each log event is one object in the top-level array. * Each of these log event objects is an array of field/value pairs. *

* * @param results * The log events that matched the query criteria during the most recent time it ran.

*

* The results value is an array of arrays. Each log event is one object in the top-level * array. Each of these log event objects is an array of field/value pairs. * @return Returns a reference to this object so that method calls can be chained together. */ Builder results(Collection... results); /** *

* Includes the number of log events scanned by the query, the number of log events that matched the query * criteria, and the total number of bytes in the scanned log events. These values reflect the full raw results * of the query. *

* * @param statistics * Includes the number of log events scanned by the query, the number of log events that matched the * query criteria, and the total number of bytes in the scanned log events. These values reflect the full * raw results of the query. * @return Returns a reference to this object so that method calls can be chained together. */ Builder statistics(QueryStatistics statistics); /** *

* Includes the number of log events scanned by the query, the number of log events that matched the query * criteria, and the total number of bytes in the scanned log events. These values reflect the full raw results * of the query. *

* This is a convenience method that creates an instance of the {@link QueryStatistics.Builder} avoiding the * need to create one manually via {@link QueryStatistics#builder()}. * *

* When the {@link Consumer} completes, {@link QueryStatistics.Builder#build()} is called immediately and its * result is passed to {@link #statistics(QueryStatistics)}. * * @param statistics * a consumer that will call methods on {@link QueryStatistics.Builder} * @return Returns a reference to this object so that method calls can be chained together. * @see #statistics(QueryStatistics) */ default Builder statistics(Consumer statistics) { return statistics(QueryStatistics.builder().applyMutation(statistics).build()); } /** *

* The status of the most recent running of the query. Possible values are Cancelled, * Complete, Failed, Running, Scheduled, * Timeout, and Unknown. *

*

* Queries time out after 60 minutes of runtime. To avoid having your queries time out, reduce the time range * being searched or partition your query into a number of queries. *

* * @param status * The status of the most recent running of the query. Possible values are Cancelled, * Complete, Failed, Running, Scheduled, * Timeout, and Unknown.

*

* Queries time out after 60 minutes of runtime. To avoid having your queries time out, reduce the time * range being searched or partition your query into a number of queries. * @see QueryStatus * @return Returns a reference to this object so that method calls can be chained together. * @see QueryStatus */ Builder status(String status); /** *

* The status of the most recent running of the query. Possible values are Cancelled, * Complete, Failed, Running, Scheduled, * Timeout, and Unknown. *

*

* Queries time out after 60 minutes of runtime. To avoid having your queries time out, reduce the time range * being searched or partition your query into a number of queries. *

* * @param status * The status of the most recent running of the query. Possible values are Cancelled, * Complete, Failed, Running, Scheduled, * Timeout, and Unknown.

*

* Queries time out after 60 minutes of runtime. To avoid having your queries time out, reduce the time * range being searched or partition your query into a number of queries. * @see QueryStatus * @return Returns a reference to this object so that method calls can be chained together. * @see QueryStatus */ Builder status(QueryStatus status); /** *

* If you associated an KMS key with the CloudWatch Logs Insights query results in this account, this field * displays the ARN of the key that's used to encrypt the query results when StartQuery stores them. *

* * @param encryptionKey * If you associated an KMS key with the CloudWatch Logs Insights query results in this account, this * field displays the ARN of the key that's used to encrypt the query results when StartQuery stores them. * @return Returns a reference to this object so that method calls can be chained together. */ Builder encryptionKey(String encryptionKey); } static final class BuilderImpl extends CloudWatchLogsResponse.BuilderImpl implements Builder { private List> results = DefaultSdkAutoConstructList.getInstance(); private QueryStatistics statistics; private String status; private String encryptionKey; private BuilderImpl() { } private BuilderImpl(GetQueryResultsResponse model) { super(model); results(model.results); statistics(model.statistics); status(model.status); encryptionKey(model.encryptionKey); } public final List> getResults() { List> result = QueryResultsCopier.copyToBuilder(this.results); if (result instanceof SdkAutoConstructList) { return null; } return result; } public final void setResults(Collection> results) { this.results = QueryResultsCopier.copyFromBuilder(results); } @Override public final Builder results(Collection> results) { this.results = QueryResultsCopier.copy(results); return this; } @Override @SafeVarargs public final Builder results(Collection... results) { results(Arrays.asList(results)); return this; } public final QueryStatistics.Builder getStatistics() { return statistics != null ? statistics.toBuilder() : null; } public final void setStatistics(QueryStatistics.BuilderImpl statistics) { this.statistics = statistics != null ? statistics.build() : null; } @Override public final Builder statistics(QueryStatistics statistics) { this.statistics = statistics; return this; } public final String getStatus() { return status; } public final void setStatus(String status) { this.status = status; } @Override public final Builder status(String status) { this.status = status; return this; } @Override public final Builder status(QueryStatus status) { this.status(status == null ? null : status.toString()); return this; } public final String getEncryptionKey() { return encryptionKey; } public final void setEncryptionKey(String encryptionKey) { this.encryptionKey = encryptionKey; } @Override public final Builder encryptionKey(String encryptionKey) { this.encryptionKey = encryptionKey; return this; } @Override public GetQueryResultsResponse build() { return new GetQueryResultsResponse(this); } @Override public List> sdkFields() { return SDK_FIELDS; } } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy