Skip to content

Commit 69898f1

Browse files
author
ci.datadog-api-spec
committed
Regenerate client from commit f39beecd of spec repo
1 parent 9ca8ca2 commit 69898f1

File tree

12 files changed

+475
-4
lines changed

12 files changed

+475
-4
lines changed

.apigentools-info

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
"spec_versions": {
55
"v1": {
66
"apigentools_version": "1.6.6",
7-
"regenerated": "2023-11-14 15:18:14.889333",
8-
"spec_repo_commit": "b95546fe"
7+
"regenerated": "2023-11-15 13:47:24.562787",
8+
"spec_repo_commit": "f39beecd"
99
},
1010
"v2": {
1111
"apigentools_version": "1.6.6",
12-
"regenerated": "2023-11-14 15:18:14.904239",
13-
"spec_repo_commit": "b95546fe"
12+
"regenerated": "2023-11-15 13:47:24.578752",
13+
"spec_repo_commit": "f39beecd"
1414
}
1515
}
1616
}

.generator/schemas/v2/openapi.yaml

+98
Original file line numberDiff line numberDiff line change
@@ -11747,6 +11747,53 @@ components:
1174711747
type: string
1174811748
x-enum-varnames:
1174911749
- PROCESS
11750+
ProjectedCost:
11751+
description: Projected Cost data.
11752+
properties:
11753+
attributes:
11754+
$ref: '#/components/schemas/ProjectedCostAttributes'
11755+
id:
11756+
description: Unique ID of the response.
11757+
type: string
11758+
type:
11759+
$ref: '#/components/schemas/CostByOrgType'
11760+
type: object
11761+
ProjectedCostAttributes:
11762+
description: Projected Cost attributes data.
11763+
properties:
11764+
charges:
11765+
description: List of charges data reported for the requested month.
11766+
items:
11767+
$ref: '#/components/schemas/ChargebackBreakdown'
11768+
type: array
11769+
date:
11770+
description: The month requested.
11771+
format: date-time
11772+
type: string
11773+
org_name:
11774+
description: The organization name.
11775+
type: string
11776+
projected_total_cost:
11777+
description: The total projected cost of products for the month.
11778+
format: double
11779+
type: number
11780+
public_id:
11781+
description: The organization public ID.
11782+
type: string
11783+
region:
11784+
description: The region of the Datadog instance that the organization belongs
11785+
to.
11786+
type: string
11787+
type: object
11788+
ProjectedCostResponse:
11789+
description: Projected Cost response.
11790+
properties:
11791+
data:
11792+
description: Response containing Projected Cost.
11793+
items:
11794+
$ref: '#/components/schemas/ProjectedCost'
11795+
type: array
11796+
type: object
1175011797
QueryFormula:
1175111798
description: A formula for calculation based on one or more queries.
1175211799
properties:
@@ -29935,6 +29982,57 @@ paths:
2993529982
summary: Get hourly usage for observability pipelines
2993629983
tags:
2993729984
- Usage Metering
29985+
/api/v2/usage/projected_cost:
29986+
get:
29987+
description: 'Get projected cost across multi-org and single root-org accounts.
29988+
29989+
Projected cost data is only available for the current month and becomes available
29990+
around the 12th of the month.
29991+
29992+
This endpoint requires the usage_read authorization scope.'
29993+
operationId: GetProjectedCost
29994+
parameters:
29995+
- description: String to specify whether cost is broken down at a parent-org
29996+
level or at the sub-org level. Available views are `summary` and `sub-org`.
29997+
Defaults to `summary`.
29998+
in: query
29999+
name: view
30000+
required: false
30001+
schema:
30002+
type: string
30003+
responses:
30004+
'200':
30005+
content:
30006+
application/json;datetime-format=rfc3339:
30007+
schema:
30008+
$ref: '#/components/schemas/ProjectedCostResponse'
30009+
description: OK
30010+
'400':
30011+
content:
30012+
application/json;datetime-format=rfc3339:
30013+
schema:
30014+
$ref: '#/components/schemas/APIErrorResponse'
30015+
description: Bad Request
30016+
'403':
30017+
content:
30018+
application/json;datetime-format=rfc3339:
30019+
schema:
30020+
$ref: '#/components/schemas/APIErrorResponse'
30021+
description: Forbidden - User is not authorized
30022+
'429':
30023+
content:
30024+
application/json;datetime-format=rfc3339:
30025+
schema:
30026+
$ref: '#/components/schemas/APIErrorResponse'
30027+
description: Too many requests
30028+
security:
30029+
- apiKeyAuth: []
30030+
appKeyAuth: []
30031+
- AuthZ:
30032+
- usage_read
30033+
summary: Get projected cost across your account
30034+
tags:
30035+
- Usage Metering
2993830036
/api/v2/user_invitations:
2993930037
post:
2994030038
description: Sends emails to one or more users inviting them to join the organization.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/**
2+
* Get projected cost across your account returns "OK" response
3+
*/
4+
5+
import { client, v2 } from "@datadog/datadog-api-client";
6+
7+
const configuration = client.createConfiguration();
8+
const apiInstance = new v2.UsageMeteringApi(configuration);
9+
10+
const params: v2.UsageMeteringApiGetProjectedCostRequest = {
11+
view: "sub-org",
12+
};
13+
14+
apiInstance
15+
.getProjectedCost(params)
16+
.then((data: v2.ProjectedCostResponse) => {
17+
console.log(
18+
"API called successfully. Returned data: " + JSON.stringify(data)
19+
);
20+
})
21+
.catch((error: any) => console.error(error));

features/support/scenarios_model_mapping.ts

+7
Original file line numberDiff line numberDiff line change
@@ -5180,6 +5180,13 @@ export const ScenariosModelMappings: {[key: string]: {[key: string]: any}} = {
51805180
},
51815181
"operationResponseType": "UsageObservabilityPipelinesResponse",
51825182
},
5183+
"v2.GetProjectedCost": {
5184+
"view": {
5185+
"type": "string",
5186+
"format": "",
5187+
},
5188+
"operationResponseType": "ProjectedCostResponse",
5189+
},
51835190
"v2.SendInvitations": {
51845191
"body": {
51855192
"type": "UserInvitationsRequest",

features/v2/undo.json

+6
Original file line numberDiff line numberDiff line change
@@ -1884,6 +1884,12 @@
18841884
"type": "safe"
18851885
}
18861886
},
1887+
"GetProjectedCost": {
1888+
"tag": "Usage Metering",
1889+
"undo": {
1890+
"type": "safe"
1891+
}
1892+
},
18871893
"SendInvitations": {
18881894
"tag": "Users",
18891895
"undo": {

features/v2/usage_metering.feature

+13
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,19 @@ Feature: Usage Metering
149149
And the response "data[0].type" is equal to "usage_timeseries"
150150
And the response "data[0].attributes.product_family" is equal to "observability-pipelines"
151151

152+
@generated @skip @team:DataDog/red-zone-revenue-query
153+
Scenario: Get projected cost across your account returns "Bad Request" response
154+
Given new "GetProjectedCost" request
155+
When the request is sent
156+
Then the response status is 400 Bad Request
157+
158+
@skip @team:DataDog/red-zone-revenue-query
159+
Scenario: Get projected cost across your account returns "OK" response
160+
Given new "GetProjectedCost" request
161+
And request contains "view" parameter with value "sub-org"
162+
When the request is sent
163+
Then the response status is 200 OK
164+
152165
@team:DataDog/red-zone-revenue-query
153166
Scenario: GetEstimatedCostByOrg with both start_month and start_date returns "Bad Request" response
154167
Given new "GetEstimatedCostByOrg" request

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

+131
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import { ApiException } from "../../datadog-api-client-common/exception";
1919
import { APIErrorResponse } from "../models/APIErrorResponse";
2020
import { CostByOrgResponse } from "../models/CostByOrgResponse";
2121
import { HourlyUsageResponse } from "../models/HourlyUsageResponse";
22+
import { ProjectedCostResponse } from "../models/ProjectedCostResponse";
2223
import { UsageApplicationSecurityMonitoringResponse } from "../models/UsageApplicationSecurityMonitoringResponse";
2324
import { UsageLambdaTracedInvocationsResponse } from "../models/UsageLambdaTracedInvocationsResponse";
2425
import { UsageObservabilityPipelinesResponse } from "../models/UsageObservabilityPipelinesResponse";
@@ -290,6 +291,43 @@ export class UsageMeteringApiRequestFactory extends BaseAPIRequestFactory {
290291
return requestContext;
291292
}
292293

294+
public async getProjectedCost(
295+
view?: string,
296+
_options?: Configuration
297+
): Promise<RequestContext> {
298+
const _config = _options || this.configuration;
299+
300+
// Path Params
301+
const localVarPath = "/api/v2/usage/projected_cost";
302+
303+
// Make Request Context
304+
const requestContext = _config
305+
.getServer("v2.UsageMeteringApi.getProjectedCost")
306+
.makeRequestContext(localVarPath, HttpMethod.GET);
307+
requestContext.setHeaderParam(
308+
"Accept",
309+
"application/json;datetime-format=rfc3339"
310+
);
311+
requestContext.setHttpConfig(_config.httpConfig);
312+
313+
// Query Params
314+
if (view !== undefined) {
315+
requestContext.setQueryParam(
316+
"view",
317+
ObjectSerializer.serialize(view, "string", "")
318+
);
319+
}
320+
321+
// Apply auth methods
322+
applySecurityAuthentication(_config, requestContext, [
323+
"AuthZ",
324+
"apiKeyAuth",
325+
"appKeyAuth",
326+
]);
327+
328+
return requestContext;
329+
}
330+
293331
public async getUsageApplicationSecurityMonitoring(
294332
startHr: Date,
295333
endHr?: Date,
@@ -690,6 +728,68 @@ export class UsageMeteringApiResponseProcessor {
690728
);
691729
}
692730

731+
/**
732+
* Unwraps the actual response sent by the server from the response context and deserializes the response content
733+
* to the expected objects
734+
*
735+
* @params response Response returned by the server for a request to getProjectedCost
736+
* @throws ApiException if the response code was not in [200, 299]
737+
*/
738+
public async getProjectedCost(
739+
response: ResponseContext
740+
): Promise<ProjectedCostResponse> {
741+
const contentType = ObjectSerializer.normalizeMediaType(
742+
response.headers["content-type"]
743+
);
744+
if (response.httpStatusCode == 200) {
745+
const body: ProjectedCostResponse = ObjectSerializer.deserialize(
746+
ObjectSerializer.parse(await response.body.text(), contentType),
747+
"ProjectedCostResponse"
748+
) as ProjectedCostResponse;
749+
return body;
750+
}
751+
if (
752+
response.httpStatusCode == 400 ||
753+
response.httpStatusCode == 403 ||
754+
response.httpStatusCode == 429
755+
) {
756+
const bodyText = ObjectSerializer.parse(
757+
await response.body.text(),
758+
contentType
759+
);
760+
let body: APIErrorResponse;
761+
try {
762+
body = ObjectSerializer.deserialize(
763+
bodyText,
764+
"APIErrorResponse"
765+
) as APIErrorResponse;
766+
} catch (error) {
767+
logger.info(`Got error deserializing error: ${error}`);
768+
throw new ApiException<APIErrorResponse>(
769+
response.httpStatusCode,
770+
bodyText
771+
);
772+
}
773+
throw new ApiException<APIErrorResponse>(response.httpStatusCode, body);
774+
}
775+
776+
// Work around for missing responses in specification, e.g. for petstore.yaml
777+
if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) {
778+
const body: ProjectedCostResponse = ObjectSerializer.deserialize(
779+
ObjectSerializer.parse(await response.body.text(), contentType),
780+
"ProjectedCostResponse",
781+
""
782+
) as ProjectedCostResponse;
783+
return body;
784+
}
785+
786+
const body = (await response.body.text()) || "";
787+
throw new ApiException<string>(
788+
response.httpStatusCode,
789+
'Unknown API Status Code!\nBody: "' + body + '"'
790+
);
791+
}
792+
693793
/**
694794
* Unwraps the actual response sent by the server from the response context and deserializes the response content
695795
* to the expected objects
@@ -994,6 +1094,14 @@ export interface UsageMeteringApiGetHourlyUsageRequest {
9941094
pageNextRecordId?: string;
9951095
}
9961096

1097+
export interface UsageMeteringApiGetProjectedCostRequest {
1098+
/**
1099+
* String to specify whether cost is broken down at a parent-org level or at the sub-org level. Available views are `summary` and `sub-org`. Defaults to `summary`.
1100+
* @type string
1101+
*/
1102+
view?: string;
1103+
}
1104+
9971105
export interface UsageMeteringApiGetUsageApplicationSecurityMonitoringRequest {
9981106
/**
9991107
* Datetime in ISO-8601 format, UTC, precise to hour: `[YYYY-MM-DDThh]` for usage beginning at this hour.
@@ -1159,6 +1267,29 @@ export class UsageMeteringApi {
11591267
});
11601268
}
11611269

1270+
/**
1271+
* Get projected cost across multi-org and single root-org accounts.
1272+
* Projected cost data is only available for the current month and becomes available around the 12th of the month.
1273+
* This endpoint requires the usage_read authorization scope.
1274+
* @param param The request object
1275+
*/
1276+
public getProjectedCost(
1277+
param: UsageMeteringApiGetProjectedCostRequest = {},
1278+
options?: Configuration
1279+
): Promise<ProjectedCostResponse> {
1280+
const requestContextPromise = this.requestFactory.getProjectedCost(
1281+
param.view,
1282+
options
1283+
);
1284+
return requestContextPromise.then((requestContext) => {
1285+
return this.configuration.httpApi
1286+
.send(requestContext)
1287+
.then((responseContext) => {
1288+
return this.responseProcessor.getProjectedCost(responseContext);
1289+
});
1290+
});
1291+
}
1292+
11621293
/**
11631294
* Get hourly usage for application security .
11641295
* **Note:** hourly usage data for all products is now available in the [Get hourly usage by product family API](https://docs.datadoghq.com/api/latest/usage-metering/#get-hourly-usage-by-product-family)

packages/datadog-api-client-v2/index.ts

+4
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,7 @@ export {
405405
UsageMeteringApiGetEstimatedCostByOrgRequest,
406406
UsageMeteringApiGetHistoricalCostByOrgRequest,
407407
UsageMeteringApiGetHourlyUsageRequest,
408+
UsageMeteringApiGetProjectedCostRequest,
408409
UsageMeteringApiGetUsageApplicationSecurityMonitoringRequest,
409410
UsageMeteringApiGetUsageLambdaTracedInvocationsRequest,
410411
UsageMeteringApiGetUsageObservabilityPipelinesRequest,
@@ -1144,6 +1145,9 @@ export { ProcessSummariesResponse } from "./models/ProcessSummariesResponse";
11441145
export { ProcessSummary } from "./models/ProcessSummary";
11451146
export { ProcessSummaryAttributes } from "./models/ProcessSummaryAttributes";
11461147
export { ProcessSummaryType } from "./models/ProcessSummaryType";
1148+
export { ProjectedCost } from "./models/ProjectedCost";
1149+
export { ProjectedCostAttributes } from "./models/ProjectedCostAttributes";
1150+
export { ProjectedCostResponse } from "./models/ProjectedCostResponse";
11471151
export { QueryFormula } from "./models/QueryFormula";
11481152
export { QuerySortOrder } from "./models/QuerySortOrder";
11491153
export { RelationshipToIncidentAttachment } from "./models/RelationshipToIncidentAttachment";

0 commit comments

Comments
 (0)