diff --git a/airflow/providers/google/CHANGELOG.rst b/airflow/providers/google/CHANGELOG.rst index 6129659bad43e..516c67c46c908 100644 --- a/airflow/providers/google/CHANGELOG.rst +++ b/airflow/providers/google/CHANGELOG.rst @@ -23,6 +23,16 @@ Changelog --------- +10.0.0 +...... + +Breaking changes +~~~~~~~~~~~~~~~~ + +Google has announced sunset of Campaign Manager 360 v3.5 by Apr 20, 2023. For more information +please check: ``_ . As a result, the +default api version for Campaign Manager 360 operator was updated to the latest v4 version. + 9.0.0 ..... diff --git a/airflow/providers/google/marketing_platform/hooks/campaign_manager.py b/airflow/providers/google/marketing_platform/hooks/campaign_manager.py index f64d3f3b3cf6a..f0a02ddd255e3 100644 --- a/airflow/providers/google/marketing_platform/hooks/campaign_manager.py +++ b/airflow/providers/google/marketing_platform/hooks/campaign_manager.py @@ -34,7 +34,7 @@ class GoogleCampaignManagerHook(GoogleBaseHook): def __init__( self, - api_version: str = "v3.3", + api_version: str = "v4", gcp_conn_id: str = "google_cloud_default", delegate_to: str | None = None, impersonation_chain: str | Sequence[str] | None = None, @@ -236,7 +236,7 @@ def conversions_batch_insert( :param profile_id: User profile ID associated with this request. :param conversions: Conversations to insert, should by type of Conversation: - https://developers.google.com/doubleclick-advertisers/v3.3/conversions#resource + https://developers.google.com/doubleclick-advertisers/rest/v4/conversions/batchinsert :param encryption_entity_type: The encryption entity type. This should match the encryption configuration for ad serving or Data Transfer. :param encryption_entity_id: The encryption entity ID. This should match the encryption @@ -280,7 +280,7 @@ def conversions_batch_update( :param profile_id: User profile ID associated with this request. :param conversions: Conversations to update, should by type of Conversation: - https://developers.google.com/doubleclick-advertisers/v3.3/conversions#resource + https://developers.google.com/doubleclick-advertisers/rest/v4/conversions/batchupdate :param encryption_entity_type: The encryption entity type. This should match the encryption configuration for ad serving or Data Transfer. :param encryption_entity_id: The encryption entity ID. This should match the encryption diff --git a/airflow/providers/google/marketing_platform/operators/campaign_manager.py b/airflow/providers/google/marketing_platform/operators/campaign_manager.py index e9dcfc95dd302..739d1328892ae 100644 --- a/airflow/providers/google/marketing_platform/operators/campaign_manager.py +++ b/airflow/providers/google/marketing_platform/operators/campaign_manager.py @@ -40,7 +40,7 @@ class GoogleCampaignManagerDeleteReportOperator(BaseOperator): .. seealso:: Check official API docs: - https://developers.google.com/doubleclick-advertisers/v3.3/reports/delete + `https://developers.google.com/doubleclick-advertisers/rest/v4/reports/delete` .. seealso:: For more information on how to use this operator, take a look at the guide: @@ -49,7 +49,7 @@ class GoogleCampaignManagerDeleteReportOperator(BaseOperator): :param profile_id: The DFA user profile ID. :param report_name: The name of the report to delete. :param report_id: The ID of the report. - :param api_version: The version of the api that will be requested for example 'v3'. + :param api_version: The version of the api that will be requested, for example 'v4'. :param gcp_conn_id: The connection ID to use when fetching connection info. :param delegate_to: The account to impersonate using domain-wide delegation of authority, if any. For this to work, the service account making the request must have @@ -80,7 +80,7 @@ def __init__( profile_id: str, report_name: str | None = None, report_id: str | None = None, - api_version: str = "v3.3", + api_version: str = "v4", gcp_conn_id: str = "google_cloud_default", delegate_to: str | None = None, impersonation_chain: str | Sequence[str] | None = None, @@ -127,7 +127,7 @@ class GoogleCampaignManagerDownloadReportOperator(BaseOperator): .. seealso:: Check official API docs: - https://developers.google.com/doubleclick-advertisers/v3.3/reports/files/get + `https://developers.google.com/doubleclick-advertisers/rest/v4/reports/get` .. seealso:: For more information on how to use this operator, take a look at the guide: @@ -140,7 +140,7 @@ class GoogleCampaignManagerDownloadReportOperator(BaseOperator): :param report_name: The report name to set when uploading the local file. :param gzip: Option to compress local file or file data for upload :param chunk_size: File will be downloaded in chunks of this many bytes. - :param api_version: The version of the api that will be requested for example 'v3'. + :param api_version: The version of the api that will be requested, for example 'v4'. :param gcp_conn_id: The connection ID to use when fetching connection info. :param delegate_to: The account to impersonate using domain-wide delegation of authority, if any. For this to work, the service account making the request must have @@ -178,7 +178,7 @@ def __init__( report_name: str | None = None, gzip: bool = True, chunk_size: int = 10 * 1024 * 1024, - api_version: str = "v3.3", + api_version: str = "v4", gcp_conn_id: str = "google_cloud_default", delegate_to: str | None = None, impersonation_chain: str | Sequence[str] | None = None, @@ -259,7 +259,7 @@ class GoogleCampaignManagerInsertReportOperator(BaseOperator): .. seealso:: Check official API docs: - https://developers.google.com/doubleclick-advertisers/v3.3/reports/insert + `https://developers.google.com/doubleclick-advertisers/rest/v4/reports/insert` .. seealso:: For more information on how to use this operator, take a look at the guide: @@ -267,7 +267,7 @@ class GoogleCampaignManagerInsertReportOperator(BaseOperator): :param profile_id: The DFA user profile ID. :param report: Report to be created. - :param api_version: The version of the api that will be requested for example 'v3'. + :param api_version: The version of the api that will be requested, for example 'v4'. :param gcp_conn_id: The connection ID to use when fetching connection info. :param delegate_to: The account to impersonate using domain-wide delegation of authority, if any. For this to work, the service account making the request must have @@ -298,7 +298,7 @@ def __init__( *, profile_id: str, report: dict[str, Any], - api_version: str = "v3.3", + api_version: str = "v4", gcp_conn_id: str = "google_cloud_default", delegate_to: str | None = None, impersonation_chain: str | Sequence[str] | None = None, @@ -339,7 +339,7 @@ class GoogleCampaignManagerRunReportOperator(BaseOperator): .. seealso:: Check official API docs: - https://developers.google.com/doubleclick-advertisers/v3.3/reports/run + `https://developers.google.com/doubleclick-advertisers/rest/v4/reports/run` .. seealso:: For more information on how to use this operator, take a look at the guide: @@ -348,7 +348,7 @@ class GoogleCampaignManagerRunReportOperator(BaseOperator): :param profile_id: The DFA profile ID. :param report_id: The ID of the report. :param synchronous: If set and true, tries to run the report synchronously. - :param api_version: The version of the api that will be requested for example 'v3'. + :param api_version: The version of the api that will be requested, for example 'v4'. :param gcp_conn_id: The connection ID to use when fetching connection info. :param delegate_to: The account to impersonate using domain-wide delegation of authority, if any. For this to work, the service account making the request must have @@ -379,7 +379,7 @@ def __init__( profile_id: str, report_id: str, synchronous: bool = False, - api_version: str = "v3.3", + api_version: str = "v4", gcp_conn_id: str = "google_cloud_default", delegate_to: str | None = None, impersonation_chain: str | Sequence[str] | None = None, @@ -419,15 +419,15 @@ class GoogleCampaignManagerBatchInsertConversionsOperator(BaseOperator): .. seealso:: Check official API docs: - https://developers.google.com/doubleclick-advertisers/v3.3/conversions/batchinsert + `https://developers.google.com/doubleclick-advertisers/rest/v4/conversions/batchinsert` .. seealso:: For more information on how to use this operator, take a look at the guide: :ref:`howto/operator:GoogleCampaignManagerBatchInsertConversionsOperator` :param profile_id: User profile ID associated with this request. - :param conversions: Conversations to insert, should by type of Conversation: - https://developers.google.com/doubleclick-advertisers/v3.3/conversions#resource + :param conversions: Conversions to insert, should be type of Conversion: + https://developers.google.com/doubleclick-advertisers/rest/v4/conversions :param encryption_entity_type: The encryption entity type. This should match the encryption configuration for ad serving or Data Transfer. :param encryption_entity_id: The encryption entity ID. This should match the encryption @@ -435,7 +435,7 @@ class GoogleCampaignManagerBatchInsertConversionsOperator(BaseOperator): :param encryption_source: Describes whether the encrypted cookie was received from ad serving (the %m macro) or from Data Transfer. :param max_failed_inserts: The maximum number of conversions that failed to be inserted - :param api_version: The version of the api that will be requested for example 'v3'. + :param api_version: The version of the api that will be requested, for example 'v4'. :param gcp_conn_id: The connection ID to use when fetching connection info. :param delegate_to: The account to impersonate using domain-wide delegation of authority, if any. For this to work, the service account making the request must have @@ -468,7 +468,7 @@ def __init__( encryption_entity_id: int, encryption_source: str, max_failed_inserts: int = 0, - api_version: str = "v3.3", + api_version: str = "v4", gcp_conn_id: str = "google_cloud_default", delegate_to: str | None = None, impersonation_chain: str | Sequence[str] | None = None, @@ -510,15 +510,15 @@ class GoogleCampaignManagerBatchUpdateConversionsOperator(BaseOperator): .. seealso:: Check official API docs: - https://developers.google.com/doubleclick-advertisers/v3.3/conversions/batchupdate + `https://developers.google.com/doubleclick-advertisers/rest/v4/conversions/batchupdate` .. seealso:: For more information on how to use this operator, take a look at the guide: :ref:`howto/operator:GoogleCampaignManagerBatchUpdateConversionsOperator` :param profile_id: User profile ID associated with this request. - :param conversions: Conversations to update, should by type of Conversation: - https://developers.google.com/doubleclick-advertisers/v3.3/conversions#resource + :param conversions: Conversations to update, should be type of Conversion: + https://developers.google.com/doubleclick-advertisers/rest/v4/conversions :param encryption_entity_type: The encryption entity type. This should match the encryption configuration for ad serving or Data Transfer. :param encryption_entity_id: The encryption entity ID. This should match the encryption @@ -526,7 +526,7 @@ class GoogleCampaignManagerBatchUpdateConversionsOperator(BaseOperator): :param encryption_source: Describes whether the encrypted cookie was received from ad serving (the %m macro) or from Data Transfer. :param max_failed_updates: The maximum number of conversions that failed to be updated - :param api_version: The version of the api that will be requested for example 'v3'. + :param api_version: The version of the api that will be requested, for example 'v4'. :param gcp_conn_id: The connection ID to use when fetching connection info. :param delegate_to: The account to impersonate using domain-wide delegation of authority, if any. For this to work, the service account making the request must have @@ -559,7 +559,7 @@ def __init__( encryption_entity_id: int, encryption_source: str, max_failed_updates: int = 0, - api_version: str = "v3.3", + api_version: str = "v4", gcp_conn_id: str = "google_cloud_default", delegate_to: str | None = None, impersonation_chain: str | Sequence[str] | None = None, diff --git a/airflow/providers/google/marketing_platform/sensors/campaign_manager.py b/airflow/providers/google/marketing_platform/sensors/campaign_manager.py index d8c0a3166c211..0bc5ae1d8b556 100644 --- a/airflow/providers/google/marketing_platform/sensors/campaign_manager.py +++ b/airflow/providers/google/marketing_platform/sensors/campaign_manager.py @@ -33,7 +33,7 @@ class GoogleCampaignManagerReportSensor(BaseSensorOperator): .. seealso:: Check official API docs: - https://developers.google.com/doubleclick-advertisers/v3.3/reports/get + https://developers.google.com/doubleclick-advertisers/rest/v4/reports/get .. seealso:: For more information on how to use this operator, take a look at the guide: @@ -42,7 +42,7 @@ class GoogleCampaignManagerReportSensor(BaseSensorOperator): :param profile_id: The DFA user profile ID. :param report_id: The ID of the report. :param file_id: The ID of the report file. - :param api_version: The version of the api that will be requested for example 'v3'. + :param api_version: The version of the api that will be requested, for example 'v4'. :param gcp_conn_id: The connection ID to use when fetching connection info. :param delegate_to: The account to impersonate using domain-wide delegation of authority, if any. For this to work, the service account making the request must have @@ -81,7 +81,7 @@ def __init__( profile_id: str, report_id: str, file_id: str, - api_version: str = "v3.3", + api_version: str = "v4", gcp_conn_id: str = "google_cloud_default", delegate_to: str | None = None, mode: str = "reschedule", diff --git a/airflow/providers/google/provider.yaml b/airflow/providers/google/provider.yaml index 6b3006c8c0229..6211b2d60d918 100644 --- a/airflow/providers/google/provider.yaml +++ b/airflow/providers/google/provider.yaml @@ -30,6 +30,7 @@ description: | suspended: false versions: + - 10.0.0 - 9.0.0 - 8.12.0 - 8.11.0 diff --git a/docs/apache-airflow-providers-google/operators/marketing_platform/campaign_manager.rst b/docs/apache-airflow-providers-google/operators/marketing_platform/campaign_manager.rst index 4305962399d34..2c01bd95f084f 100644 --- a/docs/apache-airflow-providers-google/operators/marketing_platform/campaign_manager.rst +++ b/docs/apache-airflow-providers-google/operators/marketing_platform/campaign_manager.rst @@ -19,8 +19,8 @@ Google Campaign Manager Operators ================================= Google Campaign Manager operators allow you to insert, run, get or delete -reports. For more information about the Campaign Manager API check -`official documentation `__. +reports. For more information about the Campaign Manager report API check +`official documentation `__. Prerequisite Tasks ^^^^^^^^^^^^^^^^^^ @@ -124,7 +124,7 @@ The result is saved to :ref:`XCom `, which allows it to be used b .. _howto/operator:GoogleCampaignManagerBatchInsertConversionsOperator: -Inserting a conversions +Inserting conversions ^^^^^^^^^^^^^^^^^^^^^^^ To insert Campaign Manager conversions you can use the @@ -143,7 +143,7 @@ The result is saved to :ref:`XCom `, which allows it to be used b .. _howto/operator:GoogleCampaignManagerBatchUpdateConversionsOperator: -Updating a conversions +Updating conversions ^^^^^^^^^^^^^^^^^^^^^^ To update Campaign Manager conversions you can use the diff --git a/tests/providers/google/marketing_platform/hooks/test_campaign_manager.py b/tests/providers/google/marketing_platform/hooks/test_campaign_manager.py index c7fcc2a048f61..2e7cd821b3c25 100644 --- a/tests/providers/google/marketing_platform/hooks/test_campaign_manager.py +++ b/tests/providers/google/marketing_platform/hooks/test_campaign_manager.py @@ -22,7 +22,7 @@ from airflow.providers.google.marketing_platform.hooks.campaign_manager import GoogleCampaignManagerHook from tests.providers.google.cloud.utils.base_gcp_mock import mock_base_gcp_hook_default_project_id -API_VERSION = "v3.3" +API_VERSION = "v4" GCP_CONN_ID = "google_cloud_default" REPORT_ID = "REPORT_ID" diff --git a/tests/providers/google/marketing_platform/operators/test_campaign_manager.py b/tests/providers/google/marketing_platform/operators/test_campaign_manager.py index bd52f05b176f4..adb38369bb4db 100644 --- a/tests/providers/google/marketing_platform/operators/test_campaign_manager.py +++ b/tests/providers/google/marketing_platform/operators/test_campaign_manager.py @@ -35,7 +35,7 @@ from airflow.utils import timezone from airflow.utils.session import create_session -API_VERSION = "api_version" +API_VERSION = "v4" GCP_CONN_ID = "google_cloud_default" CONVERSION = { diff --git a/tests/providers/google/marketing_platform/sensors/test_campaign_manager.py b/tests/providers/google/marketing_platform/sensors/test_campaign_manager.py index 09fcb12748815..3c74a3c8f117f 100644 --- a/tests/providers/google/marketing_platform/sensors/test_campaign_manager.py +++ b/tests/providers/google/marketing_platform/sensors/test_campaign_manager.py @@ -23,7 +23,7 @@ GoogleCampaignManagerReportSensor, ) -API_VERSION = "api_version" +API_VERSION = "v4" GCP_CONN_ID = "google_cloud_default" diff --git a/tests/system/providers/google/marketing_platform/example_campaign_manager.py b/tests/system/providers/google/marketing_platform/example_campaign_manager.py index a59c718e65cec..9c8fd0a5b4867 100644 --- a/tests/system/providers/google/marketing_platform/example_campaign_manager.py +++ b/tests/system/providers/google/marketing_platform/example_campaign_manager.py @@ -22,6 +22,7 @@ import os import time +import uuid from datetime import datetime from typing import cast @@ -53,19 +54,31 @@ DEVICE_ID = os.environ.get("DEVICE_ID", "12345") BUCKET_NAME = f"bucket_{DAG_ID}_{ENV_ID}" REPORT_NAME = f"report_{DAG_ID}_{ENV_ID}" +FILE_NAME = f"file_{DAG_ID}_{ENV_ID}" +ACCOUNT_ID = f"account_{DAG_ID}_{ENV_ID}" +FORMAT = "CSV" + +# For more information, please check +# https://developers.google.com/doubleclick-advertisers/rest/v4/reports#type REPORT = { + "kind": "dfareporting#report", "type": "STANDARD", "name": REPORT_NAME, + "fileName": FILE_NAME, + "accountId": ACCOUNT_ID, + "format": FORMAT, "criteria": { "dateRange": { "kind": "dfareporting#dateRange", "relativeDateRange": "LAST_365_DAYS", }, - "dimensions": [{"kind": "dfareporting#sortedDimension", "name": "dfa:advertiser"}], - "metricNames": ["dfa:activeViewImpressionDistributionViewable"], + "dimensions": [{"kind": "dfareporting#sortedDimension", "name": "campaign"}], + "metricNames": ["activeViewImpressionDistributionViewable"], }, } +# For more information, please check +# https://developers.google.com/doubleclick-advertisers/rest/v4/Conversion CONVERSION = { "kind": "dfareporting#conversion", "floodlightActivityId": FLOODLIGHT_ACTIVITY_ID, @@ -129,12 +142,13 @@ # [END howto_campaign_manager_wait_for_operation] # [START howto_campaign_manager_get_report_operator] + report_name = f"reports/report_{str(uuid.uuid1())}" get_report = GoogleCampaignManagerDownloadReportOperator( task_id="get_report", profile_id=PROFILE_ID, report_id=report_id, file_id=file_id, - report_name="test_report.csv", + report_name=report_name, bucket_name=BUCKET_NAME, ) # [END howto_campaign_manager_get_report_operator]