3
3
# Copyright 2019-Present Datadog, Inc.
4
4
from __future__ import annotations
5
5
6
+ import collections
6
7
from typing import Any , Dict , Union
7
8
8
9
from datadog_api_client .api_client import ApiClient , Endpoint as _Endpoint
9
10
from datadog_api_client .configuration import Configuration
10
11
from datadog_api_client .model_utils import (
12
+ set_attribute_from_path ,
13
+ get_attribute_from_path ,
11
14
UnsetType ,
12
15
unset ,
13
16
)
17
20
from datadog_api_client .v2 .model .metric_tag_configuration_metric_type_category import (
18
21
MetricTagConfigurationMetricTypeCategory ,
19
22
)
23
+ from datadog_api_client .v2 .model .metrics_and_metric_tag_configurations import MetricsAndMetricTagConfigurations
20
24
from datadog_api_client .v2 .model .metric_bulk_tag_config_response import MetricBulkTagConfigResponse
21
25
from datadog_api_client .v2 .model .metric_bulk_tag_config_delete_request import MetricBulkTagConfigDeleteRequest
22
26
from datadog_api_client .v2 .model .metric_bulk_tag_config_create_request import MetricBulkTagConfigCreateRequest
@@ -329,6 +333,20 @@ def __init__(self, api_client=None):
329
333
"attribute" : "window[seconds]" ,
330
334
"location" : "query" ,
331
335
},
336
+ "page_size" : {
337
+ "validation" : {
338
+ "inclusive_maximum" : 10000 ,
339
+ "inclusive_minimum" : 1 ,
340
+ },
341
+ "openapi_types" : (int ,),
342
+ "attribute" : "page[size]" ,
343
+ "location" : "query" ,
344
+ },
345
+ "page_cursor" : {
346
+ "openapi_types" : (str ,),
347
+ "attribute" : "page[cursor]" ,
348
+ "location" : "query" ,
349
+ },
332
350
},
333
351
headers_map = {
334
352
"accept" : ["application/json" ],
@@ -674,10 +692,15 @@ def list_tag_configurations(
674
692
filter_queried : Union [bool , UnsetType ] = unset ,
675
693
filter_tags : Union [str , UnsetType ] = unset ,
676
694
window_seconds : Union [int , UnsetType ] = unset ,
695
+ page_size : Union [int , UnsetType ] = unset ,
696
+ page_cursor : Union [str , UnsetType ] = unset ,
677
697
) -> MetricsAndMetricTagConfigurationsResponse :
678
698
"""Get a list of metrics.
679
699
680
700
Returns all metrics that can be configured in the Metrics Summary page or with Metrics without Limits™ (matching additional filters if specified).
701
+ Optionally, paginate by using the ``page[cursor]`` and/or ``page[size]`` query parameters.
702
+ To fetch the first page, pass in a query parameter with either a valid ``page[size]`` or an empty cursor like ``page[cursor]=``. To fetch the next page, pass in the ``next_cursor`` value from the response as the new ``page[cursor]`` value.
703
+ Once the ``meta.pagination.next_cursor`` value is null, all pages have been retrieved.
681
704
682
705
:param filter_configured: Filter custom metrics that have configured tags.
683
706
:type filter_configured: bool, optional
@@ -697,6 +720,12 @@ def list_tag_configurations(
697
720
:param window_seconds: The number of seconds of look back (from now) to apply to a filter[tag] or filter[queried] query.
698
721
Default value is 3600 (1 hour), maximum value is 2,592,000 (30 days).
699
722
:type window_seconds: int, optional
723
+ :param page_size: Maximum number of results returned.
724
+ :type page_size: int, optional
725
+ :param page_cursor: String to query the next page of results.
726
+ This key is provided with each valid response from the API in ``meta.pagination.next_cursor``.
727
+ Once the ``meta.pagination.next_cursor`` key is null, all pages have been retrieved.
728
+ :type page_cursor: str, optional
700
729
:rtype: MetricsAndMetricTagConfigurationsResponse
701
730
"""
702
731
kwargs : Dict [str , Any ] = {}
@@ -721,8 +750,100 @@ def list_tag_configurations(
721
750
if window_seconds is not unset :
722
751
kwargs ["window_seconds" ] = window_seconds
723
752
753
+ if page_size is not unset :
754
+ kwargs ["page_size" ] = page_size
755
+
756
+ if page_cursor is not unset :
757
+ kwargs ["page_cursor" ] = page_cursor
758
+
724
759
return self ._list_tag_configurations_endpoint .call_with_http_info (** kwargs )
725
760
761
+ def list_tag_configurations_with_pagination (
762
+ self ,
763
+ * ,
764
+ filter_configured : Union [bool , UnsetType ] = unset ,
765
+ filter_tags_configured : Union [str , UnsetType ] = unset ,
766
+ filter_metric_type : Union [MetricTagConfigurationMetricTypeCategory , UnsetType ] = unset ,
767
+ filter_include_percentiles : Union [bool , UnsetType ] = unset ,
768
+ filter_queried : Union [bool , UnsetType ] = unset ,
769
+ filter_tags : Union [str , UnsetType ] = unset ,
770
+ window_seconds : Union [int , UnsetType ] = unset ,
771
+ page_size : Union [int , UnsetType ] = unset ,
772
+ page_cursor : Union [str , UnsetType ] = unset ,
773
+ ) -> collections .abc .Iterable [MetricsAndMetricTagConfigurations ]:
774
+ """Get a list of metrics.
775
+
776
+ Provide a paginated version of :meth:`list_tag_configurations`, returning all items.
777
+
778
+ :param filter_configured: Filter custom metrics that have configured tags.
779
+ :type filter_configured: bool, optional
780
+ :param filter_tags_configured: Filter tag configurations by configured tags.
781
+ :type filter_tags_configured: str, optional
782
+ :param filter_metric_type: Filter metrics by metric type.
783
+ :type filter_metric_type: MetricTagConfigurationMetricTypeCategory, optional
784
+ :param filter_include_percentiles: Filter distributions with additional percentile
785
+ aggregations enabled or disabled.
786
+ :type filter_include_percentiles: bool, optional
787
+ :param filter_queried: (Beta) Filter custom metrics that have or have not been queried in the specified window[seconds].
788
+ If no window is provided or the window is less than 2 hours, a default of 2 hours will be applied.
789
+ :type filter_queried: bool, optional
790
+ :param filter_tags: Filter metrics that have been submitted with the given tags. Supports boolean and wildcard expressions.
791
+ Can only be combined with the filter[queried] filter.
792
+ :type filter_tags: str, optional
793
+ :param window_seconds: The number of seconds of look back (from now) to apply to a filter[tag] or filter[queried] query.
794
+ Default value is 3600 (1 hour), maximum value is 2,592,000 (30 days).
795
+ :type window_seconds: int, optional
796
+ :param page_size: Maximum number of results returned.
797
+ :type page_size: int, optional
798
+ :param page_cursor: String to query the next page of results.
799
+ This key is provided with each valid response from the API in ``meta.pagination.next_cursor``.
800
+ Once the ``meta.pagination.next_cursor`` key is null, all pages have been retrieved.
801
+ :type page_cursor: str, optional
802
+
803
+ :return: A generator of paginated results.
804
+ :rtype: collections.abc.Iterable[MetricsAndMetricTagConfigurations]
805
+ """
806
+ kwargs : Dict [str , Any ] = {}
807
+ if filter_configured is not unset :
808
+ kwargs ["filter_configured" ] = filter_configured
809
+
810
+ if filter_tags_configured is not unset :
811
+ kwargs ["filter_tags_configured" ] = filter_tags_configured
812
+
813
+ if filter_metric_type is not unset :
814
+ kwargs ["filter_metric_type" ] = filter_metric_type
815
+
816
+ if filter_include_percentiles is not unset :
817
+ kwargs ["filter_include_percentiles" ] = filter_include_percentiles
818
+
819
+ if filter_queried is not unset :
820
+ kwargs ["filter_queried" ] = filter_queried
821
+
822
+ if filter_tags is not unset :
823
+ kwargs ["filter_tags" ] = filter_tags
824
+
825
+ if window_seconds is not unset :
826
+ kwargs ["window_seconds" ] = window_seconds
827
+
828
+ if page_size is not unset :
829
+ kwargs ["page_size" ] = page_size
830
+
831
+ if page_cursor is not unset :
832
+ kwargs ["page_cursor" ] = page_cursor
833
+
834
+ local_page_size = get_attribute_from_path (kwargs , "page_size" , 10000 )
835
+ endpoint = self ._list_tag_configurations_endpoint
836
+ set_attribute_from_path (kwargs , "page_size" , local_page_size , endpoint .params_map )
837
+ pagination = {
838
+ "limit_value" : local_page_size ,
839
+ "results_path" : "data" ,
840
+ "cursor_param" : "page_cursor" ,
841
+ "cursor_path" : "meta.pagination.next_cursor" ,
842
+ "endpoint" : endpoint ,
843
+ "kwargs" : kwargs ,
844
+ }
845
+ return endpoint .call_with_http_info_paginated (pagination )
846
+
726
847
def list_tags_by_metric_name (
727
848
self ,
728
849
metric_name : str ,
0 commit comments