-
Notifications
You must be signed in to change notification settings - Fork 52
Expand file tree
/
Copy pathusage_metering_api.py
More file actions
910 lines (807 loc) · 41.4 KB
/
usage_metering_api.py
File metadata and controls
910 lines (807 loc) · 41.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
# This product includes software developed at Datadog (https://www.datadoghq.com/).
# Copyright 2019-Present Datadog, Inc.
from __future__ import annotations
from typing import Any, Dict, Union
import warnings
from datadog_api_client.api_client import ApiClient, Endpoint as _Endpoint
from datadog_api_client.configuration import Configuration
from datadog_api_client.model_utils import (
datetime,
UnsetType,
unset,
)
from datadog_api_client.v2.model.active_billing_dimensions_response import ActiveBillingDimensionsResponse
from datadog_api_client.v2.model.monthly_cost_attribution_response import MonthlyCostAttributionResponse
from datadog_api_client.v2.model.sort_direction import SortDirection
from datadog_api_client.v2.model.usage_application_security_monitoring_response import (
UsageApplicationSecurityMonitoringResponse,
)
from datadog_api_client.v2.model.billing_dimensions_mapping_response import BillingDimensionsMappingResponse
from datadog_api_client.v2.model.cost_by_org_response import CostByOrgResponse
from datadog_api_client.v2.model.cost_aggregation_type import CostAggregationType
from datadog_api_client.v2.model.hourly_usage_response import HourlyUsageResponse
from datadog_api_client.v2.model.usage_lambda_traced_invocations_response import UsageLambdaTracedInvocationsResponse
from datadog_api_client.v2.model.usage_observability_pipelines_response import UsageObservabilityPipelinesResponse
from datadog_api_client.v2.model.projected_cost_response import ProjectedCostResponse
from datadog_api_client.v2.model.usage_attribution_types_response import UsageAttributionTypesResponse
class UsageMeteringApi:
"""
The usage metering API allows you to get hourly, daily, and
monthly usage across multiple facets of Datadog.
This API is available to all Pro and Enterprise customers.
**Note** : Usage data is delayed by up to 72 hours from when it was incurred.
It is retained for 15 months.
You can retrieve up to 24 hours of hourly usage data for multiple organizations,
and up to two months of hourly usage data for a single organization in one request.
Learn more on the `usage details documentation <https://docs.datadoghq.com/account_management/billing/usage_details/>`_.
"""
def __init__(self, api_client=None):
if api_client is None:
api_client = ApiClient(Configuration())
self.api_client = api_client
self._get_active_billing_dimensions_endpoint = _Endpoint(
settings={
"response_type": (ActiveBillingDimensionsResponse,),
"auth": ["apiKeyAuth", "appKeyAuth", "AuthZ"],
"endpoint_path": "/api/v2/cost_by_tag/active_billing_dimensions",
"operation_id": "get_active_billing_dimensions",
"http_method": "GET",
"version": "v2",
},
params_map={},
headers_map={
"accept": ["application/json;datetime-format=rfc3339"],
},
api_client=api_client,
)
self._get_billing_dimension_mapping_endpoint = _Endpoint(
settings={
"response_type": (BillingDimensionsMappingResponse,),
"auth": ["apiKeyAuth", "appKeyAuth", "AuthZ"],
"endpoint_path": "/api/v2/usage/billing_dimension_mapping",
"operation_id": "get_billing_dimension_mapping",
"http_method": "GET",
"version": "v2",
},
params_map={
"filter_month": {
"openapi_types": (datetime,),
"attribute": "filter[month]",
"location": "query",
},
"filter_view": {
"openapi_types": (str,),
"attribute": "filter[view]",
"location": "query",
},
},
headers_map={
"accept": ["application/json;datetime-format=rfc3339"],
},
api_client=api_client,
)
self._get_cost_by_org_endpoint = _Endpoint(
settings={
"response_type": (CostByOrgResponse,),
"auth": ["apiKeyAuth", "appKeyAuth", "AuthZ"],
"endpoint_path": "/api/v2/usage/cost_by_org",
"operation_id": "get_cost_by_org",
"http_method": "GET",
"version": "v2",
},
params_map={
"start_month": {
"required": True,
"openapi_types": (datetime,),
"attribute": "start_month",
"location": "query",
},
"end_month": {
"openapi_types": (datetime,),
"attribute": "end_month",
"location": "query",
},
},
headers_map={
"accept": ["application/json;datetime-format=rfc3339"],
},
api_client=api_client,
)
self._get_estimated_cost_by_org_endpoint = _Endpoint(
settings={
"response_type": (CostByOrgResponse,),
"auth": ["apiKeyAuth", "appKeyAuth", "AuthZ"],
"endpoint_path": "/api/v2/usage/estimated_cost",
"operation_id": "get_estimated_cost_by_org",
"http_method": "GET",
"version": "v2",
},
params_map={
"view": {
"openapi_types": (str,),
"attribute": "view",
"location": "query",
},
"start_month": {
"openapi_types": (datetime,),
"attribute": "start_month",
"location": "query",
},
"end_month": {
"openapi_types": (datetime,),
"attribute": "end_month",
"location": "query",
},
"start_date": {
"openapi_types": (datetime,),
"attribute": "start_date",
"location": "query",
},
"end_date": {
"openapi_types": (datetime,),
"attribute": "end_date",
"location": "query",
},
"cost_aggregation": {
"openapi_types": (CostAggregationType,),
"attribute": "cost_aggregation",
"location": "query",
},
"include_connected_accounts": {
"openapi_types": (bool,),
"attribute": "include_connected_accounts",
"location": "query",
},
},
headers_map={
"accept": ["application/json;datetime-format=rfc3339"],
},
api_client=api_client,
)
self._get_historical_cost_by_org_endpoint = _Endpoint(
settings={
"response_type": (CostByOrgResponse,),
"auth": ["apiKeyAuth", "appKeyAuth", "AuthZ"],
"endpoint_path": "/api/v2/usage/historical_cost",
"operation_id": "get_historical_cost_by_org",
"http_method": "GET",
"version": "v2",
},
params_map={
"start_month": {
"required": True,
"openapi_types": (datetime,),
"attribute": "start_month",
"location": "query",
},
"view": {
"openapi_types": (str,),
"attribute": "view",
"location": "query",
},
"end_month": {
"openapi_types": (datetime,),
"attribute": "end_month",
"location": "query",
},
"include_connected_accounts": {
"openapi_types": (bool,),
"attribute": "include_connected_accounts",
"location": "query",
},
},
headers_map={
"accept": ["application/json;datetime-format=rfc3339"],
},
api_client=api_client,
)
self._get_hourly_usage_endpoint = _Endpoint(
settings={
"response_type": (HourlyUsageResponse,),
"auth": ["apiKeyAuth", "appKeyAuth", "AuthZ"],
"endpoint_path": "/api/v2/usage/hourly_usage",
"operation_id": "get_hourly_usage",
"http_method": "GET",
"version": "v2",
},
params_map={
"filter_timestamp_start": {
"required": True,
"openapi_types": (datetime,),
"attribute": "filter[timestamp][start]",
"location": "query",
},
"filter_timestamp_end": {
"openapi_types": (datetime,),
"attribute": "filter[timestamp][end]",
"location": "query",
},
"filter_product_families": {
"required": True,
"openapi_types": (str,),
"attribute": "filter[product_families]",
"location": "query",
},
"filter_include_descendants": {
"openapi_types": (bool,),
"attribute": "filter[include_descendants]",
"location": "query",
},
"filter_include_connected_accounts": {
"openapi_types": (bool,),
"attribute": "filter[include_connected_accounts]",
"location": "query",
},
"filter_include_breakdown": {
"openapi_types": (bool,),
"attribute": "filter[include_breakdown]",
"location": "query",
},
"filter_versions": {
"openapi_types": (str,),
"attribute": "filter[versions]",
"location": "query",
},
"page_limit": {
"validation": {
"inclusive_maximum": 500,
"inclusive_minimum": 1,
},
"openapi_types": (int,),
"attribute": "page[limit]",
"location": "query",
},
"page_next_record_id": {
"openapi_types": (str,),
"attribute": "page[next_record_id]",
"location": "query",
},
},
headers_map={
"accept": ["application/json;datetime-format=rfc3339"],
},
api_client=api_client,
)
self._get_monthly_cost_attribution_endpoint = _Endpoint(
settings={
"response_type": (MonthlyCostAttributionResponse,),
"auth": ["apiKeyAuth", "appKeyAuth", "AuthZ"],
"endpoint_path": "/api/v2/cost_by_tag/monthly_cost_attribution",
"operation_id": "get_monthly_cost_attribution",
"http_method": "GET",
"version": "v2",
},
params_map={
"start_month": {
"required": True,
"openapi_types": (datetime,),
"attribute": "start_month",
"location": "query",
},
"end_month": {
"openapi_types": (datetime,),
"attribute": "end_month",
"location": "query",
},
"fields": {
"required": True,
"openapi_types": (str,),
"attribute": "fields",
"location": "query",
},
"sort_direction": {
"openapi_types": (SortDirection,),
"attribute": "sort_direction",
"location": "query",
},
"sort_name": {
"openapi_types": (str,),
"attribute": "sort_name",
"location": "query",
},
"tag_breakdown_keys": {
"openapi_types": (str,),
"attribute": "tag_breakdown_keys",
"location": "query",
},
"next_record_id": {
"openapi_types": (str,),
"attribute": "next_record_id",
"location": "query",
},
"include_descendants": {
"openapi_types": (bool,),
"attribute": "include_descendants",
"location": "query",
},
},
headers_map={
"accept": ["application/json;datetime-format=rfc3339"],
},
api_client=api_client,
)
self._get_projected_cost_endpoint = _Endpoint(
settings={
"response_type": (ProjectedCostResponse,),
"auth": ["apiKeyAuth", "appKeyAuth", "AuthZ"],
"endpoint_path": "/api/v2/usage/projected_cost",
"operation_id": "get_projected_cost",
"http_method": "GET",
"version": "v2",
},
params_map={
"view": {
"openapi_types": (str,),
"attribute": "view",
"location": "query",
},
"include_connected_accounts": {
"openapi_types": (bool,),
"attribute": "include_connected_accounts",
"location": "query",
},
},
headers_map={
"accept": ["application/json;datetime-format=rfc3339"],
},
api_client=api_client,
)
self._get_usage_application_security_monitoring_endpoint = _Endpoint(
settings={
"response_type": (UsageApplicationSecurityMonitoringResponse,),
"auth": ["apiKeyAuth", "appKeyAuth", "AuthZ"],
"endpoint_path": "/api/v2/usage/application_security",
"operation_id": "get_usage_application_security_monitoring",
"http_method": "GET",
"version": "v2",
},
params_map={
"start_hr": {
"required": True,
"openapi_types": (datetime,),
"attribute": "start_hr",
"location": "query",
},
"end_hr": {
"openapi_types": (datetime,),
"attribute": "end_hr",
"location": "query",
},
},
headers_map={
"accept": ["application/json;datetime-format=rfc3339"],
},
api_client=api_client,
)
self._get_usage_attribution_types_endpoint = _Endpoint(
settings={
"response_type": (UsageAttributionTypesResponse,),
"auth": ["apiKeyAuth", "appKeyAuth", "AuthZ"],
"endpoint_path": "/api/v2/usage/usage-attribution-types",
"operation_id": "get_usage_attribution_types",
"http_method": "GET",
"version": "v2",
},
params_map={},
headers_map={
"accept": ["application/json;datetime-format=rfc3339"],
},
api_client=api_client,
)
self._get_usage_lambda_traced_invocations_endpoint = _Endpoint(
settings={
"response_type": (UsageLambdaTracedInvocationsResponse,),
"auth": ["apiKeyAuth", "appKeyAuth", "AuthZ"],
"endpoint_path": "/api/v2/usage/lambda_traced_invocations",
"operation_id": "get_usage_lambda_traced_invocations",
"http_method": "GET",
"version": "v2",
},
params_map={
"start_hr": {
"required": True,
"openapi_types": (datetime,),
"attribute": "start_hr",
"location": "query",
},
"end_hr": {
"openapi_types": (datetime,),
"attribute": "end_hr",
"location": "query",
},
},
headers_map={
"accept": ["application/json;datetime-format=rfc3339"],
},
api_client=api_client,
)
self._get_usage_observability_pipelines_endpoint = _Endpoint(
settings={
"response_type": (UsageObservabilityPipelinesResponse,),
"auth": ["apiKeyAuth", "appKeyAuth", "AuthZ"],
"endpoint_path": "/api/v2/usage/observability_pipelines",
"operation_id": "get_usage_observability_pipelines",
"http_method": "GET",
"version": "v2",
},
params_map={
"start_hr": {
"required": True,
"openapi_types": (datetime,),
"attribute": "start_hr",
"location": "query",
},
"end_hr": {
"openapi_types": (datetime,),
"attribute": "end_hr",
"location": "query",
},
},
headers_map={
"accept": ["application/json;datetime-format=rfc3339"],
},
api_client=api_client,
)
def get_active_billing_dimensions(
self,
) -> ActiveBillingDimensionsResponse:
"""Get active billing dimensions for cost attribution.
Get active billing dimensions for cost attribution. Cost data for a given month becomes available no later than the 19th of the following month.
:rtype: ActiveBillingDimensionsResponse
"""
kwargs: Dict[str, Any] = {}
return self._get_active_billing_dimensions_endpoint.call_with_http_info(**kwargs)
def get_billing_dimension_mapping(
self,
*,
filter_month: Union[datetime, UnsetType] = unset,
filter_view: Union[str, UnsetType] = unset,
) -> BillingDimensionsMappingResponse:
"""Get billing dimension mapping for usage endpoints.
Get a mapping of billing dimensions to the corresponding keys for the supported usage metering public API endpoints.
Mapping data is updated on a monthly cadence.
This endpoint is only accessible to `parent-level organizations <https://docs.datadoghq.com/account_management/multi_organization/>`_.
:param filter_month: Datetime in ISO-8601 format, UTC, and for mappings beginning this month. Defaults to the current month.
:type filter_month: datetime, optional
:param filter_view: String to specify whether to retrieve active billing dimension mappings for the contract or for all available mappings. Allowed views have the string ``active`` or ``all``. Defaults to ``active``.
:type filter_view: str, optional
:rtype: BillingDimensionsMappingResponse
"""
kwargs: Dict[str, Any] = {}
if filter_month is not unset:
kwargs["filter_month"] = filter_month
if filter_view is not unset:
kwargs["filter_view"] = filter_view
return self._get_billing_dimension_mapping_endpoint.call_with_http_info(**kwargs)
def get_cost_by_org(
self,
start_month: datetime,
*,
end_month: Union[datetime, UnsetType] = unset,
) -> CostByOrgResponse:
"""Get cost across multi-org account. **Deprecated**.
Get cost across multi-org account.
Cost by org data for a given month becomes available no later than the 16th of the following month.
**Note:** This endpoint has been deprecated. Please use the new endpoint
` ``/historical_cost`` <https://docs.datadoghq.com/api/latest/usage-metering/#get-historical-cost-across-your-account>`_
instead.
This endpoint is only accessible for `parent-level organizations <https://docs.datadoghq.com/account_management/multi_organization/>`_.
:param start_month: Datetime in ISO-8601 format, UTC, precise to month: ``[YYYY-MM]`` for cost beginning this month.
:type start_month: datetime
:param end_month: Datetime in ISO-8601 format, UTC, precise to month: ``[YYYY-MM]`` for cost ending this month.
:type end_month: datetime, optional
:rtype: CostByOrgResponse
"""
kwargs: Dict[str, Any] = {}
kwargs["start_month"] = start_month
if end_month is not unset:
kwargs["end_month"] = end_month
warnings.warn("get_cost_by_org is deprecated", DeprecationWarning, stacklevel=2)
return self._get_cost_by_org_endpoint.call_with_http_info(**kwargs)
def get_estimated_cost_by_org(
self,
*,
view: Union[str, UnsetType] = unset,
start_month: Union[datetime, UnsetType] = unset,
end_month: Union[datetime, UnsetType] = unset,
start_date: Union[datetime, UnsetType] = unset,
end_date: Union[datetime, UnsetType] = unset,
cost_aggregation: Union[CostAggregationType, UnsetType] = unset,
include_connected_accounts: Union[bool, UnsetType] = unset,
) -> CostByOrgResponse:
"""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
and is delayed by up to 72 hours from when it was incurred.
To access historical costs prior to this, use the ``/historical_cost`` endpoint.
This endpoint is only accessible for `parent-level organizations <https://docs.datadoghq.com/account_management/multi_organization/>`_.
:param view: 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``.
:type view: str, optional
:param start_month: 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). Provide an ``end_month`` to view month-over-month cost.
:type start_month: datetime, optional
:param end_month: Datetime in ISO-8601 format, UTC, precise to month: ``[YYYY-MM]`` for cost ending this month.
:type end_month: datetime, optional
:param start_date: 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). Provide an ``end_date`` to view day-over-day cumulative cost.
:type start_date: datetime, optional
:param end_date: Datetime in ISO-8601 format, UTC, precise to day: ``[YYYY-MM-DD]`` for cost ending this day.
:type end_date: datetime, optional
:param cost_aggregation: Controls how costs are aggregated when using ``start_date``. The ``cumulative`` option returns month-to-date running totals.
:type cost_aggregation: CostAggregationType, optional
:param include_connected_accounts: Boolean to specify whether to include accounts connected to the current account as partner customers in the Datadog partner network program. Defaults to ``false``.
:type include_connected_accounts: bool, optional
:rtype: CostByOrgResponse
"""
kwargs: Dict[str, Any] = {}
if view is not unset:
kwargs["view"] = view
if start_month is not unset:
kwargs["start_month"] = start_month
if end_month is not unset:
kwargs["end_month"] = end_month
if start_date is not unset:
kwargs["start_date"] = start_date
if end_date is not unset:
kwargs["end_date"] = end_date
if cost_aggregation is not unset:
kwargs["cost_aggregation"] = cost_aggregation
if include_connected_accounts is not unset:
kwargs["include_connected_accounts"] = include_connected_accounts
return self._get_estimated_cost_by_org_endpoint.call_with_http_info(**kwargs)
def get_historical_cost_by_org(
self,
start_month: datetime,
*,
view: Union[str, UnsetType] = unset,
end_month: Union[datetime, UnsetType] = unset,
include_connected_accounts: Union[bool, UnsetType] = unset,
) -> CostByOrgResponse:
"""Get historical cost across your account.
Get historical cost across multi-org and single root-org accounts.
Cost data for a given month becomes available no later than the 16th of the following month.
This endpoint is only accessible for `parent-level organizations <https://docs.datadoghq.com/account_management/multi_organization/>`_.
:param start_month: Datetime in ISO-8601 format, UTC, precise to month: ``[YYYY-MM]`` for cost beginning this month.
:type start_month: datetime
:param view: 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``.
:type view: str, optional
:param end_month: Datetime in ISO-8601 format, UTC, precise to month: ``[YYYY-MM]`` for cost ending this month.
:type end_month: datetime, optional
:param include_connected_accounts: Boolean to specify whether to include accounts connected to the current account as partner customers in the Datadog partner network program. Defaults to ``false``.
:type include_connected_accounts: bool, optional
:rtype: CostByOrgResponse
"""
kwargs: Dict[str, Any] = {}
kwargs["start_month"] = start_month
if view is not unset:
kwargs["view"] = view
if end_month is not unset:
kwargs["end_month"] = end_month
if include_connected_accounts is not unset:
kwargs["include_connected_accounts"] = include_connected_accounts
return self._get_historical_cost_by_org_endpoint.call_with_http_info(**kwargs)
def get_hourly_usage(
self,
filter_timestamp_start: datetime,
filter_product_families: str,
*,
filter_timestamp_end: Union[datetime, UnsetType] = unset,
filter_include_descendants: Union[bool, UnsetType] = unset,
filter_include_connected_accounts: Union[bool, UnsetType] = unset,
filter_include_breakdown: Union[bool, UnsetType] = unset,
filter_versions: Union[str, UnsetType] = unset,
page_limit: Union[int, UnsetType] = unset,
page_next_record_id: Union[str, UnsetType] = unset,
) -> HourlyUsageResponse:
"""Get hourly usage by product family.
Get hourly usage by product family.
:param filter_timestamp_start: Datetime in ISO-8601 format, UTC, precise to hour: [YYYY-MM-DDThh] for usage beginning at this hour.
:type filter_timestamp_start: datetime
:param filter_product_families: Comma separated list of product families to retrieve. Available families are ``all`` , ``analyzed_logs`` ,
``application_security`` , ``audit_trail`` , ``bits_ai`` , ``serverless`` , ``ci_app`` , ``cloud_cost_management`` , ``cloud_siem`` ,
``csm_container_enterprise`` , ``csm_host_enterprise`` , ``cspm`` , ``custom_events`` , ``cws`` , ``dbm`` , ``error_tracking`` ,
``fargate`` , ``infra_hosts`` , ``incident_management`` , ``indexed_logs`` , ``indexed_spans`` , ``ingested_spans`` , ``iot`` ,
``lambda_traced_invocations`` , ``llm_observability`` , ``logs`` , ``network_flows`` , ``network_hosts`` , ``network_monitoring`` ,
``observability_pipelines`` , ``online_archive`` , ``profiling`` , ``product_analytics`` , ``rum`` , ``rum_browser_sessions`` ,
``rum_mobile_sessions`` , ``sds`` , ``snmp`` , ``software_delivery`` , ``synthetics_api`` , ``synthetics_browser`` ,
``synthetics_mobile`` , ``synthetics_parallel_testing`` , ``timeseries`` , ``vuln_management`` and ``workflow_executions``.
The following product family has been **deprecated** : ``audit_logs``.
:type filter_product_families: str
:param filter_timestamp_end: Datetime in ISO-8601 format, UTC, precise to hour: [YYYY-MM-DDThh] for usage ending **before** this hour.
:type filter_timestamp_end: datetime, optional
:param filter_include_descendants: Include child org usage in the response. Defaults to false.
:type filter_include_descendants: bool, optional
:param filter_include_connected_accounts: Boolean to specify whether to include accounts connected to the current account as partner customers in the Datadog partner network program. Defaults to false.
:type filter_include_connected_accounts: bool, optional
:param filter_include_breakdown: Include breakdown of usage by subcategories where applicable (for product family logs only). Defaults to false.
:type filter_include_breakdown: bool, optional
:param filter_versions: Comma separated list of product family versions to use in the format ``product_family:version``. For example,
``infra_hosts:1.0.0``. If this parameter is not used, the API will use the latest version of each requested
product family. Currently all families have one version ``1.0.0``.
:type filter_versions: str, optional
:param page_limit: Maximum number of results to return (between 1 and 500) - defaults to 500 if limit not specified.
:type page_limit: int, optional
:param page_next_record_id: List following results with a next_record_id provided in the previous query.
:type page_next_record_id: str, optional
:rtype: HourlyUsageResponse
"""
kwargs: Dict[str, Any] = {}
kwargs["filter_timestamp_start"] = filter_timestamp_start
if filter_timestamp_end is not unset:
kwargs["filter_timestamp_end"] = filter_timestamp_end
kwargs["filter_product_families"] = filter_product_families
if filter_include_descendants is not unset:
kwargs["filter_include_descendants"] = filter_include_descendants
if filter_include_connected_accounts is not unset:
kwargs["filter_include_connected_accounts"] = filter_include_connected_accounts
if filter_include_breakdown is not unset:
kwargs["filter_include_breakdown"] = filter_include_breakdown
if filter_versions is not unset:
kwargs["filter_versions"] = filter_versions
if page_limit is not unset:
kwargs["page_limit"] = page_limit
if page_next_record_id is not unset:
kwargs["page_next_record_id"] = page_next_record_id
return self._get_hourly_usage_endpoint.call_with_http_info(**kwargs)
def get_monthly_cost_attribution(
self,
start_month: datetime,
fields: str,
*,
end_month: Union[datetime, UnsetType] = unset,
sort_direction: Union[SortDirection, UnsetType] = unset,
sort_name: Union[str, UnsetType] = unset,
tag_breakdown_keys: Union[str, UnsetType] = unset,
next_record_id: Union[str, UnsetType] = unset,
include_descendants: Union[bool, UnsetType] = unset,
) -> MonthlyCostAttributionResponse:
"""Get Monthly Cost Attribution.
Get monthly cost attribution by tag across multi-org and single root-org accounts.
Cost Attribution data for a given month becomes available no later than the 19th of the following month.
This API endpoint is paginated. To make sure you receive all records, check if the value of ``next_record_id`` is
set in the response. If it is, make another request and pass ``next_record_id`` as a parameter.
Pseudo code example:
.. code-block::
response := GetMonthlyCostAttribution(start_month, end_month)
cursor := response.metadata.pagination.next_record_id
WHILE cursor != null BEGIN
sleep(5 seconds) # Avoid running into rate limit
response := GetMonthlyCostAttribution(start_month, end_month, next_record_id=cursor)
cursor := response.metadata.pagination.next_record_id
END
This endpoint is only accessible for `parent-level organizations <https://docs.datadoghq.com/account_management/multi_organization/>`_. This endpoint is not available in the Government (US1-FED) site.
:param start_month: Datetime in ISO-8601 format, UTC, precise to month: ``[YYYY-MM]`` for cost beginning in this month.
:type start_month: datetime
:param fields: Comma-separated list specifying cost types (e.g., ``<billing_dimension>_on_demand_cost`` , ``<billing_dimension>_committed_cost`` , ``<billing_dimension>_total_cost`` ) and the
proportions ( ``<billing_dimension>_percentage_in_org`` , ``<billing_dimension>_percentage_in_account`` ). Use ``*`` to retrieve all fields.
Example: ``infra_host_on_demand_cost,infra_host_percentage_in_account``
To obtain the complete list of active billing dimensions that can be used to replace
``<billing_dimension>`` in the field names, make a request to the `Get active billing dimensions API <https://docs.datadoghq.com/api/latest/usage-metering/#get-active-billing-dimensions-for-cost-attribution>`_.
:type fields: str
:param end_month: Datetime in ISO-8601 format, UTC, precise to month: ``[YYYY-MM]`` for cost ending this month.
:type end_month: datetime, optional
:param sort_direction: The direction to sort by: ``[desc, asc]``.
:type sort_direction: SortDirection, optional
:param sort_name: The billing dimension to sort by. Always sorted by total cost. Example: ``infra_host``.
:type sort_name: str, optional
:param tag_breakdown_keys: Comma separated list of tag keys used to group cost. If no value is provided the cost will not be broken down by tags.
To see which tags are available, look for the value of ``tag_config_source`` in the API response.
:type tag_breakdown_keys: str, optional
:param next_record_id: List following results with a next_record_id provided in the previous query.
:type next_record_id: str, optional
:param include_descendants: Include child org cost in the response. Defaults to ``true``.
:type include_descendants: bool, optional
:rtype: MonthlyCostAttributionResponse
"""
kwargs: Dict[str, Any] = {}
kwargs["start_month"] = start_month
if end_month is not unset:
kwargs["end_month"] = end_month
kwargs["fields"] = fields
if sort_direction is not unset:
kwargs["sort_direction"] = sort_direction
if sort_name is not unset:
kwargs["sort_name"] = sort_name
if tag_breakdown_keys is not unset:
kwargs["tag_breakdown_keys"] = tag_breakdown_keys
if next_record_id is not unset:
kwargs["next_record_id"] = next_record_id
if include_descendants is not unset:
kwargs["include_descendants"] = include_descendants
return self._get_monthly_cost_attribution_endpoint.call_with_http_info(**kwargs)
def get_projected_cost(
self,
*,
view: Union[str, UnsetType] = unset,
include_connected_accounts: Union[bool, UnsetType] = unset,
) -> ProjectedCostResponse:
"""Get projected cost across your account.
Get projected cost across multi-org and single root-org accounts.
Projected cost data is only available for the current month and becomes available around the 12th of the month.
This endpoint is only accessible for `parent-level organizations <https://docs.datadoghq.com/account_management/multi_organization/>`_.
:param view: 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``.
:type view: str, optional
:param include_connected_accounts: Boolean to specify whether to include accounts connected to the current account as partner customers in the Datadog partner network program. Defaults to ``false``.
:type include_connected_accounts: bool, optional
:rtype: ProjectedCostResponse
"""
kwargs: Dict[str, Any] = {}
if view is not unset:
kwargs["view"] = view
if include_connected_accounts is not unset:
kwargs["include_connected_accounts"] = include_connected_accounts
return self._get_projected_cost_endpoint.call_with_http_info(**kwargs)
def get_usage_application_security_monitoring(
self,
start_hr: datetime,
*,
end_hr: Union[datetime, UnsetType] = unset,
) -> UsageApplicationSecurityMonitoringResponse:
"""Get hourly usage for application security. **Deprecated**.
Get hourly usage for application security .
**Note:** This endpoint has been deprecated. 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>`_
:param start_hr: Datetime in ISO-8601 format, UTC, precise to hour: ``[YYYY-MM-DDThh]`` for usage beginning at this hour.
:type start_hr: datetime
:param end_hr: Datetime in ISO-8601 format, UTC, precise to hour: ``[YYYY-MM-DDThh]`` for usage ending
**before** this hour.
:type end_hr: datetime, optional
:rtype: UsageApplicationSecurityMonitoringResponse
"""
kwargs: Dict[str, Any] = {}
kwargs["start_hr"] = start_hr
if end_hr is not unset:
kwargs["end_hr"] = end_hr
warnings.warn("get_usage_application_security_monitoring is deprecated", DeprecationWarning, stacklevel=2)
return self._get_usage_application_security_monitoring_endpoint.call_with_http_info(**kwargs)
def get_usage_attribution_types(
self,
) -> UsageAttributionTypesResponse:
"""Get usage attribution types.
Get usage attribution types.
:rtype: UsageAttributionTypesResponse
"""
kwargs: Dict[str, Any] = {}
return self._get_usage_attribution_types_endpoint.call_with_http_info(**kwargs)
def get_usage_lambda_traced_invocations(
self,
start_hr: datetime,
*,
end_hr: Union[datetime, UnsetType] = unset,
) -> UsageLambdaTracedInvocationsResponse:
"""Get hourly usage for Lambda traced invocations. **Deprecated**.
Get hourly usage for Lambda traced invocations.
**Note:** This endpoint has been deprecated.. 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>`_
:param start_hr: Datetime in ISO-8601 format, UTC, precise to hour: ``[YYYY-MM-DDThh]`` for usage beginning at this hour.
:type start_hr: datetime
:param end_hr: Datetime in ISO-8601 format, UTC, precise to hour: ``[YYYY-MM-DDThh]`` for usage ending
**before** this hour.
:type end_hr: datetime, optional
:rtype: UsageLambdaTracedInvocationsResponse
"""
kwargs: Dict[str, Any] = {}
kwargs["start_hr"] = start_hr
if end_hr is not unset:
kwargs["end_hr"] = end_hr
warnings.warn("get_usage_lambda_traced_invocations is deprecated", DeprecationWarning, stacklevel=2)
return self._get_usage_lambda_traced_invocations_endpoint.call_with_http_info(**kwargs)
def get_usage_observability_pipelines(
self,
start_hr: datetime,
*,
end_hr: Union[datetime, UnsetType] = unset,
) -> UsageObservabilityPipelinesResponse:
"""Get hourly usage for observability pipelines. **Deprecated**.
Get hourly usage for observability pipelines.
**Note:** This endpoint has been deprecated. 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>`_
:param start_hr: Datetime in ISO-8601 format, UTC, precise to hour: ``[YYYY-MM-DDThh]`` for usage beginning at this hour.
:type start_hr: datetime
:param end_hr: Datetime in ISO-8601 format, UTC, precise to hour: ``[YYYY-MM-DDThh]`` for usage ending
**before** this hour.
:type end_hr: datetime, optional
:rtype: UsageObservabilityPipelinesResponse
"""
kwargs: Dict[str, Any] = {}
kwargs["start_hr"] = start_hr
if end_hr is not unset:
kwargs["end_hr"] = end_hr
warnings.warn("get_usage_observability_pipelines is deprecated", DeprecationWarning, stacklevel=2)
return self._get_usage_observability_pipelines_endpoint.call_with_http_info(**kwargs)