Skip to content

Commit

Permalink
add custom group_by for RESOURCE_NAME (#25)
Browse files Browse the repository at this point in the history
* add custom group_by for RESOURCE_NAME
  • Loading branch information
fishnix authored Jul 8, 2021
1 parent 75c3512 commit e0ea54d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ GET /v1/cost/{account}/spaces/{spaceid}?start=2021-04-01&end=2021-05-31
GET /v1/cost/{account}/spaces/{spaceid}?start=2021-04-01&end=2021-05-31&groupby=INSTANCE_TYPE_FAMILY
```

Valid 'groupby' values are AZ, INSTANCE_TYPE, LINKED_ACCOUNT, OPERATION, PURCHASE_TYPE, SERVICE, USAGE_TYPE, PLATFORM, TENANCY, RECORD_TYPE, LEGAL_ENTITY_NAME, DEPLOYMENT_OPTION, DATABASE_ENGINE, CACHE_ENGINE, INSTANCE_TYPE_FAMILY, REGION, BILLING_ENTITY, RESERVATION_ID, SAVINGS_PLANS_TYPE, SAVINGS_PLAN_ARN, OPERATING_SYSTEM.
Supported default 'groupby' values are AZ, INSTANCE_TYPE, LINKED_ACCOUNT, OPERATION, PURCHASE_TYPE, SERVICE, USAGE_TYPE, PLATFORM, TENANCY, RECORD_TYPE, LEGAL_ENTITY_NAME, DEPLOYMENT_OPTION, DATABASE_ENGINE, CACHE_ENGINE, INSTANCE_TYPE_FAMILY, REGION, BILLING_ENTITY, RESERVATION_ID, SAVINGS_PLANS_TYPE, SAVINGS_PLAN_ARN, OPERATING_SYSTEM. In addition, the custom RESOURCE_NAME 'groupby' is supported using the Name tag.

#### Response

Expand Down
10 changes: 9 additions & 1 deletion api/handlers_spaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,15 @@ func (s *server) SpaceGetHandler(w http.ResponseWriter, r *http.Request) {
},
}

if groupBy != "" {
switch {
case groupBy == "RESOURCE_NAME":
input.GroupBy = []*costexplorer.GroupDefinition{
{
Key: aws.String("Name"),
Type: aws.String("TAG"),
},
}
case groupBy != "":
input.GroupBy = []*costexplorer.GroupDefinition{
{
Key: aws.String(groupBy),
Expand Down

0 comments on commit e0ea54d

Please sign in to comment.