Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate delegate_to param in GCP operators and update docs #29088

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions airflow/providers/apache/beam/operators/beam.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import os
import stat
import tempfile
import warnings
from abc import ABC, ABCMeta, abstractmethod
from concurrent.futures import ThreadPoolExecutor, as_completed
from contextlib import ExitStack
Expand Down Expand Up @@ -169,6 +170,10 @@ def __init__(
self.default_pipeline_options = default_pipeline_options or {}
self.pipeline_options = pipeline_options or {}
self.gcp_conn_id = gcp_conn_id
if delegate_to:
warnings.warn(
"'delegate_to' parameter is deprecated, please use 'impersonation_chain'", DeprecationWarning
)
self.delegate_to = delegate_to
if isinstance(dataflow_config, dict):
self.dataflow_config = DataflowConfiguration(**dataflow_config)
Expand Down
5 changes: 5 additions & 0 deletions airflow/providers/google/cloud/hooks/automl.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"""
from __future__ import annotations

import warnings
from typing import Sequence

from google.api_core.gapic_v1.method import DEFAULT, _MethodDefault
Expand Down Expand Up @@ -67,6 +68,10 @@ def __init__(
delegate_to: str | None = None,
impersonation_chain: str | Sequence[str] | None = None,
) -> None:
if delegate_to:
warnings.warn(
"'delegate_to' parameter is deprecated, please use 'impersonation_chain'", DeprecationWarning
)
super().__init__(
gcp_conn_id=gcp_conn_id,
delegate_to=delegate_to,
Expand Down
4 changes: 4 additions & 0 deletions airflow/providers/google/cloud/hooks/bigquery.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,10 @@ def __init__(
impersonation_chain: str | Sequence[str] | None = None,
labels: dict | None = None,
) -> None:
if delegate_to:
warnings.warn(
"'delegate_to' parameter is deprecated, please use 'impersonation_chain'", DeprecationWarning
)
super().__init__(
gcp_conn_id=gcp_conn_id,
delegate_to=delegate_to,
Expand Down
5 changes: 5 additions & 0 deletions airflow/providers/google/cloud/hooks/bigquery_dts.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"""This module contains a BigQuery Hook."""
from __future__ import annotations

import warnings
from copy import copy
from typing import Sequence

Expand Down Expand Up @@ -61,6 +62,10 @@ def __init__(
location: str | None = None,
impersonation_chain: str | Sequence[str] | None = None,
) -> None:
if delegate_to:
warnings.warn(
"'delegate_to' parameter is deprecated, please use 'impersonation_chain'", DeprecationWarning
)
super().__init__(
gcp_conn_id=gcp_conn_id,
delegate_to=delegate_to,
Expand Down
5 changes: 5 additions & 0 deletions airflow/providers/google/cloud/hooks/bigtable.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
from __future__ import annotations

import enum
import warnings
from typing import Sequence

from google.cloud.bigtable import Client
Expand Down Expand Up @@ -46,6 +47,10 @@ def __init__(
delegate_to: str | None = None,
impersonation_chain: str | Sequence[str] | None = None,
) -> None:
if delegate_to:
warnings.warn(
"'delegate_to' parameter is deprecated, please use 'impersonation_chain'", DeprecationWarning
)
super().__init__(
gcp_conn_id=gcp_conn_id,
delegate_to=delegate_to,
Expand Down
5 changes: 5 additions & 0 deletions airflow/providers/google/cloud/hooks/cloud_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"""Hook for Google Cloud Build service."""
from __future__ import annotations

import warnings
from typing import Sequence

from google.api_core.exceptions import AlreadyExists
Expand Down Expand Up @@ -59,6 +60,10 @@ def __init__(
delegate_to: str | None = None,
impersonation_chain: str | Sequence[str] | None = None,
) -> None:
if delegate_to:
warnings.warn(
"'delegate_to' parameter is deprecated, please use 'impersonation_chain'", DeprecationWarning
)
super().__init__(
gcp_conn_id=gcp_conn_id, delegate_to=delegate_to, impersonation_chain=impersonation_chain
)
Expand Down
5 changes: 5 additions & 0 deletions airflow/providers/google/cloud/hooks/cloud_memorystore.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"""
from __future__ import annotations

import warnings
from typing import Sequence

from google.api_core import path_template
Expand Down Expand Up @@ -76,6 +77,10 @@ def __init__(
delegate_to: str | None = None,
impersonation_chain: str | Sequence[str] | None = None,
) -> None:
if delegate_to:
warnings.warn(
"'delegate_to' parameter is deprecated, please use 'impersonation_chain'", DeprecationWarning
)
super().__init__(
gcp_conn_id=gcp_conn_id,
delegate_to=delegate_to,
Expand Down
5 changes: 5 additions & 0 deletions airflow/providers/google/cloud/hooks/cloud_sql.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import subprocess
import time
import uuid
import warnings
from inspect import signature
from pathlib import Path
from subprocess import PIPE, Popen
Expand Down Expand Up @@ -94,6 +95,10 @@ def __init__(
delegate_to: str | None = None,
impersonation_chain: str | Sequence[str] | None = None,
) -> None:
if delegate_to:
warnings.warn(
"'delegate_to' parameter is deprecated, please use 'impersonation_chain'", DeprecationWarning
)
super().__init__(
gcp_conn_id=gcp_conn_id,
delegate_to=delegate_to,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,10 @@ def __init__(
delegate_to: str | None = None,
impersonation_chain: str | Sequence[str] | None = None,
) -> None:
if delegate_to:
warnings.warn(
"'delegate_to' parameter is deprecated, please use 'impersonation_chain'", DeprecationWarning
)
super().__init__(
gcp_conn_id=gcp_conn_id,
delegate_to=delegate_to,
Expand Down
5 changes: 5 additions & 0 deletions airflow/providers/google/cloud/hooks/compute.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
from __future__ import annotations

import time
import warnings
from typing import Any, Sequence

from google.api_core.retry import Retry
Expand Down Expand Up @@ -58,6 +59,10 @@ def __init__(
delegate_to: str | None = None,
impersonation_chain: str | Sequence[str] | None = None,
) -> None:
if delegate_to:
warnings.warn(
"'delegate_to' parameter is deprecated, please use 'impersonation_chain'", DeprecationWarning
)
super().__init__(
gcp_conn_id=gcp_conn_id,
delegate_to=delegate_to,
Expand Down
5 changes: 5 additions & 0 deletions airflow/providers/google/cloud/hooks/compute_ssh.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import shlex
import time
import warnings
from io import StringIO
from typing import Any

Expand Down Expand Up @@ -122,6 +123,10 @@ def __init__(
self.use_oslogin = use_oslogin
self.expire_time = expire_time
self.gcp_conn_id = gcp_conn_id
if delegate_to:
warnings.warn(
"'delegate_to' parameter is deprecated, please use 'impersonation_chain'", DeprecationWarning
)
self.delegate_to = delegate_to
self._conn: Any | None = None

Expand Down
5 changes: 5 additions & 0 deletions airflow/providers/google/cloud/hooks/datacatalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
# under the License.
from __future__ import annotations

import warnings
from typing import Sequence

from google.api_core.gapic_v1.method import DEFAULT, _MethodDefault
Expand Down Expand Up @@ -62,6 +63,10 @@ def __init__(
delegate_to: str | None = None,
impersonation_chain: str | Sequence[str] | None = None,
) -> None:
if delegate_to:
warnings.warn(
"'delegate_to' parameter is deprecated, please use 'impersonation_chain'", DeprecationWarning
)
super().__init__(
gcp_conn_id=gcp_conn_id,
delegate_to=delegate_to,
Expand Down
4 changes: 4 additions & 0 deletions airflow/providers/google/cloud/hooks/dataflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,10 @@ def __init__(
self.wait_until_finished = wait_until_finished
self.job_id: str | None = None
self.beam_hook = BeamHook(BeamRunnerType.DataflowRunner)
if delegate_to:
warnings.warn(
"'delegate_to' parameter is deprecated, please use 'impersonation_chain'", DeprecationWarning
)
super().__init__(
gcp_conn_id=gcp_conn_id,
delegate_to=delegate_to,
Expand Down
5 changes: 5 additions & 0 deletions airflow/providers/google/cloud/hooks/datafusion.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import json
import os
import warnings
from time import monotonic, sleep
from typing import Any, Dict, Sequence
from urllib.parse import quote, urlencode, urljoin
Expand Down Expand Up @@ -69,6 +70,10 @@ def __init__(
delegate_to: str | None = None,
impersonation_chain: str | Sequence[str] | None = None,
) -> None:
if delegate_to:
warnings.warn(
"'delegate_to' parameter is deprecated, please use 'impersonation_chain'", DeprecationWarning
)
super().__init__(
gcp_conn_id=gcp_conn_id,
delegate_to=delegate_to,
Expand Down
5 changes: 5 additions & 0 deletions airflow/providers/google/cloud/hooks/dataplex.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"""This module contains Google Dataplex hook."""
from __future__ import annotations

import warnings
from typing import Any, Sequence

from google.api_core.client_options import ClientOptions
Expand Down Expand Up @@ -59,6 +60,10 @@ def __init__(
delegate_to: str | None = None,
impersonation_chain: str | Sequence[str] | None = None,
) -> None:
if delegate_to:
warnings.warn(
"'delegate_to' parameter is deprecated, please use 'impersonation_chain'", DeprecationWarning
)
super().__init__(
gcp_conn_id=gcp_conn_id,
delegate_to=delegate_to,
Expand Down
5 changes: 5 additions & 0 deletions airflow/providers/google/cloud/hooks/dataproc.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import time
import uuid
import warnings
from typing import Any, Sequence

from google.api_core.client_options import ClientOptions
Expand Down Expand Up @@ -210,6 +211,10 @@ def __init__(
delegate_to: str | None = None,
impersonation_chain: str | Sequence[str] | None = None,
) -> None:
if delegate_to:
warnings.warn(
"'delegate_to' parameter is deprecated, please use 'impersonation_chain'", DeprecationWarning
)
super().__init__(gcp_conn_id, delegate_to, impersonation_chain)

def get_cluster_client(self, region: str | None = None) -> ClusterControllerClient:
Expand Down
5 changes: 5 additions & 0 deletions airflow/providers/google/cloud/hooks/datastore.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
from __future__ import annotations

import time
import warnings
from typing import Any, Sequence

from googleapiclient.discovery import Resource, build
Expand All @@ -43,6 +44,10 @@ def __init__(
api_version: str = "v1",
impersonation_chain: str | Sequence[str] | None = None,
) -> None:
if delegate_to:
warnings.warn(
"'delegate_to' parameter is deprecated, please use 'impersonation_chain'", DeprecationWarning
)
super().__init__(
gcp_conn_id=gcp_conn_id,
delegate_to=delegate_to,
Expand Down
5 changes: 5 additions & 0 deletions airflow/providers/google/cloud/hooks/dlp.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

import re
import time
import warnings
from typing import Sequence

from google.api_core.gapic_v1.method import DEFAULT, _MethodDefault
Expand Down Expand Up @@ -91,6 +92,10 @@ def __init__(
delegate_to: str | None = None,
impersonation_chain: str | Sequence[str] | None = None,
) -> None:
if delegate_to:
warnings.warn(
"'delegate_to' parameter is deprecated, please use 'impersonation_chain'", DeprecationWarning
)
super().__init__(
gcp_conn_id=gcp_conn_id,
delegate_to=delegate_to,
Expand Down
5 changes: 5 additions & 0 deletions airflow/providers/google/cloud/hooks/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
from __future__ import annotations

import time
import warnings
from typing import Sequence

import requests
Expand Down Expand Up @@ -48,6 +49,10 @@ def __init__(
delegate_to: str | None = None,
impersonation_chain: str | Sequence[str] | None = None,
) -> None:
if delegate_to:
warnings.warn(
"'delegate_to' parameter is deprecated, please use 'impersonation_chain'", DeprecationWarning
)
super().__init__(
gcp_conn_id=gcp_conn_id,
delegate_to=delegate_to,
Expand Down
5 changes: 5 additions & 0 deletions airflow/providers/google/cloud/hooks/gcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import os
import shutil
import time
import warnings
from contextlib import contextmanager
from datetime import datetime
from functools import partial
Expand Down Expand Up @@ -144,6 +145,10 @@ def __init__(
delegate_to: str | None = None,
impersonation_chain: str | Sequence[str] | None = None,
) -> None:
if delegate_to:
warnings.warn(
"'delegate_to' parameter is deprecated, please use 'impersonation_chain'", DeprecationWarning
)
super().__init__(
gcp_conn_id=gcp_conn_id,
delegate_to=delegate_to,
Expand Down
5 changes: 5 additions & 0 deletions airflow/providers/google/cloud/hooks/gdm.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
# under the License.
from __future__ import annotations

import warnings
from typing import Any, Sequence

from googleapiclient.discovery import Resource, build
Expand All @@ -37,6 +38,10 @@ def __init__(
delegate_to: str | None = None,
impersonation_chain: str | Sequence[str] | None = None,
) -> None:
if delegate_to:
warnings.warn(
"'delegate_to' parameter is deprecated, please use 'impersonation_chain'", DeprecationWarning
)
super().__init__(
gcp_conn_id=gcp_conn_id,
delegate_to=delegate_to,
Expand Down
5 changes: 5 additions & 0 deletions airflow/providers/google/cloud/hooks/kms.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
from __future__ import annotations

import base64
import warnings
from typing import Sequence

from google.api_core.gapic_v1.method import DEFAULT, _MethodDefault
Expand Down Expand Up @@ -63,6 +64,10 @@ def __init__(
delegate_to: str | None = None,
impersonation_chain: str | Sequence[str] | None = None,
) -> None:
if delegate_to:
warnings.warn(
"'delegate_to' parameter is deprecated, please use 'impersonation_chain'", DeprecationWarning
)
super().__init__(
gcp_conn_id=gcp_conn_id,
delegate_to=delegate_to,
Expand Down
Loading