diff --git a/src/datadog_api_client/api_client.py b/src/datadog_api_client/api_client.py index 3ada61834a..c048e29978 100644 --- a/src/datadog_api_client/api_client.py +++ b/src/datadog_api_client/api_client.py @@ -54,6 +54,8 @@ def __init__(self, configuration: Configuration): self.default_headers = {} if self.configuration.compress: self.default_headers["Accept-Encoding"] = "gzip" + if self.configuration.is_iac: + self.default_headers["X-Datadog-Managed-By"] = "iac" # Set default User-Agent. self.user_agent = user_agent() diff --git a/src/datadog_api_client/configuration.py b/src/datadog_api_client/configuration.py index ae141d25cd..3d8e652708 100644 --- a/src/datadog_api_client/configuration.py +++ b/src/datadog_api_client/configuration.py @@ -150,6 +150,10 @@ class Configuration: :type delegated_auth_provider: str :param delegated_auth_org_uuid: The organization UUID for delegated authentication. :type delegated_auth_org_uuid: str + :param is_iac: Set to True to indicate that requests made through this client originate from + infrastructure-as-code or other automation tooling. When set, the client sends the + ``X-Datadog-Managed-By: iac`` header on every request. + :type is_iac: bool """ def __init__( @@ -180,6 +184,7 @@ def __init__( retry_policy=None, delegated_auth_provider=None, delegated_auth_org_uuid=None, + is_iac=False, ): """Constructor.""" self._base_path = "https://api.datadoghq.com" if host is None else host @@ -231,6 +236,10 @@ def __init__( # Will translate to a Accept-Encoding header self.compress = compress + # Set to True to indicate that requests are made from infrastructure-as-code tooling. + # Will translate to a X-Datadog-Managed-By header. + self.is_iac = is_iac + self.return_http_data_only = return_http_data_only self.preload_content = preload_content self.request_timeout = request_timeout diff --git a/tests/generated-test/test-runner-data/manifest.json b/tests/generated-test/test-runner-data/manifest.json index 37b3220a10..82ac36b3ff 100644 --- a/tests/generated-test/test-runner-data/manifest.json +++ b/tests/generated-test/test-runner-data/manifest.json @@ -2142,20 +2142,6 @@ "scenario": "Get monthly usage attribution returns \"OK\" response", "version": "v1" }, - { - "feature": "Usage Metering", - "feature_file": "../../v1/features/usage_metering.feature", - "file": "v1/usage-metering/get-specified-daily-custom-reports-returns-ok-response.json", - "scenario": "Get specified daily custom reports returns \"OK\" response", - "version": "v1" - }, - { - "feature": "Usage Metering", - "feature_file": "../../v1/features/usage_metering.feature", - "file": "v1/usage-metering/get-specified-monthly-custom-reports-returns-ok-response.json", - "scenario": "Get specified monthly custom reports returns \"OK\" response", - "version": "v1" - }, { "feature": "Users", "feature_file": "../../v1/features/users.feature", @@ -11522,13 +11508,6 @@ "scenario": "Get billing dimension mapping for usage endpoints returns \"Bad Request\" response", "version": "v2" }, - { - "feature": "Usage Metering", - "feature_file": "../../v2/features/usage_metering.feature", - "file": "v2/usage-metering/get-cost-across-multi-org-account-returns-ok-response.json", - "scenario": "Get cost across multi-org account returns \"OK\" response", - "version": "v2" - }, { "feature": "Usage Metering", "feature_file": "../../v2/features/usage_metering.feature", @@ -11550,48 +11529,6 @@ "scenario": "Get hourly usage by product family returns \"OK\" response", "version": "v2" }, - { - "feature": "Usage Metering", - "feature_file": "../../v2/features/usage_metering.feature", - "file": "v2/usage-metering/get-hourly-usage-for-application-security-returns-bad-request-response.json", - "scenario": "Get hourly usage for Application Security returns \"Bad Request\" response", - "version": "v2" - }, - { - "feature": "Usage Metering", - "feature_file": "../../v2/features/usage_metering.feature", - "file": "v2/usage-metering/get-hourly-usage-for-lambda-traced-invocations-returns-bad-request-response.json", - "scenario": "Get hourly usage for Lambda traced invocations returns \"Bad Request\" response", - "version": "v2" - }, - { - "feature": "Usage Metering", - "feature_file": "../../v2/features/usage_metering.feature", - "file": "v2/usage-metering/get-hourly-usage-for-lambda-traced-invocations-returns-ok-response.json", - "scenario": "Get hourly usage for Lambda traced invocations returns \"OK\" response", - "version": "v2" - }, - { - "feature": "Usage Metering", - "feature_file": "../../v2/features/usage_metering.feature", - "file": "v2/usage-metering/get-hourly-usage-for-observability-pipelines-returns-bad-request-response.json", - "scenario": "Get hourly usage for Observability Pipelines returns \"Bad Request\" response", - "version": "v2" - }, - { - "feature": "Usage Metering", - "feature_file": "../../v2/features/usage_metering.feature", - "file": "v2/usage-metering/get-hourly-usage-for-application-security-returns-ok-response.json", - "scenario": "Get hourly usage for application security returns \"OK\" response", - "version": "v2" - }, - { - "feature": "Usage Metering", - "feature_file": "../../v2/features/usage_metering.feature", - "file": "v2/usage-metering/get-hourly-usage-for-observability-pipelines-returns-ok-response.json", - "scenario": "Get hourly usage for observability pipelines returns \"OK\" response", - "version": "v2" - }, { "feature": "Usage Metering", "feature_file": "../../v2/features/usage_metering.feature", diff --git a/tests/generated-test/test-runner-data/v1/usage-metering/get-specified-daily-custom-reports-returns-ok-response.json b/tests/generated-test/test-runner-data/v1/usage-metering/get-specified-daily-custom-reports-returns-ok-response.json deleted file mode 100644 index d7016d24ec..0000000000 --- a/tests/generated-test/test-runner-data/v1/usage-metering/get-specified-daily-custom-reports-returns-ok-response.json +++ /dev/null @@ -1,35 +0,0 @@ -{ - "api": "UsageMetering", - "expected_status": 200, - "feature": "Usage Metering", - "id": "v1/Usage Metering/Get specified daily custom reports returns \"OK\" response", - "operation_id": "GetSpecifiedDailyCustomReports", - "request": { - "body": null, - "content_type": null, - "method": "GET", - "pagination": false, - "parameters": [ - { - "explode": null, - "in": "path", - "name": "report_id", - "required": true, - "schema": { - "format": null, - "ref": null, - "type": "string" - }, - "source": { - "type": "literal", - "value": "2022-03-20" - }, - "style": null - } - ], - "path": "/api/v1/daily_custom_reports/{report_id}" - }, - "scenario": "Get specified daily custom reports returns \"OK\" response", - "schema_version": 1, - "version": "v1" -} diff --git a/tests/generated-test/test-runner-data/v1/usage-metering/get-specified-monthly-custom-reports-returns-ok-response.json b/tests/generated-test/test-runner-data/v1/usage-metering/get-specified-monthly-custom-reports-returns-ok-response.json deleted file mode 100644 index 4df2ff37f0..0000000000 --- a/tests/generated-test/test-runner-data/v1/usage-metering/get-specified-monthly-custom-reports-returns-ok-response.json +++ /dev/null @@ -1,35 +0,0 @@ -{ - "api": "UsageMetering", - "expected_status": 200, - "feature": "Usage Metering", - "id": "v1/Usage Metering/Get specified monthly custom reports returns \"OK\" response", - "operation_id": "GetSpecifiedMonthlyCustomReports", - "request": { - "body": null, - "content_type": null, - "method": "GET", - "pagination": false, - "parameters": [ - { - "explode": null, - "in": "path", - "name": "report_id", - "required": true, - "schema": { - "format": null, - "ref": null, - "type": "string" - }, - "source": { - "type": "literal", - "value": "2021-05-01" - }, - "style": null - } - ], - "path": "/api/v1/monthly_custom_reports/{report_id}" - }, - "scenario": "Get specified monthly custom reports returns \"OK\" response", - "schema_version": 1, - "version": "v1" -} diff --git a/tests/generated-test/test-runner-data/v2/usage-metering/get-cost-across-multi-org-account-returns-ok-response.json b/tests/generated-test/test-runner-data/v2/usage-metering/get-cost-across-multi-org-account-returns-ok-response.json deleted file mode 100644 index fcce9c8274..0000000000 --- a/tests/generated-test/test-runner-data/v2/usage-metering/get-cost-across-multi-org-account-returns-ok-response.json +++ /dev/null @@ -1,35 +0,0 @@ -{ - "api": "UsageMetering", - "expected_status": 200, - "feature": "Usage Metering", - "id": "v2/Usage Metering/Get cost across multi-org account returns \"OK\" response", - "operation_id": "GetCostByOrg", - "request": { - "body": null, - "content_type": null, - "method": "GET", - "pagination": false, - "parameters": [ - { - "explode": null, - "in": "query", - "name": "start_month", - "required": true, - "schema": { - "format": "date-time", - "ref": null, - "type": "string" - }, - "source": { - "type": "literal", - "value": "{{ timeISO('now - 3d') }}" - }, - "style": null - } - ], - "path": "/api/v2/usage/cost_by_org" - }, - "scenario": "Get cost across multi-org account returns \"OK\" response", - "schema_version": 1, - "version": "v2" -} diff --git a/tests/generated-test/test-runner-data/v2/usage-metering/get-hourly-usage-for-application-security-returns-bad-request-response.json b/tests/generated-test/test-runner-data/v2/usage-metering/get-hourly-usage-for-application-security-returns-bad-request-response.json deleted file mode 100644 index 781b0ccd66..0000000000 --- a/tests/generated-test/test-runner-data/v2/usage-metering/get-hourly-usage-for-application-security-returns-bad-request-response.json +++ /dev/null @@ -1,51 +0,0 @@ -{ - "api": "UsageMetering", - "expected_status": 400, - "feature": "Usage Metering", - "id": "v2/Usage Metering/Get hourly usage for Application Security returns \"Bad Request\" response", - "operation_id": "GetUsageApplicationSecurityMonitoring", - "request": { - "body": null, - "content_type": null, - "method": "GET", - "pagination": false, - "parameters": [ - { - "explode": null, - "in": "query", - "name": "start_hr", - "required": true, - "schema": { - "format": "date-time", - "ref": null, - "type": "string" - }, - "source": { - "type": "literal", - "value": "{{ timeISO('now - 3d') }}" - }, - "style": null - }, - { - "explode": null, - "in": "query", - "name": "end_hr", - "required": false, - "schema": { - "format": "date-time", - "ref": null, - "type": "string" - }, - "source": { - "type": "literal", - "value": "{{ timeISO('now - 5d') }}" - }, - "style": null - } - ], - "path": "/api/v2/usage/application_security" - }, - "scenario": "Get hourly usage for Application Security returns \"Bad Request\" response", - "schema_version": 1, - "version": "v2" -} diff --git a/tests/generated-test/test-runner-data/v2/usage-metering/get-hourly-usage-for-application-security-returns-ok-response.json b/tests/generated-test/test-runner-data/v2/usage-metering/get-hourly-usage-for-application-security-returns-ok-response.json deleted file mode 100644 index 18d5991e8e..0000000000 --- a/tests/generated-test/test-runner-data/v2/usage-metering/get-hourly-usage-for-application-security-returns-ok-response.json +++ /dev/null @@ -1,51 +0,0 @@ -{ - "api": "UsageMetering", - "expected_status": 200, - "feature": "Usage Metering", - "id": "v2/Usage Metering/Get hourly usage for application security returns \"OK\" response", - "operation_id": "GetUsageApplicationSecurityMonitoring", - "request": { - "body": null, - "content_type": null, - "method": "GET", - "pagination": false, - "parameters": [ - { - "explode": null, - "in": "query", - "name": "start_hr", - "required": true, - "schema": { - "format": "date-time", - "ref": null, - "type": "string" - }, - "source": { - "type": "literal", - "value": "{{ timeISO('now - 5d') }}" - }, - "style": null - }, - { - "explode": null, - "in": "query", - "name": "end_hr", - "required": false, - "schema": { - "format": "date-time", - "ref": null, - "type": "string" - }, - "source": { - "type": "literal", - "value": "{{ timeISO('now - 3d') }}" - }, - "style": null - } - ], - "path": "/api/v2/usage/application_security" - }, - "scenario": "Get hourly usage for application security returns \"OK\" response", - "schema_version": 1, - "version": "v2" -} diff --git a/tests/generated-test/test-runner-data/v2/usage-metering/get-hourly-usage-for-lambda-traced-invocations-returns-bad-request-response.json b/tests/generated-test/test-runner-data/v2/usage-metering/get-hourly-usage-for-lambda-traced-invocations-returns-bad-request-response.json deleted file mode 100644 index 51ccc8ef5e..0000000000 --- a/tests/generated-test/test-runner-data/v2/usage-metering/get-hourly-usage-for-lambda-traced-invocations-returns-bad-request-response.json +++ /dev/null @@ -1,51 +0,0 @@ -{ - "api": "UsageMetering", - "expected_status": 400, - "feature": "Usage Metering", - "id": "v2/Usage Metering/Get hourly usage for Lambda traced invocations returns \"Bad Request\" response", - "operation_id": "GetUsageLambdaTracedInvocations", - "request": { - "body": null, - "content_type": null, - "method": "GET", - "pagination": false, - "parameters": [ - { - "explode": null, - "in": "query", - "name": "start_hr", - "required": true, - "schema": { - "format": "date-time", - "ref": null, - "type": "string" - }, - "source": { - "type": "literal", - "value": "{{ timeISO('now - 3d') }}" - }, - "style": null - }, - { - "explode": null, - "in": "query", - "name": "end_hr", - "required": false, - "schema": { - "format": "date-time", - "ref": null, - "type": "string" - }, - "source": { - "type": "literal", - "value": "{{ timeISO('now - 5d') }}" - }, - "style": null - } - ], - "path": "/api/v2/usage/lambda_traced_invocations" - }, - "scenario": "Get hourly usage for Lambda traced invocations returns \"Bad Request\" response", - "schema_version": 1, - "version": "v2" -} diff --git a/tests/generated-test/test-runner-data/v2/usage-metering/get-hourly-usage-for-lambda-traced-invocations-returns-ok-response.json b/tests/generated-test/test-runner-data/v2/usage-metering/get-hourly-usage-for-lambda-traced-invocations-returns-ok-response.json deleted file mode 100644 index bab1f200bc..0000000000 --- a/tests/generated-test/test-runner-data/v2/usage-metering/get-hourly-usage-for-lambda-traced-invocations-returns-ok-response.json +++ /dev/null @@ -1,51 +0,0 @@ -{ - "api": "UsageMetering", - "expected_status": 200, - "feature": "Usage Metering", - "id": "v2/Usage Metering/Get hourly usage for Lambda traced invocations returns \"OK\" response", - "operation_id": "GetUsageLambdaTracedInvocations", - "request": { - "body": null, - "content_type": null, - "method": "GET", - "pagination": false, - "parameters": [ - { - "explode": null, - "in": "query", - "name": "start_hr", - "required": true, - "schema": { - "format": "date-time", - "ref": null, - "type": "string" - }, - "source": { - "type": "literal", - "value": "{{ timeISO('now - 5d') }}" - }, - "style": null - }, - { - "explode": null, - "in": "query", - "name": "end_hr", - "required": false, - "schema": { - "format": "date-time", - "ref": null, - "type": "string" - }, - "source": { - "type": "literal", - "value": "{{ timeISO('now - 3d') }}" - }, - "style": null - } - ], - "path": "/api/v2/usage/lambda_traced_invocations" - }, - "scenario": "Get hourly usage for Lambda traced invocations returns \"OK\" response", - "schema_version": 1, - "version": "v2" -} diff --git a/tests/generated-test/test-runner-data/v2/usage-metering/get-hourly-usage-for-observability-pipelines-returns-bad-request-response.json b/tests/generated-test/test-runner-data/v2/usage-metering/get-hourly-usage-for-observability-pipelines-returns-bad-request-response.json deleted file mode 100644 index 1df4205055..0000000000 --- a/tests/generated-test/test-runner-data/v2/usage-metering/get-hourly-usage-for-observability-pipelines-returns-bad-request-response.json +++ /dev/null @@ -1,51 +0,0 @@ -{ - "api": "UsageMetering", - "expected_status": 400, - "feature": "Usage Metering", - "id": "v2/Usage Metering/Get hourly usage for Observability Pipelines returns \"Bad Request\" response", - "operation_id": "GetUsageObservabilityPipelines", - "request": { - "body": null, - "content_type": null, - "method": "GET", - "pagination": false, - "parameters": [ - { - "explode": null, - "in": "query", - "name": "start_hr", - "required": true, - "schema": { - "format": "date-time", - "ref": null, - "type": "string" - }, - "source": { - "type": "literal", - "value": "{{ timeISO('now - 3d') }}" - }, - "style": null - }, - { - "explode": null, - "in": "query", - "name": "end_hr", - "required": false, - "schema": { - "format": "date-time", - "ref": null, - "type": "string" - }, - "source": { - "type": "literal", - "value": "{{ timeISO('now - 5d') }}" - }, - "style": null - } - ], - "path": "/api/v2/usage/observability_pipelines" - }, - "scenario": "Get hourly usage for Observability Pipelines returns \"Bad Request\" response", - "schema_version": 1, - "version": "v2" -} diff --git a/tests/generated-test/test-runner-data/v2/usage-metering/get-hourly-usage-for-observability-pipelines-returns-ok-response.json b/tests/generated-test/test-runner-data/v2/usage-metering/get-hourly-usage-for-observability-pipelines-returns-ok-response.json deleted file mode 100644 index 999137fbad..0000000000 --- a/tests/generated-test/test-runner-data/v2/usage-metering/get-hourly-usage-for-observability-pipelines-returns-ok-response.json +++ /dev/null @@ -1,51 +0,0 @@ -{ - "api": "UsageMetering", - "expected_status": 200, - "feature": "Usage Metering", - "id": "v2/Usage Metering/Get hourly usage for observability pipelines returns \"OK\" response", - "operation_id": "GetUsageObservabilityPipelines", - "request": { - "body": null, - "content_type": null, - "method": "GET", - "pagination": false, - "parameters": [ - { - "explode": null, - "in": "query", - "name": "start_hr", - "required": true, - "schema": { - "format": "date-time", - "ref": null, - "type": "string" - }, - "source": { - "type": "literal", - "value": "{{ timeISO('now - 5d') }}" - }, - "style": null - }, - { - "explode": null, - "in": "query", - "name": "end_hr", - "required": false, - "schema": { - "format": "date-time", - "ref": null, - "type": "string" - }, - "source": { - "type": "literal", - "value": "{{ timeISO('now - 3d') }}" - }, - "style": null - } - ], - "path": "/api/v2/usage/observability_pipelines" - }, - "scenario": "Get hourly usage for observability pipelines returns \"OK\" response", - "schema_version": 1, - "version": "v2" -} diff --git a/tests/v1/features/usage_metering.feature b/tests/v1/features/usage_metering.feature index e8651834ac..9f1d1b4afc 100644 --- a/tests/v1/features/usage_metering.feature +++ b/tests/v1/features/usage_metering.feature @@ -645,7 +645,7 @@ Feature: Usage Metering When the request is sent Then the response status is 404 Not Found - @replay-only @team:DataDog/billing-hub + @replay-only @skip @team:DataDog/billing-hub Scenario: Get specified daily custom reports returns "OK" response Given new "GetSpecifiedDailyCustomReports" request And request contains "report_id" parameter with value "2022-03-20" @@ -666,7 +666,7 @@ Feature: Usage Metering When the request is sent Then the response status is 404 Not Found - @replay-only @team:DataDog/billing-hub + @replay-only @skip @team:DataDog/billing-hub Scenario: Get specified monthly custom reports returns "OK" response Given new "GetSpecifiedMonthlyCustomReports" request And request contains "report_id" parameter with value "2021-05-01" diff --git a/tests/v2/features/usage_metering.feature b/tests/v2/features/usage_metering.feature index ca4cfbd670..ee69898922 100644 --- a/tests/v2/features/usage_metering.feature +++ b/tests/v2/features/usage_metering.feature @@ -86,7 +86,7 @@ Feature: Usage Metering When the request is sent Then the response status is 400 Bad Request - @replay-only @team:DataDog/billing-hub + @replay-only @skip @team:DataDog/billing-hub Scenario: Get cost across multi-org account returns "OK" response Given new "GetCostByOrg" request And request contains "start_month" parameter with value "{{ timeISO('now - 3d') }}" @@ -139,7 +139,7 @@ Feature: Usage Metering And the response "data[0].type" is equal to "usage_timeseries" And the response "data[0].attributes.region" is equal to "us" - @team:DataDog/billing-hub + @skip @team:DataDog/billing-hub Scenario: Get hourly usage for Application Security returns "Bad Request" response Given new "GetUsageApplicationSecurityMonitoring" request And request contains "start_hr" parameter with value "{{ timeISO('now - 3d') }}" @@ -147,7 +147,7 @@ Feature: Usage Metering When the request is sent Then the response status is 400 Bad Request - @team:DataDog/billing-hub + @skip @team:DataDog/billing-hub Scenario: Get hourly usage for Lambda traced invocations returns "Bad Request" response Given new "GetUsageLambdaTracedInvocations" request And request contains "start_hr" parameter with value "{{ timeISO('now - 3d') }}" @@ -155,7 +155,7 @@ Feature: Usage Metering When the request is sent Then the response status is 400 Bad Request - @team:DataDog/billing-hub + @skip @team:DataDog/billing-hub Scenario: Get hourly usage for Lambda traced invocations returns "OK" response Given new "GetUsageLambdaTracedInvocations" request And request contains "start_hr" parameter with value "{{ timeISO('now - 5d') }}" @@ -165,7 +165,7 @@ Feature: Usage Metering And the response "data[0].type" is equal to "usage_timeseries" And the response "data[0].attributes.product_family" is equal to "lambda-traced-invocations" - @team:DataDog/billing-hub + @skip @team:DataDog/billing-hub Scenario: Get hourly usage for Observability Pipelines returns "Bad Request" response Given new "GetUsageObservabilityPipelines" request And request contains "start_hr" parameter with value "{{ timeISO('now - 3d') }}" @@ -180,7 +180,7 @@ Feature: Usage Metering When the request is sent Then the response status is 400 Bad Request - @team:DataDog/billing-hub + @skip @team:DataDog/billing-hub Scenario: Get hourly usage for application security returns "OK" response Given new "GetUsageApplicationSecurityMonitoring" request And request contains "start_hr" parameter with value "{{ timeISO('now - 5d') }}" @@ -197,7 +197,7 @@ Feature: Usage Metering When the request is sent Then the response status is 400 Bad Request - @team:DataDog/billing-hub + @skip @team:DataDog/billing-hub Scenario: Get hourly usage for observability pipelines returns "OK" response Given new "GetUsageObservabilityPipelines" request And request contains "start_hr" parameter with value "{{ timeISO('now - 5d') }}"