yuseok89 commented on code in PR #64966:
URL: https://github.com/apache/airflow/pull/64966#discussion_r3148296252


##########
providers/microsoft/azure/src/airflow/providers/microsoft/azure/transfers/gcs_to_wasb.py:
##########
@@ -0,0 +1,258 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+"""This module contains Google Cloud Storage to Azure Blob Storage operator."""
+
+from __future__ import annotations
+
+import os
+from collections.abc import Sequence
+from typing import TYPE_CHECKING
+
+from packaging.version import Version
+
+from airflow.providers.common.compat.sdk import BaseOperator
+from airflow.providers.microsoft.azure.hooks.wasb import WasbHook
+
+try:
+    from airflow.providers.google.cloud.hooks.gcs import GCSHook
+except ModuleNotFoundError as e:
+    from airflow.providers.common.compat.sdk import 
AirflowOptionalProviderFeatureException
+
+    raise AirflowOptionalProviderFeatureException(e)
+
+if TYPE_CHECKING:
+    from airflow.providers.openlineage.extractors import OperatorLineage
+    from airflow.sdk import Context
+
+
+class GCSToAzureBlobStorageOperator(BaseOperator):
+    """
+    Synchronizes objects from a Google Cloud Storage bucket to Azure Blob 
Storage.
+
+    .. note::
+        When ``flatten_structure=True``, it takes precedence over 
``keep_directory_structure``.
+        For example, with ``flatten_structure=True``, 
``folder/subfolder/file.txt`` becomes
+        ``file.txt`` regardless of the ``keep_directory_structure`` setting.
+
+        Objects whose names end with ``/`` (GCS console folder markers) and 
keys that become an
+        empty destination path after ``flatten_structure`` are skipped.
+
+    .. seealso::
+        For more information on how to use this operator, take a look at the 
guide:
+        :ref:`howto/operator:GCSToAzureBlobStorageOperator`
+
+    :param gcs_bucket: The GCS bucket to list objects from. (templated)
+    :param prefix: Prefix to filter object names under the bucket. (templated)
+    :param gcp_conn_id: Airflow connection ID for Google Cloud.
+    :param google_impersonation_chain: Optional impersonation chain for GCP 
credentials.
+    :param gcp_user_project: Requester-pays billing project for GCS requests, 
if required.
+    :param match_glob: Optional glob filter for object names (requires
+        ``apache-airflow-providers-google>=10.3.0``).
+    :param container_name: Azure Blob container to upload into. (templated)
+    :param blob_prefix: Base blob path for uploaded objects. (templated)
+    :param wasb_conn_id: Airflow connection ID for Azure Blob Storage.
+    :param replace: If ``True``, overwrite existing blobs (``overwrite=True`` 
on upload) and
+        upload all listed objects. If ``False``, skip objects that already 
exist under
+        ``blob_prefix`` with the same relative path and pass 
``overwrite=False`` on upload.
+    :param keep_directory_structure: When ``False`` and ``prefix`` is set (and
+        ``flatten_structure`` is ``False``), append ``prefix`` to 
``blob_prefix``.
+    :param flatten_structure: If ``True``, upload each object using only its 
file name
+        under ``blob_prefix``. Takes precedence over 
``keep_directory_structure``.
+    :param create_container: If ``True``, create the container when missing 
before upload.
+    """
+
+    template_fields: Sequence[str] = (
+        "gcs_bucket",
+        "prefix",
+        "blob_prefix",
+        "container_name",
+        "google_impersonation_chain",
+        "gcp_user_project",
+        "match_glob",
+    )
+    ui_color = "#f0eee4"
+
+    def __init__(
+        self,
+        *,
+        gcs_bucket: str,
+        container_name: str,
+        blob_prefix: str = "",
+        prefix: str | None = None,
+        gcp_conn_id: str = "google_cloud_default",
+        google_impersonation_chain: str | Sequence[str] | None = None,
+        wasb_conn_id: str = "wasb_default",
+        replace: bool = False,
+        keep_directory_structure: bool = True,
+        flatten_structure: bool = False,
+        match_glob: str | None = None,
+        gcp_user_project: str | None = None,
+        create_container: bool = False,
+        **kwargs,
+    ) -> None:
+        super().__init__(**kwargs)
+        self.gcs_bucket = gcs_bucket
+        self.prefix = prefix
+        self.gcp_conn_id = gcp_conn_id
+        self.google_impersonation_chain = google_impersonation_chain
+        self.container_name = container_name
+        self.blob_prefix = blob_prefix
+        self.wasb_conn_id = wasb_conn_id
+        self.replace = replace
+        self.keep_directory_structure = keep_directory_structure
+        self.flatten_structure = flatten_structure
+        self.gcp_user_project = gcp_user_project
+        self.create_container = create_container
+
+        if self.flatten_structure and self.keep_directory_structure:
+            self.log.warning("flatten_structure=True takes precedence over 
keep_directory_structure=True")
+
+        try:
+            from airflow.providers.google import __version__ as 
_GOOGLE_PROVIDER_VERSION
+
+            if Version(Version(_GOOGLE_PROVIDER_VERSION).base_version) >= 
Version("10.3.0"):
+                self.__is_match_glob_supported = True
+            else:
+                self.__is_match_glob_supported = False
+        except ImportError:
+            self.__is_match_glob_supported = False

Review Comment:
   Applied. Also renamed line 134.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to