@@ -19,6 +19,7 @@ import { ApiException } from "../../datadog-api-client-common/exception";
19
19
import { APIErrorResponse } from "../models/APIErrorResponse" ;
20
20
import { CostByOrgResponse } from "../models/CostByOrgResponse" ;
21
21
import { HourlyUsageResponse } from "../models/HourlyUsageResponse" ;
22
+ import { ProjectedCostResponse } from "../models/ProjectedCostResponse" ;
22
23
import { UsageApplicationSecurityMonitoringResponse } from "../models/UsageApplicationSecurityMonitoringResponse" ;
23
24
import { UsageLambdaTracedInvocationsResponse } from "../models/UsageLambdaTracedInvocationsResponse" ;
24
25
import { UsageObservabilityPipelinesResponse } from "../models/UsageObservabilityPipelinesResponse" ;
@@ -290,6 +291,43 @@ export class UsageMeteringApiRequestFactory extends BaseAPIRequestFactory {
290
291
return requestContext ;
291
292
}
292
293
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
+
293
331
public async getUsageApplicationSecurityMonitoring (
294
332
startHr : Date ,
295
333
endHr ?: Date ,
@@ -690,6 +728,68 @@ export class UsageMeteringApiResponseProcessor {
690
728
) ;
691
729
}
692
730
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
+
693
793
/**
694
794
* Unwraps the actual response sent by the server from the response context and deserializes the response content
695
795
* to the expected objects
@@ -994,6 +1094,14 @@ export interface UsageMeteringApiGetHourlyUsageRequest {
994
1094
pageNextRecordId ?: string ;
995
1095
}
996
1096
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
+
997
1105
export interface UsageMeteringApiGetUsageApplicationSecurityMonitoringRequest {
998
1106
/**
999
1107
* 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 {
1159
1267
} ) ;
1160
1268
}
1161
1269
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
+
1162
1293
/**
1163
1294
* Get hourly usage for application security .
1164
1295
* **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)
0 commit comments