Skip to content

Commit 0ef7277

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-spec
andauthored
Regenerate client from commit a68d81e0 of spec repo (#780)
Co-authored-by: ci.datadog-api-spec <[email protected]> Co-authored-by: api-clients-generation-pipeline[bot] <54105614+api-clients-generation-pipeline[bot]@users.noreply.github.com>
1 parent b0ca1ea commit 0ef7277

File tree

10 files changed

+174
-43
lines changed

10 files changed

+174
-43
lines changed

.apigentools-info

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
"spec_versions": {
55
"v1": {
66
"apigentools_version": "1.6.2",
7-
"regenerated": "2022-07-29 13:43:08.165233",
8-
"spec_repo_commit": "42e24f61"
7+
"regenerated": "2022-07-29 18:24:29.943707",
8+
"spec_repo_commit": "a68d81e0"
99
},
1010
"v2": {
1111
"apigentools_version": "1.6.2",
12-
"regenerated": "2022-07-29 13:43:08.177187",
13-
"spec_repo_commit": "42e24f61"
12+
"regenerated": "2022-07-29 18:24:29.959460",
13+
"spec_repo_commit": "a68d81e0"
1414
}
1515
}
1616
}

.generator/schemas/v2/openapi.yaml

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13917,14 +13917,25 @@ paths:
1391713917
x-menu-order: 5
1391813918
x-undo:
1391913919
type: safe
13920-
/api/v2/usage/estimated_cost_by_org:
13920+
/api/v2/usage/estimated_cost:
1392113921
get:
13922-
description: Get estimated cost across multi-org account.
13922+
description: 'Get estimated cost across multi-org and single root-org accounts.
13923+
13924+
Estimated cost data is only available for the current month and previous month.
13925+
To access historical costs prior to this, use the /cost_by_org endpoint.'
1392313926
operationId: GetEstimatedCostByOrg
1392413927
parameters:
13928+
- description: String to specify whether cost is broken down at a parent-org
13929+
level or at the sub-org level. Currently, only the 'sub-org' view is supported.
13930+
in: query
13931+
name: view
13932+
required: true
13933+
schema:
13934+
type: string
1392513935
- description: 'Datetime in ISO-8601 format, UTC, precise to month: `[YYYY-MM]`
1392613936
for cost beginning this month. Either start_month or start_date should be
13927-
specified, but not both.'
13937+
specified, but not both. (start_month cannot go beyond two months in the
13938+
past)'
1392813939
in: query
1392913940
name: start_month
1393013941
required: false
@@ -13941,7 +13952,8 @@ paths:
1394113952
type: string
1394213953
- description: 'Datetime in ISO-8601 format, UTC, precise to day: `[YYYY-MM-DD]`
1394313954
for cost beginning this day. Either start_month or start_date should be
13944-
specified, but not both.'
13955+
specified, but not both. (start_date cannot go beyond two months in the
13956+
past)'
1394513957
in: query
1394613958
name: start_date
1394713959
required: false
@@ -13986,12 +13998,16 @@ paths:
1398613998
appKeyAuth: []
1398713999
- AuthZ:
1398814000
- usage_read
13989-
summary: Get estimated cost across multi-org account
14001+
summary: Get estimated cost across your account
1399014002
tags:
1399114003
- Usage Metering
1399214004
x-menu-order: 39
1399314005
x-undo:
1399414006
type: safe
14007+
x-unstable: '**Note**: This endpoint is in public beta.
14008+
14009+
Only the sub-org view is available currently, the summary view will be released
14010+
at a later date.'
1399514011
/api/v2/usage/hourly_usage:
1399614012
get:
1399714013
description: Get hourly usage by product family
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
"2022-07-29T14:22:55.359Z"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
{
2+
"log": {
3+
"_recordingName": "Usage Metering/GetEstimatedCostByOrg with start_date returns \"OK\" response",
4+
"creator": {
5+
"comment": "persister:fs",
6+
"name": "Polly.JS",
7+
"version": "6.0.4"
8+
},
9+
"entries": [
10+
{
11+
"_id": "7cb949d5c1eece97c2e37535350712e3",
12+
"_order": 0,
13+
"cache": {},
14+
"request": {
15+
"bodySize": 0,
16+
"cookies": [],
17+
"headers": [
18+
{
19+
"_fromType": "array",
20+
"name": "accept",
21+
"value": "application/json;datetime-format=rfc3339"
22+
}
23+
],
24+
"headersSize": 599,
25+
"httpVersion": "HTTP/1.1",
26+
"method": "GET",
27+
"queryString": [
28+
{
29+
"name": "start_date",
30+
"value": "2022-07-24T14:22:55.359Z"
31+
},
32+
{
33+
"name": "view",
34+
"value": "sub-org"
35+
}
36+
],
37+
"url": "https://api.datadoghq.com/api/v2/usage/estimated_cost?start_date=2022-07-24T14%3A22%3A55.359Z&view=sub-org"
38+
},
39+
"response": {
40+
"bodySize": 12,
41+
"content": {
42+
"mimeType": "application/json",
43+
"size": 12,
44+
"text": "{\"data\":[]}\n"
45+
},
46+
"cookies": [],
47+
"headers": [
48+
{
49+
"name": "content-type",
50+
"value": "application/json"
51+
}
52+
],
53+
"headersSize": 595,
54+
"httpVersion": "HTTP/1.1",
55+
"redirectURL": "",
56+
"status": 200,
57+
"statusText": "OK"
58+
},
59+
"startedDateTime": "2022-07-29T14:22:55.378Z",
60+
"time": 714
61+
}
62+
],
63+
"pages": [],
64+
"version": "1.2"
65+
}
66+
}

examples/v2/usage-metering/GetEstimatedCostByOrg.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
11
/**
2-
* Get estimated cost across multi-org account returns "OK" response
2+
* Get estimated cost across your account returns "OK" response
33
*/
44

55
import { client, v2 } from "@datadog/datadog-api-client";
66

77
const configuration = client.createConfiguration();
8+
configuration.unstableOperations["getEstimatedCostByOrg"] = true;
89
const apiInstance = new v2.UsageMeteringApi(configuration);
910

11+
const params: v2.UsageMeteringApiGetEstimatedCostByOrgRequest = {
12+
view: "view",
13+
};
14+
1015
apiInstance
11-
.getEstimatedCostByOrg()
16+
.getEstimatedCostByOrg(params)
1217
.then((data: v2.CostByOrgResponse) => {
1318
console.log(
1419
"API called successfully. Returned data: " + JSON.stringify(data)

examples/v2/usage-metering/GetEstimatedCostByOrg_627383212.ts renamed to examples/v2/usage-metering/GetEstimatedCostByOrg_2734954020.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
/**
2-
* Get estimated cost across multi-org account with date returns "OK" response
2+
* GetEstimatedCostByOrg with start_date returns "OK" response
33
*/
44

55
import { client, v2 } from "@datadog/datadog-api-client";
66

77
const configuration = client.createConfiguration();
8+
configuration.unstableOperations["getEstimatedCostByOrg"] = true;
89
const apiInstance = new v2.UsageMeteringApi(configuration);
910

1011
const params: v2.UsageMeteringApiGetEstimatedCostByOrgRequest = {
12+
view: "sub-org",
1113
startDate: new Date(new Date().getTime() / 1000 + -5 * 86400),
12-
endDate: new Date(new Date().getTime() / 1000 + -3 * 86400),
1314
};
1415

1516
apiInstance

examples/v2/usage-metering/GetEstimatedCostByOrg_1171921972.ts renamed to examples/v2/usage-metering/GetEstimatedCostByOrg_3186693804.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
/**
2-
* Get estimated cost across multi-org account with month returns "OK" response
2+
* GetEstimatedCostByOrg with start_month returns "OK" response
33
*/
44

55
import { client, v2 } from "@datadog/datadog-api-client";
66

77
const configuration = client.createConfiguration();
8+
configuration.unstableOperations["getEstimatedCostByOrg"] = true;
89
const apiInstance = new v2.UsageMeteringApi(configuration);
910

1011
const params: v2.UsageMeteringApiGetEstimatedCostByOrgRequest = {
12+
view: "sub-org",
1113
startMonth: new Date(new Date().getTime() / 1000 + -5 * 86400),
12-
endMonth: new Date(new Date().getTime() / 1000 + -3 * 86400),
1314
};
1415

1516
apiInstance

features/v2/usage_metering.feature

Lines changed: 36 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -28,33 +28,19 @@ Feature: Usage Metering
2828
When the request is sent
2929
Then the response status is 200 OK
3030

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

3939
@generated @skip @team:DataDog/red-zone-revenue-query
40-
Scenario: Get estimated cost across multi-org account returns "OK" response
41-
Given new "GetEstimatedCostByOrg" request
42-
When the request is sent
43-
Then the response status is 200 OK
44-
45-
@replay-only @team:DataDog/red-zone-revenue-query
46-
Scenario: Get estimated cost across multi-org account with date returns "OK" response
47-
Given new "GetEstimatedCostByOrg" request
48-
And request contains "start_date" parameter with value "{{ timeISO('now - 5d') }}"
49-
And request contains "end_date" parameter with value "{{ timeISO('now - 3d') }}"
50-
When the request is sent
51-
Then the response status is 200 OK
52-
53-
@replay-only @team:DataDog/red-zone-revenue-query
54-
Scenario: Get estimated cost across multi-org account with month returns "OK" response
55-
Given new "GetEstimatedCostByOrg" request
56-
And request contains "start_month" parameter with value "{{ timeISO('now - 5d') }}"
57-
And request contains "end_month" parameter with value "{{ timeISO('now - 3d') }}"
40+
Scenario: Get estimated cost across your account returns "OK" response
41+
Given operation "GetEstimatedCostByOrg" enabled
42+
And new "GetEstimatedCostByOrg" request
43+
And request contains "view" parameter from "REPLACE.ME"
5844
When the request is sent
5945
Then the response status is 200 OK
6046

@@ -164,3 +150,30 @@ Feature: Usage Metering
164150
And request contains "start_hr" parameter from "REPLACE.ME"
165151
When the request is sent
166152
Then the response status is 200 OK
153+
154+
@skip @team:DataDog/red-zone-revenue-query
155+
Scenario: GetEstimatedCostByOrg with both start_month and start_date returns "Bad Request" response
156+
Given new "GetEstimatedCostByOrg" request
157+
And request contains "view" parameter with value "sub-org"
158+
And request contains "start_month" parameter with value "{{ timeISO('now - 3d') }}"
159+
And request contains "start_date" parameter with value "{{ timeISO('now - 3d') }}"
160+
When the request is sent
161+
Then the response status is 400 Bad Request
162+
163+
@replay-only @team:DataDog/red-zone-revenue-query
164+
Scenario: GetEstimatedCostByOrg with start_date returns "OK" response
165+
Given operation "GetEstimatedCostByOrg" enabled
166+
And new "GetEstimatedCostByOrg" request
167+
And request contains "view" parameter with value "sub-org"
168+
And request contains "start_date" parameter with value "{{ timeISO('now - 5d') }}"
169+
When the request is sent
170+
Then the response status is 200 OK
171+
172+
@skip @team:DataDog/red-zone-revenue-query
173+
Scenario: GetEstimatedCostByOrg with start_month returns "OK" response
174+
Given operation "GetEstimatedCostByOrg" enabled
175+
And new "GetEstimatedCostByOrg" request
176+
And request contains "view" parameter with value "sub-org"
177+
And request contains "start_month" parameter with value "{{ timeISO('now - 5d') }}"
178+
When the request is sent
179+
Then the response status is 200 OK

packages/datadog-api-client-common/configuration.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ export function createConfiguration(
127127
"v2.getIncidentTeam": false,
128128
"v2.listIncidentTeams": false,
129129
"v2.updateIncidentTeam": false,
130+
"v2.getEstimatedCostByOrg": false,
130131
},
131132
httpApi: conf.httpApi || new DefaultHttpLibrary(),
132133
authMethods: configureAuthMethods(authMethods),

packages/datadog-api-client-v2/apis/UsageMeteringApi.ts

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {
1313
ResponseContext,
1414
} from "../../datadog-api-client-common/http/http";
1515

16+
import { logger } from "../../../logger";
1617
import { ObjectSerializer } from "../models/ObjectSerializer";
1718
import { ApiException } from "../../datadog-api-client-common/exception";
1819
import { isCodeInRange } from "../../datadog-api-client-common/util";
@@ -78,6 +79,7 @@ export class UsageMeteringApiRequestFactory extends BaseAPIRequestFactory {
7879
}
7980

8081
public async getEstimatedCostByOrg(
82+
view: string,
8183
startMonth?: Date,
8284
endMonth?: Date,
8385
startDate?: Date,
@@ -86,8 +88,20 @@ export class UsageMeteringApiRequestFactory extends BaseAPIRequestFactory {
8688
): Promise<RequestContext> {
8789
const _config = _options || this.configuration;
8890

91+
logger.warn("Using unstable operation 'getEstimatedCostByOrg'");
92+
if (!_config.unstableOperations["v2.getEstimatedCostByOrg"]) {
93+
throw new Error("Unstable operation 'getEstimatedCostByOrg' is disabled");
94+
}
95+
96+
// verify required parameter 'view' is not null or undefined
97+
if (view === null || view === undefined) {
98+
throw new RequiredError(
99+
"Required parameter view was null or undefined when calling getEstimatedCostByOrg."
100+
);
101+
}
102+
89103
// Path Params
90-
const localVarPath = "/api/v2/usage/estimated_cost_by_org";
104+
const localVarPath = "/api/v2/usage/estimated_cost";
91105

92106
// Make Request Context
93107
const requestContext = getServer(
@@ -101,6 +115,12 @@ export class UsageMeteringApiRequestFactory extends BaseAPIRequestFactory {
101115
requestContext.setHttpConfig(_config.httpConfig);
102116

103117
// Query Params
118+
if (view !== undefined) {
119+
requestContext.setQueryParam(
120+
"view",
121+
ObjectSerializer.serialize(view, "string", "")
122+
);
123+
}
104124
if (startMonth !== undefined) {
105125
requestContext.setQueryParam(
106126
"start_month",
@@ -788,7 +808,12 @@ export interface UsageMeteringApiGetCostByOrgRequest {
788808

789809
export interface UsageMeteringApiGetEstimatedCostByOrgRequest {
790810
/**
791-
* 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.
811+
* 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.
812+
* @type string
813+
*/
814+
view: string;
815+
/**
816+
* 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. (start_month cannot go beyond two months in the past)
792817
* @type Date
793818
*/
794819
startMonth?: Date;
@@ -798,7 +823,7 @@ export interface UsageMeteringApiGetEstimatedCostByOrgRequest {
798823
*/
799824
endMonth?: Date;
800825
/**
801-
* 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.
826+
* 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. (start_date cannot go beyond two months in the past)
802827
* @type Date
803828
*/
804829
startDate?: Date;
@@ -936,14 +961,16 @@ export class UsageMeteringApi {
936961
}
937962

938963
/**
939-
* Get estimated cost across multi-org account.
964+
* Get estimated cost across multi-org and single root-org accounts.
965+
* 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.
940966
* @param param The request object
941967
*/
942968
public getEstimatedCostByOrg(
943-
param: UsageMeteringApiGetEstimatedCostByOrgRequest = {},
969+
param: UsageMeteringApiGetEstimatedCostByOrgRequest,
944970
options?: Configuration
945971
): Promise<CostByOrgResponse> {
946972
const requestContextPromise = this.requestFactory.getEstimatedCostByOrg(
973+
param.view,
947974
param.startMonth,
948975
param.endMonth,
949976
param.startDate,

0 commit comments

Comments
 (0)