GetCostAndUsageInput
import "github.com/aws/aws-sdk-go/service/costexplorer"
type GetCostAndUsageInput struct { Filter *Expression `type:"structure"` Granularity *string `type:"string" enum:"Granularity"` GroupBy []*GroupDefinition `type:"list"` Metrics []*string `type:"list"` NextPageToken *string `type:"string"` TimePeriod *DateInterval `type:"structure"` }
- Filter
-
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 INSTANCE_TYPE==m4.xlarge OR INSTANCE_TYPE==c4.large. The Expression for that looks like this:
{ "Dimensions": { "Key": "INSTANCE_TYPE", "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 ((INSTANCE_TYPE == m4.large OR INSTANCE_TYPE == m3.large) OR (TAG.Type == Type1)) AND (USAGE_TYPE != DataTransfer). The Expression for that looks like this:
{ "And": [ {"Or": [ {"Dimensions": { "Key": "INSTANCE_TYPE", "Values": [
"m4.x.large", "c4.large" ] }}, {"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": [ ... ], "DimensionValues": { "Dimension": "USAGE_TYPE", "Values":
[ "DataTransfer" ] } }
-
- Granularity
-
Type:
*string
Sets the AWS cost granularity to MONTHLY or DAILY. If Granularity isn't set, the response object doesn't include the Granularity, either MONTHLY or DAILY.
The GetCostAndUsageRequest operation supports only DAILY and MONTHLY granularities.
- GroupBy
-
Represents a group when you specify a group by criteria or in the response to a query with a specific grouping.
- Metrics
-
Type:
[]*string
Which metrics are returned in the query. For more information about blended and unblended rates, see Why does the "blended" annotation appear on some line items in my bill? (https://aws.amazon.com/premiumsupport/knowledge-center/blended-rates-intro/).
Valid values are AmortizedCost, BlendedCost, NetAmortizedCost, NetUnblendedCost, NormalizedUsageAmount, UnblendedCost, and UsageQuantity.
If you return the UsageQuantity metric, the service aggregates all usage numbers without taking into account the units. For example, if you aggregate usageQuantity across all of Amazon EC2, the results aren't meaningful because Amazon EC2 compute hours and data transfer are measured in different units (for example, hours vs. GB). To get more meaningful UsageQuantity metrics, filter by UsageType or UsageTypeGroups.
Metrics is required for GetCostAndUsage requests.
- NextPageToken
-
Type:
*string
The token to retrieve the next set of results. AWS provides the token when the response from a previous call has more results than the maximum page size.
- TimePeriod
-
The time period that you want the usage and costs for.
Method
GoString
func (s GetCostAndUsageInput) GoString() string
GoString returns the string representation
SetFilter
func (s *GetCostAndUsageInput) SetFilter(v *Expression) *GetCostAndUsageInput
SetFilter sets the Filter field's value.
SetGranularity
func (s *GetCostAndUsageInput) SetGranularity(v string) *GetCostAndUsageInput
SetGranularity sets the Granularity field's value.
SetGroupBy
func (s *GetCostAndUsageInput) SetGroupBy(v []*GroupDefinition) *GetCostAndUsageInput
SetGroupBy sets the GroupBy field's value.
SetMetrics
func (s *GetCostAndUsageInput) SetMetrics(v []*string) *GetCostAndUsageInput
SetMetrics sets the Metrics field's value.
SetNextPageToken
func (s *GetCostAndUsageInput) SetNextPageToken(v string) *GetCostAndUsageInput
SetNextPageToken sets the NextPageToken field's value.
SetTimePeriod
func (s *GetCostAndUsageInput) SetTimePeriod(v *DateInterval) *GetCostAndUsageInput
SetTimePeriod sets the TimePeriod field's value.
String
func (s GetCostAndUsageInput) String() string
String returns the string representation
Validate
func (s *GetCostAndUsageInput) Validate() error
Validate inspects the fields of the type to determine if they are valid.