1// Code generated by smithy-go-codegen DO NOT EDIT. 2 3package costexplorer 4 5import ( 6 "context" 7 awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware" 8 "github.com/aws/aws-sdk-go-v2/aws/signer/v4" 9 "github.com/aws/aws-sdk-go-v2/service/costexplorer/types" 10 "github.com/aws/smithy-go/middleware" 11 smithyhttp "github.com/aws/smithy-go/transport/http" 12) 13 14// Retrieves an array of Cost Category names and values incurred cost. If some Cost 15// Category names and values are not associated with any cost, they will not be 16// returned by this API. 17func (c *Client) GetCostCategories(ctx context.Context, params *GetCostCategoriesInput, optFns ...func(*Options)) (*GetCostCategoriesOutput, error) { 18 if params == nil { 19 params = &GetCostCategoriesInput{} 20 } 21 22 result, metadata, err := c.invokeOperation(ctx, "GetCostCategories", params, optFns, addOperationGetCostCategoriesMiddlewares) 23 if err != nil { 24 return nil, err 25 } 26 27 out := result.(*GetCostCategoriesOutput) 28 out.ResultMetadata = metadata 29 return out, nil 30} 31 32type GetCostCategoriesInput struct { 33 34 // The time period of the request. 35 // 36 // This member is required. 37 TimePeriod *types.DateInterval 38 39 // The unique name of the Cost Category. 40 CostCategoryName *string 41 42 // Use Expression to filter by cost or by usage. There are two patterns: 43 // 44 // * Simple 45 // dimension values - You can set the dimension name and values for the filters 46 // that you plan to use. For example, you can filter for REGION==us-east-1 OR 47 // REGION==us-west-1. For GetRightsizingRecommendation, the Region is a full name 48 // (for example, REGION==US East (N. Virginia). The Expression example looks like: 49 // { "Dimensions": { "Key": "REGION", "Values": [ "us-east-1", “us-west-1” ] } } 50 // The list of dimension values are OR'd together to retrieve cost or usage data. 51 // You can create Expression and DimensionValues objects using either with* methods 52 // or set* methods in multiple lines. 53 // 54 // * Compound dimension values with logical 55 // operations - You can use multiple Expression types and the logical operators 56 // AND/OR/NOT to create a list of one or more Expression objects. This allows you 57 // to filter on more advanced options. For example, you can filter on ((REGION == 58 // us-east-1 OR REGION == us-west-1) OR (TAG.Type == Type1)) AND (USAGE_TYPE != 59 // DataTransfer). The Expression for that looks like this: { "And": [ {"Or": [ 60 // {"Dimensions": { "Key": "REGION", "Values": [ "us-east-1", "us-west-1" ] }}, 61 // {"Tags": { "Key": "TagName", "Values": ["Value1"] } } ]}, {"Not": {"Dimensions": 62 // { "Key": "USAGE_TYPE", "Values": ["DataTransfer"] }}} ] } Because each 63 // Expression can have only one operator, the service returns an error if more than 64 // one is specified. The following example shows an Expression object that creates 65 // an error. { "And": [ ... ], "DimensionValues": { "Dimension": "USAGE_TYPE", 66 // "Values": [ "DataTransfer" ] } } 67 // 68 // For the GetRightsizingRecommendation action, a 69 // combination of OR and NOT is not supported. OR is not supported between 70 // different dimensions, or dimensions and tags. NOT operators aren't supported. 71 // Dimensions are also limited to LINKED_ACCOUNT, REGION, or RIGHTSIZING_TYPE. For 72 // the GetReservationPurchaseRecommendation action, only NOT is supported. AND and 73 // OR are not supported. Dimensions are limited to LINKED_ACCOUNT. 74 Filter *types.Expression 75 76 // This field is only used when SortBy is provided in the request. The maximum 77 // number of objects that to be returned for this request. If MaxResults is not 78 // specified with SortBy, the request will return 1000 results as the default value 79 // for this parameter. For GetCostCategories, MaxResults has an upper limit of 80 // 1000. 81 MaxResults int32 82 83 // If the number of objects that are still available for retrieval exceeds the 84 // limit, AWS returns a NextPageToken value in the response. To retrieve the next 85 // batch of objects, provide the NextPageToken from the prior call in your next 86 // request. 87 NextPageToken *string 88 89 // The value that you want to search the filter values for. If you do not specify a 90 // CostCategoryName, SearchString will be used to filter Cost Category names that 91 // match the SearchString pattern. If you do specifiy a CostCategoryName, 92 // SearchString will be used to filter Cost Category values that match the 93 // SearchString pattern. 94 SearchString *string 95 96 // The value by which you want to sort the data. The key represents cost and usage 97 // metrics. The following values are supported: 98 // 99 // * BlendedCost 100 // 101 // * UnblendedCost 102 // 103 // * 104 // AmortizedCost 105 // 106 // * NetAmortizedCost 107 // 108 // * NetUnblendedCost 109 // 110 // * UsageQuantity 111 // 112 // * 113 // NormalizedUsageAmount 114 // 115 // Supported values for SortOrder are ASCENDING or 116 // DESCENDING. When using SortBy, NextPageToken and SearchString are not supported. 117 SortBy []types.SortDefinition 118} 119 120type GetCostCategoriesOutput struct { 121 122 // The number of objects returned. 123 // 124 // This member is required. 125 ReturnSize *int32 126 127 // The total number of objects. 128 // 129 // This member is required. 130 TotalSize *int32 131 132 // The names of the Cost Categories. 133 CostCategoryNames []string 134 135 // The Cost Category values. CostCategoryValues are not returned if 136 // CostCategoryName is not specified in the request. 137 CostCategoryValues []string 138 139 // If the number of objects that are still available for retrieval exceeds the 140 // limit, AWS returns a NextPageToken value in the response. To retrieve the next 141 // batch of objects, provide the marker from the prior call in your next request. 142 NextPageToken *string 143 144 // Metadata pertaining to the operation's result. 145 ResultMetadata middleware.Metadata 146} 147 148func addOperationGetCostCategoriesMiddlewares(stack *middleware.Stack, options Options) (err error) { 149 err = stack.Serialize.Add(&awsAwsjson11_serializeOpGetCostCategories{}, middleware.After) 150 if err != nil { 151 return err 152 } 153 err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpGetCostCategories{}, middleware.After) 154 if err != nil { 155 return err 156 } 157 if err = addSetLoggerMiddleware(stack, options); err != nil { 158 return err 159 } 160 if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil { 161 return err 162 } 163 if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil { 164 return err 165 } 166 if err = addResolveEndpointMiddleware(stack, options); err != nil { 167 return err 168 } 169 if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil { 170 return err 171 } 172 if err = addRetryMiddlewares(stack, options); err != nil { 173 return err 174 } 175 if err = addHTTPSignerV4Middleware(stack, options); err != nil { 176 return err 177 } 178 if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil { 179 return err 180 } 181 if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil { 182 return err 183 } 184 if err = addClientUserAgent(stack); err != nil { 185 return err 186 } 187 if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { 188 return err 189 } 190 if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { 191 return err 192 } 193 if err = addOpGetCostCategoriesValidationMiddleware(stack); err != nil { 194 return err 195 } 196 if err = stack.Initialize.Add(newServiceMetadataMiddleware_opGetCostCategories(options.Region), middleware.Before); err != nil { 197 return err 198 } 199 if err = addRequestIDRetrieverMiddleware(stack); err != nil { 200 return err 201 } 202 if err = addResponseErrorMiddleware(stack); err != nil { 203 return err 204 } 205 if err = addRequestResponseLogging(stack, options); err != nil { 206 return err 207 } 208 return nil 209} 210 211func newServiceMetadataMiddleware_opGetCostCategories(region string) *awsmiddleware.RegisterServiceMetadata { 212 return &awsmiddleware.RegisterServiceMetadata{ 213 Region: region, 214 ServiceID: ServiceID, 215 SigningName: "ce", 216 OperationName: "GetCostCategories", 217 } 218} 219