
software.amazon.awssdk.services.cloudwatchlogs.model.PutLogEventsRequest Maven / Gradle / Ivy
/*
* 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 extends Builder> 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
© 2015 - 2025 Weber Informatics LLC | Privacy Policy