phanikumv commented on code in PR #30618:
URL: https://github.com/apache/airflow/pull/30618#discussion_r1179059814


##########
airflow/providers/google/cloud/triggers/gcs.py:
##########
@@ -200,3 +200,76 @@ async def _is_blob_updated_after(
                 if blob_updated_time > target_date:
                     return True, {"status": "success", "message": "success"}
             return False, {"status": "pending", "message": "pending"}
+
+
+class GCSPrefixBlobTrigger(GCSBlobTrigger):
+    """
+    Looks for objects in bucket matching a prefix.
+    If none found, sleep for interval and check again. Otherwise, return 
matches.
+
+    :param bucket: the bucket in the google cloud storage where the objects 
are residing.
+    :param prefix: The prefix of the blob_names to match in the Google cloud 
storage bucket
+    :param google_cloud_conn_id: reference to the Google Connection
+    :param poke_interval: polling period in seconds to check
+    """
+
+    def __init__(
+        self,
+        bucket: str,
+        prefix: str,
+        poke_interval: float,
+        google_cloud_conn_id: str,
+        hook_params: dict[str, Any],
+    ):
+        super().__init__(
+            bucket=bucket,
+            object_name=prefix,
+            poke_interval=poke_interval,
+            google_cloud_conn_id=google_cloud_conn_id,
+            hook_params=hook_params,
+        )
+        self.prefix = prefix
+
+    def serialize(self) -> tuple[str, dict[str, Any]]:
+        """Serializes GCSPrefixBlobTrigger arguments and classpath."""
+        return (
+            "airflow.providers.google.cloud.triggers.gcs.GCSPrefixBlobTrigger",
+            {
+                "bucket": self.bucket,
+                "prefix": self.prefix,
+                "poke_interval": self.poke_interval,
+                "google_cloud_conn_id": self.google_cloud_conn_id,
+                "hook_params": self.hook_params,
+            },
+        )
+
+    async def run(self) -> AsyncIterator[TriggerEvent]:
+        """Simple loop until the matches are found for the given prefix on the 
bucket."""
+        try:
+            hook = self._get_async_hook()
+            while True:
+                res = await self._list_blobs_with_prefix(

Review Comment:
   made the change



-- 
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