You are viewing documentation for version 3 of the AWS SDK for Ruby. Version 2 documentation can be found here.

Class: Aws::CostExplorer::Types::Expression

Inherits:
Struct
  • Object
show all
Defined in:
gems/aws-sdk-costexplorer/lib/aws-sdk-costexplorer/types.rb

Overview

Note:

When making an API call, you may pass Expression data as a hash:

{
  or: [
    {
      or: {
        # recursive Expressions
      },
      and: {
        # recursive Expressions
      },
      not: {
        # recursive Expression
      },
      dimensions: {
        key: "AZ", # accepts AZ, INSTANCE_TYPE, LINKED_ACCOUNT, OPERATION, PURCHASE_TYPE, REGION, SERVICE, USAGE_TYPE, USAGE_TYPE_GROUP, RECORD_TYPE, OPERATING_SYSTEM, TENANCY, SCOPE, PLATFORM, SUBSCRIPTION_ID
        values: ["Value"],
      },
      tags: {
        key: "TagKey",
        values: ["Value"],
      },
    },
  ],
  and: [
    {
      or: {
        # recursive Expressions
      },
      and: {
        # recursive Expressions
      },
      not: {
        # recursive Expression
      },
      dimensions: {
        key: "AZ", # accepts AZ, INSTANCE_TYPE, LINKED_ACCOUNT, OPERATION, PURCHASE_TYPE, REGION, SERVICE, USAGE_TYPE, USAGE_TYPE_GROUP, RECORD_TYPE, OPERATING_SYSTEM, TENANCY, SCOPE, PLATFORM, SUBSCRIPTION_ID
        values: ["Value"],
      },
      tags: {
        key: "TagKey",
        values: ["Value"],
      },
    },
  ],
  not: {
    or: [
      {
        # recursive Expression
      },
    ],
    and: [
      {
        # recursive Expression
      },
    ],
    not: {
      # recursive Expression
    },
    dimensions: {
      key: "AZ", # accepts AZ, INSTANCE_TYPE, LINKED_ACCOUNT, OPERATION, PURCHASE_TYPE, REGION, SERVICE, USAGE_TYPE, USAGE_TYPE_GROUP, RECORD_TYPE, OPERATING_SYSTEM, TENANCY, SCOPE, PLATFORM, SUBSCRIPTION_ID
      values: ["Value"],
    },
    tags: {
      key: "TagKey",
      values: ["Value"],
    },
  },
  dimensions: {
    key: "AZ", # accepts AZ, INSTANCE_TYPE, LINKED_ACCOUNT, OPERATION, PURCHASE_TYPE, REGION, SERVICE, USAGE_TYPE, USAGE_TYPE_GROUP, RECORD_TYPE, OPERATING_SYSTEM, TENANCY, SCOPE, PLATFORM, SUBSCRIPTION_ID
    values: ["Value"],
  },
  tags: {
    key: "TagKey",
    values: ["Value"],
  },
}

Use Expression to filter by cost or by usage. There are two patterns:

  • Simple dimension values - You can set the dimension name and values for the filters that you plan to use. For example, you can filter for InstanceType==m4.xlarge OR InstanceType==c4.large. The Expression for that looks like this.

    \{ "Dimensions": \{ "Key": "InstanceType", "Values": [ "m4.xlarge", “c4.large” ] \} \}

    The list of dimension values are OR'd together to retrieve cost or usage data. You can create Expression and DimensionValues objects using either with* methods or set* methods in multiple lines.

  • Compound dimension values 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. This allows you to filter on more advanced options. For example, you can filter on ((InstanceType == m4.large OR InstanceType == m3.large) OR (Tag.Type == Type1)) AND (UsageType != DataTransfer). The Expression for that looks like this.

    \{ "And": [ \{"Or": [ \{"Dimensions": \{ "Key": "InstanceType", "Values": [ "m4.x.large", "c4.large" ] \}\}, \{"Tag": \{ "Key": "TagName", "Values": ["Value1"] \} \} ]\}, \{"Not": \{"dimensions": \{ "Key": "UsageType", "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 will create an error.

    \{ "And": [ ... ], "DimensionValues": \{ "Dimension": "UsageType", "Values": [ "DataTransfer" ] \} \}

Instance Attribute Summary collapse

Instance Attribute Details

#andArray<Types::Expression>

Return results that match both Dimension objects.

Returns:



232
233
234
235
236
237
238
239
# File 'gems/aws-sdk-costexplorer/lib/aws-sdk-costexplorer/types.rb', line 232

class Expression < Struct.new(
  :or,
  :and,
  :not,
  :dimensions,
  :tags)
  include Aws::Structure
end

#dimensionsTypes::DimensionValues

The specific Dimension to use for Expression.



232
233
234
235
236
237
238
239
# File 'gems/aws-sdk-costexplorer/lib/aws-sdk-costexplorer/types.rb', line 232

class Expression < Struct.new(
  :or,
  :and,
  :not,
  :dimensions,
  :tags)
  include Aws::Structure
end

#notTypes::Expression

Return results that don't match Dimension.

Returns:



232
233
234
235
236
237
238
239
# File 'gems/aws-sdk-costexplorer/lib/aws-sdk-costexplorer/types.rb', line 232

class Expression < Struct.new(
  :or,
  :and,
  :not,
  :dimensions,
  :tags)
  include Aws::Structure
end

#orArray<Types::Expression>

Return results that match either Dimension.

Returns:



232
233
234
235
236
237
238
239
# File 'gems/aws-sdk-costexplorer/lib/aws-sdk-costexplorer/types.rb', line 232

class Expression < Struct.new(
  :or,
  :and,
  :not,
  :dimensions,
  :tags)
  include Aws::Structure
end

#tagsTypes::TagValues

The specific Tag to use for Expression.

Returns:



232
233
234
235
236
237
238
239
# File 'gems/aws-sdk-costexplorer/lib/aws-sdk-costexplorer/types.rb', line 232

class Expression < Struct.new(
  :or,
  :and,
  :not,
  :dimensions,
  :tags)
  include Aws::Structure
end