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

software.amazon.awssdk.services.cloudwatchlogs.model.PutQueryDefinitionRequest 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.awscore.AwsRequestOverrideConfiguration;
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 PutQueryDefinitionRequest extends CloudWatchLogsRequest implements
        ToCopyableBuilder {
    private static final SdkField NAME_FIELD = SdkField. builder(MarshallingType.STRING).memberName("name")
            .getter(getter(PutQueryDefinitionRequest::name)).setter(setter(Builder::name))
            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("name").build()).build();

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

    private static final SdkField> LOG_GROUP_NAMES_FIELD = SdkField
            .> builder(MarshallingType.LIST)
            .memberName("logGroupNames")
            .getter(getter(PutQueryDefinitionRequest::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 SdkField QUERY_STRING_FIELD = SdkField. builder(MarshallingType.STRING)
            .memberName("queryString").getter(getter(PutQueryDefinitionRequest::queryString))
            .setter(setter(Builder::queryString))
            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("queryString").build()).build();

    private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(NAME_FIELD,
            QUERY_DEFINITION_ID_FIELD, LOG_GROUP_NAMES_FIELD, QUERY_STRING_FIELD));

    private final String name;

    private final String queryDefinitionId;

    private final List logGroupNames;

    private final String queryString;

    private PutQueryDefinitionRequest(BuilderImpl builder) {
        super(builder);
        this.name = builder.name;
        this.queryDefinitionId = builder.queryDefinitionId;
        this.logGroupNames = builder.logGroupNames;
        this.queryString = builder.queryString;
    }

    /**
     * 

* A name for the query definition. If you are saving a lot of query definitions, we recommend that you name them so * that you can easily find the ones you want by using the first part of the name as a filter in the * queryDefinitionNamePrefix parameter of DescribeQueryDefinitions. *

* * @return A name for the query definition. If you are saving a lot of query definitions, we recommend that you name * them so that you can easily find the ones you want by using the first part of the name as a filter in the * queryDefinitionNamePrefix parameter of DescribeQueryDefinitions. */ public final String name() { return name; } /** *

* If you are updating a query definition, use this parameter to specify the ID of the query definition that you * want to update. You can use DescribeQueryDefinitions to retrieve the IDs of your saved query definitions. *

*

* If you are creating a query definition, do not specify this parameter. CloudWatch generates a unique ID for the * new query definition and include it in the response to this operation. *

* * @return If you are updating a query definition, use this parameter to specify the ID of the query definition that * you want to update. You can use DescribeQueryDefinitions to retrieve the IDs of your saved query definitions.

*

* If you are creating a query definition, do not specify this parameter. CloudWatch generates a unique ID * for the new query definition and include it in the response to this operation. */ public final String queryDefinitionId() { return queryDefinitionId; } /** * Returns true if the LogGroupNames property was specified by the sender (it may be empty), or false if the sender * did not specify the value (it will be empty). For responses returned by the SDK, the sender is the AWS service. */ public final boolean hasLogGroupNames() { return logGroupNames != null && !(logGroupNames instanceof SdkAutoConstructList); } /** *

* Use this parameter to include specific log groups as part of your query definition. *

*

* If you are updating a query definition and you omit this parameter, then the updated definition will contain no * log groups. *

*

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

*

* You can use {@link #hasLogGroupNames()} to see if a value was sent in this field. *

* * @return Use this parameter to include specific log groups as part of your query definition.

*

* If you are updating a query definition and you omit this parameter, then the updated definition will * contain no log groups. */ public final List logGroupNames() { return logGroupNames; } /** *

* 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; } @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(name()); hashCode = 31 * hashCode + Objects.hashCode(queryDefinitionId()); hashCode = 31 * hashCode + Objects.hashCode(hasLogGroupNames() ? logGroupNames() : null); hashCode = 31 * hashCode + Objects.hashCode(queryString()); 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 PutQueryDefinitionRequest)) { return false; } PutQueryDefinitionRequest other = (PutQueryDefinitionRequest) obj; return Objects.equals(name(), other.name()) && Objects.equals(queryDefinitionId(), other.queryDefinitionId()) && hasLogGroupNames() == other.hasLogGroupNames() && Objects.equals(logGroupNames(), other.logGroupNames()) && Objects.equals(queryString(), other.queryString()); } /** * 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("PutQueryDefinitionRequest").add("Name", name()).add("QueryDefinitionId", queryDefinitionId()) .add("LogGroupNames", hasLogGroupNames() ? logGroupNames() : null).add("QueryString", queryString()).build(); } public final Optional getValueForField(String fieldName, Class clazz) { switch (fieldName) { case "name": return Optional.ofNullable(clazz.cast(name())); case "queryDefinitionId": return Optional.ofNullable(clazz.cast(queryDefinitionId())); case "logGroupNames": return Optional.ofNullable(clazz.cast(logGroupNames())); case "queryString": return Optional.ofNullable(clazz.cast(queryString())); default: return Optional.empty(); } } @Override public final List> sdkFields() { return SDK_FIELDS; } private static Function getter(Function g) { return obj -> g.apply((PutQueryDefinitionRequest) obj); } private static BiConsumer setter(BiConsumer s) { return (obj, val) -> s.accept((Builder) obj, val); } public interface Builder extends CloudWatchLogsRequest.Builder, SdkPojo, CopyableBuilder { /** *

* A name for the query definition. If you are saving a lot of query definitions, we recommend that you name * them so that you can easily find the ones you want by using the first part of the name as a filter in the * queryDefinitionNamePrefix parameter of DescribeQueryDefinitions. *

* * @param name * A name for the query definition. If you are saving a lot of query definitions, we recommend that you * name them so that you can easily find the ones you want by using the first part of the name as a * filter in the queryDefinitionNamePrefix parameter of DescribeQueryDefinitions. * @return Returns a reference to this object so that method calls can be chained together. */ Builder name(String name); /** *

* If you are updating a query definition, use this parameter to specify the ID of the query definition that you * want to update. You can use DescribeQueryDefinitions to retrieve the IDs of your saved query definitions. *

*

* If you are creating a query definition, do not specify this parameter. CloudWatch generates a unique ID for * the new query definition and include it in the response to this operation. *

* * @param queryDefinitionId * If you are updating a query definition, use this parameter to specify the ID of the query definition * that you want to update. You can use DescribeQueryDefinitions to retrieve the IDs of your saved query definitions.

*

* If you are creating a query definition, do not specify this parameter. CloudWatch generates a unique * ID for the new query definition and include it in the response to this operation. * @return Returns a reference to this object so that method calls can be chained together. */ Builder queryDefinitionId(String queryDefinitionId); /** *

* Use this parameter to include specific log groups as part of your query definition. *

*

* If you are updating a query definition and you omit this parameter, then the updated definition will contain * no log groups. *

* * @param logGroupNames * Use this parameter to include specific log groups as part of your query definition.

*

* If you are updating a query definition and you omit this parameter, then the updated definition will * contain no log groups. * @return Returns a reference to this object so that method calls can be chained together. */ Builder logGroupNames(Collection logGroupNames); /** *

* Use this parameter to include specific log groups as part of your query definition. *

*

* If you are updating a query definition and you omit this parameter, then the updated definition will contain * no log groups. *

* * @param logGroupNames * Use this parameter to include specific log groups as part of your query definition.

*

* If you are updating a query definition and you omit this parameter, then the updated definition will * contain no log groups. * @return Returns a reference to this object so that method calls can be chained together. */ Builder logGroupNames(String... logGroupNames); /** *

* 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); @Override Builder overrideConfiguration(AwsRequestOverrideConfiguration overrideConfiguration); @Override Builder overrideConfiguration(Consumer builderConsumer); } static final class BuilderImpl extends CloudWatchLogsRequest.BuilderImpl implements Builder { private String name; private String queryDefinitionId; private List logGroupNames = DefaultSdkAutoConstructList.getInstance(); private String queryString; private BuilderImpl() { } private BuilderImpl(PutQueryDefinitionRequest model) { super(model); name(model.name); queryDefinitionId(model.queryDefinitionId); logGroupNames(model.logGroupNames); queryString(model.queryString); } public final String getName() { return name; } @Override public final Builder name(String name) { this.name = name; return this; } public final void setName(String name) { this.name = name; } public final String getQueryDefinitionId() { return queryDefinitionId; } @Override public final Builder queryDefinitionId(String queryDefinitionId) { this.queryDefinitionId = queryDefinitionId; return this; } public final void setQueryDefinitionId(String queryDefinitionId) { this.queryDefinitionId = queryDefinitionId; } public final Collection getLogGroupNames() { if (logGroupNames instanceof SdkAutoConstructList) { return null; } return 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; } public final void setLogGroupNames(Collection logGroupNames) { this.logGroupNames = LogGroupNamesCopier.copy(logGroupNames); } public final String getQueryString() { return queryString; } @Override public final Builder queryString(String queryString) { this.queryString = queryString; return this; } public final void setQueryString(String queryString) { this.queryString = queryString; } @Override public Builder overrideConfiguration(AwsRequestOverrideConfiguration overrideConfiguration) { super.overrideConfiguration(overrideConfiguration); return this; } @Override public Builder overrideConfiguration(Consumer builderConsumer) { super.overrideConfiguration(builderConsumer); return this; } @Override public PutQueryDefinitionRequest build() { return new PutQueryDefinitionRequest(this); } @Override public List> sdkFields() { return SDK_FIELDS; } } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy