
software.amazon.awssdk.services.cloudwatchlogs.model.ConfigurationTemplate 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.io.Serializable;
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.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;
/**
*
* A structure containing information about the deafult settings and available settings that you can use to configure a
* delivery or a delivery
* destination.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class ConfigurationTemplate implements SdkPojo, Serializable,
ToCopyableBuilder {
private static final SdkField SERVICE_FIELD = SdkField. builder(MarshallingType.STRING).memberName("service")
.getter(getter(ConfigurationTemplate::service)).setter(setter(Builder::service))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("service").build()).build();
private static final SdkField LOG_TYPE_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("logType").getter(getter(ConfigurationTemplate::logType)).setter(setter(Builder::logType))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("logType").build()).build();
private static final SdkField RESOURCE_TYPE_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("resourceType").getter(getter(ConfigurationTemplate::resourceType)).setter(setter(Builder::resourceType))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("resourceType").build()).build();
private static final SdkField DELIVERY_DESTINATION_TYPE_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("deliveryDestinationType").getter(getter(ConfigurationTemplate::deliveryDestinationTypeAsString))
.setter(setter(Builder::deliveryDestinationType))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("deliveryDestinationType").build())
.build();
private static final SdkField DEFAULT_DELIVERY_CONFIG_VALUES_FIELD = SdkField
. builder(MarshallingType.SDK_POJO)
.memberName("defaultDeliveryConfigValues")
.getter(getter(ConfigurationTemplate::defaultDeliveryConfigValues))
.setter(setter(Builder::defaultDeliveryConfigValues))
.constructor(ConfigurationTemplateDeliveryConfigValues::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("defaultDeliveryConfigValues")
.build()).build();
private static final SdkField> ALLOWED_FIELDS_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("allowedFields")
.getter(getter(ConfigurationTemplate::allowedFields))
.setter(setter(Builder::allowedFields))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("allowedFields").build(),
ListTrait
.builder()
.memberLocationName(null)
.memberFieldInfo(
SdkField. builder(MarshallingType.SDK_POJO)
.constructor(RecordField::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("member").build()).build()).build()).build();
private static final SdkField> ALLOWED_OUTPUT_FORMATS_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("allowedOutputFormats")
.getter(getter(ConfigurationTemplate::allowedOutputFormatsAsStrings))
.setter(setter(Builder::allowedOutputFormatsWithStrings))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("allowedOutputFormats").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 ALLOWED_ACTION_FOR_ALLOW_VENDED_LOGS_DELIVERY_FOR_RESOURCE_FIELD = SdkField
. builder(MarshallingType.STRING)
.memberName("allowedActionForAllowVendedLogsDeliveryForResource")
.getter(getter(ConfigurationTemplate::allowedActionForAllowVendedLogsDeliveryForResource))
.setter(setter(Builder::allowedActionForAllowVendedLogsDeliveryForResource))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("allowedActionForAllowVendedLogsDeliveryForResource").build()).build();
private static final SdkField> ALLOWED_FIELD_DELIMITERS_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("allowedFieldDelimiters")
.getter(getter(ConfigurationTemplate::allowedFieldDelimiters))
.setter(setter(Builder::allowedFieldDelimiters))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("allowedFieldDelimiters").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> ALLOWED_SUFFIX_PATH_FIELDS_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("allowedSuffixPathFields")
.getter(getter(ConfigurationTemplate::allowedSuffixPathFields))
.setter(setter(Builder::allowedSuffixPathFields))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("allowedSuffixPathFields").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(SERVICE_FIELD, LOG_TYPE_FIELD,
RESOURCE_TYPE_FIELD, DELIVERY_DESTINATION_TYPE_FIELD, DEFAULT_DELIVERY_CONFIG_VALUES_FIELD, ALLOWED_FIELDS_FIELD,
ALLOWED_OUTPUT_FORMATS_FIELD, ALLOWED_ACTION_FOR_ALLOW_VENDED_LOGS_DELIVERY_FOR_RESOURCE_FIELD,
ALLOWED_FIELD_DELIMITERS_FIELD, ALLOWED_SUFFIX_PATH_FIELDS_FIELD));
private static final long serialVersionUID = 1L;
private final String service;
private final String logType;
private final String resourceType;
private final String deliveryDestinationType;
private final ConfigurationTemplateDeliveryConfigValues defaultDeliveryConfigValues;
private final List allowedFields;
private final List allowedOutputFormats;
private final String allowedActionForAllowVendedLogsDeliveryForResource;
private final List allowedFieldDelimiters;
private final List allowedSuffixPathFields;
private ConfigurationTemplate(BuilderImpl builder) {
this.service = builder.service;
this.logType = builder.logType;
this.resourceType = builder.resourceType;
this.deliveryDestinationType = builder.deliveryDestinationType;
this.defaultDeliveryConfigValues = builder.defaultDeliveryConfigValues;
this.allowedFields = builder.allowedFields;
this.allowedOutputFormats = builder.allowedOutputFormats;
this.allowedActionForAllowVendedLogsDeliveryForResource = builder.allowedActionForAllowVendedLogsDeliveryForResource;
this.allowedFieldDelimiters = builder.allowedFieldDelimiters;
this.allowedSuffixPathFields = builder.allowedSuffixPathFields;
}
/**
*
* A string specifying which service this configuration template applies to. For more information about supported
* services see Enable logging
* from Amazon Web Services services..
*
*
* @return A string specifying which service this configuration template applies to. For more information about
* supported services see Enable
* logging from Amazon Web Services services..
*/
public final String service() {
return service;
}
/**
*
* A string specifying which log type this configuration template applies to.
*
*
* @return A string specifying which log type this configuration template applies to.
*/
public final String logType() {
return logType;
}
/**
*
* A string specifying which resource type this configuration template applies to.
*
*
* @return A string specifying which resource type this configuration template applies to.
*/
public final String resourceType() {
return resourceType;
}
/**
*
* A string specifying which destination type this configuration template applies to.
*
*
* If the service returns an enum value that is not available in the current SDK version,
* {@link #deliveryDestinationType} will return {@link DeliveryDestinationType#UNKNOWN_TO_SDK_VERSION}. The raw
* value returned by the service is available from {@link #deliveryDestinationTypeAsString}.
*
*
* @return A string specifying which destination type this configuration template applies to.
* @see DeliveryDestinationType
*/
public final DeliveryDestinationType deliveryDestinationType() {
return DeliveryDestinationType.fromValue(deliveryDestinationType);
}
/**
*
* A string specifying which destination type this configuration template applies to.
*
*
* If the service returns an enum value that is not available in the current SDK version,
* {@link #deliveryDestinationType} will return {@link DeliveryDestinationType#UNKNOWN_TO_SDK_VERSION}. The raw
* value returned by the service is available from {@link #deliveryDestinationTypeAsString}.
*
*
* @return A string specifying which destination type this configuration template applies to.
* @see DeliveryDestinationType
*/
public final String deliveryDestinationTypeAsString() {
return deliveryDestinationType;
}
/**
*
* A mapping that displays the default value of each property within a delivery’s configuration, if it is not
* specified in the request.
*
*
* @return A mapping that displays the default value of each property within a delivery’s configuration, if it is
* not specified in the request.
*/
public final ConfigurationTemplateDeliveryConfigValues defaultDeliveryConfigValues() {
return defaultDeliveryConfigValues;
}
/**
* For responses, this returns true if the service returned a value for the AllowedFields 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 hasAllowedFields() {
return allowedFields != null && !(allowedFields instanceof SdkAutoConstructList);
}
/**
*
* The allowed fields that a caller can use in the recordFields
parameter of a CreateDelivery or UpdateDeliveryConfiguration operation.
*
*
* 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 #hasAllowedFields} method.
*
*
* @return The allowed fields that a caller can use in the recordFields
parameter of a CreateDelivery or UpdateDeliveryConfiguration operation.
*/
public final List allowedFields() {
return allowedFields;
}
/**
*
* The list of delivery destination output formats that are supported by this log source.
*
*
* 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 #hasAllowedOutputFormats} method.
*
*
* @return The list of delivery destination output formats that are supported by this log source.
*/
public final List allowedOutputFormats() {
return OutputFormatsCopier.copyStringToEnum(allowedOutputFormats);
}
/**
* For responses, this returns true if the service returned a value for the AllowedOutputFormats 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 hasAllowedOutputFormats() {
return allowedOutputFormats != null && !(allowedOutputFormats instanceof SdkAutoConstructList);
}
/**
*
* The list of delivery destination output formats that are supported by this log source.
*
*
* 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 #hasAllowedOutputFormats} method.
*
*
* @return The list of delivery destination output formats that are supported by this log source.
*/
public final List allowedOutputFormatsAsStrings() {
return allowedOutputFormats;
}
/**
*
* The action permissions that a caller needs to have to be able to successfully create a delivery source on the
* desired resource type when calling PutDeliverySource.
*
*
* @return The action permissions that a caller needs to have to be able to successfully create a delivery source on
* the desired resource type when calling PutDeliverySource.
*/
public final String allowedActionForAllowVendedLogsDeliveryForResource() {
return allowedActionForAllowVendedLogsDeliveryForResource;
}
/**
* For responses, this returns true if the service returned a value for the AllowedFieldDelimiters 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 hasAllowedFieldDelimiters() {
return allowedFieldDelimiters != null && !(allowedFieldDelimiters instanceof SdkAutoConstructList);
}
/**
*
* The valid values that a caller can use as field delimiters when calling CreateDelivery or UpdateDeliveryConfiguration on a delivery that delivers in Plain
, W3C
, or
* Raw
format.
*
*
* 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 #hasAllowedFieldDelimiters} method.
*
*
* @return The valid values that a caller can use as field delimiters when calling CreateDelivery or UpdateDeliveryConfiguration on a delivery that delivers in Plain
, W3C
, or
* Raw
format.
*/
public final List allowedFieldDelimiters() {
return allowedFieldDelimiters;
}
/**
* For responses, this returns true if the service returned a value for the AllowedSuffixPathFields 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 hasAllowedSuffixPathFields() {
return allowedSuffixPathFields != null && !(allowedSuffixPathFields instanceof SdkAutoConstructList);
}
/**
*
* The list of variable fields that can be used in the suffix path of a delivery that delivers to an S3 bucket.
*
*
* 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 #hasAllowedSuffixPathFields} method.
*
*
* @return The list of variable fields that can be used in the suffix path of a delivery that delivers to an S3
* bucket.
*/
public final List allowedSuffixPathFields() {
return allowedSuffixPathFields;
}
@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 + Objects.hashCode(service());
hashCode = 31 * hashCode + Objects.hashCode(logType());
hashCode = 31 * hashCode + Objects.hashCode(resourceType());
hashCode = 31 * hashCode + Objects.hashCode(deliveryDestinationTypeAsString());
hashCode = 31 * hashCode + Objects.hashCode(defaultDeliveryConfigValues());
hashCode = 31 * hashCode + Objects.hashCode(hasAllowedFields() ? allowedFields() : null);
hashCode = 31 * hashCode + Objects.hashCode(hasAllowedOutputFormats() ? allowedOutputFormatsAsStrings() : null);
hashCode = 31 * hashCode + Objects.hashCode(allowedActionForAllowVendedLogsDeliveryForResource());
hashCode = 31 * hashCode + Objects.hashCode(hasAllowedFieldDelimiters() ? allowedFieldDelimiters() : null);
hashCode = 31 * hashCode + Objects.hashCode(hasAllowedSuffixPathFields() ? allowedSuffixPathFields() : null);
return hashCode;
}
@Override
public final boolean equals(Object obj) {
return equalsBySdkFields(obj);
}
@Override
public final boolean equalsBySdkFields(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof ConfigurationTemplate)) {
return false;
}
ConfigurationTemplate other = (ConfigurationTemplate) obj;
return Objects.equals(service(), other.service())
&& Objects.equals(logType(), other.logType())
&& Objects.equals(resourceType(), other.resourceType())
&& Objects.equals(deliveryDestinationTypeAsString(), other.deliveryDestinationTypeAsString())
&& Objects.equals(defaultDeliveryConfigValues(), other.defaultDeliveryConfigValues())
&& hasAllowedFields() == other.hasAllowedFields()
&& Objects.equals(allowedFields(), other.allowedFields())
&& hasAllowedOutputFormats() == other.hasAllowedOutputFormats()
&& Objects.equals(allowedOutputFormatsAsStrings(), other.allowedOutputFormatsAsStrings())
&& Objects.equals(allowedActionForAllowVendedLogsDeliveryForResource(),
other.allowedActionForAllowVendedLogsDeliveryForResource())
&& hasAllowedFieldDelimiters() == other.hasAllowedFieldDelimiters()
&& Objects.equals(allowedFieldDelimiters(), other.allowedFieldDelimiters())
&& hasAllowedSuffixPathFields() == other.hasAllowedSuffixPathFields()
&& Objects.equals(allowedSuffixPathFields(), other.allowedSuffixPathFields());
}
/**
* 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("ConfigurationTemplate").add("Service", service()).add("LogType", logType())
.add("ResourceType", resourceType()).add("DeliveryDestinationType", deliveryDestinationTypeAsString())
.add("DefaultDeliveryConfigValues", defaultDeliveryConfigValues())
.add("AllowedFields", hasAllowedFields() ? allowedFields() : null)
.add("AllowedOutputFormats", hasAllowedOutputFormats() ? allowedOutputFormatsAsStrings() : null)
.add("AllowedActionForAllowVendedLogsDeliveryForResource", allowedActionForAllowVendedLogsDeliveryForResource())
.add("AllowedFieldDelimiters", hasAllowedFieldDelimiters() ? allowedFieldDelimiters() : null)
.add("AllowedSuffixPathFields", hasAllowedSuffixPathFields() ? allowedSuffixPathFields() : null).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "service":
return Optional.ofNullable(clazz.cast(service()));
case "logType":
return Optional.ofNullable(clazz.cast(logType()));
case "resourceType":
return Optional.ofNullable(clazz.cast(resourceType()));
case "deliveryDestinationType":
return Optional.ofNullable(clazz.cast(deliveryDestinationTypeAsString()));
case "defaultDeliveryConfigValues":
return Optional.ofNullable(clazz.cast(defaultDeliveryConfigValues()));
case "allowedFields":
return Optional.ofNullable(clazz.cast(allowedFields()));
case "allowedOutputFormats":
return Optional.ofNullable(clazz.cast(allowedOutputFormatsAsStrings()));
case "allowedActionForAllowVendedLogsDeliveryForResource":
return Optional.ofNullable(clazz.cast(allowedActionForAllowVendedLogsDeliveryForResource()));
case "allowedFieldDelimiters":
return Optional.ofNullable(clazz.cast(allowedFieldDelimiters()));
case "allowedSuffixPathFields":
return Optional.ofNullable(clazz.cast(allowedSuffixPathFields()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function