
software.amazon.awssdk.services.cloudwatchlogs.model.MetricTransformation 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.Collections;
import java.util.List;
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.LocationTrait;
import software.amazon.awssdk.utils.ToString;
import software.amazon.awssdk.utils.builder.CopyableBuilder;
import software.amazon.awssdk.utils.builder.ToCopyableBuilder;
/**
*
* Indicates how to transform ingested log events to metric data in a CloudWatch metric.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class MetricTransformation implements SdkPojo, Serializable,
ToCopyableBuilder {
private static final SdkField METRIC_NAME_FIELD = SdkField. builder(MarshallingType.STRING)
.getter(getter(MetricTransformation::metricName)).setter(setter(Builder::metricName))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("metricName").build()).build();
private static final SdkField METRIC_NAMESPACE_FIELD = SdkField. builder(MarshallingType.STRING)
.getter(getter(MetricTransformation::metricNamespace)).setter(setter(Builder::metricNamespace))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("metricNamespace").build()).build();
private static final SdkField METRIC_VALUE_FIELD = SdkField. builder(MarshallingType.STRING)
.getter(getter(MetricTransformation::metricValue)).setter(setter(Builder::metricValue))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("metricValue").build()).build();
private static final SdkField DEFAULT_VALUE_FIELD = SdkField. builder(MarshallingType.DOUBLE)
.getter(getter(MetricTransformation::defaultValue)).setter(setter(Builder::defaultValue))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("defaultValue").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(METRIC_NAME_FIELD,
METRIC_NAMESPACE_FIELD, METRIC_VALUE_FIELD, DEFAULT_VALUE_FIELD));
private static final long serialVersionUID = 1L;
private final String metricName;
private final String metricNamespace;
private final String metricValue;
private final Double defaultValue;
private MetricTransformation(BuilderImpl builder) {
this.metricName = builder.metricName;
this.metricNamespace = builder.metricNamespace;
this.metricValue = builder.metricValue;
this.defaultValue = builder.defaultValue;
}
/**
*
* The name of the CloudWatch metric.
*
*
* @return The name of the CloudWatch metric.
*/
public String metricName() {
return metricName;
}
/**
*
* A custom namespace to contain your metric in CloudWatch. Use namespaces to group together metrics that are
* similar. For more information, see Namespaces.
*
*
* @return A custom namespace to contain your metric in CloudWatch. Use namespaces to group together metrics that
* are similar. For more information, see Namespaces.
*/
public String metricNamespace() {
return metricNamespace;
}
/**
*
* The value to publish to the CloudWatch metric when a filter pattern matches a log event.
*
*
* @return The value to publish to the CloudWatch metric when a filter pattern matches a log event.
*/
public String metricValue() {
return metricValue;
}
/**
*
* (Optional) The value to emit when a filter pattern does not match a log event. This value can be null.
*
*
* @return (Optional) The value to emit when a filter pattern does not match a log event. This value can be null.
*/
public Double defaultValue() {
return defaultValue;
}
@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(metricName());
hashCode = 31 * hashCode + Objects.hashCode(metricNamespace());
hashCode = 31 * hashCode + Objects.hashCode(metricValue());
hashCode = 31 * hashCode + Objects.hashCode(defaultValue());
return hashCode;
}
@Override
public boolean equals(Object obj) {
return equalsBySdkFields(obj);
}
@Override
public boolean equalsBySdkFields(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof MetricTransformation)) {
return false;
}
MetricTransformation other = (MetricTransformation) obj;
return Objects.equals(metricName(), other.metricName()) && Objects.equals(metricNamespace(), other.metricNamespace())
&& Objects.equals(metricValue(), other.metricValue()) && Objects.equals(defaultValue(), other.defaultValue());
}
/**
* 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("MetricTransformation").add("MetricName", metricName()).add("MetricNamespace", metricNamespace())
.add("MetricValue", metricValue()).add("DefaultValue", defaultValue()).build();
}
public Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "metricName":
return Optional.ofNullable(clazz.cast(metricName()));
case "metricNamespace":
return Optional.ofNullable(clazz.cast(metricNamespace()));
case "metricValue":
return Optional.ofNullable(clazz.cast(metricValue()));
case "defaultValue":
return Optional.ofNullable(clazz.cast(defaultValue()));
default:
return Optional.empty();
}
}
@Override
public List> sdkFields() {
return SDK_FIELDS;
}
private static Function
© 2015 - 2025 Weber Informatics LLC | Privacy Policy