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

com.amazonaws.services.costexplorer.model.Expression Maven / Gradle / Ivy

Go to download

The AWS Java SDK for AWS Cost Explorer module holds the client classes that are used for communicating with AWS Cost Explorer Service

The newest version!
/*
 * Copyright 2020-2025 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 com.amazonaws.services.costexplorer.model;

import java.io.Serializable;
import javax.annotation.Generated;
import com.amazonaws.protocol.StructuredPojo;
import com.amazonaws.protocol.ProtocolMarshaller;

/**
 * 

* Use Expression to filter in various Cost Explorer APIs. *

*

* Not all Expression types are supported in each API. Refer to the documentation for each specific API to * see what is supported. *

*

* There are two patterns: *

*
    *
  • *

    * Simple dimension values. *

    *
      *
    • *

      * There are three types of simple dimension values: CostCategories, Tags, and * Dimensions. *

      *
        *
      • *

        * Specify the CostCategories field to define a filter that acts on Cost Categories. *

        *
      • *
      • *

        * Specify the Tags field to define a filter that acts on Cost Allocation Tags. *

        *
      • *
      • *

        * Specify the Dimensions field to define a filter that acts on the * DimensionValues . *

        *
      • *
      *
    • *
    • *

      * For each filter type, you can set the dimension name and values for the filters that you plan to use. *

      *
        *
      • *

        * For example, you can filter for REGION==us-east-1 OR REGION==us-west-1. For * GetRightsizingRecommendation, the Region is a full name (for example, * REGION==US East (N. Virginia). *

        *
      • *
      • *

        * The corresponding Expression for this example is as follows: * { "Dimensions": { "Key": "REGION", "Values": [ "us-east-1", "us-west-1" ] } } *

        *
      • *
      • *

        * As shown in the previous example, lists of dimension values are combined with OR when applying the * filter. *

        *
      • *
      *
    • *
    • *

      * You can also set different match options to further control how the filter behaves. Not all APIs support match * options. Refer to the documentation for each specific API to see what is supported. *

      *
        *
      • *

        * For example, you can filter for linked account names that start with "a". *

        *
      • *
      • *

        * The corresponding Expression for this example is as follows: * { "Dimensions": { "Key": "LINKED_ACCOUNT_NAME", "MatchOptions": [ "STARTS_WITH" ], "Values": [ "a" ] } } *

        *
      • *
      *
    • *
    *
  • *
  • *

    * Compound Expression types with logical operations. *

    *
      *
    • *

      * You can use multiple Expression types and the logical operators AND/OR/NOT to create a list * of one or more Expression objects. By doing this, you can filter by more advanced options. *

      *
    • *
    • *

      * For example, you can filter by * ((REGION == us-east-1 OR REGION == us-west-1) OR (TAG.Type == Type1)) AND (USAGE_TYPE != DataTransfer). *

      *
    • *
    • *

      * The corresponding Expression for this example is as follows: * { "And": [ {"Or": [ {"Dimensions": { "Key": "REGION", "Values": [ "us-east-1", "us-west-1" ] }}, {"Tags": { "Key": "TagName", "Values": ["Value1"] } } ]}, {"Not": {"Dimensions": { "Key": "USAGE_TYPE", "Values": ["DataTransfer"] }}} ] } *

      *
    • *
    * *

    * Because each Expression can have only one operator, the service returns an error if more than one is * specified. The following example shows an Expression object that creates an error: * { "And": [ ... ], "Dimensions": { "Key": "USAGE_TYPE", "Values": [ "DataTransfer" ] } } *

    *

    * The following is an example of the corresponding error message: * "Expression has more than one roots. Only one root operator is allowed for each expression: And, Or, Not, Dimensions, Tags, CostCategories" *

    *
  • *
* *

* For the GetRightsizingRecommendation action, a combination of OR and NOT isn't supported. OR isn't * supported between different dimensions, or dimensions and tags. NOT operators aren't supported. Dimensions are also * limited to LINKED_ACCOUNT, REGION, or RIGHTSIZING_TYPE. *

*

* For the GetReservationPurchaseRecommendation action, only NOT is supported. AND and OR aren't supported. * Dimensions are limited to LINKED_ACCOUNT. *

*
* * @see AWS API * Documentation */ @Generated("com.amazonaws:aws-java-sdk-code-generator") public class Expression implements Serializable, Cloneable, StructuredPojo { /** *

* Return results that match either Dimension object. *

*/ private java.util.List or; /** *

* Return results that match both Dimension objects. *

*/ private java.util.List and; /** *

* Return results that don't match a Dimension object. *

*/ private Expression not; /** *

* The specific Dimension to use for Expression. *

*/ private DimensionValues dimensions; /** *

* The specific Tag to use for Expression. *

*/ private TagValues tags; /** *

* The filter that's based on CostCategory values. *

*/ private CostCategoryValues costCategories; /** *

* Return results that match either Dimension object. *

* * @return Return results that match either Dimension object. */ public java.util.List getOr() { return or; } /** *

* Return results that match either Dimension object. *

* * @param or * Return results that match either Dimension object. */ public void setOr(java.util.Collection or) { if (or == null) { this.or = null; return; } this.or = new java.util.ArrayList(or); } /** *

* Return results that match either Dimension object. *

*

* NOTE: This method appends the values to the existing list (if any). Use * {@link #setOr(java.util.Collection)} or {@link #withOr(java.util.Collection)} if you want to override the * existing values. *

* * @param or * Return results that match either Dimension object. * @return Returns a reference to this object so that method calls can be chained together. */ public Expression withOr(Expression... or) { if (this.or == null) { setOr(new java.util.ArrayList(or.length)); } for (Expression ele : or) { this.or.add(ele); } return this; } /** *

* Return results that match either Dimension object. *

* * @param or * Return results that match either Dimension object. * @return Returns a reference to this object so that method calls can be chained together. */ public Expression withOr(java.util.Collection or) { setOr(or); return this; } /** *

* Return results that match both Dimension objects. *

* * @return Return results that match both Dimension objects. */ public java.util.List getAnd() { return and; } /** *

* Return results that match both Dimension objects. *

* * @param and * Return results that match both Dimension objects. */ public void setAnd(java.util.Collection and) { if (and == null) { this.and = null; return; } this.and = new java.util.ArrayList(and); } /** *

* Return results that match both Dimension objects. *

*

* NOTE: This method appends the values to the existing list (if any). Use * {@link #setAnd(java.util.Collection)} or {@link #withAnd(java.util.Collection)} if you want to override the * existing values. *

* * @param and * Return results that match both Dimension objects. * @return Returns a reference to this object so that method calls can be chained together. */ public Expression withAnd(Expression... and) { if (this.and == null) { setAnd(new java.util.ArrayList(and.length)); } for (Expression ele : and) { this.and.add(ele); } return this; } /** *

* Return results that match both Dimension objects. *

* * @param and * Return results that match both Dimension objects. * @return Returns a reference to this object so that method calls can be chained together. */ public Expression withAnd(java.util.Collection and) { setAnd(and); return this; } /** *

* Return results that don't match a Dimension object. *

* * @param not * Return results that don't match a Dimension object. */ public void setNot(Expression not) { this.not = not; } /** *

* Return results that don't match a Dimension object. *

* * @return Return results that don't match a Dimension object. */ public Expression getNot() { return this.not; } /** *

* Return results that don't match a Dimension object. *

* * @param not * Return results that don't match a Dimension object. * @return Returns a reference to this object so that method calls can be chained together. */ public Expression withNot(Expression not) { setNot(not); return this; } /** *

* The specific Dimension to use for Expression. *

* * @param dimensions * The specific Dimension to use for Expression. */ public void setDimensions(DimensionValues dimensions) { this.dimensions = dimensions; } /** *

* The specific Dimension to use for Expression. *

* * @return The specific Dimension to use for Expression. */ public DimensionValues getDimensions() { return this.dimensions; } /** *

* The specific Dimension to use for Expression. *

* * @param dimensions * The specific Dimension to use for Expression. * @return Returns a reference to this object so that method calls can be chained together. */ public Expression withDimensions(DimensionValues dimensions) { setDimensions(dimensions); return this; } /** *

* The specific Tag to use for Expression. *

* * @param tags * The specific Tag to use for Expression. */ public void setTags(TagValues tags) { this.tags = tags; } /** *

* The specific Tag to use for Expression. *

* * @return The specific Tag to use for Expression. */ public TagValues getTags() { return this.tags; } /** *

* The specific Tag to use for Expression. *

* * @param tags * The specific Tag to use for Expression. * @return Returns a reference to this object so that method calls can be chained together. */ public Expression withTags(TagValues tags) { setTags(tags); return this; } /** *

* The filter that's based on CostCategory values. *

* * @param costCategories * The filter that's based on CostCategory values. */ public void setCostCategories(CostCategoryValues costCategories) { this.costCategories = costCategories; } /** *

* The filter that's based on CostCategory values. *

* * @return The filter that's based on CostCategory values. */ public CostCategoryValues getCostCategories() { return this.costCategories; } /** *

* The filter that's based on CostCategory values. *

* * @param costCategories * The filter that's based on CostCategory values. * @return Returns a reference to this object so that method calls can be chained together. */ public Expression withCostCategories(CostCategoryValues costCategories) { setCostCategories(costCategories); return this; } /** * 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. * * @return A string representation of this object. * * @see java.lang.Object#toString() */ @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("{"); if (getOr() != null) sb.append("Or: ").append(getOr()).append(","); if (getAnd() != null) sb.append("And: ").append(getAnd()).append(","); if (getNot() != null) sb.append("Not: ").append(getNot()).append(","); if (getDimensions() != null) sb.append("Dimensions: ").append(getDimensions()).append(","); if (getTags() != null) sb.append("Tags: ").append(getTags()).append(","); if (getCostCategories() != null) sb.append("CostCategories: ").append(getCostCategories()); sb.append("}"); return sb.toString(); } @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (obj instanceof Expression == false) return false; Expression other = (Expression) obj; if (other.getOr() == null ^ this.getOr() == null) return false; if (other.getOr() != null && other.getOr().equals(this.getOr()) == false) return false; if (other.getAnd() == null ^ this.getAnd() == null) return false; if (other.getAnd() != null && other.getAnd().equals(this.getAnd()) == false) return false; if (other.getNot() == null ^ this.getNot() == null) return false; if (other.getNot() != null && other.getNot().equals(this.getNot()) == false) return false; if (other.getDimensions() == null ^ this.getDimensions() == null) return false; if (other.getDimensions() != null && other.getDimensions().equals(this.getDimensions()) == false) return false; if (other.getTags() == null ^ this.getTags() == null) return false; if (other.getTags() != null && other.getTags().equals(this.getTags()) == false) return false; if (other.getCostCategories() == null ^ this.getCostCategories() == null) return false; if (other.getCostCategories() != null && other.getCostCategories().equals(this.getCostCategories()) == false) return false; return true; } @Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getOr() == null) ? 0 : getOr().hashCode()); hashCode = prime * hashCode + ((getAnd() == null) ? 0 : getAnd().hashCode()); hashCode = prime * hashCode + ((getNot() == null) ? 0 : getNot().hashCode()); hashCode = prime * hashCode + ((getDimensions() == null) ? 0 : getDimensions().hashCode()); hashCode = prime * hashCode + ((getTags() == null) ? 0 : getTags().hashCode()); hashCode = prime * hashCode + ((getCostCategories() == null) ? 0 : getCostCategories().hashCode()); return hashCode; } @Override public Expression clone() { try { return (Expression) super.clone(); } catch (CloneNotSupportedException e) { throw new IllegalStateException("Got a CloneNotSupportedException from Object.clone() " + "even though we're Cloneable!", e); } } @com.amazonaws.annotation.SdkInternalApi @Override public void marshall(ProtocolMarshaller protocolMarshaller) { com.amazonaws.services.costexplorer.model.transform.ExpressionMarshaller.getInstance().marshall(this, protocolMarshaller); } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy