gopidesupavan commented on code in PR #39592:
URL: https://github.com/apache/airflow/pull/39592#discussion_r1599402592


##########
airflow/providers/amazon/aws/operators/comprehend.py:
##########
@@ -0,0 +1,195 @@
+# 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.
+from __future__ import annotations
+
+from functools import cached_property
+from typing import TYPE_CHECKING, Any, Sequence
+
+from airflow.configuration import conf
+from airflow.exceptions import AirflowException
+from airflow.providers.amazon.aws.hooks.comprehend import ComprehendHook
+from airflow.providers.amazon.aws.operators.base_aws import AwsBaseOperator
+from airflow.providers.amazon.aws.triggers.comprehend import 
ComprehendPiiEntitiesDetectionJobCompletedTrigger
+from airflow.providers.amazon.aws.utils import validate_execute_complete_event
+from airflow.providers.amazon.aws.utils.mixins import aws_template_fields
+from airflow.utils.timezone import utcnow
+
+if TYPE_CHECKING:
+    import boto3
+
+    from airflow.utils.context import Context
+
+
+class ComprehendBaseOperator(AwsBaseOperator[ComprehendHook]):
+    """
+    This is the base operator for Comprehend Service operators (not supposed 
to be used directly in DAGs).
+
+    :param input_data_config: The input properties for a PII entities 
detection job. (templated)
+    :param output_data_config: Provides `configuration` parameters for the 
output of PII entity detection
+        jobs. (templated)
+    :param mode: Specifies whether the output provides the locations (offsets) 
of PII  entities or a file in
+        which PII entities are redacted. If you set the mode parameter to 
ONLY_REDACTION. In that case you
+        must provide a RedactionConfig.
+    :param data_access_role_arn: The Amazon Resource Name (ARN) of the IAM 
role that grants Amazon Comprehend
+        read access to your input data. (templated)
+    :param language_code: The language of the input documents. (templated)
+    """
+
+    aws_hook_class = ComprehendHook
+
+    template_fields: Sequence[str] = aws_template_fields(
+        "input_data_config", "output_data_config", "data_access_role_arn", 
"language_code"
+    )
+
+    template_fields_renderers: dict = {"input_data_config": "json", 
"output_data_config": "json"}
+
+    def __init__(
+        self,
+        input_data_config: dict,
+        output_data_config: dict,
+        data_access_role_arn: str,
+        language_code: str,
+        **kwargs,
+    ):
+        super().__init__(**kwargs)
+        self.input_data_config = input_data_config
+        self.output_data_config = output_data_config
+        self.data_access_role_arn = data_access_role_arn
+        self.language_code = language_code
+
+    @cached_property
+    def client(self) -> boto3.client:
+        """Create and return the Comprehend client."""
+        return self.hook.conn
+
+    def execute(self, context: Context):
+        """Must overwrite in child classes."""
+        raise NotImplementedError("Please implement execute() in subclass")
+
+
+class ComprehendStartPiiEntitiesDetectionJobOperator(ComprehendBaseOperator):
+    """
+    Create a comprehend pii entities detection job for a collection of 
documents.
+
+    .. seealso::
+        For more information on how to use this operator, take a look at the 
guide:
+        :ref:`howto/operator:ComprehendStartPiiEntitiesDetectionJobOperator`
+
+    :param input_data_config: The input properties for a PII entities 
detection job. (templated)
+    :param output_data_config: Provides `configuration` parameters for the 
output of PII entity detection
+        jobs. (templated)
+    :param mode: Specifies whether the output provides the locations (offsets) 
of PII  entities or a file in
+        which PII entities are redacted. If you set the mode parameter to 
ONLY_REDACTION. In that case you
+        must provide a RedactionConfig.

Review Comment:
   Yes it comes from pii entities kwargs , have updated little more description 
now 😄 .



-- 
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: commits-unsubscr...@airflow.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to