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

software.amazon.awssdk.services.cloudwatchlogs.model.QueryDefinition Maven / Gradle / Ivy

Go to download

The AWS Java SDK for Amazon CloudWatch Logs module holds the client classes that are used for communicating with Amazon CloudWatch Logs Service

There is a newer version: 2.30.1
Show newest version
/*
 * 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.io.Serializable;
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.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;

/**
 * 

* This structure contains details about a saved CloudWatch Logs Insights query definition. *

*/ @Generated("software.amazon.awssdk:codegen") public final class QueryDefinition implements SdkPojo, Serializable, ToCopyableBuilder { private static final SdkField QUERY_DEFINITION_ID_FIELD = SdkField. builder(MarshallingType.STRING) .memberName("queryDefinitionId").getter(getter(QueryDefinition::queryDefinitionId)) .setter(setter(Builder::queryDefinitionId)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("queryDefinitionId").build()).build(); private static final SdkField NAME_FIELD = SdkField. builder(MarshallingType.STRING).memberName("name") .getter(getter(QueryDefinition::name)).setter(setter(Builder::name)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("name").build()).build(); private static final SdkField QUERY_STRING_FIELD = SdkField. builder(MarshallingType.STRING) .memberName("queryString").getter(getter(QueryDefinition::queryString)).setter(setter(Builder::queryString)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("queryString").build()).build(); private static final SdkField LAST_MODIFIED_FIELD = SdkField. builder(MarshallingType.LONG) .memberName("lastModified").getter(getter(QueryDefinition::lastModified)).setter(setter(Builder::lastModified)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("lastModified").build()).build(); private static final SdkField> LOG_GROUP_NAMES_FIELD = SdkField .> builder(MarshallingType.LIST) .memberName("logGroupNames") .getter(getter(QueryDefinition::logGroupNames)) .setter(setter(Builder::logGroupNames)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("logGroupNames").build(), ListTrait .builder() .memberLocationName(null) .memberFieldInfo( SdkField. builder(MarshallingType.STRING) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) .locationName("member").build()).build()).build()).build(); private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(QUERY_DEFINITION_ID_FIELD, NAME_FIELD, QUERY_STRING_FIELD, LAST_MODIFIED_FIELD, LOG_GROUP_NAMES_FIELD)); private static final long serialVersionUID = 1L; private final String queryDefinitionId; private final String name; private final String queryString; private final Long lastModified; private final List logGroupNames; private QueryDefinition(BuilderImpl builder) { this.queryDefinitionId = builder.queryDefinitionId; this.name = builder.name; this.queryString = builder.queryString; this.lastModified = builder.lastModified; this.logGroupNames = builder.logGroupNames; } /** *

* The unique ID of the query definition. *

* * @return The unique ID of the query definition. */ public final String queryDefinitionId() { return queryDefinitionId; } /** *

* The name of the query definition. *

* * @return The name of the query definition. */ public final String name() { return name; } /** *

* The query string to use for this definition. For more information, see CloudWatch Logs Insights * Query Syntax. *

* * @return The query string to use for this definition. For more information, see CloudWatch Logs * Insights Query Syntax. */ public final String queryString() { return queryString; } /** *

* The date that the query definition was most recently modified. *

* * @return The date that the query definition was most recently modified. */ public final Long lastModified() { return lastModified; } /** * For responses, this returns true if the service returned a value for the LogGroupNames 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 hasLogGroupNames() { return logGroupNames != null && !(logGroupNames instanceof SdkAutoConstructList); } /** *

* If this query definition contains a list of log groups that it is limited to, that list appears here. *

*

* 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 #hasLogGroupNames} method. *

* * @return If this query definition contains a list of log groups that it is limited to, that list appears here. */ public final List logGroupNames() { return logGroupNames; } @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 + Objects.hashCode(queryDefinitionId()); hashCode = 31 * hashCode + Objects.hashCode(name()); hashCode = 31 * hashCode + Objects.hashCode(queryString()); hashCode = 31 * hashCode + Objects.hashCode(lastModified()); hashCode = 31 * hashCode + Objects.hashCode(hasLogGroupNames() ? logGroupNames() : null); 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 QueryDefinition)) { return false; } QueryDefinition other = (QueryDefinition) obj; return Objects.equals(queryDefinitionId(), other.queryDefinitionId()) && Objects.equals(name(), other.name()) && Objects.equals(queryString(), other.queryString()) && Objects.equals(lastModified(), other.lastModified()) && hasLogGroupNames() == other.hasLogGroupNames() && Objects.equals(logGroupNames(), other.logGroupNames()); } /** * 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("QueryDefinition").add("QueryDefinitionId", queryDefinitionId()).add("Name", name()) .add("QueryString", queryString()).add("LastModified", lastModified()) .add("LogGroupNames", hasLogGroupNames() ? logGroupNames() : null).build(); } public final Optional getValueForField(String fieldName, Class clazz) { switch (fieldName) { case "queryDefinitionId": return Optional.ofNullable(clazz.cast(queryDefinitionId())); case "name": return Optional.ofNullable(clazz.cast(name())); case "queryString": return Optional.ofNullable(clazz.cast(queryString())); case "lastModified": return Optional.ofNullable(clazz.cast(lastModified())); case "logGroupNames": return Optional.ofNullable(clazz.cast(logGroupNames())); default: return Optional.empty(); } } @Override public final List> sdkFields() { return SDK_FIELDS; } private static Function getter(Function g) { return obj -> g.apply((QueryDefinition) obj); } private static BiConsumer setter(BiConsumer s) { return (obj, val) -> s.accept((Builder) obj, val); } public interface Builder extends SdkPojo, CopyableBuilder { /** *

* The unique ID of the query definition. *

* * @param queryDefinitionId * The unique ID of the query definition. * @return Returns a reference to this object so that method calls can be chained together. */ Builder queryDefinitionId(String queryDefinitionId); /** *

* The name of the query definition. *

* * @param name * The name of the query definition. * @return Returns a reference to this object so that method calls can be chained together. */ Builder name(String name); /** *

* The query string to use for this definition. For more information, see CloudWatch Logs Insights * Query Syntax. *

* * @param queryString * The query string to use for this definition. For more information, see CloudWatch Logs * Insights Query Syntax. * @return Returns a reference to this object so that method calls can be chained together. */ Builder queryString(String queryString); /** *

* The date that the query definition was most recently modified. *

* * @param lastModified * The date that the query definition was most recently modified. * @return Returns a reference to this object so that method calls can be chained together. */ Builder lastModified(Long lastModified); /** *

* If this query definition contains a list of log groups that it is limited to, that list appears here. *

* * @param logGroupNames * If this query definition contains a list of log groups that it is limited to, that list appears here. * @return Returns a reference to this object so that method calls can be chained together. */ Builder logGroupNames(Collection logGroupNames); /** *

* If this query definition contains a list of log groups that it is limited to, that list appears here. *

* * @param logGroupNames * If this query definition contains a list of log groups that it is limited to, that list appears here. * @return Returns a reference to this object so that method calls can be chained together. */ Builder logGroupNames(String... logGroupNames); } static final class BuilderImpl implements Builder { private String queryDefinitionId; private String name; private String queryString; private Long lastModified; private List logGroupNames = DefaultSdkAutoConstructList.getInstance(); private BuilderImpl() { } private BuilderImpl(QueryDefinition model) { queryDefinitionId(model.queryDefinitionId); name(model.name); queryString(model.queryString); lastModified(model.lastModified); logGroupNames(model.logGroupNames); } public final String getQueryDefinitionId() { return queryDefinitionId; } public final void setQueryDefinitionId(String queryDefinitionId) { this.queryDefinitionId = queryDefinitionId; } @Override public final Builder queryDefinitionId(String queryDefinitionId) { this.queryDefinitionId = queryDefinitionId; return this; } public final String getName() { return name; } public final void setName(String name) { this.name = name; } @Override public final Builder name(String name) { this.name = name; return this; } public final String getQueryString() { return queryString; } public final void setQueryString(String queryString) { this.queryString = queryString; } @Override public final Builder queryString(String queryString) { this.queryString = queryString; return this; } public final Long getLastModified() { return lastModified; } public final void setLastModified(Long lastModified) { this.lastModified = lastModified; } @Override public final Builder lastModified(Long lastModified) { this.lastModified = lastModified; return this; } public final Collection getLogGroupNames() { if (logGroupNames instanceof SdkAutoConstructList) { return null; } return logGroupNames; } public final void setLogGroupNames(Collection logGroupNames) { this.logGroupNames = LogGroupNamesCopier.copy(logGroupNames); } @Override public final Builder logGroupNames(Collection logGroupNames) { this.logGroupNames = LogGroupNamesCopier.copy(logGroupNames); return this; } @Override @SafeVarargs public final Builder logGroupNames(String... logGroupNames) { logGroupNames(Arrays.asList(logGroupNames)); return this; } @Override public QueryDefinition build() { return new QueryDefinition(this); } @Override public List> sdkFields() { return SDK_FIELDS; } } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy