Skip to content

Commit

Permalink
Regenerate client from commit a68d81e0 of spec repo (#1614)
Browse files Browse the repository at this point in the history
Co-authored-by: ci.datadog-api-spec <packages@datadoghq.com>
Co-authored-by: api-clients-generation-pipeline[bot] <54105614+api-clients-generation-pipeline[bot]@users.noreply.github.com>
api-clients-generation-pipeline[bot] and ci.datadog-api-spec authored Jul 29, 2022
1 parent 63ef06e commit 82e484e
Showing 10 changed files with 115 additions and 45 deletions.
8 changes: 4 additions & 4 deletions .apigentools-info
Original file line number Diff line number Diff line change
@@ -4,13 +4,13 @@
"spec_versions": {
"v1": {
"apigentools_version": "1.6.2",
"regenerated": "2022-07-29 13:43:04.267813",
"spec_repo_commit": "42e24f61"
"regenerated": "2022-07-29 18:24:39.825037",
"spec_repo_commit": "a68d81e0"
},
"v2": {
"apigentools_version": "1.6.2",
"regenerated": "2022-07-29 13:43:04.280579",
"spec_repo_commit": "42e24f61"
"regenerated": "2022-07-29 18:24:39.834529",
"spec_repo_commit": "a68d81e0"
}
}
}
26 changes: 21 additions & 5 deletions .generator/schemas/v2/openapi.yaml
Original file line number Diff line number Diff line change
@@ -13917,14 +13917,25 @@ paths:
x-menu-order: 5
x-undo:
type: safe
/api/v2/usage/estimated_cost_by_org:
/api/v2/usage/estimated_cost:
get:
description: Get estimated cost across multi-org account.
description: 'Get estimated cost across multi-org and single root-org accounts.
Estimated cost data is only available for the current month and previous month.
To access historical costs prior to this, use the /cost_by_org endpoint.'
operationId: GetEstimatedCostByOrg
parameters:
- description: String to specify whether cost is broken down at a parent-org
level or at the sub-org level. Currently, only the 'sub-org' view is supported.
in: query
name: view
required: true
schema:
type: string
- description: 'Datetime in ISO-8601 format, UTC, precise to month: `[YYYY-MM]`
for cost beginning this month. Either start_month or start_date should be
specified, but not both.'
specified, but not both. (start_month cannot go beyond two months in the
past)'
in: query
name: start_month
required: false
@@ -13941,7 +13952,8 @@ paths:
type: string
- description: 'Datetime in ISO-8601 format, UTC, precise to day: `[YYYY-MM-DD]`
for cost beginning this day. Either start_month or start_date should be
specified, but not both.'
specified, but not both. (start_date cannot go beyond two months in the
past)'
in: query
name: start_date
required: false
@@ -13986,12 +13998,16 @@ paths:
appKeyAuth: []
- AuthZ:
- usage_read
summary: Get estimated cost across multi-org account
summary: Get estimated cost across your account
tags:
- Usage Metering
x-menu-order: 39
x-undo:
type: safe
x-unstable: '**Note**: This endpoint is in public beta.
Only the sub-org view is available currently, the summary view will be released
at a later date.'
/api/v2/usage/hourly_usage:
get:
description: Get hourly usage by product family
1 change: 1 addition & 0 deletions api/common/configuration.go
Original file line number Diff line number Diff line change
@@ -382,6 +382,7 @@ func NewConfiguration() *Configuration {
"v2.GetIncidentTeam": false,
"v2.ListIncidentTeams": false,
"v2.UpdateIncidentTeam": false,
"v2.GetEstimatedCostByOrg": false,
},
}
return cfg
30 changes: 23 additions & 7 deletions api/v2/datadog/api_usage_metering.go
Original file line number Diff line number Diff line change
@@ -7,7 +7,9 @@ package datadog
import (
"bytes"
_context "context"
_fmt "fmt"
_ioutil "io/ioutil"
_log "log"
_nethttp "net/http"
_neturl "net/url"
"time"
@@ -189,6 +191,7 @@ func (a *UsageMeteringApi) getCostByOrgExecute(r apiGetCostByOrgRequest) (CostBy

type apiGetEstimatedCostByOrgRequest struct {
ctx _context.Context
view *string
startMonth *time.Time
endMonth *time.Time
startDate *time.Time
@@ -233,9 +236,10 @@ func (r *GetEstimatedCostByOrgOptionalParameters) WithEndDate(endDate time.Time)
return r
}

func (a *UsageMeteringApi) buildGetEstimatedCostByOrgRequest(ctx _context.Context, o ...GetEstimatedCostByOrgOptionalParameters) (apiGetEstimatedCostByOrgRequest, error) {
func (a *UsageMeteringApi) buildGetEstimatedCostByOrgRequest(ctx _context.Context, view string, o ...GetEstimatedCostByOrgOptionalParameters) (apiGetEstimatedCostByOrgRequest, error) {
req := apiGetEstimatedCostByOrgRequest{
ctx: ctx,
ctx: ctx,
view: &view,
}

if len(o) > 1 {
@@ -251,10 +255,11 @@ func (a *UsageMeteringApi) buildGetEstimatedCostByOrgRequest(ctx _context.Contex
return req, nil
}

// GetEstimatedCostByOrg Get estimated cost across multi-org account.
// Get estimated cost across multi-org account.
func (a *UsageMeteringApi) GetEstimatedCostByOrg(ctx _context.Context, o ...GetEstimatedCostByOrgOptionalParameters) (CostByOrgResponse, *_nethttp.Response, error) {
req, err := a.buildGetEstimatedCostByOrgRequest(ctx, o...)
// GetEstimatedCostByOrg Get estimated cost across your account.
// Get estimated cost across multi-org and single root-org accounts.
// Estimated cost data is only available for the current month and previous month. To access historical costs prior to this, use the /cost_by_org endpoint.
func (a *UsageMeteringApi) GetEstimatedCostByOrg(ctx _context.Context, view string, o ...GetEstimatedCostByOrgOptionalParameters) (CostByOrgResponse, *_nethttp.Response, error) {
req, err := a.buildGetEstimatedCostByOrgRequest(ctx, view, o...)
if err != nil {
var localVarReturnValue CostByOrgResponse
return localVarReturnValue, nil, err
@@ -271,16 +276,27 @@ func (a *UsageMeteringApi) getEstimatedCostByOrgExecute(r apiGetEstimatedCostByO
localVarReturnValue CostByOrgResponse
)

operationId := "v2.GetEstimatedCostByOrg"
if a.Client.Cfg.IsUnstableOperationEnabled(operationId) {
_log.Printf("WARNING: Using unstable operation '%s'", operationId)
} else {
return localVarReturnValue, nil, common.GenericOpenAPIError{ErrorMessage: _fmt.Sprintf("Unstable operation '%s' is disabled", operationId)}
}

localBasePath, err := a.Client.Cfg.ServerURLWithContext(r.ctx, "v2.UsageMeteringApi.GetEstimatedCostByOrg")
if err != nil {
return localVarReturnValue, nil, common.GenericOpenAPIError{ErrorMessage: err.Error()}
}

localVarPath := localBasePath + "/api/v2/usage/estimated_cost_by_org"
localVarPath := localBasePath + "/api/v2/usage/estimated_cost"

localVarHeaderParams := make(map[string]string)
localVarQueryParams := _neturl.Values{}
localVarFormParams := _neturl.Values{}
if r.view == nil {
return localVarReturnValue, nil, common.ReportError("view is required and must be specified")
}
localVarQueryParams.Add("view", common.ParameterToString(*r.view, ""))
if r.startMonth != nil {
localVarQueryParams.Add("start_month", common.ParameterToString(*r.startMonth, ""))
}
5 changes: 3 additions & 2 deletions examples/v2/usage-metering/GetEstimatedCostByOrg.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Get estimated cost across multi-org account returns "OK" response
// Get estimated cost across your account returns "OK" response

package main

@@ -15,9 +15,10 @@ import (
func main() {
ctx := common.NewDefaultContext(context.Background())
configuration := common.NewConfiguration()
configuration.SetUnstableOperationEnabled("v2.GetEstimatedCostByOrg", true)
apiClient := common.NewAPIClient(configuration)
api := datadog.NewUsageMeteringApi(apiClient)
resp, r, err := api.GetEstimatedCostByOrg(ctx, *datadog.NewGetEstimatedCostByOrgOptionalParameters())
resp, r, err := api.GetEstimatedCostByOrg(ctx, "view", *datadog.NewGetEstimatedCostByOrgOptionalParameters())

if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `UsageMeteringApi.GetEstimatedCostByOrg`: %v\n", err)
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Get estimated cost across multi-org account with month returns "OK" response
// GetEstimatedCostByOrg with start_date returns "OK" response

package main

@@ -16,9 +16,10 @@ import (
func main() {
ctx := common.NewDefaultContext(context.Background())
configuration := common.NewConfiguration()
configuration.SetUnstableOperationEnabled("v2.GetEstimatedCostByOrg", true)
apiClient := common.NewAPIClient(configuration)
api := datadog.NewUsageMeteringApi(apiClient)
resp, r, err := api.GetEstimatedCostByOrg(ctx, *datadog.NewGetEstimatedCostByOrgOptionalParameters().WithStartMonth(time.Now().AddDate(0, 0, -5)).WithEndMonth(time.Now().AddDate(0, 0, -3)))
resp, r, err := api.GetEstimatedCostByOrg(ctx, "sub-org", *datadog.NewGetEstimatedCostByOrgOptionalParameters().WithStartDate(time.Now().AddDate(0, 0, -5)))

if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `UsageMeteringApi.GetEstimatedCostByOrg`: %v\n", err)
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Get estimated cost across multi-org account with date returns "OK" response
// GetEstimatedCostByOrg with start_month returns "OK" response

package main

@@ -16,9 +16,10 @@ import (
func main() {
ctx := common.NewDefaultContext(context.Background())
configuration := common.NewConfiguration()
configuration.SetUnstableOperationEnabled("v2.GetEstimatedCostByOrg", true)
apiClient := common.NewAPIClient(configuration)
api := datadog.NewUsageMeteringApi(apiClient)
resp, r, err := api.GetEstimatedCostByOrg(ctx, *datadog.NewGetEstimatedCostByOrgOptionalParameters().WithStartDate(time.Now().AddDate(0, 0, -5)).WithEndDate(time.Now().AddDate(0, 0, -3)))
resp, r, err := api.GetEstimatedCostByOrg(ctx, "sub-org", *datadog.NewGetEstimatedCostByOrgOptionalParameters().WithStartMonth(time.Now().AddDate(0, 0, -5)))

if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `UsageMeteringApi.GetEstimatedCostByOrg`: %v\n", err)
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2022-07-29T14:22:55.359Z
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
interactions:
- request:
body: ''
form: {}
headers:
Accept:
- application/json;datetime-format=rfc3339
method: GET
url: https://api.datadoghq.com/api/v2/usage/estimated_cost?start_date=2022-07-24T14%3A22%3A55.359Z&view=sub-org
response:
body: '{"data":[]}
'
code: 200
duration: ''
headers:
Content-Type:
- application/json
status: 200 OK
version: 1
59 changes: 36 additions & 23 deletions tests/scenarios/features/v2/usage_metering.feature
Original file line number Diff line number Diff line change
@@ -28,33 +28,19 @@ Feature: Usage Metering
When the request is sent
Then the response status is 200 OK

@skip @team:DataDog/red-zone-revenue-query
Scenario: Get estimated cost across multi-org account returns "Bad Request" response
Given new "GetEstimatedCostByOrg" request
And request contains "start_month" parameter with value "{{ timeISO('now - 3d') }}"
And request contains "start_date" parameter with value "{{ timeISO('now - 3d') }}"
@generated @skip @team:DataDog/red-zone-revenue-query
Scenario: Get estimated cost across your account returns "Bad Request" response
Given operation "GetEstimatedCostByOrg" enabled
And new "GetEstimatedCostByOrg" request
And request contains "view" parameter from "REPLACE.ME"
When the request is sent
Then the response status is 400 Bad Request

@generated @skip @team:DataDog/red-zone-revenue-query
Scenario: Get estimated cost across multi-org account returns "OK" response
Given new "GetEstimatedCostByOrg" request
When the request is sent
Then the response status is 200 OK

@replay-only @team:DataDog/red-zone-revenue-query
Scenario: Get estimated cost across multi-org account with date returns "OK" response
Given new "GetEstimatedCostByOrg" request
And request contains "start_date" parameter with value "{{ timeISO('now - 5d') }}"
And request contains "end_date" parameter with value "{{ timeISO('now - 3d') }}"
When the request is sent
Then the response status is 200 OK

@replay-only @team:DataDog/red-zone-revenue-query
Scenario: Get estimated cost across multi-org account with month returns "OK" response
Given new "GetEstimatedCostByOrg" request
And request contains "start_month" parameter with value "{{ timeISO('now - 5d') }}"
And request contains "end_month" parameter with value "{{ timeISO('now - 3d') }}"
Scenario: Get estimated cost across your account returns "OK" response
Given operation "GetEstimatedCostByOrg" enabled
And new "GetEstimatedCostByOrg" request
And request contains "view" parameter from "REPLACE.ME"
When the request is sent
Then the response status is 200 OK

@@ -164,3 +150,30 @@ Feature: Usage Metering
And request contains "start_hr" parameter from "REPLACE.ME"
When the request is sent
Then the response status is 200 OK

@skip @team:DataDog/red-zone-revenue-query
Scenario: GetEstimatedCostByOrg with both start_month and start_date returns "Bad Request" response
Given new "GetEstimatedCostByOrg" request
And request contains "view" parameter with value "sub-org"
And request contains "start_month" parameter with value "{{ timeISO('now - 3d') }}"
And request contains "start_date" parameter with value "{{ timeISO('now - 3d') }}"
When the request is sent
Then the response status is 400 Bad Request

@replay-only @team:DataDog/red-zone-revenue-query
Scenario: GetEstimatedCostByOrg with start_date returns "OK" response
Given operation "GetEstimatedCostByOrg" enabled
And new "GetEstimatedCostByOrg" request
And request contains "view" parameter with value "sub-org"
And request contains "start_date" parameter with value "{{ timeISO('now - 5d') }}"
When the request is sent
Then the response status is 200 OK

@skip @team:DataDog/red-zone-revenue-query
Scenario: GetEstimatedCostByOrg with start_month returns "OK" response
Given operation "GetEstimatedCostByOrg" enabled
And new "GetEstimatedCostByOrg" request
And request contains "view" parameter with value "sub-org"
And request contains "start_month" parameter with value "{{ timeISO('now - 5d') }}"
When the request is sent
Then the response status is 200 OK

0 comments on commit 82e484e

Please sign in to comment.