From 996d15c302d5dd26b4885f414dfaff70c7941898 Mon Sep 17 00:00:00 2001 From: "ci.datadog-api-spec" Date: Wed, 20 Apr 2022 18:59:55 +0000 Subject: [PATCH] Regenerate client from commit 8df9ca3b of spec repo --- .apigentools-info | 8 +- .generator/schemas/v1/openapi.yaml | 17 +- .generator/schemas/v2/openapi.yaml | 151 ++++++++++++++++++ docs/datadog_api_client.v2.api.rst | 8 + docs/datadog_api_client.v2.model.rst | 48 ++++++ .../GetUsageObservabilityPipelines.py | 18 +++ .../v1/model/usage_summary_date.py | 5 + .../v1/model/usage_summary_date_org.py | 5 + .../v1/model/usage_summary_response.py | 5 + .../v2/api/usage_metering_api.py | 94 +++++++++++ src/datadog_api_client/v2/apis/__init__.py | 1 + .../v2/model/hourly_usage_type.py | 54 +++++++ .../v2/model/usage_attributes_object.py | 71 ++++++++ .../v2/model/usage_data_object.py | 61 +++++++ .../usage_observability_pipelines_response.py | 49 ++++++ .../v2/model/usage_time_series_object.py | 49 ++++++ .../v2/model/usage_time_series_type.py | 54 +++++++ src/datadog_api_client/v2/models/__init__.py | 6 + tests/v1/features/usage_metering.feature | 6 +- ...elines_returns_bad_request_response.frozen | 1 + ...ipelines_returns_bad_request_response.yaml | 20 +++ ...ility_pipelines_returns_ok_response.frozen | 1 + ...ability_pipelines_returns_ok_response.yaml | 20 +++ tests/v2/features/undo.json | 6 + tests/v2/features/usage_metering.feature | 30 ++++ 25 files changed, 780 insertions(+), 8 deletions(-) create mode 100644 examples/v2/usage-metering/GetUsageObservabilityPipelines.py create mode 100644 src/datadog_api_client/v2/api/usage_metering_api.py create mode 100644 src/datadog_api_client/v2/model/hourly_usage_type.py create mode 100644 src/datadog_api_client/v2/model/usage_attributes_object.py create mode 100644 src/datadog_api_client/v2/model/usage_data_object.py create mode 100644 src/datadog_api_client/v2/model/usage_observability_pipelines_response.py create mode 100644 src/datadog_api_client/v2/model/usage_time_series_object.py create mode 100644 src/datadog_api_client/v2/model/usage_time_series_type.py create mode 100644 tests/v2/cassettes/test_scenarios/test_get_hourly_usage_for_observability_pipelines_returns_bad_request_response.frozen create mode 100644 tests/v2/cassettes/test_scenarios/test_get_hourly_usage_for_observability_pipelines_returns_bad_request_response.yaml create mode 100644 tests/v2/cassettes/test_scenarios/test_get_hourly_usage_for_observability_pipelines_returns_ok_response.frozen create mode 100644 tests/v2/cassettes/test_scenarios/test_get_hourly_usage_for_observability_pipelines_returns_ok_response.yaml create mode 100644 tests/v2/features/usage_metering.feature diff --git a/.apigentools-info b/.apigentools-info index e134a8ac42..478549e97f 100644 --- a/.apigentools-info +++ b/.apigentools-info @@ -4,13 +4,13 @@ "spec_versions": { "v1": { "apigentools_version": "1.6.2", - "regenerated": "2022-04-20 13:39:47.339075", - "spec_repo_commit": "7cce8766" + "regenerated": "2022-04-20 18:58:38.947898", + "spec_repo_commit": "8df9ca3b" }, "v2": { "apigentools_version": "1.6.2", - "regenerated": "2022-04-20 13:39:47.354440", - "spec_repo_commit": "7cce8766" + "regenerated": "2022-04-20 18:58:38.961982", + "spec_repo_commit": "8df9ca3b" } } } \ No newline at end of file diff --git a/.generator/schemas/v1/openapi.yaml b/.generator/schemas/v1/openapi.yaml index ad4a78179f..3e0ead26fb 100644 --- a/.generator/schemas/v1/openapi.yaml +++ b/.generator/schemas/v1/openapi.yaml @@ -14613,6 +14613,11 @@ components: all hours in the current date for all organizations. format: int64 type: integer + observability_pipelines_bytes_processed_sum: + description: Sum of all observability pipelines bytes processed over all + hours in the current date for the given org. + format: int64 + type: integer online_archive_events_count_sum: description: Sum of all online archived events over all hours in the current date for all organizations. @@ -14930,6 +14935,11 @@ components: all hours in the current date for the given org. format: int64 type: integer + observability_pipelines_bytes_processed_sum: + description: Sum of all observability pipelines bytes processed over all + hours in the current date for the given org. + format: int64 + type: integer online_archive_events_count_sum: description: Sum of all online archived events over all hours in the current date for the given org. @@ -15271,6 +15281,11 @@ components: all hours in the current months for all organizations. format: int64 type: integer + observability_pipelines_bytes_processed_agg_sum: + description: Sum of all observability pipelines bytes processed over all + hours in the current months for all organizations. + format: int64 + type: integer online_archive_events_count_agg_sum: description: Sum of all online archived events over all hours in the current months for all organizations. @@ -28435,7 +28450,7 @@ tags: **Note**: Usage data is delayed by up to 72 hours from when it was incurred. - It is retained for the past 15 months. + It is retained for 15 months. You can retrieve up to 24 hours of hourly usage data for multiple organizations, diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 1d7f67fb8c..b64091ff4a 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -1594,6 +1594,14 @@ components: required: - name type: object + HourlyUsageType: + description: Usage type that is being measured. + enum: + - observability_pipelines_bytes_processed + example: observability_pipelines_bytes_processed + type: string + x-enum-varnames: + - OBSERVABILITY_PIPELINES_BYTES_PROCESSSED IdPMetadataFormData: description: The form data submitted to upload IdP metadata properties: @@ -6454,6 +6462,69 @@ components: required: - data type: object + UsageAttributesObject: + description: Usage attributes data. + properties: + org_name: + description: The organization name. + type: string + product_family: + description: The product for which usage is being reported. + type: string + public_id: + description: The organization public ID. + type: string + timeseries: + description: List of usage data reported for each requested hour. + items: + $ref: '#/components/schemas/UsageTimeSeriesObject' + type: array + usage_type: + $ref: '#/components/schemas/HourlyUsageType' + type: object + UsageDataObject: + description: Usage data. + properties: + attributes: + $ref: '#/components/schemas/UsageAttributesObject' + id: + description: Unique ID of the response. + type: string + type: + $ref: '#/components/schemas/UsageTimeSeriesType' + type: object + UsageObservabilityPipelinesResponse: + description: Observability Pipelines usage response. + properties: + data: + description: Response containing Observability Pipelines usage. + items: + $ref: '#/components/schemas/UsageDataObject' + type: array + type: object + UsageTimeSeriesObject: + description: Usage timeseries data. + properties: + timestamp: + description: Datetime in ISO-8601 format, UTC. The hour for the usage. + format: date-time + type: string + value: + description: Contains the number measured for the given usage_type during + the hour. + format: int64 + nullable: true + type: integer + type: object + UsageTimeSeriesType: + default: usage_timeseries + description: Type of usage data. + enum: + - usage_timeseries + example: usage_timeseries + type: string + x-enum-varnames: + - USAGE_TIMESERIES User: description: User object returned by the API. properties: @@ -11930,6 +12001,65 @@ paths: x-unstable: '**Note**: This endpoint is in public beta. If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' + /api/v2/usage/observability_pipelines: + get: + description: Get hourly usage for Observability Pipelines. + operationId: GetUsageObservabilityPipelines + parameters: + - description: 'Datetime in ISO-8601 format, UTC, precise to hour: `[YYYY-MM-DDThh]` + for usage beginning at this hour.' + in: query + name: start_hr + required: true + schema: + format: date-time + type: string + - description: 'Datetime in ISO-8601 format, UTC, precise to hour: `[YYYY-MM-DDThh]` + for usage ending + + **before** this hour.' + in: query + name: end_hr + required: false + schema: + format: date-time + type: string + responses: + '200': + content: + application/json;datetime-format=rfc3339: + schema: + $ref: '#/components/schemas/UsageObservabilityPipelinesResponse' + description: OK + '400': + content: + application/json;datetime-format=rfc3339: + schema: + $ref: '#/components/schemas/APIErrorResponse' + description: Bad Request + '403': + content: + application/json;datetime-format=rfc3339: + schema: + $ref: '#/components/schemas/APIErrorResponse' + description: Forbidden - User is not authorized + '429': + content: + application/json;datetime-format=rfc3339: + schema: + $ref: '#/components/schemas/APIErrorResponse' + description: Too many requests + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - usage_read + summary: Get hourly usage for Observability Pipelines + tags: + - Usage Metering + x-menu-order: 38 + x-undo: + type: safe /api/v2/user_invitations: post: description: Sends emails to one or more users inviting them to join the organization. @@ -12501,6 +12631,27 @@ tags: name: Security Monitoring - description: Create, edit, and disable service accounts. name: Service Accounts +- description: '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. + + Usage is only accessible for [parent-level organizations](https://docs.datadoghq.com/account_management/multi_organization/). + + + **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.' + externalDocs: + description: Find out more at + url: https://docs.datadoghq.com/account_management/billing/usage_details/ + name: Usage Metering - description: Create, edit, and disable users. externalDocs: url: https://docs.datadoghq.com/account_management/users diff --git a/docs/datadog_api_client.v2.api.rst b/docs/datadog_api_client.v2.api.rst index 227df61e2d..12861899ce 100644 --- a/docs/datadog_api_client.v2.api.rst +++ b/docs/datadog_api_client.v2.api.rst @@ -145,6 +145,14 @@ service\_accounts\_api :undoc-members: :show-inheritance: +usage\_metering\_api +-------------------- + +.. automodule:: datadog_api_client.v2.api.usage_metering_api + :members: + :undoc-members: + :show-inheritance: + users\_api ---------- diff --git a/docs/datadog_api_client.v2.model.rst b/docs/datadog_api_client.v2.model.rst index fcd2deddcd..eabc23772a 100644 --- a/docs/datadog_api_client.v2.model.rst +++ b/docs/datadog_api_client.v2.model.rst @@ -673,6 +673,14 @@ full\_application\_key\_attributes :undoc-members: :show-inheritance: +hourly\_usage\_type +------------------- + +.. automodule:: datadog_api_client.v2.model.hourly_usage_type + :members: + :undoc-members: + :show-inheritance: + http\_log --------- @@ -3281,6 +3289,46 @@ service\_account\_create\_request :undoc-members: :show-inheritance: +usage\_attributes\_object +------------------------- + +.. automodule:: datadog_api_client.v2.model.usage_attributes_object + :members: + :undoc-members: + :show-inheritance: + +usage\_data\_object +------------------- + +.. automodule:: datadog_api_client.v2.model.usage_data_object + :members: + :undoc-members: + :show-inheritance: + +usage\_observability\_pipelines\_response +----------------------------------------- + +.. automodule:: datadog_api_client.v2.model.usage_observability_pipelines_response + :members: + :undoc-members: + :show-inheritance: + +usage\_time\_series\_object +--------------------------- + +.. automodule:: datadog_api_client.v2.model.usage_time_series_object + :members: + :undoc-members: + :show-inheritance: + +usage\_time\_series\_type +------------------------- + +.. automodule:: datadog_api_client.v2.model.usage_time_series_type + :members: + :undoc-members: + :show-inheritance: + user ---- diff --git a/examples/v2/usage-metering/GetUsageObservabilityPipelines.py b/examples/v2/usage-metering/GetUsageObservabilityPipelines.py new file mode 100644 index 0000000000..efe0838520 --- /dev/null +++ b/examples/v2/usage-metering/GetUsageObservabilityPipelines.py @@ -0,0 +1,18 @@ +""" +Get hourly usage for Observability Pipelines returns "OK" response +""" + +from datetime import datetime +from dateutil.relativedelta import relativedelta +from datadog_api_client.v2 import ApiClient, Configuration +from datadog_api_client.v2.api.usage_metering_api import UsageMeteringApi + +configuration = Configuration() +with ApiClient(configuration) as api_client: + api_instance = UsageMeteringApi(api_client) + response = api_instance.get_usage_observability_pipelines( + start_hr=(datetime.now() + relativedelta(days=-5)).isoformat(timespec="seconds"), + end_hr=(datetime.now() + relativedelta(days=-3)).isoformat(timespec="seconds"), + ) + + print(response) diff --git a/src/datadog_api_client/v1/model/usage_summary_date.py b/src/datadog_api_client/v1/model/usage_summary_date.py index 2b9e1f9fa9..5a48c4b282 100644 --- a/src/datadog_api_client/v1/model/usage_summary_date.py +++ b/src/datadog_api_client/v1/model/usage_summary_date.py @@ -68,6 +68,7 @@ def openapi_types(_): "mobile_rum_units_sum": (int,), "netflow_indexed_events_count_sum": (int,), "npm_host_top99p": (int,), + "observability_pipelines_bytes_processed_sum": (int,), "online_archive_events_count_sum": (int,), "opentelemetry_host_top99p": (int,), "orgs": ([UsageSummaryDateOrg],), @@ -133,6 +134,7 @@ def openapi_types(_): "mobile_rum_units_sum": "mobile_rum_units_sum", "netflow_indexed_events_count_sum": "netflow_indexed_events_count_sum", "npm_host_top99p": "npm_host_top99p", + "observability_pipelines_bytes_processed_sum": "observability_pipelines_bytes_processed_sum", "online_archive_events_count_sum": "online_archive_events_count_sum", "opentelemetry_host_top99p": "opentelemetry_host_top99p", "orgs": "orgs", @@ -295,6 +297,9 @@ def __init__(self, *args, **kwargs): :param npm_host_top99p: Shows the 99th percentile of all distinct Networks hosts over all hours in the current date for all organizations. :type npm_host_top99p: int, optional + :param observability_pipelines_bytes_processed_sum: Sum of all observability pipelines bytes processed over all hours in the current date for the given org. + :type observability_pipelines_bytes_processed_sum: int, optional + :param online_archive_events_count_sum: Sum of all online archived events over all hours in the current date for all organizations. :type online_archive_events_count_sum: int, optional diff --git a/src/datadog_api_client/v1/model/usage_summary_date_org.py b/src/datadog_api_client/v1/model/usage_summary_date_org.py index e287f3f5d6..d0e6510c0e 100644 --- a/src/datadog_api_client/v1/model/usage_summary_date_org.py +++ b/src/datadog_api_client/v1/model/usage_summary_date_org.py @@ -61,6 +61,7 @@ def openapi_types(_): "name": (str,), "netflow_indexed_events_count_sum": (int,), "npm_host_top99p": (int,), + "observability_pipelines_bytes_processed_sum": (int,), "online_archive_events_count_sum": (int,), "opentelemetry_host_top99p": (int,), "profiling_host_top99p": (int,), @@ -127,6 +128,7 @@ def openapi_types(_): "name": "name", "netflow_indexed_events_count_sum": "netflow_indexed_events_count_sum", "npm_host_top99p": "npm_host_top99p", + "observability_pipelines_bytes_processed_sum": "observability_pipelines_bytes_processed_sum", "online_archive_events_count_sum": "online_archive_events_count_sum", "opentelemetry_host_top99p": "opentelemetry_host_top99p", "profiling_host_top99p": "profiling_host_top99p", @@ -292,6 +294,9 @@ def __init__(self, *args, **kwargs): :param npm_host_top99p: Shows the 99th percentile of all distinct Networks hosts over all hours in the current date for the given org. :type npm_host_top99p: int, optional + :param observability_pipelines_bytes_processed_sum: Sum of all observability pipelines bytes processed over all hours in the current date for the given org. + :type observability_pipelines_bytes_processed_sum: int, optional + :param online_archive_events_count_sum: Sum of all online archived events over all hours in the current date for the given org. :type online_archive_events_count_sum: int, optional diff --git a/src/datadog_api_client/v1/model/usage_summary_response.py b/src/datadog_api_client/v1/model/usage_summary_response.py index 2d4ec0485b..c4356139c9 100644 --- a/src/datadog_api_client/v1/model/usage_summary_response.py +++ b/src/datadog_api_client/v1/model/usage_summary_response.py @@ -75,6 +75,7 @@ def openapi_types(_): "mobile_rum_units_agg_sum": (int,), "netflow_indexed_events_count_agg_sum": (int,), "npm_host_top99p_sum": (int,), + "observability_pipelines_bytes_processed_agg_sum": (int,), "online_archive_events_count_agg_sum": (int,), "opentelemetry_host_top99p_sum": (int,), "profiling_container_agent_count_avg": (int,), @@ -149,6 +150,7 @@ def openapi_types(_): "mobile_rum_units_agg_sum": "mobile_rum_units_agg_sum", "netflow_indexed_events_count_agg_sum": "netflow_indexed_events_count_agg_sum", "npm_host_top99p_sum": "npm_host_top99p_sum", + "observability_pipelines_bytes_processed_agg_sum": "observability_pipelines_bytes_processed_agg_sum", "online_archive_events_count_agg_sum": "online_archive_events_count_agg_sum", "opentelemetry_host_top99p_sum": "opentelemetry_host_top99p_sum", "profiling_container_agent_count_avg": "profiling_container_agent_count_avg", @@ -330,6 +332,9 @@ def __init__(self, *args, **kwargs): :param npm_host_top99p_sum: Shows the 99th percentile of all distinct Networks hosts over all hours in the current months for all organizations. :type npm_host_top99p_sum: int, optional + :param observability_pipelines_bytes_processed_agg_sum: Sum of all observability pipelines bytes processed over all hours in the current months for all organizations. + :type observability_pipelines_bytes_processed_agg_sum: int, optional + :param online_archive_events_count_agg_sum: Sum of all online archived events over all hours in the current months for all organizations. :type online_archive_events_count_agg_sum: int, optional diff --git a/src/datadog_api_client/v2/api/usage_metering_api.py b/src/datadog_api_client/v2/api/usage_metering_api.py new file mode 100644 index 0000000000..298f7fedc3 --- /dev/null +++ b/src/datadog_api_client/v2/api/usage_metering_api.py @@ -0,0 +1,94 @@ +# 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 datadog_api_client.api_client import ApiClient, Endpoint as _Endpoint +from datadog_api_client.model_utils import ( + datetime, +) +from datadog_api_client.v2.model.usage_observability_pipelines_response import UsageObservabilityPipelinesResponse + + +class UsageMeteringApi: + def __init__(self, api_client=None): + if api_client is None: + api_client = ApiClient() + self.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", + "servers": None, + }, + 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"], + "content_type": [], + }, + api_client=api_client, + ) + + def get_usage_observability_pipelines(self, start_hr, **kwargs): + """Get hourly usage for Observability Pipelines. + + Get hourly usage for Observability Pipelines. + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True. + + >>> thread = api.get_usage_observability_pipelines(start_hr, async_req=True) + >>> result = thread.get() + + :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 + :param _return_http_data_only: Response data without head status + code and headers. Default is True. + :type _return_http_data_only: bool + :param _preload_content: If False, the urllib3.HTTPResponse object + will be returned without reading/decoding response data. + Default is True. + :type _preload_content: bool + :param _request_timeout: Timeout setting for this request. If one + number provided, it will be total request timeout. It can also be a + pair (tuple) of (connection, read) timeouts. Default is None. + :type _request_timeout: float/tuple + :param _check_input_type: Specifies if type checking should be done one + the data sent to the server. Default is True. + :type _check_input_type: bool + :param _check_return_type: Specifies if type checking should be done + one the data received from the server. Default is True. + :type _check_return_type: bool + :param _host_index: Specifies the index of the server that we want to + use. Default is read from the configuration. + :type _host_index: int/None + :param async_req: Execute request asynchronously. + :type async_req: bool + + :return: If the method is called asynchronously, returns the request thread. + :rtype: UsageObservabilityPipelinesResponse + """ + kwargs = self._get_usage_observability_pipelines_endpoint.default_arguments(kwargs) + kwargs["start_hr"] = start_hr + + return self._get_usage_observability_pipelines_endpoint.call_with_http_info(**kwargs) diff --git a/src/datadog_api_client/v2/apis/__init__.py b/src/datadog_api_client/v2/apis/__init__.py index a3df385498..6dead9e63c 100644 --- a/src/datadog_api_client/v2/apis/__init__.py +++ b/src/datadog_api_client/v2/apis/__init__.py @@ -16,4 +16,5 @@ from datadog_api_client.v2.api.roles_api import RolesApi from datadog_api_client.v2.api.security_monitoring_api import SecurityMonitoringApi from datadog_api_client.v2.api.service_accounts_api import ServiceAccountsApi +from datadog_api_client.v2.api.usage_metering_api import UsageMeteringApi from datadog_api_client.v2.api.users_api import UsersApi diff --git a/src/datadog_api_client/v2/model/hourly_usage_type.py b/src/datadog_api_client/v2/model/hourly_usage_type.py new file mode 100644 index 0000000000..11d814b596 --- /dev/null +++ b/src/datadog_api_client/v2/model/hourly_usage_type.py @@ -0,0 +1,54 @@ +# 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 datadog_api_client.model_utils import ( + ModelSimple, + cached_property, +) + + +class HourlyUsageType(ModelSimple): + + allowed_values = { + "value": { + "OBSERVABILITY_PIPELINES_BYTES_PROCESSSED": "observability_pipelines_bytes_processed", + }, + } + + @cached_property + def openapi_types(_): + return { + "value": (str,), + } + + def __init__(self, *args, **kwargs): + """ + Usage type that is being measured. + + Note that value can be passed either in args or in kwargs, but not in both. + + :param value: If omitted defaults to "observability_pipelines_bytes_processed". Must be one of ["observability_pipelines_bytes_processed"]. + :type value: str + """ + super().__init__(kwargs) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + value = "observability_pipelines_bytes_processed" + + self._check_pos_args(args) + + self.value = value + + self._check_kw_args(kwargs) + + @classmethod + def _from_openapi_data(cls, *args, **kwargs): + """Helper creating a new instance from a response.""" + return cls(*args, **kwargs) diff --git a/src/datadog_api_client/v2/model/usage_attributes_object.py b/src/datadog_api_client/v2/model/usage_attributes_object.py new file mode 100644 index 0000000000..e82589eb46 --- /dev/null +++ b/src/datadog_api_client/v2/model/usage_attributes_object.py @@ -0,0 +1,71 @@ +# 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 datadog_api_client.model_utils import ( + ModelNormal, + cached_property, +) + + +def lazy_import(): + from datadog_api_client.v2.model.usage_time_series_object import UsageTimeSeriesObject + from datadog_api_client.v2.model.hourly_usage_type import HourlyUsageType + + globals()["UsageTimeSeriesObject"] = UsageTimeSeriesObject + globals()["HourlyUsageType"] = HourlyUsageType + + +class UsageAttributesObject(ModelNormal): + @cached_property + def openapi_types(_): + lazy_import() + return { + "org_name": (str,), + "product_family": (str,), + "public_id": (str,), + "timeseries": ([UsageTimeSeriesObject],), + "usage_type": (HourlyUsageType,), + } + + attribute_map = { + "org_name": "org_name", + "product_family": "product_family", + "public_id": "public_id", + "timeseries": "timeseries", + "usage_type": "usage_type", + } + + def __init__(self, *args, **kwargs): + """ + Usage attributes data. + + :param org_name: The organization name. + :type org_name: str, optional + + :param product_family: The product for which usage is being reported. + :type product_family: str, optional + + :param public_id: The organization public ID. + :type public_id: str, optional + + :param timeseries: List of usage data reported for each requested hour. + :type timeseries: [UsageTimeSeriesObject], optional + + :param usage_type: Usage type that is being measured. + :type usage_type: HourlyUsageType, optional + """ + super().__init__(kwargs) + + self._check_pos_args(args) + + @classmethod + def _from_openapi_data(cls, *args, **kwargs): + """Helper creating a new instance from a response.""" + + self = super(UsageAttributesObject, cls)._from_openapi_data(kwargs) + + self._check_pos_args(args) + + return self diff --git a/src/datadog_api_client/v2/model/usage_data_object.py b/src/datadog_api_client/v2/model/usage_data_object.py new file mode 100644 index 0000000000..aa83251224 --- /dev/null +++ b/src/datadog_api_client/v2/model/usage_data_object.py @@ -0,0 +1,61 @@ +# 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 datadog_api_client.model_utils import ( + ModelNormal, + cached_property, +) + + +def lazy_import(): + from datadog_api_client.v2.model.usage_attributes_object import UsageAttributesObject + from datadog_api_client.v2.model.usage_time_series_type import UsageTimeSeriesType + + globals()["UsageAttributesObject"] = UsageAttributesObject + globals()["UsageTimeSeriesType"] = UsageTimeSeriesType + + +class UsageDataObject(ModelNormal): + @cached_property + def openapi_types(_): + lazy_import() + return { + "attributes": (UsageAttributesObject,), + "id": (str,), + "type": (UsageTimeSeriesType,), + } + + attribute_map = { + "attributes": "attributes", + "id": "id", + "type": "type", + } + + def __init__(self, *args, **kwargs): + """ + Usage data. + + :param attributes: Usage attributes data. + :type attributes: UsageAttributesObject, optional + + :param id: Unique ID of the response. + :type id: str, optional + + :param type: Type of usage data. + :type type: UsageTimeSeriesType, optional + """ + super().__init__(kwargs) + + self._check_pos_args(args) + + @classmethod + def _from_openapi_data(cls, *args, **kwargs): + """Helper creating a new instance from a response.""" + + self = super(UsageDataObject, cls)._from_openapi_data(kwargs) + + self._check_pos_args(args) + + return self diff --git a/src/datadog_api_client/v2/model/usage_observability_pipelines_response.py b/src/datadog_api_client/v2/model/usage_observability_pipelines_response.py new file mode 100644 index 0000000000..b9fe5c9abb --- /dev/null +++ b/src/datadog_api_client/v2/model/usage_observability_pipelines_response.py @@ -0,0 +1,49 @@ +# 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 datadog_api_client.model_utils import ( + ModelNormal, + cached_property, +) + + +def lazy_import(): + from datadog_api_client.v2.model.usage_data_object import UsageDataObject + + globals()["UsageDataObject"] = UsageDataObject + + +class UsageObservabilityPipelinesResponse(ModelNormal): + @cached_property + def openapi_types(_): + lazy_import() + return { + "data": ([UsageDataObject],), + } + + attribute_map = { + "data": "data", + } + + def __init__(self, *args, **kwargs): + """ + Observability Pipelines usage response. + + :param data: Response containing Observability Pipelines usage. + :type data: [UsageDataObject], optional + """ + super().__init__(kwargs) + + self._check_pos_args(args) + + @classmethod + def _from_openapi_data(cls, *args, **kwargs): + """Helper creating a new instance from a response.""" + + self = super(UsageObservabilityPipelinesResponse, cls)._from_openapi_data(kwargs) + + self._check_pos_args(args) + + return self diff --git a/src/datadog_api_client/v2/model/usage_time_series_object.py b/src/datadog_api_client/v2/model/usage_time_series_object.py new file mode 100644 index 0000000000..ad4b020bbe --- /dev/null +++ b/src/datadog_api_client/v2/model/usage_time_series_object.py @@ -0,0 +1,49 @@ +# 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 datadog_api_client.model_utils import ( + ModelNormal, + cached_property, + datetime, + none_type, +) + + +class UsageTimeSeriesObject(ModelNormal): + @cached_property + def openapi_types(_): + return { + "timestamp": (datetime,), + "value": (int, none_type), + } + + attribute_map = { + "timestamp": "timestamp", + "value": "value", + } + + def __init__(self, *args, **kwargs): + """ + Usage timeseries data. + + :param timestamp: Datetime in ISO-8601 format, UTC. The hour for the usage. + :type timestamp: datetime, optional + + :param value: Contains the number measured for the given usage_type during the hour. + :type value: int, none_type, optional + """ + super().__init__(kwargs) + + self._check_pos_args(args) + + @classmethod + def _from_openapi_data(cls, *args, **kwargs): + """Helper creating a new instance from a response.""" + + self = super(UsageTimeSeriesObject, cls)._from_openapi_data(kwargs) + + self._check_pos_args(args) + + return self diff --git a/src/datadog_api_client/v2/model/usage_time_series_type.py b/src/datadog_api_client/v2/model/usage_time_series_type.py new file mode 100644 index 0000000000..b9673db875 --- /dev/null +++ b/src/datadog_api_client/v2/model/usage_time_series_type.py @@ -0,0 +1,54 @@ +# 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 datadog_api_client.model_utils import ( + ModelSimple, + cached_property, +) + + +class UsageTimeSeriesType(ModelSimple): + + allowed_values = { + "value": { + "USAGE_TIMESERIES": "usage_timeseries", + }, + } + + @cached_property + def openapi_types(_): + return { + "value": (str,), + } + + def __init__(self, *args, **kwargs): + """ + Type of usage data. + + Note that value can be passed either in args or in kwargs, but not in both. + + :param value: If omitted defaults to "usage_timeseries". Must be one of ["usage_timeseries"]. + :type value: str + """ + super().__init__(kwargs) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + value = "usage_timeseries" + + self._check_pos_args(args) + + self.value = value + + self._check_kw_args(kwargs) + + @classmethod + def _from_openapi_data(cls, *args, **kwargs): + """Helper creating a new instance from a response.""" + return cls(*args, **kwargs) diff --git a/src/datadog_api_client/v2/models/__init__.py b/src/datadog_api_client/v2/models/__init__.py index e3e8122bdd..1d427f44bf 100644 --- a/src/datadog_api_client/v2/models/__init__.py +++ b/src/datadog_api_client/v2/models/__init__.py @@ -108,6 +108,7 @@ from datadog_api_client.v2.model.http_log_error import HTTPLogError from datadog_api_client.v2.model.http_log_errors import HTTPLogErrors from datadog_api_client.v2.model.http_log_item import HTTPLogItem +from datadog_api_client.v2.model.hourly_usage_type import HourlyUsageType from datadog_api_client.v2.model.idp_metadata_form_data import IdPMetadataFormData from datadog_api_client.v2.model.incident_create_attributes import IncidentCreateAttributes from datadog_api_client.v2.model.incident_create_data import IncidentCreateData @@ -478,6 +479,11 @@ from datadog_api_client.v2.model.service_account_create_attributes import ServiceAccountCreateAttributes from datadog_api_client.v2.model.service_account_create_data import ServiceAccountCreateData from datadog_api_client.v2.model.service_account_create_request import ServiceAccountCreateRequest +from datadog_api_client.v2.model.usage_attributes_object import UsageAttributesObject +from datadog_api_client.v2.model.usage_data_object import UsageDataObject +from datadog_api_client.v2.model.usage_observability_pipelines_response import UsageObservabilityPipelinesResponse +from datadog_api_client.v2.model.usage_time_series_object import UsageTimeSeriesObject +from datadog_api_client.v2.model.usage_time_series_type import UsageTimeSeriesType from datadog_api_client.v2.model.user import User from datadog_api_client.v2.model.user_attributes import UserAttributes from datadog_api_client.v2.model.user_create_attributes import UserCreateAttributes diff --git a/tests/v1/features/usage_metering.feature b/tests/v1/features/usage_metering.feature index 743c0f4d7e..a322787840 100644 --- a/tests/v1/features/usage_metering.feature +++ b/tests/v1/features/usage_metering.feature @@ -5,9 +5,9 @@ Feature: Usage Metering Enterprise customers. Usage is only accessible for [parent-level organizat ions](https://docs.datadoghq.com/account_management/multi_organization/). **Note**: Usage data is delayed by up to 72 hours from when it was - incurred. It is retained for the past 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. + 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. Background: Given a valid "apiKeyAuth" key in the system diff --git a/tests/v2/cassettes/test_scenarios/test_get_hourly_usage_for_observability_pipelines_returns_bad_request_response.frozen b/tests/v2/cassettes/test_scenarios/test_get_hourly_usage_for_observability_pipelines_returns_bad_request_response.frozen new file mode 100644 index 0000000000..497111cfbe --- /dev/null +++ b/tests/v2/cassettes/test_scenarios/test_get_hourly_usage_for_observability_pipelines_returns_bad_request_response.frozen @@ -0,0 +1 @@ +2022-04-20T18:23:39.831Z \ No newline at end of file diff --git a/tests/v2/cassettes/test_scenarios/test_get_hourly_usage_for_observability_pipelines_returns_bad_request_response.yaml b/tests/v2/cassettes/test_scenarios/test_get_hourly_usage_for_observability_pipelines_returns_bad_request_response.yaml new file mode 100644 index 0000000000..e4d5b89be4 --- /dev/null +++ b/tests/v2/cassettes/test_scenarios/test_get_hourly_usage_for_observability_pipelines_returns_bad_request_response.yaml @@ -0,0 +1,20 @@ +interactions: +- request: + body: null + headers: + accept: + - application/json;datetime-format=rfc3339 + method: GET + uri: https://api.datadoghq.com/api/v2/usage/observability_pipelines?start_hr=2022-04-17T18%3A23%3A39.831Z&end_hr=2022-04-15T18%3A23%3A39.831Z + response: + body: + string: '{"errors":["start_hr [YYYY-MM-DDThh] must be before end_hr [YYYY-MM-DDThh]"]} + + ' + headers: + content-type: + - application/json + status: + code: 400 + message: Bad Request +version: 1 diff --git a/tests/v2/cassettes/test_scenarios/test_get_hourly_usage_for_observability_pipelines_returns_ok_response.frozen b/tests/v2/cassettes/test_scenarios/test_get_hourly_usage_for_observability_pipelines_returns_ok_response.frozen new file mode 100644 index 0000000000..4d818160b8 --- /dev/null +++ b/tests/v2/cassettes/test_scenarios/test_get_hourly_usage_for_observability_pipelines_returns_ok_response.frozen @@ -0,0 +1 @@ +2022-04-20T18:23:40.123Z \ No newline at end of file diff --git a/tests/v2/cassettes/test_scenarios/test_get_hourly_usage_for_observability_pipelines_returns_ok_response.yaml b/tests/v2/cassettes/test_scenarios/test_get_hourly_usage_for_observability_pipelines_returns_ok_response.yaml new file mode 100644 index 0000000000..3416f9a4f9 --- /dev/null +++ b/tests/v2/cassettes/test_scenarios/test_get_hourly_usage_for_observability_pipelines_returns_ok_response.yaml @@ -0,0 +1,20 @@ +interactions: +- request: + body: null + headers: + accept: + - application/json;datetime-format=rfc3339 + method: GET + uri: https://api.datadoghq.com/api/v2/usage/observability_pipelines?start_hr=2022-04-15T18%3A23%3A40.123Z&end_hr=2022-04-17T18%3A23%3A40.123Z + response: + body: + string: '{"data":[{"attributes":{"org_name":"DD Integration Tests (321813)","usage_type":"observability_pipelines_bytes_processed","public_id":"fasjyydbcgwwc2uc","timeseries":[{"timestamp":"2022-04-15T18:00:00+00:00","value":null},{"timestamp":"2022-04-15T19:00:00+00:00","value":null},{"timestamp":"2022-04-15T20:00:00+00:00","value":null},{"timestamp":"2022-04-15T21:00:00+00:00","value":null},{"timestamp":"2022-04-15T22:00:00+00:00","value":null},{"timestamp":"2022-04-15T23:00:00+00:00","value":null},{"timestamp":"2022-04-16T00:00:00+00:00","value":null},{"timestamp":"2022-04-16T01:00:00+00:00","value":null},{"timestamp":"2022-04-16T02:00:00+00:00","value":null},{"timestamp":"2022-04-16T03:00:00+00:00","value":null},{"timestamp":"2022-04-16T04:00:00+00:00","value":null},{"timestamp":"2022-04-16T05:00:00+00:00","value":null},{"timestamp":"2022-04-16T06:00:00+00:00","value":null},{"timestamp":"2022-04-16T07:00:00+00:00","value":null},{"timestamp":"2022-04-16T08:00:00+00:00","value":null},{"timestamp":"2022-04-16T09:00:00+00:00","value":null},{"timestamp":"2022-04-16T10:00:00+00:00","value":null},{"timestamp":"2022-04-16T11:00:00+00:00","value":null},{"timestamp":"2022-04-16T12:00:00+00:00","value":null},{"timestamp":"2022-04-16T13:00:00+00:00","value":null},{"timestamp":"2022-04-16T14:00:00+00:00","value":null},{"timestamp":"2022-04-16T15:00:00+00:00","value":null},{"timestamp":"2022-04-16T16:00:00+00:00","value":null},{"timestamp":"2022-04-16T17:00:00+00:00","value":null},{"timestamp":"2022-04-16T18:00:00+00:00","value":null},{"timestamp":"2022-04-16T19:00:00+00:00","value":null},{"timestamp":"2022-04-16T20:00:00+00:00","value":null},{"timestamp":"2022-04-16T21:00:00+00:00","value":null},{"timestamp":"2022-04-16T22:00:00+00:00","value":null},{"timestamp":"2022-04-16T23:00:00+00:00","value":null},{"timestamp":"2022-04-17T00:00:00+00:00","value":null},{"timestamp":"2022-04-17T01:00:00+00:00","value":null},{"timestamp":"2022-04-17T02:00:00+00:00","value":null},{"timestamp":"2022-04-17T03:00:00+00:00","value":null},{"timestamp":"2022-04-17T04:00:00+00:00","value":null},{"timestamp":"2022-04-17T05:00:00+00:00","value":null},{"timestamp":"2022-04-17T06:00:00+00:00","value":null},{"timestamp":"2022-04-17T07:00:00+00:00","value":null},{"timestamp":"2022-04-17T08:00:00+00:00","value":null},{"timestamp":"2022-04-17T09:00:00+00:00","value":null},{"timestamp":"2022-04-17T10:00:00+00:00","value":null},{"timestamp":"2022-04-17T11:00:00+00:00","value":null},{"timestamp":"2022-04-17T12:00:00+00:00","value":null},{"timestamp":"2022-04-17T13:00:00+00:00","value":null},{"timestamp":"2022-04-17T14:00:00+00:00","value":null},{"timestamp":"2022-04-17T15:00:00+00:00","value":null},{"timestamp":"2022-04-17T16:00:00+00:00","value":null},{"timestamp":"2022-04-17T17:00:00+00:00","value":null}],"product_family":"observability-pipelines"},"type":"usage_timeseries","id":"5d1702ab10f060719ae5aa1fd7ba09e3d7e0fb371b8319051c616a1fcad254e9"}]} + + ' + headers: + content-type: + - application/json + status: + code: 200 + message: OK +version: 1 diff --git a/tests/v2/features/undo.json b/tests/v2/features/undo.json index 555993b7c6..07284b0aec 100644 --- a/tests/v2/features/undo.json +++ b/tests/v2/features/undo.json @@ -782,6 +782,12 @@ "type": "idempotent" } }, + "GetUsageObservabilityPipelines": { + "tag": "Usage Metering", + "undo": { + "type": "safe" + } + }, "SendInvitations": { "tag": "Users", "undo": { diff --git a/tests/v2/features/usage_metering.feature b/tests/v2/features/usage_metering.feature new file mode 100644 index 0000000000..b47c3dddd0 --- /dev/null +++ b/tests/v2/features/usage_metering.feature @@ -0,0 +1,30 @@ +@endpoint(usage-metering) @endpoint(usage-metering-v2) +Feature: Usage Metering + 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. Usage is only accessible for [parent-level organizat + ions](https://docs.datadoghq.com/account_management/multi_organization/). + **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. + + Background: + Given a valid "apiKeyAuth" key in the system + And a valid "appKeyAuth" key in the system + And an instance of "UsageMetering" API + And new "GetUsageObservabilityPipelines" request + + @team:DataDog/red-zone-revenue-query + Scenario: Get hourly usage for Observability Pipelines returns "Bad Request" response + Given request contains "start_hr" parameter with value "{{ timeISO('now - 3d') }}" + And request contains "end_hr" parameter with value "{{ timeISO('now - 5d') }}" + When the request is sent + Then the response status is 400 Bad Request + + @team:DataDog/red-zone-revenue-query + Scenario: Get hourly usage for Observability Pipelines returns "OK" response + Given request contains "start_hr" parameter with value "{{ timeISO('now - 5d') }}" + And request contains "end_hr" parameter with value "{{ timeISO('now - 3d') }}" + When the request is sent + Then the response status is 200 OK