From 00d10caf9fe1dfd78c48ee9412e48445bd4d71d2 Mon Sep 17 00:00:00 2001 From: "ci.datadog-api-spec" Date: Wed, 31 Jan 2024 21:51:37 +0000 Subject: [PATCH] Regenerate client from commit 28008cdb of spec repo --- .apigentools-info | 8 +-- .generator/schemas/v1/openapi.yaml | 12 ++++ .generator/schemas/v2/openapi.yaml | 12 ++++ .../gcp-integration/CreateGCPIntegration.py | 3 + .../UpdateGCPIntegration_3544259255.py | 34 ++++++++++ .../CreateGCPSTSAccount_194782945.py | 30 +++++++++ .../UpdateGCPSTSAccount_2241994060.py | 34 ++++++++++ .../v1/model/gcp_account.py | 9 +++ .../gcpsts_service_account_attributes.py | 9 +++ ...gcp_integration_returns_ok_response.frozen | 2 +- ...a_gcp_integration_returns_ok_response.yaml | 4 +- ...evision_filters_returns_ok_response.frozen | 1 + ..._revision_filters_returns_ok_response.yaml | 62 +++++++++++++++++++ tests/v1/features/gcp_integration.feature | 16 +++-- ...filters_enabled_returns_ok_response.frozen | 1 + ...n_filters_enabled_returns_ok_response.yaml | 38 ++++++++++++ ...nse_with_cloud_run_revision_filters.frozen | 1 + ...ponse_with_cloud_run_revision_filters.yaml | 58 +++++++++++++++++ tests/v2/features/gcp_integration.feature | 27 ++++++-- 19 files changed, 346 insertions(+), 15 deletions(-) create mode 100644 examples/v1/gcp-integration/UpdateGCPIntegration_3544259255.py create mode 100644 examples/v2/gcp-integration/CreateGCPSTSAccount_194782945.py create mode 100644 examples/v2/gcp-integration/UpdateGCPSTSAccount_2241994060.py create mode 100644 tests/v1/cassettes/test_scenarios/test_update_a_gcp_integration_cloud_run_revision_filters_returns_ok_response.frozen create mode 100644 tests/v1/cassettes/test_scenarios/test_update_a_gcp_integration_cloud_run_revision_filters_returns_ok_response.yaml create mode 100644 tests/v2/cassettes/test_scenarios/test_create_a_new_entry_for_your_service_account_with_cloud_run_revision_filters_enabled_returns_ok_response.frozen create mode 100644 tests/v2/cassettes/test_scenarios/test_create_a_new_entry_for_your_service_account_with_cloud_run_revision_filters_enabled_returns_ok_response.yaml create mode 100644 tests/v2/cassettes/test_scenarios/test_update_sts_service_account_returns_ok_response_with_cloud_run_revision_filters.frozen create mode 100644 tests/v2/cassettes/test_scenarios/test_update_sts_service_account_returns_ok_response_with_cloud_run_revision_filters.yaml diff --git a/.apigentools-info b/.apigentools-info index bd1c1c10c1..0c4cc6e256 100644 --- a/.apigentools-info +++ b/.apigentools-info @@ -4,13 +4,13 @@ "spec_versions": { "v1": { "apigentools_version": "1.6.6", - "regenerated": "2024-01-31 20:51:09.699607", - "spec_repo_commit": "e545b10b" + "regenerated": "2024-01-31 21:51:01.839882", + "spec_repo_commit": "28008cdb" }, "v2": { "apigentools_version": "1.6.6", - "regenerated": "2024-01-31 20:51:09.736111", - "spec_repo_commit": "e545b10b" + "regenerated": "2024-01-31 21:51:01.854347", + "spec_repo_commit": "28008cdb" } } } \ No newline at end of file diff --git a/.generator/schemas/v1/openapi.yaml b/.generator/schemas/v1/openapi.yaml index a52bd550c9..0a95dd4df7 100644 --- a/.generator/schemas/v1/openapi.yaml +++ b/.generator/schemas/v1/openapi.yaml @@ -3207,6 +3207,18 @@ components: key.' example: https://www.googleapis.com/robot/v1/metadata/x509/$CLIENT_EMAIL type: string + cloud_run_revision_filters: + description: 'Limit the Cloud Run revisions that are pulled into Datadog + by using tags. + + Only Cloud Run revision resources that apply to specified filters are + imported into Datadog.' + example: + - $KEY:$VALUE + items: + description: Cloud Run Filters + type: string + type: array errors: description: An array of errors. example: diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 58db4b9ef5..e7cd4218cc 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -7016,6 +7016,18 @@ components: description: Your service account email address. example: datadog-service-account@test-project.iam.gserviceaccount.com type: string + cloud_run_revision_filters: + description: 'List of filters to limit the Cloud Run revisions that are + pulled into Datadog by using tags. + + Only Cloud Run revision resources that apply to specified filters are + imported into Datadog.' + example: + - $KEY:$VALUE + items: + description: Cloud Run Filters + type: string + type: array host_filters: description: Your Host Filters. items: diff --git a/examples/v1/gcp-integration/CreateGCPIntegration.py b/examples/v1/gcp-integration/CreateGCPIntegration.py index 0cd0bfd52b..c53fba10b0 100644 --- a/examples/v1/gcp-integration/CreateGCPIntegration.py +++ b/examples/v1/gcp-integration/CreateGCPIntegration.py @@ -13,6 +13,9 @@ client_id="163662907116366290710", client_x509_cert_url="https://www.googleapis.com/robot/v1/metadata/x509/$CLIENT_EMAIL", host_filters="key:value,filter:example", + cloud_run_revision_filters=[ + "dr:dre", + ], is_cspm_enabled=True, is_security_command_center_enabled=True, private_key="private_key", diff --git a/examples/v1/gcp-integration/UpdateGCPIntegration_3544259255.py b/examples/v1/gcp-integration/UpdateGCPIntegration_3544259255.py new file mode 100644 index 0000000000..d3c02d0774 --- /dev/null +++ b/examples/v1/gcp-integration/UpdateGCPIntegration_3544259255.py @@ -0,0 +1,34 @@ +""" +Update a GCP integration cloud run revision filters returns "OK" response +""" + +from datadog_api_client import ApiClient, Configuration +from datadog_api_client.v1.api.gcp_integration_api import GCPIntegrationApi +from datadog_api_client.v1.model.gcp_account import GCPAccount + +body = GCPAccount( + auth_provider_x509_cert_url="https://www.googleapis.com/oauth2/v1/certs", + auth_uri="https://accounts.google.com/o/oauth2/auth", + client_email="252bf553ef04b351@example.com", + client_id="163662907116366290710", + client_x509_cert_url="https://www.googleapis.com/robot/v1/metadata/x509/$CLIENT_EMAIL", + host_filters="key:value,filter:example", + cloud_run_revision_filters=[ + "merp:derp", + ], + is_cspm_enabled=True, + is_security_command_center_enabled=True, + private_key="private_key", + private_key_id="123456789abcdefghi123456789abcdefghijklm", + project_id="datadog-apitest", + resource_collection_enabled=True, + token_uri="https://accounts.google.com/o/oauth2/token", + type="service_account", +) + +configuration = Configuration() +with ApiClient(configuration) as api_client: + api_instance = GCPIntegrationApi(api_client) + response = api_instance.update_gcp_integration(body=body) + + print(response) diff --git a/examples/v2/gcp-integration/CreateGCPSTSAccount_194782945.py b/examples/v2/gcp-integration/CreateGCPSTSAccount_194782945.py new file mode 100644 index 0000000000..67380cc30f --- /dev/null +++ b/examples/v2/gcp-integration/CreateGCPSTSAccount_194782945.py @@ -0,0 +1,30 @@ +""" +Create a new entry for your service account with cloud run revision filters enabled returns "OK" response +""" + +from datadog_api_client import ApiClient, Configuration +from datadog_api_client.v2.api.gcp_integration_api import GCPIntegrationApi +from datadog_api_client.v2.model.gcp_service_account_type import GCPServiceAccountType +from datadog_api_client.v2.model.gcpsts_service_account_attributes import GCPSTSServiceAccountAttributes +from datadog_api_client.v2.model.gcpsts_service_account_create_request import GCPSTSServiceAccountCreateRequest +from datadog_api_client.v2.model.gcpsts_service_account_data import GCPSTSServiceAccountData + +body = GCPSTSServiceAccountCreateRequest( + data=GCPSTSServiceAccountData( + attributes=GCPSTSServiceAccountAttributes( + cloud_run_revision_filters=[ + "meh:bleh", + ], + client_email="252bf553ef04b351@test-project.iam.gserviceaccount.com", + host_filters=[], + ), + type=GCPServiceAccountType.GCP_SERVICE_ACCOUNT, + ), +) + +configuration = Configuration() +with ApiClient(configuration) as api_client: + api_instance = GCPIntegrationApi(api_client) + response = api_instance.create_gcpsts_account(body=body) + + print(response) diff --git a/examples/v2/gcp-integration/UpdateGCPSTSAccount_2241994060.py b/examples/v2/gcp-integration/UpdateGCPSTSAccount_2241994060.py new file mode 100644 index 0000000000..0486189018 --- /dev/null +++ b/examples/v2/gcp-integration/UpdateGCPSTSAccount_2241994060.py @@ -0,0 +1,34 @@ +""" +Update STS Service Account returns "OK" response with cloud run revision filters +""" + +from os import environ +from datadog_api_client import ApiClient, Configuration +from datadog_api_client.v2.api.gcp_integration_api import GCPIntegrationApi +from datadog_api_client.v2.model.gcp_service_account_type import GCPServiceAccountType +from datadog_api_client.v2.model.gcpsts_service_account_attributes import GCPSTSServiceAccountAttributes +from datadog_api_client.v2.model.gcpsts_service_account_update_request import GCPSTSServiceAccountUpdateRequest +from datadog_api_client.v2.model.gcpsts_service_account_update_request_data import GCPSTSServiceAccountUpdateRequestData + +# there is a valid "gcp_sts_account" in the system +GCP_STS_ACCOUNT_DATA_ID = environ["GCP_STS_ACCOUNT_DATA_ID"] + +body = GCPSTSServiceAccountUpdateRequest( + data=GCPSTSServiceAccountUpdateRequestData( + attributes=GCPSTSServiceAccountAttributes( + client_email="252bf553ef04b351@example.com", + cloud_run_revision_filters=[ + "merp:derp", + ], + ), + id=GCP_STS_ACCOUNT_DATA_ID, + type=GCPServiceAccountType.GCP_SERVICE_ACCOUNT, + ), +) + +configuration = Configuration() +with ApiClient(configuration) as api_client: + api_instance = GCPIntegrationApi(api_client) + response = api_instance.update_gcpsts_account(account_id=GCP_STS_ACCOUNT_DATA_ID, body=body) + + print(response) diff --git a/src/datadog_api_client/v1/model/gcp_account.py b/src/datadog_api_client/v1/model/gcp_account.py index e64e615515..3161ad5245 100644 --- a/src/datadog_api_client/v1/model/gcp_account.py +++ b/src/datadog_api_client/v1/model/gcp_account.py @@ -23,6 +23,7 @@ def openapi_types(_): "client_email": (str,), "client_id": (str,), "client_x509_cert_url": (str,), + "cloud_run_revision_filters": ([str],), "errors": ([str],), "host_filters": (str,), "is_cspm_enabled": (bool,), @@ -42,6 +43,7 @@ def openapi_types(_): "client_email": "client_email", "client_id": "client_id", "client_x509_cert_url": "client_x509_cert_url", + "cloud_run_revision_filters": "cloud_run_revision_filters", "errors": "errors", "host_filters": "host_filters", "is_cspm_enabled": "is_cspm_enabled", @@ -62,6 +64,7 @@ def __init__( client_email: Union[str, UnsetType] = unset, client_id: Union[str, UnsetType] = unset, client_x509_cert_url: Union[str, UnsetType] = unset, + cloud_run_revision_filters: Union[List[str], UnsetType] = unset, errors: Union[List[str], UnsetType] = unset, host_filters: Union[str, UnsetType] = unset, is_cspm_enabled: Union[bool, UnsetType] = unset, @@ -96,6 +99,10 @@ def __init__( where ``$CLIENT_EMAIL`` is the email found in your JSON service account key. :type client_x509_cert_url: str, optional + :param cloud_run_revision_filters: Limit the Cloud Run revisions that are pulled into Datadog by using tags. + Only Cloud Run revision resources that apply to specified filters are imported into Datadog. + :type cloud_run_revision_filters: [str], optional + :param errors: An array of errors. :type errors: [str], optional @@ -139,6 +146,8 @@ def __init__( kwargs["client_id"] = client_id if client_x509_cert_url is not unset: kwargs["client_x509_cert_url"] = client_x509_cert_url + if cloud_run_revision_filters is not unset: + kwargs["cloud_run_revision_filters"] = cloud_run_revision_filters if errors is not unset: kwargs["errors"] = errors if host_filters is not unset: diff --git a/src/datadog_api_client/v2/model/gcpsts_service_account_attributes.py b/src/datadog_api_client/v2/model/gcpsts_service_account_attributes.py index b6fdec233f..a9af87ad96 100644 --- a/src/datadog_api_client/v2/model/gcpsts_service_account_attributes.py +++ b/src/datadog_api_client/v2/model/gcpsts_service_account_attributes.py @@ -20,6 +20,7 @@ def openapi_types(_): "account_tags": ([str],), "automute": (bool,), "client_email": (str,), + "cloud_run_revision_filters": ([str],), "host_filters": ([str],), "is_cspm_enabled": (bool,), "is_security_command_center_enabled": (bool,), @@ -30,6 +31,7 @@ def openapi_types(_): "account_tags": "account_tags", "automute": "automute", "client_email": "client_email", + "cloud_run_revision_filters": "cloud_run_revision_filters", "host_filters": "host_filters", "is_cspm_enabled": "is_cspm_enabled", "is_security_command_center_enabled": "is_security_command_center_enabled", @@ -41,6 +43,7 @@ def __init__( account_tags: Union[List[str], UnsetType] = unset, automute: Union[bool, UnsetType] = unset, client_email: Union[str, UnsetType] = unset, + cloud_run_revision_filters: Union[List[str], UnsetType] = unset, host_filters: Union[List[str], UnsetType] = unset, is_cspm_enabled: Union[bool, UnsetType] = unset, is_security_command_center_enabled: Union[bool, UnsetType] = unset, @@ -59,6 +62,10 @@ def __init__( :param client_email: Your service account email address. :type client_email: str, optional + :param cloud_run_revision_filters: List of filters to limit the Cloud Run revisions that are pulled into Datadog by using tags. + Only Cloud Run revision resources that apply to specified filters are imported into Datadog. + :type cloud_run_revision_filters: [str], optional + :param host_filters: Your Host Filters. :type host_filters: [str], optional @@ -77,6 +84,8 @@ def __init__( kwargs["automute"] = automute if client_email is not unset: kwargs["client_email"] = client_email + if cloud_run_revision_filters is not unset: + kwargs["cloud_run_revision_filters"] = cloud_run_revision_filters if host_filters is not unset: kwargs["host_filters"] = host_filters if is_cspm_enabled is not unset: diff --git a/tests/v1/cassettes/test_scenarios/test_create_a_gcp_integration_returns_ok_response.frozen b/tests/v1/cassettes/test_scenarios/test_create_a_gcp_integration_returns_ok_response.frozen index 3677f3cb1d..3898833e13 100644 --- a/tests/v1/cassettes/test_scenarios/test_create_a_gcp_integration_returns_ok_response.frozen +++ b/tests/v1/cassettes/test_scenarios/test_create_a_gcp_integration_returns_ok_response.frozen @@ -1 +1 @@ -2023-12-20T13:18:07.717Z \ No newline at end of file +2024-01-31T21:16:03.254Z \ No newline at end of file diff --git a/tests/v1/cassettes/test_scenarios/test_create_a_gcp_integration_returns_ok_response.yaml b/tests/v1/cassettes/test_scenarios/test_create_a_gcp_integration_returns_ok_response.yaml index 01df779c92..157c10c1ca 100644 --- a/tests/v1/cassettes/test_scenarios/test_create_a_gcp_integration_returns_ok_response.yaml +++ b/tests/v1/cassettes/test_scenarios/test_create_a_gcp_integration_returns_ok_response.yaml @@ -1,6 +1,6 @@ interactions: - request: - body: '{"auth_provider_x509_cert_url":"https://www.googleapis.com/oauth2/v1/certs","auth_uri":"https://accounts.google.com/o/oauth2/auth","client_email":"e5bbc86fb86ab202@example.com","client_id":"170307828717030782870","client_x509_cert_url":"https://www.googleapis.com/robot/v1/metadata/x509/$CLIENT_EMAIL","host_filters":"key:value,filter:example","is_cspm_enabled":true,"is_security_command_center_enabled":true,"private_key":"private_key","private_key_id":"123456789abcdefghi123456789abcdefghijklm","project_id":"datadog-apitest","resource_collection_enabled":true,"token_uri":"https://accounts.google.com/o/oauth2/token","type":"service_account"}' + body: '{"auth_provider_x509_cert_url":"https://www.googleapis.com/oauth2/v1/certs","auth_uri":"https://accounts.google.com/o/oauth2/auth","client_email":"3af93b0f1c973838@example.com","client_id":"170673576317067357630","client_x509_cert_url":"https://www.googleapis.com/robot/v1/metadata/x509/$CLIENT_EMAIL","cloud_run_revision_filters":["dr:dre"],"host_filters":"key:value,filter:example","is_cspm_enabled":true,"is_security_command_center_enabled":true,"private_key":"private_key","private_key_id":"123456789abcdefghi123456789abcdefghijklm","project_id":"datadog-apitest","resource_collection_enabled":true,"token_uri":"https://accounts.google.com/o/oauth2/token","type":"service_account"}' headers: accept: - application/json @@ -20,7 +20,7 @@ interactions: code: 200 message: OK - request: - body: '{"client_email":"e5bbc86fb86ab202@example.com","client_id":"170307828717030782870","project_id":"datadog-apitest"}' + body: '{"client_email":"3af93b0f1c973838@example.com","client_id":"170673576317067357630","project_id":"datadog-apitest"}' headers: accept: - application/json diff --git a/tests/v1/cassettes/test_scenarios/test_update_a_gcp_integration_cloud_run_revision_filters_returns_ok_response.frozen b/tests/v1/cassettes/test_scenarios/test_update_a_gcp_integration_cloud_run_revision_filters_returns_ok_response.frozen new file mode 100644 index 0000000000..6f951f6ba5 --- /dev/null +++ b/tests/v1/cassettes/test_scenarios/test_update_a_gcp_integration_cloud_run_revision_filters_returns_ok_response.frozen @@ -0,0 +1 @@ +2024-01-31T21:16:03.829Z \ No newline at end of file diff --git a/tests/v1/cassettes/test_scenarios/test_update_a_gcp_integration_cloud_run_revision_filters_returns_ok_response.yaml b/tests/v1/cassettes/test_scenarios/test_update_a_gcp_integration_cloud_run_revision_filters_returns_ok_response.yaml new file mode 100644 index 0000000000..8b85d1cc1e --- /dev/null +++ b/tests/v1/cassettes/test_scenarios/test_update_a_gcp_integration_cloud_run_revision_filters_returns_ok_response.yaml @@ -0,0 +1,62 @@ +interactions: +- request: + body: '{"auth_provider_x509_cert_url":"https://www.googleapis.com/oauth2/v1/certs","auth_uri":"https://accounts.google.com/o/oauth2/auth","client_email":"edcdf6542ac6e6b6@example.com","client_id":"170673576317067357630","client_x509_cert_url":"https://www.googleapis.com/robot/v1/metadata/x509/$CLIENT_EMAIL","host_filters":"key:value,filter:example","is_cspm_enabled":true,"is_security_command_center_enabled":true,"private_key":"private_key","private_key_id":"123456789abcdefghi123456789abcdefghijklm","project_id":"datadog-apitest","resource_collection_enabled":true,"token_uri":"https://accounts.google.com/o/oauth2/token","type":"service_account"}' + headers: + accept: + - application/json + content-type: + - application/json + method: POST + uri: https://api.datadoghq.com/api/v1/integration/gcp + response: + body: + string: '{} + + ' + headers: + content-type: + - application/json + status: + code: 200 + message: OK +- request: + body: '{"auth_provider_x509_cert_url":"https://www.googleapis.com/oauth2/v1/certs","auth_uri":"https://accounts.google.com/o/oauth2/auth","client_email":"edcdf6542ac6e6b6@example.com","client_id":"170673576317067357630","client_x509_cert_url":"https://www.googleapis.com/robot/v1/metadata/x509/$CLIENT_EMAIL","cloud_run_revision_filters":["merp:derp"],"host_filters":"key:value,filter:example","is_cspm_enabled":true,"is_security_command_center_enabled":true,"private_key":"private_key","private_key_id":"123456789abcdefghi123456789abcdefghijklm","project_id":"datadog-apitest","resource_collection_enabled":true,"token_uri":"https://accounts.google.com/o/oauth2/token","type":"service_account"}' + headers: + accept: + - application/json + content-type: + - application/json + method: PUT + uri: https://api.datadoghq.com/api/v1/integration/gcp + response: + body: + string: '{} + + ' + headers: + content-type: + - application/json + status: + code: 200 + message: OK +- request: + body: '{"client_email":"edcdf6542ac6e6b6@example.com","client_id":"170673576317067357630","project_id":"datadog-apitest"}' + headers: + accept: + - application/json + content-type: + - application/json + method: DELETE + uri: https://api.datadoghq.com/api/v1/integration/gcp + response: + body: + string: '{} + + ' + headers: + content-type: + - application/json + status: + code: 200 + message: OK +version: 1 diff --git a/tests/v1/features/gcp_integration.feature b/tests/v1/features/gcp_integration.feature index cc078be2f0..2b656ab202 100644 --- a/tests/v1/features/gcp_integration.feature +++ b/tests/v1/features/gcp_integration.feature @@ -13,21 +13,21 @@ Feature: GCP Integration @generated @skip @team:DataDog/gcp-integrations Scenario: Create a GCP integration returns "Bad Request" response Given new "CreateGCPIntegration" request - And body with value {"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs", "auth_uri": "https://accounts.google.com/o/oauth2/auth", "client_email": "api-dev@datadog-sandbox.iam.gserviceaccount.com", "client_id": "123456712345671234567", "client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/$CLIENT_EMAIL", "errors": ["*"], "host_filters": "key:value,filter:example", "is_cspm_enabled": true, "is_security_command_center_enabled": true, "private_key": "private_key", "private_key_id": "123456789abcdefghi123456789abcdefghijklm", "project_id": "datadog-apitest", "resource_collection_enabled": true, "token_uri": "https://accounts.google.com/o/oauth2/token", "type": "service_account"} + And body with value {"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs", "auth_uri": "https://accounts.google.com/o/oauth2/auth", "client_email": "api-dev@datadog-sandbox.iam.gserviceaccount.com", "client_id": "123456712345671234567", "client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/$CLIENT_EMAIL", "cloud_run_revision_filters": ["$KEY:$VALUE"], "errors": ["*"], "host_filters": "key:value,filter:example", "is_cspm_enabled": true, "is_security_command_center_enabled": true, "private_key": "private_key", "private_key_id": "123456789abcdefghi123456789abcdefghijklm", "project_id": "datadog-apitest", "resource_collection_enabled": true, "token_uri": "https://accounts.google.com/o/oauth2/token", "type": "service_account"} When the request is sent Then the response status is 400 Bad Request @team:DataDog/gcp-integrations Scenario: Create a GCP integration returns "OK" response Given new "CreateGCPIntegration" request - And body with value {"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs", "auth_uri": "https://accounts.google.com/o/oauth2/auth", "client_email": "{{unique_hash}}@example.com", "client_id": "{{ timestamp("now") }}{{ timestamp("now") }}0", "client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/$CLIENT_EMAIL", "host_filters": "key:value,filter:example", "is_cspm_enabled": true, "is_security_command_center_enabled": true, "private_key": "private_key", "private_key_id": "123456789abcdefghi123456789abcdefghijklm", "project_id": "datadog-apitest", "resource_collection_enabled": true, "token_uri": "https://accounts.google.com/o/oauth2/token", "type": "service_account"} + And body with value {"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs", "auth_uri": "https://accounts.google.com/o/oauth2/auth", "client_email": "{{unique_hash}}@example.com", "client_id": "{{ timestamp("now") }}{{ timestamp("now") }}0", "client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/$CLIENT_EMAIL", "host_filters": "key:value,filter:example", "cloud_run_revision_filters": ["dr:dre"], "is_cspm_enabled": true, "is_security_command_center_enabled": true, "private_key": "private_key", "private_key_id": "123456789abcdefghi123456789abcdefghijklm", "project_id": "datadog-apitest", "resource_collection_enabled": true, "token_uri": "https://accounts.google.com/o/oauth2/token", "type": "service_account"} When the request is sent Then the response status is 200 OK @generated @skip @team:DataDog/gcp-integrations Scenario: Delete a GCP integration returns "Bad Request" response Given new "DeleteGCPIntegration" request - And body with value {"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs", "auth_uri": "https://accounts.google.com/o/oauth2/auth", "client_email": "api-dev@datadog-sandbox.iam.gserviceaccount.com", "client_id": "123456712345671234567", "client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/$CLIENT_EMAIL", "errors": ["*"], "host_filters": "key:value,filter:example", "is_cspm_enabled": true, "is_security_command_center_enabled": true, "private_key": "private_key", "private_key_id": "123456789abcdefghi123456789abcdefghijklm", "project_id": "datadog-apitest", "resource_collection_enabled": true, "token_uri": "https://accounts.google.com/o/oauth2/token", "type": "service_account"} + And body with value {"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs", "auth_uri": "https://accounts.google.com/o/oauth2/auth", "client_email": "api-dev@datadog-sandbox.iam.gserviceaccount.com", "client_id": "123456712345671234567", "client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/$CLIENT_EMAIL", "cloud_run_revision_filters": ["$KEY:$VALUE"], "errors": ["*"], "host_filters": "key:value,filter:example", "is_cspm_enabled": true, "is_security_command_center_enabled": true, "private_key": "private_key", "private_key_id": "123456789abcdefghi123456789abcdefghijklm", "project_id": "datadog-apitest", "resource_collection_enabled": true, "token_uri": "https://accounts.google.com/o/oauth2/token", "type": "service_account"} When the request is sent Then the response status is 400 Bad Request @@ -51,10 +51,18 @@ Feature: GCP Integration When the request is sent Then the response status is 200 OK + @team:DataDog/gcp-integrations + Scenario: Update a GCP integration cloud run revision filters returns "OK" response + Given there is a valid "gcp_account" in the system + And new "UpdateGCPIntegration" request + And body with value {"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs", "auth_uri": "https://accounts.google.com/o/oauth2/auth", "client_email": "{{unique_hash}}@example.com", "client_id": "{{ timestamp("now") }}{{ timestamp("now") }}0", "client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/$CLIENT_EMAIL", "host_filters": "key:value,filter:example", "cloud_run_revision_filters": ["merp:derp"], "is_cspm_enabled": true, "is_security_command_center_enabled": true, "private_key": "private_key", "private_key_id": "123456789abcdefghi123456789abcdefghijklm", "project_id": "datadog-apitest", "resource_collection_enabled": true, "token_uri": "https://accounts.google.com/o/oauth2/token", "type": "service_account"} + When the request is sent + Then the response status is 200 OK + @generated @skip @team:DataDog/gcp-integrations Scenario: Update a GCP integration returns "Bad Request" response Given new "UpdateGCPIntegration" request - And body with value {"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs", "auth_uri": "https://accounts.google.com/o/oauth2/auth", "client_email": "api-dev@datadog-sandbox.iam.gserviceaccount.com", "client_id": "123456712345671234567", "client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/$CLIENT_EMAIL", "errors": ["*"], "host_filters": "key:value,filter:example", "is_cspm_enabled": true, "is_security_command_center_enabled": true, "private_key": "private_key", "private_key_id": "123456789abcdefghi123456789abcdefghijklm", "project_id": "datadog-apitest", "resource_collection_enabled": true, "token_uri": "https://accounts.google.com/o/oauth2/token", "type": "service_account"} + And body with value {"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs", "auth_uri": "https://accounts.google.com/o/oauth2/auth", "client_email": "api-dev@datadog-sandbox.iam.gserviceaccount.com", "client_id": "123456712345671234567", "client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/$CLIENT_EMAIL", "cloud_run_revision_filters": ["$KEY:$VALUE"], "errors": ["*"], "host_filters": "key:value,filter:example", "is_cspm_enabled": true, "is_security_command_center_enabled": true, "private_key": "private_key", "private_key_id": "123456789abcdefghi123456789abcdefghijklm", "project_id": "datadog-apitest", "resource_collection_enabled": true, "token_uri": "https://accounts.google.com/o/oauth2/token", "type": "service_account"} When the request is sent Then the response status is 400 Bad Request diff --git a/tests/v2/cassettes/test_scenarios/test_create_a_new_entry_for_your_service_account_with_cloud_run_revision_filters_enabled_returns_ok_response.frozen b/tests/v2/cassettes/test_scenarios/test_create_a_new_entry_for_your_service_account_with_cloud_run_revision_filters_enabled_returns_ok_response.frozen new file mode 100644 index 0000000000..5078f78fe6 --- /dev/null +++ b/tests/v2/cassettes/test_scenarios/test_create_a_new_entry_for_your_service_account_with_cloud_run_revision_filters_enabled_returns_ok_response.frozen @@ -0,0 +1 @@ +2024-01-31T21:16:04.924Z \ No newline at end of file diff --git a/tests/v2/cassettes/test_scenarios/test_create_a_new_entry_for_your_service_account_with_cloud_run_revision_filters_enabled_returns_ok_response.yaml b/tests/v2/cassettes/test_scenarios/test_create_a_new_entry_for_your_service_account_with_cloud_run_revision_filters_enabled_returns_ok_response.yaml new file mode 100644 index 0000000000..daa4599713 --- /dev/null +++ b/tests/v2/cassettes/test_scenarios/test_create_a_new_entry_for_your_service_account_with_cloud_run_revision_filters_enabled_returns_ok_response.yaml @@ -0,0 +1,38 @@ +interactions: +- request: + body: '{"data":{"attributes":{"client_email":"feb37f50ee7be467@test-project.iam.gserviceaccount.com","cloud_run_revision_filters":["meh:bleh"],"host_filters":[]},"type":"gcp_service_account"}}' + headers: + accept: + - application/json + content-type: + - application/json + method: POST + uri: https://api.datadoghq.com/api/v2/integration/gcp/accounts + response: + body: + string: '{"data":{"type":"gcp_service_account","attributes":{"cloud_run_revision_filters":["meh:bleh"],"resource_collection_enabled":false,"host_filters":[],"automute":false,"is_cspm_enabled":false,"account_tags":[],"client_email":"feb37f50ee7be467@test-project.iam.gserviceaccount.com","is_security_command_center_enabled":false},"id":"e1157377-8d5c-4a94-9730-10c3fa9d6ff5"}} + + ' + headers: + content-type: + - application/json + status: + code: 201 + message: Created +- request: + body: null + headers: + accept: + - '*/*' + method: DELETE + uri: https://api.datadoghq.com/api/v2/integration/gcp/accounts/e1157377-8d5c-4a94-9730-10c3fa9d6ff5 + response: + body: + string: '' + headers: + content-type: + - text/html; charset=utf-8 + status: + code: 204 + message: No Content +version: 1 diff --git a/tests/v2/cassettes/test_scenarios/test_update_sts_service_account_returns_ok_response_with_cloud_run_revision_filters.frozen b/tests/v2/cassettes/test_scenarios/test_update_sts_service_account_returns_ok_response_with_cloud_run_revision_filters.frozen new file mode 100644 index 0000000000..92757ea39a --- /dev/null +++ b/tests/v2/cassettes/test_scenarios/test_update_sts_service_account_returns_ok_response_with_cloud_run_revision_filters.frozen @@ -0,0 +1 @@ +2024-01-31T21:16:05.705Z \ No newline at end of file diff --git a/tests/v2/cassettes/test_scenarios/test_update_sts_service_account_returns_ok_response_with_cloud_run_revision_filters.yaml b/tests/v2/cassettes/test_scenarios/test_update_sts_service_account_returns_ok_response_with_cloud_run_revision_filters.yaml new file mode 100644 index 0000000000..9089bfc2ef --- /dev/null +++ b/tests/v2/cassettes/test_scenarios/test_update_sts_service_account_returns_ok_response_with_cloud_run_revision_filters.yaml @@ -0,0 +1,58 @@ +interactions: +- request: + body: '{"data":{"attributes":{"client_email":"a8e08a7fa29a1adb@example.com","host_filters":[]},"type":"gcp_service_account"}}' + headers: + accept: + - application/json + content-type: + - application/json + method: POST + uri: https://api.datadoghq.com/api/v2/integration/gcp/accounts + response: + body: + string: '{"data":{"type":"gcp_service_account","id":"3e6ad31b-2da5-4ad4-878a-4d290520173b","attributes":{"account_tags":[],"resource_collection_enabled":false,"is_cspm_enabled":false,"automute":false,"host_filters":[],"is_security_command_center_enabled":false,"cloud_run_revision_filters":[],"client_email":"a8e08a7fa29a1adb@example.com"}}} + + ' + headers: + content-type: + - application/json + status: + code: 201 + message: Created +- request: + body: '{"data":{"attributes":{"client_email":"a8e08a7fa29a1adb@example.com","cloud_run_revision_filters":["merp:derp"]},"id":"3e6ad31b-2da5-4ad4-878a-4d290520173b","type":"gcp_service_account"}}' + headers: + accept: + - application/json + content-type: + - application/json + method: PATCH + uri: https://api.datadoghq.com/api/v2/integration/gcp/accounts/3e6ad31b-2da5-4ad4-878a-4d290520173b + response: + body: + string: '{"data":{"type":"gcp_service_account","id":"3e6ad31b-2da5-4ad4-878a-4d290520173b","attributes":{"cloud_run_revision_filters":["merp:derp"],"host_filters":[],"automute":false,"is_security_command_center_enabled":false,"account_tags":[],"client_email":"a8e08a7fa29a1adb@example.com","is_cspm_enabled":false,"resource_collection_enabled":false}}} + + ' + headers: + content-type: + - application/json + status: + code: 201 + message: Created +- request: + body: null + headers: + accept: + - '*/*' + method: DELETE + uri: https://api.datadoghq.com/api/v2/integration/gcp/accounts/3e6ad31b-2da5-4ad4-878a-4d290520173b + response: + body: + string: '' + headers: + content-type: + - text/html; charset=utf-8 + status: + code: 204 + message: No Content +version: 1 diff --git a/tests/v2/features/gcp_integration.feature b/tests/v2/features/gcp_integration.feature index e18714ba2e..6085d6ed2f 100644 --- a/tests/v2/features/gcp_integration.feature +++ b/tests/v2/features/gcp_integration.feature @@ -34,14 +34,14 @@ Feature: GCP Integration @generated @skip @team:DataDog/gcp-integrations Scenario: Create a new entry for your service account returns "Bad Request" response Given new "CreateGCPSTSAccount" request - And body with value {"data": {"attributes": {"account_tags": [], "client_email": "datadog-service-account@test-project.iam.gserviceaccount.com", "host_filters": [], "is_security_command_center_enabled": true}, "type": "gcp_service_account"}} + And body with value {"data": {"attributes": {"account_tags": [], "client_email": "datadog-service-account@test-project.iam.gserviceaccount.com", "cloud_run_revision_filters": ["$KEY:$VALUE"], "host_filters": [], "is_security_command_center_enabled": true}, "type": "gcp_service_account"}} When the request is sent Then the response status is 400 Bad Request @generated @skip @team:DataDog/gcp-integrations Scenario: Create a new entry for your service account returns "Conflict" response Given new "CreateGCPSTSAccount" request - And body with value {"data": {"attributes": {"account_tags": [], "client_email": "datadog-service-account@test-project.iam.gserviceaccount.com", "host_filters": [], "is_security_command_center_enabled": true}, "type": "gcp_service_account"}} + And body with value {"data": {"attributes": {"account_tags": [], "client_email": "datadog-service-account@test-project.iam.gserviceaccount.com", "cloud_run_revision_filters": ["$KEY:$VALUE"], "host_filters": [], "is_security_command_center_enabled": true}, "type": "gcp_service_account"}} When the request is sent Then the response status is 409 Conflict @@ -64,6 +64,16 @@ Feature: GCP Integration And the response "data.attributes.client_email" is equal to "{{ unique_hash }}@test-project.iam.gserviceaccount.com" And the response "data.attributes.account_tags" is equal to ["lorem", "ipsum"] + @team:DataDog/gcp-integrations + Scenario: Create a new entry for your service account with cloud run revision filters enabled returns "OK" response + Given new "CreateGCPSTSAccount" request + And body with value {"data": {"attributes": {"cloud_run_revision_filters": ["meh:bleh"], "client_email": "{{ unique_hash }}@test-project.iam.gserviceaccount.com", "host_filters": []}, "type": "gcp_service_account"}} + When the request is sent + Then the response status is 201 OK + And the response "data.type" is equal to "gcp_service_account" + And the response "data.attributes.client_email" is equal to "{{ unique_hash }}@test-project.iam.gserviceaccount.com" + And the response "data.attributes.cloud_run_revision_filters" is equal to ["meh:bleh"] + @team:DataDog/gcp-integrations Scenario: Create a new entry for your service account with cspm enabled returns "OK" response Given new "CreateGCPSTSAccount" request @@ -140,7 +150,7 @@ Feature: GCP Integration Scenario: Update STS Service Account returns "Bad Request" response Given new "UpdateGCPSTSAccount" request And request contains "account_id" parameter from "REPLACE.ME" - And body with value {"data": {"attributes": {"account_tags": [], "client_email": "datadog-service-account@test-project.iam.gserviceaccount.com", "host_filters": [], "is_security_command_center_enabled": true}, "id": "d291291f-12c2-22g4-j290-123456678897", "type": "gcp_service_account"}} + And body with value {"data": {"attributes": {"account_tags": [], "client_email": "datadog-service-account@test-project.iam.gserviceaccount.com", "cloud_run_revision_filters": ["$KEY:$VALUE"], "host_filters": [], "is_security_command_center_enabled": true}, "id": "d291291f-12c2-22g4-j290-123456678897", "type": "gcp_service_account"}} When the request is sent Then the response status is 400 Bad Request @@ -148,7 +158,7 @@ Feature: GCP Integration Scenario: Update STS Service Account returns "Not Found" response Given new "UpdateGCPSTSAccount" request And request contains "account_id" parameter from "REPLACE.ME" - And body with value {"data": {"attributes": {"account_tags": [], "client_email": "datadog-service-account@test-project.iam.gserviceaccount.com", "host_filters": [], "is_security_command_center_enabled": true}, "id": "d291291f-12c2-22g4-j290-123456678897", "type": "gcp_service_account"}} + And body with value {"data": {"attributes": {"account_tags": [], "client_email": "datadog-service-account@test-project.iam.gserviceaccount.com", "cloud_run_revision_filters": ["$KEY:$VALUE"], "host_filters": [], "is_security_command_center_enabled": true}, "id": "d291291f-12c2-22g4-j290-123456678897", "type": "gcp_service_account"}} When the request is sent Then the response status is 404 Not Found @@ -161,6 +171,15 @@ Feature: GCP Integration When the request is sent Then the response status is 201 OK + @team:DataDog/gcp-integrations + Scenario: Update STS Service Account returns "OK" response with cloud run revision filters + Given there is a valid "gcp_sts_account" in the system + And new "UpdateGCPSTSAccount" request + And request contains "account_id" parameter from "gcp_sts_account.data.id" + And body with value {"data": {"attributes": {"client_email": "{{ unique_hash }}@example.com", "cloud_run_revision_filters": ["merp:derp"]}, "id": "{{ gcp_sts_account.data.id }}", "type": "gcp_service_account"}} + When the request is sent + Then the response status is 201 OK + @team:DataDog/gcp-integrations Scenario: Update STS Service Account returns "OK" response with enable resource collection turned on Given there is a valid "gcp_sts_account" in the system