
software.amazon.awssdk.services.cloudwatchlogs.model.GetLogEventsRequest 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.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.LocationTrait;
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 GetLogEventsRequest extends CloudWatchLogsRequest implements
ToCopyableBuilder {
private static final SdkField LOG_GROUP_NAME_FIELD = SdkField. builder(MarshallingType.STRING)
.getter(getter(GetLogEventsRequest::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(GetLogEventsRequest::logStreamName)).setter(setter(Builder::logStreamName))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("logStreamName").build()).build();
private static final SdkField START_TIME_FIELD = SdkField. builder(MarshallingType.LONG)
.getter(getter(GetLogEventsRequest::startTime)).setter(setter(Builder::startTime))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("startTime").build()).build();
private static final SdkField END_TIME_FIELD = SdkField. builder(MarshallingType.LONG)
.getter(getter(GetLogEventsRequest::endTime)).setter(setter(Builder::endTime))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("endTime").build()).build();
private static final SdkField NEXT_TOKEN_FIELD = SdkField. builder(MarshallingType.STRING)
.getter(getter(GetLogEventsRequest::nextToken)).setter(setter(Builder::nextToken))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("nextToken").build()).build();
private static final SdkField LIMIT_FIELD = SdkField. builder(MarshallingType.INTEGER)
.getter(getter(GetLogEventsRequest::limit)).setter(setter(Builder::limit))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("limit").build()).build();
private static final SdkField START_FROM_HEAD_FIELD = SdkField. builder(MarshallingType.BOOLEAN)
.getter(getter(GetLogEventsRequest::startFromHead)).setter(setter(Builder::startFromHead))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("startFromHead").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(LOG_GROUP_NAME_FIELD,
LOG_STREAM_NAME_FIELD, START_TIME_FIELD, END_TIME_FIELD, NEXT_TOKEN_FIELD, LIMIT_FIELD, START_FROM_HEAD_FIELD));
private final String logGroupName;
private final String logStreamName;
private final Long startTime;
private final Long endTime;
private final String nextToken;
private final Integer limit;
private final Boolean startFromHead;
private GetLogEventsRequest(BuilderImpl builder) {
super(builder);
this.logGroupName = builder.logGroupName;
this.logStreamName = builder.logStreamName;
this.startTime = builder.startTime;
this.endTime = builder.endTime;
this.nextToken = builder.nextToken;
this.limit = builder.limit;
this.startFromHead = builder.startFromHead;
}
/**
*
* 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 start of the time range, expressed as the number of milliseconds after Jan 1, 1970 00:00:00 UTC. Events with
* a timestamp equal to this time or later than this time are included. Events with a timestamp earlier than this
* time are not included.
*
*
* @return The start of the time range, expressed as the number of milliseconds after Jan 1, 1970 00:00:00 UTC.
* Events with a timestamp equal to this time or later than this time are included. Events with a timestamp
* earlier than this time are not included.
*/
public Long startTime() {
return startTime;
}
/**
*
* The end of the time range, expressed as the number of milliseconds after Jan 1, 1970 00:00:00 UTC. Events with a
* timestamp equal to or later than this time are not included.
*
*
* @return The end of the time range, expressed as the number of milliseconds after Jan 1, 1970 00:00:00 UTC. Events
* with a timestamp equal to or later than this time are not included.
*/
public Long endTime() {
return endTime;
}
/**
*
* The token for the next set of items to return. (You received this token from a previous call.)
*
*
* Using this token works only when you specify true
for startFromHead
.
*
*
* @return The token for the next set of items to return. (You received this token from a previous call.)
*
* Using this token works only when you specify true
for startFromHead
.
*/
public String nextToken() {
return nextToken;
}
/**
*
* The maximum number of log events returned. If you don't specify a value, the maximum is as many log events as can
* fit in a response size of 1 MB, up to 10,000 log events.
*
*
* @return The maximum number of log events returned. If you don't specify a value, the maximum is as many log
* events as can fit in a response size of 1 MB, up to 10,000 log events.
*/
public Integer limit() {
return limit;
}
/**
*
* If the value is true, the earliest log events are returned first. If the value is false, the latest log events
* are returned first. The default value is false.
*
*
* If you are using nextToken
in this operation, you must specify true
for
* startFromHead
.
*
*
* @return If the value is true, the earliest log events are returned first. If the value is false, the latest log
* events are returned first. The default value is false.
*
* If you are using nextToken
in this operation, you must specify true
for
* startFromHead
.
*/
public Boolean startFromHead() {
return startFromHead;
}
@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 + super.hashCode();
hashCode = 31 * hashCode + Objects.hashCode(logGroupName());
hashCode = 31 * hashCode + Objects.hashCode(logStreamName());
hashCode = 31 * hashCode + Objects.hashCode(startTime());
hashCode = 31 * hashCode + Objects.hashCode(endTime());
hashCode = 31 * hashCode + Objects.hashCode(nextToken());
hashCode = 31 * hashCode + Objects.hashCode(limit());
hashCode = 31 * hashCode + Objects.hashCode(startFromHead());
return hashCode;
}
@Override
public boolean equals(Object obj) {
return super.equals(obj) && equalsBySdkFields(obj);
}
@Override
public boolean equalsBySdkFields(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof GetLogEventsRequest)) {
return false;
}
GetLogEventsRequest other = (GetLogEventsRequest) obj;
return Objects.equals(logGroupName(), other.logGroupName()) && Objects.equals(logStreamName(), other.logStreamName())
&& Objects.equals(startTime(), other.startTime()) && Objects.equals(endTime(), other.endTime())
&& Objects.equals(nextToken(), other.nextToken()) && Objects.equals(limit(), other.limit())
&& Objects.equals(startFromHead(), other.startFromHead());
}
/**
* 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("GetLogEventsRequest").add("LogGroupName", logGroupName()).add("LogStreamName", logStreamName())
.add("StartTime", startTime()).add("EndTime", endTime()).add("NextToken", nextToken()).add("Limit", limit())
.add("StartFromHead", startFromHead()).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 "startTime":
return Optional.ofNullable(clazz.cast(startTime()));
case "endTime":
return Optional.ofNullable(clazz.cast(endTime()));
case "nextToken":
return Optional.ofNullable(clazz.cast(nextToken()));
case "limit":
return Optional.ofNullable(clazz.cast(limit()));
case "startFromHead":
return Optional.ofNullable(clazz.cast(startFromHead()));
default:
return Optional.empty();
}
}
@Override
public List> sdkFields() {
return SDK_FIELDS;
}
private static Function
*
* Using this token works only when you specify true
for startFromHead
.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder nextToken(String nextToken);
/**
*
* The maximum number of log events returned. If you don't specify a value, the maximum is as many log events as
* can fit in a response size of 1 MB, up to 10,000 log events.
*
*
* @param limit
* The maximum number of log events returned. If you don't specify a value, the maximum is as many log
* events as can fit in a response size of 1 MB, up to 10,000 log events.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder limit(Integer limit);
/**
*
* If the value is true, the earliest log events are returned first. If the value is false, the latest log
* events are returned first. The default value is false.
*
*
* If you are using nextToken
in this operation, you must specify true
for
* startFromHead
.
*
*
* @param startFromHead
* If the value is true, the earliest log events are returned first. If the value is false, the latest
* log events are returned first. The default value is false.
*
* If you are using nextToken
in this operation, you must specify true
for
* startFromHead
.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder startFromHead(Boolean startFromHead);
@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 Long startTime;
private Long endTime;
private String nextToken;
private Integer limit;
private Boolean startFromHead;
private BuilderImpl() {
}
private BuilderImpl(GetLogEventsRequest model) {
super(model);
logGroupName(model.logGroupName);
logStreamName(model.logStreamName);
startTime(model.startTime);
endTime(model.endTime);
nextToken(model.nextToken);
limit(model.limit);
startFromHead(model.startFromHead);
}
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 Long getStartTime() {
return startTime;
}
@Override
public final Builder startTime(Long startTime) {
this.startTime = startTime;
return this;
}
public final void setStartTime(Long startTime) {
this.startTime = startTime;
}
public final Long getEndTime() {
return endTime;
}
@Override
public final Builder endTime(Long endTime) {
this.endTime = endTime;
return this;
}
public final void setEndTime(Long endTime) {
this.endTime = endTime;
}
public final String getNextToken() {
return nextToken;
}
@Override
public final Builder nextToken(String nextToken) {
this.nextToken = nextToken;
return this;
}
public final void setNextToken(String nextToken) {
this.nextToken = nextToken;
}
public final Integer getLimit() {
return limit;
}
@Override
public final Builder limit(Integer limit) {
this.limit = limit;
return this;
}
public final void setLimit(Integer limit) {
this.limit = limit;
}
public final Boolean getStartFromHead() {
return startFromHead;
}
@Override
public final Builder startFromHead(Boolean startFromHead) {
this.startFromHead = startFromHead;
return this;
}
public final void setStartFromHead(Boolean startFromHead) {
this.startFromHead = startFromHead;
}
@Override
public Builder overrideConfiguration(AwsRequestOverrideConfiguration overrideConfiguration) {
super.overrideConfiguration(overrideConfiguration);
return this;
}
@Override
public Builder overrideConfiguration(Consumer builderConsumer) {
super.overrideConfiguration(builderConsumer);
return this;
}
@Override
public GetLogEventsRequest build() {
return new GetLogEventsRequest(this);
}
@Override
public List> sdkFields() {
return SDK_FIELDS;
}
}
}