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

software.amazon.awssdk.services.cloudwatchlogs.model.PutLogEventsRequest 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 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.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 java.util.stream.Collectors;
import java.util.stream.Stream;
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.utils.ToString;
import software.amazon.awssdk.utils.builder.CopyableBuilder;
import software.amazon.awssdk.utils.builder.ToCopyableBuilder;

/**
 */
@Generated("software.amazon.awssdk:codegen")
public final class PutLogEventsRequest extends CloudWatchLogsRequest implements
        ToCopyableBuilder {
    private static final SdkField LOG_GROUP_NAME_FIELD = SdkField. builder(MarshallingType.STRING)
            .getter(getter(PutLogEventsRequest::logGroupName)).setter(setter(Builder::logGroupName))
            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("logGroupName").build()).build();

    private static final SdkField LOG_STREAM_NAME_FIELD = SdkField. builder(MarshallingType.STRING)
            .getter(getter(PutLogEventsRequest::logStreamName)).setter(setter(Builder::logStreamName))
            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("logStreamName").build()).build();

    private static final SdkField> LOG_EVENTS_FIELD = SdkField
            .> builder(MarshallingType.LIST)
            .getter(getter(PutLogEventsRequest::logEvents))
            .setter(setter(Builder::logEvents))
            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("logEvents").build(),
                    ListTrait
                            .builder()
                            .memberLocationName(null)
                            .memberFieldInfo(
                                    SdkField. builder(MarshallingType.SDK_POJO)
                                            .constructor(InputLogEvent::builder)
                                            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
                                                    .locationName("member").build()).build()).build()).build();

    private static final SdkField SEQUENCE_TOKEN_FIELD = SdkField. builder(MarshallingType.STRING)
            .getter(getter(PutLogEventsRequest::sequenceToken)).setter(setter(Builder::sequenceToken))
            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("sequenceToken").build()).build();

    private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(LOG_GROUP_NAME_FIELD,
            LOG_STREAM_NAME_FIELD, LOG_EVENTS_FIELD, SEQUENCE_TOKEN_FIELD));

    private final String logGroupName;

    private final String logStreamName;

    private final List logEvents;

    private final String sequenceToken;

    private PutLogEventsRequest(BuilderImpl builder) {
        super(builder);
        this.logGroupName = builder.logGroupName;
        this.logStreamName = builder.logStreamName;
        this.logEvents = builder.logEvents;
        this.sequenceToken = builder.sequenceToken;
    }

    /**
     * 

* The name of the log group. *

* * @return The name of the log group. */ public String logGroupName() { return logGroupName; } /** *

* The name of the log stream. *

* * @return The name of the log stream. */ public String logStreamName() { return logStreamName; } /** *

* The log events. *

*

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

* * @return The log events. */ public List logEvents() { return logEvents; } /** *

* The sequence token obtained from the response of the previous PutLogEvents call. An upload in a * newly created log stream does not require a sequence token. You can also get the sequence token using * DescribeLogStreams. If you call PutLogEvents twice within a narrow time period using the same * value for sequenceToken, both calls may be successful, or one may be rejected. *

* * @return The sequence token obtained from the response of the previous PutLogEvents call. An upload * in a newly created log stream does not require a sequence token. You can also get the sequence token * using DescribeLogStreams. If you call PutLogEvents twice within a narrow time period * using the same value for sequenceToken, both calls may be successful, or one may be * rejected. */ public String sequenceToken() { return sequenceToken; } @Override public Builder toBuilder() { return new BuilderImpl(this); } public static Builder builder() { return new BuilderImpl(); } public static Class serializableBuilderClass() { return BuilderImpl.class; } @Override public int hashCode() { int hashCode = 1; hashCode = 31 * hashCode + Objects.hashCode(logGroupName()); hashCode = 31 * hashCode + Objects.hashCode(logStreamName()); hashCode = 31 * hashCode + Objects.hashCode(logEvents()); hashCode = 31 * hashCode + Objects.hashCode(sequenceToken()); return hashCode; } @Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (!(obj instanceof PutLogEventsRequest)) { return false; } PutLogEventsRequest other = (PutLogEventsRequest) obj; return Objects.equals(logGroupName(), other.logGroupName()) && Objects.equals(logStreamName(), other.logStreamName()) && Objects.equals(logEvents(), other.logEvents()) && Objects.equals(sequenceToken(), other.sequenceToken()); } /** * 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("PutLogEventsRequest").add("LogGroupName", logGroupName()).add("LogStreamName", logStreamName()) .add("LogEvents", logEvents()).add("SequenceToken", sequenceToken()).build(); } public Optional getValueForField(String fieldName, Class clazz) { switch (fieldName) { case "logGroupName": return Optional.ofNullable(clazz.cast(logGroupName())); case "logStreamName": return Optional.ofNullable(clazz.cast(logStreamName())); case "logEvents": return Optional.ofNullable(clazz.cast(logEvents())); case "sequenceToken": return Optional.ofNullable(clazz.cast(sequenceToken())); default: return Optional.empty(); } } @Override public List> sdkFields() { return SDK_FIELDS; } private static Function getter(Function g) { return obj -> g.apply((PutLogEventsRequest) obj); } private static BiConsumer setter(BiConsumer s) { return (obj, val) -> s.accept((Builder) obj, val); } public interface Builder extends CloudWatchLogsRequest.Builder, SdkPojo, CopyableBuilder { /** *

* The name of the log group. *

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

* The name of the log stream. *

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

* The log events. *

* * @param logEvents * The log events. * @return Returns a reference to this object so that method calls can be chained together. */ Builder logEvents(Collection logEvents); /** *

* The log events. *

* * @param logEvents * The log events. * @return Returns a reference to this object so that method calls can be chained together. */ Builder logEvents(InputLogEvent... logEvents); /** *

* The log events. *

* This is a convenience that creates an instance of the {@link List.Builder} avoiding the need * to create one manually via {@link List#builder()}. * * When the {@link Consumer} completes, {@link List.Builder#build()} is called immediately and * its result is passed to {@link #logEvents(List)}. * * @param logEvents * a consumer that will call methods on {@link List.Builder} * @return Returns a reference to this object so that method calls can be chained together. * @see #logEvents(List) */ Builder logEvents(Consumer... logEvents); /** *

* The sequence token obtained from the response of the previous PutLogEvents call. An upload in a * newly created log stream does not require a sequence token. You can also get the sequence token using * DescribeLogStreams. If you call PutLogEvents twice within a narrow time period using the * same value for sequenceToken, both calls may be successful, or one may be rejected. *

* * @param sequenceToken * The sequence token obtained from the response of the previous PutLogEvents call. An * upload in a newly created log stream does not require a sequence token. You can also get the sequence * token using DescribeLogStreams. If you call PutLogEvents twice within a narrow * time period using the same value for sequenceToken, both calls may be successful, or one * may be rejected. * @return Returns a reference to this object so that method calls can be chained together. */ Builder sequenceToken(String sequenceToken); @Override Builder overrideConfiguration(AwsRequestOverrideConfiguration overrideConfiguration); @Override Builder overrideConfiguration(Consumer builderConsumer); } static final class BuilderImpl extends CloudWatchLogsRequest.BuilderImpl implements Builder { private String logGroupName; private String logStreamName; private List logEvents = DefaultSdkAutoConstructList.getInstance(); private String sequenceToken; private BuilderImpl() { } private BuilderImpl(PutLogEventsRequest model) { super(model); logGroupName(model.logGroupName); logStreamName(model.logStreamName); logEvents(model.logEvents); sequenceToken(model.sequenceToken); } public final String getLogGroupName() { return logGroupName; } @Override public final Builder logGroupName(String logGroupName) { this.logGroupName = logGroupName; return this; } public final void setLogGroupName(String logGroupName) { this.logGroupName = logGroupName; } public final String getLogStreamName() { return logStreamName; } @Override public final Builder logStreamName(String logStreamName) { this.logStreamName = logStreamName; return this; } public final void setLogStreamName(String logStreamName) { this.logStreamName = logStreamName; } public final Collection getLogEvents() { return logEvents != null ? logEvents.stream().map(InputLogEvent::toBuilder).collect(Collectors.toList()) : null; } @Override public final Builder logEvents(Collection logEvents) { this.logEvents = InputLogEventsCopier.copy(logEvents); return this; } @Override @SafeVarargs public final Builder logEvents(InputLogEvent... logEvents) { logEvents(Arrays.asList(logEvents)); return this; } @Override @SafeVarargs public final Builder logEvents(Consumer... logEvents) { logEvents(Stream.of(logEvents).map(c -> InputLogEvent.builder().applyMutation(c).build()) .collect(Collectors.toList())); return this; } public final void setLogEvents(Collection logEvents) { this.logEvents = InputLogEventsCopier.copyFromBuilder(logEvents); } public final String getSequenceToken() { return sequenceToken; } @Override public final Builder sequenceToken(String sequenceToken) { this.sequenceToken = sequenceToken; return this; } public final void setSequenceToken(String sequenceToken) { this.sequenceToken = sequenceToken; } @Override public Builder overrideConfiguration(AwsRequestOverrideConfiguration overrideConfiguration) { super.overrideConfiguration(overrideConfiguration); return this; } @Override public Builder overrideConfiguration(Consumer builderConsumer) { super.overrideConfiguration(builderConsumer); return this; } @Override public PutLogEventsRequest build() { return new PutLogEventsRequest(this); } @Override public List> sdkFields() { return SDK_FIELDS; } } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy