software.amazon.awssdk.services.redshift.model.DescribeLoggingStatusResponse Maven / Gradle / Ivy
Show all versions of redshift Show documentation
/*
* 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.redshift.model;
import java.time.Instant;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
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;
/**
*
* Describes the status of logging for a cluster.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class DescribeLoggingStatusResponse extends RedshiftResponse implements
ToCopyableBuilder {
private static final SdkField LOGGING_ENABLED_FIELD = SdkField. builder(MarshallingType.BOOLEAN)
.memberName("LoggingEnabled").getter(getter(DescribeLoggingStatusResponse::loggingEnabled))
.setter(setter(Builder::loggingEnabled))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("LoggingEnabled").build()).build();
private static final SdkField BUCKET_NAME_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("BucketName").getter(getter(DescribeLoggingStatusResponse::bucketName))
.setter(setter(Builder::bucketName))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("BucketName").build()).build();
private static final SdkField S3_KEY_PREFIX_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("S3KeyPrefix").getter(getter(DescribeLoggingStatusResponse::s3KeyPrefix))
.setter(setter(Builder::s3KeyPrefix))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("S3KeyPrefix").build()).build();
private static final SdkField LAST_SUCCESSFUL_DELIVERY_TIME_FIELD = SdkField
. builder(MarshallingType.INSTANT)
.memberName("LastSuccessfulDeliveryTime")
.getter(getter(DescribeLoggingStatusResponse::lastSuccessfulDeliveryTime))
.setter(setter(Builder::lastSuccessfulDeliveryTime))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("LastSuccessfulDeliveryTime").build())
.build();
private static final SdkField LAST_FAILURE_TIME_FIELD = SdkField. builder(MarshallingType.INSTANT)
.memberName("LastFailureTime").getter(getter(DescribeLoggingStatusResponse::lastFailureTime))
.setter(setter(Builder::lastFailureTime))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("LastFailureTime").build()).build();
private static final SdkField LAST_FAILURE_MESSAGE_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("LastFailureMessage").getter(getter(DescribeLoggingStatusResponse::lastFailureMessage))
.setter(setter(Builder::lastFailureMessage))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("LastFailureMessage").build())
.build();
private static final SdkField LOG_DESTINATION_TYPE_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("LogDestinationType").getter(getter(DescribeLoggingStatusResponse::logDestinationTypeAsString))
.setter(setter(Builder::logDestinationType))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("LogDestinationType").build())
.build();
private static final SdkField> LOG_EXPORTS_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("LogExports")
.getter(getter(DescribeLoggingStatusResponse::logExports))
.setter(setter(Builder::logExports))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("LogExports").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(LOGGING_ENABLED_FIELD,
BUCKET_NAME_FIELD, S3_KEY_PREFIX_FIELD, LAST_SUCCESSFUL_DELIVERY_TIME_FIELD, LAST_FAILURE_TIME_FIELD,
LAST_FAILURE_MESSAGE_FIELD, LOG_DESTINATION_TYPE_FIELD, LOG_EXPORTS_FIELD));
private static final Map> SDK_NAME_TO_FIELD = Collections
.unmodifiableMap(new HashMap>() {
{
put("LoggingEnabled", LOGGING_ENABLED_FIELD);
put("BucketName", BUCKET_NAME_FIELD);
put("S3KeyPrefix", S3_KEY_PREFIX_FIELD);
put("LastSuccessfulDeliveryTime", LAST_SUCCESSFUL_DELIVERY_TIME_FIELD);
put("LastFailureTime", LAST_FAILURE_TIME_FIELD);
put("LastFailureMessage", LAST_FAILURE_MESSAGE_FIELD);
put("LogDestinationType", LOG_DESTINATION_TYPE_FIELD);
put("LogExports", LOG_EXPORTS_FIELD);
}
});
private final Boolean loggingEnabled;
private final String bucketName;
private final String s3KeyPrefix;
private final Instant lastSuccessfulDeliveryTime;
private final Instant lastFailureTime;
private final String lastFailureMessage;
private final String logDestinationType;
private final List logExports;
private DescribeLoggingStatusResponse(BuilderImpl builder) {
super(builder);
this.loggingEnabled = builder.loggingEnabled;
this.bucketName = builder.bucketName;
this.s3KeyPrefix = builder.s3KeyPrefix;
this.lastSuccessfulDeliveryTime = builder.lastSuccessfulDeliveryTime;
this.lastFailureTime = builder.lastFailureTime;
this.lastFailureMessage = builder.lastFailureMessage;
this.logDestinationType = builder.logDestinationType;
this.logExports = builder.logExports;
}
/**
*
* true
if logging is on, false
if logging is off.
*
*
* @return true
if logging is on, false
if logging is off.
*/
public final Boolean loggingEnabled() {
return loggingEnabled;
}
/**
*
* The name of the S3 bucket where the log files are stored.
*
*
* @return The name of the S3 bucket where the log files are stored.
*/
public final String bucketName() {
return bucketName;
}
/**
*
* The prefix applied to the log file names.
*
*
* @return The prefix applied to the log file names.
*/
public final String s3KeyPrefix() {
return s3KeyPrefix;
}
/**
*
* The last time that logs were delivered.
*
*
* @return The last time that logs were delivered.
*/
public final Instant lastSuccessfulDeliveryTime() {
return lastSuccessfulDeliveryTime;
}
/**
*
* The last time when logs failed to be delivered.
*
*
* @return The last time when logs failed to be delivered.
*/
public final Instant lastFailureTime() {
return lastFailureTime;
}
/**
*
* The message indicating that logs failed to be delivered.
*
*
* @return The message indicating that logs failed to be delivered.
*/
public final String lastFailureMessage() {
return lastFailureMessage;
}
/**
*
* The log destination type. An enum with possible values of s3
and cloudwatch
.
*
*
* If the service returns an enum value that is not available in the current SDK version,
* {@link #logDestinationType} will return {@link LogDestinationType#UNKNOWN_TO_SDK_VERSION}. The raw value returned
* by the service is available from {@link #logDestinationTypeAsString}.
*
*
* @return The log destination type. An enum with possible values of s3
and cloudwatch
.
* @see LogDestinationType
*/
public final LogDestinationType logDestinationType() {
return LogDestinationType.fromValue(logDestinationType);
}
/**
*
* The log destination type. An enum with possible values of s3
and cloudwatch
.
*
*
* If the service returns an enum value that is not available in the current SDK version,
* {@link #logDestinationType} will return {@link LogDestinationType#UNKNOWN_TO_SDK_VERSION}. The raw value returned
* by the service is available from {@link #logDestinationTypeAsString}.
*
*
* @return The log destination type. An enum with possible values of s3
and cloudwatch
.
* @see LogDestinationType
*/
public final String logDestinationTypeAsString() {
return logDestinationType;
}
/**
* For responses, this returns true if the service returned a value for the LogExports 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 hasLogExports() {
return logExports != null && !(logExports instanceof SdkAutoConstructList);
}
/**
*
* The collection of exported log types. Possible values are connectionlog
,
* useractivitylog
, and userlog
.
*
*
* 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 #hasLogExports} method.
*
*
* @return The collection of exported log types. Possible values are connectionlog
,
* useractivitylog
, and userlog
.
*/
public final List logExports() {
return logExports;
}
@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 final int hashCode() {
int hashCode = 1;
hashCode = 31 * hashCode + super.hashCode();
hashCode = 31 * hashCode + Objects.hashCode(loggingEnabled());
hashCode = 31 * hashCode + Objects.hashCode(bucketName());
hashCode = 31 * hashCode + Objects.hashCode(s3KeyPrefix());
hashCode = 31 * hashCode + Objects.hashCode(lastSuccessfulDeliveryTime());
hashCode = 31 * hashCode + Objects.hashCode(lastFailureTime());
hashCode = 31 * hashCode + Objects.hashCode(lastFailureMessage());
hashCode = 31 * hashCode + Objects.hashCode(logDestinationTypeAsString());
hashCode = 31 * hashCode + Objects.hashCode(hasLogExports() ? logExports() : null);
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 DescribeLoggingStatusResponse)) {
return false;
}
DescribeLoggingStatusResponse other = (DescribeLoggingStatusResponse) obj;
return Objects.equals(loggingEnabled(), other.loggingEnabled()) && Objects.equals(bucketName(), other.bucketName())
&& Objects.equals(s3KeyPrefix(), other.s3KeyPrefix())
&& Objects.equals(lastSuccessfulDeliveryTime(), other.lastSuccessfulDeliveryTime())
&& Objects.equals(lastFailureTime(), other.lastFailureTime())
&& Objects.equals(lastFailureMessage(), other.lastFailureMessage())
&& Objects.equals(logDestinationTypeAsString(), other.logDestinationTypeAsString())
&& hasLogExports() == other.hasLogExports() && Objects.equals(logExports(), other.logExports());
}
/**
* 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("DescribeLoggingStatusResponse").add("LoggingEnabled", loggingEnabled())
.add("BucketName", bucketName()).add("S3KeyPrefix", s3KeyPrefix())
.add("LastSuccessfulDeliveryTime", lastSuccessfulDeliveryTime()).add("LastFailureTime", lastFailureTime())
.add("LastFailureMessage", lastFailureMessage()).add("LogDestinationType", logDestinationTypeAsString())
.add("LogExports", hasLogExports() ? logExports() : null).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "LoggingEnabled":
return Optional.ofNullable(clazz.cast(loggingEnabled()));
case "BucketName":
return Optional.ofNullable(clazz.cast(bucketName()));
case "S3KeyPrefix":
return Optional.ofNullable(clazz.cast(s3KeyPrefix()));
case "LastSuccessfulDeliveryTime":
return Optional.ofNullable(clazz.cast(lastSuccessfulDeliveryTime()));
case "LastFailureTime":
return Optional.ofNullable(clazz.cast(lastFailureTime()));
case "LastFailureMessage":
return Optional.ofNullable(clazz.cast(lastFailureMessage()));
case "LogDestinationType":
return Optional.ofNullable(clazz.cast(logDestinationTypeAsString()));
case "LogExports":
return Optional.ofNullable(clazz.cast(logExports()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
@Override
public final Map> sdkFieldNameToField() {
return SDK_NAME_TO_FIELD;
}
private static Function