All Downloads are FREE. Search and download functionalities are using the official Maven repository.

software.amazon.awssdk.services.applicationsignals.model.ServiceLevelIndicatorMetricConfig 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.applicationsignals.model;

import java.io.Serializable;
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.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.traits.MapTrait;
import software.amazon.awssdk.core.util.DefaultSdkAutoConstructList;
import software.amazon.awssdk.core.util.DefaultSdkAutoConstructMap;
import software.amazon.awssdk.core.util.SdkAutoConstructList;
import software.amazon.awssdk.core.util.SdkAutoConstructMap;
import software.amazon.awssdk.utils.ToString;
import software.amazon.awssdk.utils.builder.CopyableBuilder;
import software.amazon.awssdk.utils.builder.ToCopyableBuilder;

/**
 * 

* Use this structure to specify the information for the metric that a period-based SLO will monitor. *

*/ @Generated("software.amazon.awssdk:codegen") public final class ServiceLevelIndicatorMetricConfig implements SdkPojo, Serializable, ToCopyableBuilder { private static final SdkField> KEY_ATTRIBUTES_FIELD = SdkField .> builder(MarshallingType.MAP) .memberName("KeyAttributes") .getter(getter(ServiceLevelIndicatorMetricConfig::keyAttributes)) .setter(setter(Builder::keyAttributes)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("KeyAttributes").build(), MapTrait.builder() .keyLocationName("key") .valueLocationName("value") .valueFieldInfo( SdkField. builder(MarshallingType.STRING) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) .locationName("value").build()).build()).build()).build(); private static final SdkField OPERATION_NAME_FIELD = SdkField. builder(MarshallingType.STRING) .memberName("OperationName").getter(getter(ServiceLevelIndicatorMetricConfig::operationName)) .setter(setter(Builder::operationName)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("OperationName").build()).build(); private static final SdkField METRIC_TYPE_FIELD = SdkField. builder(MarshallingType.STRING) .memberName("MetricType").getter(getter(ServiceLevelIndicatorMetricConfig::metricTypeAsString)) .setter(setter(Builder::metricType)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("MetricType").build()).build(); private static final SdkField STATISTIC_FIELD = SdkField. builder(MarshallingType.STRING) .memberName("Statistic").getter(getter(ServiceLevelIndicatorMetricConfig::statistic)) .setter(setter(Builder::statistic)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Statistic").build()).build(); private static final SdkField PERIOD_SECONDS_FIELD = SdkField. builder(MarshallingType.INTEGER) .memberName("PeriodSeconds").getter(getter(ServiceLevelIndicatorMetricConfig::periodSeconds)) .setter(setter(Builder::periodSeconds)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("PeriodSeconds").build()).build(); private static final SdkField> METRIC_DATA_QUERIES_FIELD = SdkField .> builder(MarshallingType.LIST) .memberName("MetricDataQueries") .getter(getter(ServiceLevelIndicatorMetricConfig::metricDataQueries)) .setter(setter(Builder::metricDataQueries)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("MetricDataQueries").build(), ListTrait .builder() .memberLocationName(null) .memberFieldInfo( SdkField. builder(MarshallingType.SDK_POJO) .constructor(MetricDataQuery::builder) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) .locationName("member").build()).build()).build()).build(); private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(KEY_ATTRIBUTES_FIELD, OPERATION_NAME_FIELD, METRIC_TYPE_FIELD, STATISTIC_FIELD, PERIOD_SECONDS_FIELD, METRIC_DATA_QUERIES_FIELD)); private static final Map> SDK_NAME_TO_FIELD = memberNameToFieldInitializer(); private static final long serialVersionUID = 1L; private final Map keyAttributes; private final String operationName; private final String metricType; private final String statistic; private final Integer periodSeconds; private final List metricDataQueries; private ServiceLevelIndicatorMetricConfig(BuilderImpl builder) { this.keyAttributes = builder.keyAttributes; this.operationName = builder.operationName; this.metricType = builder.metricType; this.statistic = builder.statistic; this.periodSeconds = builder.periodSeconds; this.metricDataQueries = builder.metricDataQueries; } /** * For responses, this returns true if the service returned a value for the KeyAttributes 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 hasKeyAttributes() { return keyAttributes != null && !(keyAttributes instanceof SdkAutoConstructMap); } /** *

* If this SLO is related to a metric collected by Application Signals, you must use this field to specify which * service the SLO metric is related to. To do so, you must specify at least the Type, * Name, and Environment attributes. *

*

* This is a string-to-string map. It can include the following fields. *

*
    *
  • *

    * Type designates the type of object this is. *

    *
  • *
  • *

    * ResourceType specifies the type of the resource. This field is used only when the value of the * Type field is Resource or AWS::Resource. *

    *
  • *
  • *

    * Name specifies the name of the object. This is used only if the value of the Type field * is Service, RemoteService, or AWS::Service. *

    *
  • *
  • *

    * Identifier identifies the resource objects of this resource. This is used only if the value of the * Type field is Resource or AWS::Resource. *

    *
  • *
  • *

    * Environment specifies the location where this object is hosted, or what it belongs to. *

    *
  • *
*

* 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 #hasKeyAttributes} method. *

* * @return If this SLO is related to a metric collected by Application Signals, you must use this field to specify * which service the SLO metric is related to. To do so, you must specify at least the Type, * Name, and Environment attributes.

*

* This is a string-to-string map. It can include the following fields. *

*
    *
  • *

    * Type designates the type of object this is. *

    *
  • *
  • *

    * ResourceType specifies the type of the resource. This field is used only when the value of * the Type field is Resource or AWS::Resource. *

    *
  • *
  • *

    * Name specifies the name of the object. This is used only if the value of the * Type field is Service, RemoteService, or AWS::Service * . *

    *
  • *
  • *

    * Identifier identifies the resource objects of this resource. This is used only if the value * of the Type field is Resource or AWS::Resource. *

    *
  • *
  • *

    * Environment specifies the location where this object is hosted, or what it belongs to. *

    *
  • */ public final Map keyAttributes() { return keyAttributes; } /** *

    * If the SLO is to monitor a specific operation of the service, use this field to specify the name of that * operation. *

    * * @return If the SLO is to monitor a specific operation of the service, use this field to specify the name of that * operation. */ public final String operationName() { return operationName; } /** *

    * If the SLO is to monitor either the LATENCY or AVAILABILITY metric that Application * Signals collects, use this field to specify which of those metrics is used. *

    *

    * If the service returns an enum value that is not available in the current SDK version, {@link #metricType} will * return {@link ServiceLevelIndicatorMetricType#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is * available from {@link #metricTypeAsString}. *

    * * @return If the SLO is to monitor either the LATENCY or AVAILABILITY metric that * Application Signals collects, use this field to specify which of those metrics is used. * @see ServiceLevelIndicatorMetricType */ public final ServiceLevelIndicatorMetricType metricType() { return ServiceLevelIndicatorMetricType.fromValue(metricType); } /** *

    * If the SLO is to monitor either the LATENCY or AVAILABILITY metric that Application * Signals collects, use this field to specify which of those metrics is used. *

    *

    * If the service returns an enum value that is not available in the current SDK version, {@link #metricType} will * return {@link ServiceLevelIndicatorMetricType#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is * available from {@link #metricTypeAsString}. *

    * * @return If the SLO is to monitor either the LATENCY or AVAILABILITY metric that * Application Signals collects, use this field to specify which of those metrics is used. * @see ServiceLevelIndicatorMetricType */ public final String metricTypeAsString() { return metricType; } /** *

    * The statistic to use for comparison to the threshold. It can be any CloudWatch statistic or extended statistic. * For more information about statistics, see CloudWatch * statistics definitions. *

    * * @return The statistic to use for comparison to the threshold. It can be any CloudWatch statistic or extended * statistic. For more information about statistics, see CloudWatch statistics definitions. */ public final String statistic() { return statistic; } /** *

    * The number of seconds to use as the period for SLO evaluation. Your application's performance is compared to the * SLI during each period. For each period, the application is determined to have either achieved or not achieved * the necessary performance. *

    * * @return The number of seconds to use as the period for SLO evaluation. Your application's performance is compared * to the SLI during each period. For each period, the application is determined to have either achieved or * not achieved the necessary performance. */ public final Integer periodSeconds() { return periodSeconds; } /** * For responses, this returns true if the service returned a value for the MetricDataQueries 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 hasMetricDataQueries() { return metricDataQueries != null && !(metricDataQueries instanceof SdkAutoConstructList); } /** *

    * If this SLO monitors a CloudWatch metric or the result of a CloudWatch metric math expression, use this structure * to specify that metric or expression. *

    *

    * 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 #hasMetricDataQueries} method. *

    * * @return If this SLO monitors a CloudWatch metric or the result of a CloudWatch metric math expression, use this * structure to specify that metric or expression. */ public final List metricDataQueries() { return metricDataQueries; } @Override public Builder toBuilder() { return new BuilderImpl(this); } public static Builder builder() { return new BuilderImpl(); } public static Class serializableBuilderClass() { return BuilderImpl.class; } @Override public final int hashCode() { int hashCode = 1; hashCode = 31 * hashCode + Objects.hashCode(hasKeyAttributes() ? keyAttributes() : null); hashCode = 31 * hashCode + Objects.hashCode(operationName()); hashCode = 31 * hashCode + Objects.hashCode(metricTypeAsString()); hashCode = 31 * hashCode + Objects.hashCode(statistic()); hashCode = 31 * hashCode + Objects.hashCode(periodSeconds()); hashCode = 31 * hashCode + Objects.hashCode(hasMetricDataQueries() ? metricDataQueries() : 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 ServiceLevelIndicatorMetricConfig)) { return false; } ServiceLevelIndicatorMetricConfig other = (ServiceLevelIndicatorMetricConfig) obj; return hasKeyAttributes() == other.hasKeyAttributes() && Objects.equals(keyAttributes(), other.keyAttributes()) && Objects.equals(operationName(), other.operationName()) && Objects.equals(metricTypeAsString(), other.metricTypeAsString()) && Objects.equals(statistic(), other.statistic()) && Objects.equals(periodSeconds(), other.periodSeconds()) && hasMetricDataQueries() == other.hasMetricDataQueries() && Objects.equals(metricDataQueries(), other.metricDataQueries()); } /** * 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("ServiceLevelIndicatorMetricConfig") .add("KeyAttributes", hasKeyAttributes() ? keyAttributes() : null).add("OperationName", operationName()) .add("MetricType", metricTypeAsString()).add("Statistic", statistic()).add("PeriodSeconds", periodSeconds()) .add("MetricDataQueries", hasMetricDataQueries() ? metricDataQueries() : null).build(); } public final Optional getValueForField(String fieldName, Class clazz) { switch (fieldName) { case "KeyAttributes": return Optional.ofNullable(clazz.cast(keyAttributes())); case "OperationName": return Optional.ofNullable(clazz.cast(operationName())); case "MetricType": return Optional.ofNullable(clazz.cast(metricTypeAsString())); case "Statistic": return Optional.ofNullable(clazz.cast(statistic())); case "PeriodSeconds": return Optional.ofNullable(clazz.cast(periodSeconds())); case "MetricDataQueries": return Optional.ofNullable(clazz.cast(metricDataQueries())); default: return Optional.empty(); } } @Override public final List> sdkFields() { return SDK_FIELDS; } @Override public final Map> sdkFieldNameToField() { return SDK_NAME_TO_FIELD; } private static Map> memberNameToFieldInitializer() { Map> map = new HashMap<>(); map.put("KeyAttributes", KEY_ATTRIBUTES_FIELD); map.put("OperationName", OPERATION_NAME_FIELD); map.put("MetricType", METRIC_TYPE_FIELD); map.put("Statistic", STATISTIC_FIELD); map.put("PeriodSeconds", PERIOD_SECONDS_FIELD); map.put("MetricDataQueries", METRIC_DATA_QUERIES_FIELD); return Collections.unmodifiableMap(map); } private static Function getter(Function g) { return obj -> g.apply((ServiceLevelIndicatorMetricConfig) obj); } private static BiConsumer setter(BiConsumer s) { return (obj, val) -> s.accept((Builder) obj, val); } public interface Builder extends SdkPojo, CopyableBuilder { /** *

    * If this SLO is related to a metric collected by Application Signals, you must use this field to specify which * service the SLO metric is related to. To do so, you must specify at least the Type, * Name, and Environment attributes. *

    *

    * This is a string-to-string map. It can include the following fields. *

    *
      *
    • *

      * Type designates the type of object this is. *

      *
    • *
    • *

      * ResourceType specifies the type of the resource. This field is used only when the value of the * Type field is Resource or AWS::Resource. *

      *
    • *
    • *

      * Name specifies the name of the object. This is used only if the value of the Type * field is Service, RemoteService, or AWS::Service. *

      *
    • *
    • *

      * Identifier identifies the resource objects of this resource. This is used only if the value of * the Type field is Resource or AWS::Resource. *

      *
    • *
    • *

      * Environment specifies the location where this object is hosted, or what it belongs to. *

      *
    • *
    * * @param keyAttributes * If this SLO is related to a metric collected by Application Signals, you must use this field to * specify which service the SLO metric is related to. To do so, you must specify at least the * Type, Name, and Environment attributes.

    *

    * This is a string-to-string map. It can include the following fields. *

    *
      *
    • *

      * Type designates the type of object this is. *

      *
    • *
    • *

      * ResourceType specifies the type of the resource. This field is used only when the value * of the Type field is Resource or AWS::Resource. *

      *
    • *
    • *

      * Name specifies the name of the object. This is used only if the value of the * Type field is Service, RemoteService, or * AWS::Service. *

      *
    • *
    • *

      * Identifier identifies the resource objects of this resource. This is used only if the * value of the Type field is Resource or AWS::Resource. *

      *
    • *
    • *

      * Environment specifies the location where this object is hosted, or what it belongs to. *

      *
    • * @return Returns a reference to this object so that method calls can be chained together. */ Builder keyAttributes(Map keyAttributes); /** *

      * If the SLO is to monitor a specific operation of the service, use this field to specify the name of that * operation. *

      * * @param operationName * If the SLO is to monitor a specific operation of the service, use this field to specify the name of * that operation. * @return Returns a reference to this object so that method calls can be chained together. */ Builder operationName(String operationName); /** *

      * If the SLO is to monitor either the LATENCY or AVAILABILITY metric that Application * Signals collects, use this field to specify which of those metrics is used. *

      * * @param metricType * If the SLO is to monitor either the LATENCY or AVAILABILITY metric that * Application Signals collects, use this field to specify which of those metrics is used. * @see ServiceLevelIndicatorMetricType * @return Returns a reference to this object so that method calls can be chained together. * @see ServiceLevelIndicatorMetricType */ Builder metricType(String metricType); /** *

      * If the SLO is to monitor either the LATENCY or AVAILABILITY metric that Application * Signals collects, use this field to specify which of those metrics is used. *

      * * @param metricType * If the SLO is to monitor either the LATENCY or AVAILABILITY metric that * Application Signals collects, use this field to specify which of those metrics is used. * @see ServiceLevelIndicatorMetricType * @return Returns a reference to this object so that method calls can be chained together. * @see ServiceLevelIndicatorMetricType */ Builder metricType(ServiceLevelIndicatorMetricType metricType); /** *

      * The statistic to use for comparison to the threshold. It can be any CloudWatch statistic or extended * statistic. For more information about statistics, see CloudWatch * statistics definitions. *

      * * @param statistic * The statistic to use for comparison to the threshold. It can be any CloudWatch statistic or extended * statistic. For more information about statistics, see CloudWatch statistics definitions. * @return Returns a reference to this object so that method calls can be chained together. */ Builder statistic(String statistic); /** *

      * The number of seconds to use as the period for SLO evaluation. Your application's performance is compared to * the SLI during each period. For each period, the application is determined to have either achieved or not * achieved the necessary performance. *

      * * @param periodSeconds * The number of seconds to use as the period for SLO evaluation. Your application's performance is * compared to the SLI during each period. For each period, the application is determined to have either * achieved or not achieved the necessary performance. * @return Returns a reference to this object so that method calls can be chained together. */ Builder periodSeconds(Integer periodSeconds); /** *

      * If this SLO monitors a CloudWatch metric or the result of a CloudWatch metric math expression, use this * structure to specify that metric or expression. *

      * * @param metricDataQueries * If this SLO monitors a CloudWatch metric or the result of a CloudWatch metric math expression, use * this structure to specify that metric or expression. * @return Returns a reference to this object so that method calls can be chained together. */ Builder metricDataQueries(Collection metricDataQueries); /** *

      * If this SLO monitors a CloudWatch metric or the result of a CloudWatch metric math expression, use this * structure to specify that metric or expression. *

      * * @param metricDataQueries * If this SLO monitors a CloudWatch metric or the result of a CloudWatch metric math expression, use * this structure to specify that metric or expression. * @return Returns a reference to this object so that method calls can be chained together. */ Builder metricDataQueries(MetricDataQuery... metricDataQueries); /** *

      * If this SLO monitors a CloudWatch metric or the result of a CloudWatch metric math expression, use this * structure to specify that metric or expression. *

      * This is a convenience method that creates an instance of the * {@link software.amazon.awssdk.services.applicationsignals.model.MetricDataQuery.Builder} avoiding the need to * create one manually via * {@link software.amazon.awssdk.services.applicationsignals.model.MetricDataQuery#builder()}. * *

      * When the {@link Consumer} completes, * {@link software.amazon.awssdk.services.applicationsignals.model.MetricDataQuery.Builder#build()} is called * immediately and its result is passed to {@link #metricDataQueries(List)}. * * @param metricDataQueries * a consumer that will call methods on * {@link software.amazon.awssdk.services.applicationsignals.model.MetricDataQuery.Builder} * @return Returns a reference to this object so that method calls can be chained together. * @see #metricDataQueries(java.util.Collection) */ Builder metricDataQueries(Consumer... metricDataQueries); } static final class BuilderImpl implements Builder { private Map keyAttributes = DefaultSdkAutoConstructMap.getInstance(); private String operationName; private String metricType; private String statistic; private Integer periodSeconds; private List metricDataQueries = DefaultSdkAutoConstructList.getInstance(); private BuilderImpl() { } private BuilderImpl(ServiceLevelIndicatorMetricConfig model) { keyAttributes(model.keyAttributes); operationName(model.operationName); metricType(model.metricType); statistic(model.statistic); periodSeconds(model.periodSeconds); metricDataQueries(model.metricDataQueries); } public final Map getKeyAttributes() { if (keyAttributes instanceof SdkAutoConstructMap) { return null; } return keyAttributes; } public final void setKeyAttributes(Map keyAttributes) { this.keyAttributes = AttributesCopier.copy(keyAttributes); } @Override public final Builder keyAttributes(Map keyAttributes) { this.keyAttributes = AttributesCopier.copy(keyAttributes); return this; } public final String getOperationName() { return operationName; } public final void setOperationName(String operationName) { this.operationName = operationName; } @Override public final Builder operationName(String operationName) { this.operationName = operationName; return this; } public final String getMetricType() { return metricType; } public final void setMetricType(String metricType) { this.metricType = metricType; } @Override public final Builder metricType(String metricType) { this.metricType = metricType; return this; } @Override public final Builder metricType(ServiceLevelIndicatorMetricType metricType) { this.metricType(metricType == null ? null : metricType.toString()); return this; } public final String getStatistic() { return statistic; } public final void setStatistic(String statistic) { this.statistic = statistic; } @Override public final Builder statistic(String statistic) { this.statistic = statistic; return this; } public final Integer getPeriodSeconds() { return periodSeconds; } public final void setPeriodSeconds(Integer periodSeconds) { this.periodSeconds = periodSeconds; } @Override public final Builder periodSeconds(Integer periodSeconds) { this.periodSeconds = periodSeconds; return this; } public final List getMetricDataQueries() { List result = MetricDataQueriesCopier.copyToBuilder(this.metricDataQueries); if (result instanceof SdkAutoConstructList) { return null; } return result; } public final void setMetricDataQueries(Collection metricDataQueries) { this.metricDataQueries = MetricDataQueriesCopier.copyFromBuilder(metricDataQueries); } @Override public final Builder metricDataQueries(Collection metricDataQueries) { this.metricDataQueries = MetricDataQueriesCopier.copy(metricDataQueries); return this; } @Override @SafeVarargs public final Builder metricDataQueries(MetricDataQuery... metricDataQueries) { metricDataQueries(Arrays.asList(metricDataQueries)); return this; } @Override @SafeVarargs public final Builder metricDataQueries(Consumer... metricDataQueries) { metricDataQueries(Stream.of(metricDataQueries).map(c -> MetricDataQuery.builder().applyMutation(c).build()) .collect(Collectors.toList())); return this; } @Override public ServiceLevelIndicatorMetricConfig build() { return new ServiceLevelIndicatorMetricConfig(this); } @Override public List> sdkFields() { return SDK_FIELDS; } @Override public Map> sdkFieldNameToField() { return SDK_NAME_TO_FIELD; } } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy