Taragolis commented on code in PR #34693:
URL: https://github.com/apache/airflow/pull/34693#discussion_r1341948676


##########
docs/integration-logos/aws/Amazon-OpenSearch-light.png:
##########


Review Comment:
   That is logo of OpenSearch as a product, logo of Amazon OpenSearch Service 
(ElasticSearch and OpenSearch) 
   
   
![image](https://github.com/apache/airflow/assets/3998685/bcd0f52b-ca0a-4aae-b90e-c17204e657ab)
   you could take it from https://aws.amazon.com/architecture/icons/
   



##########
airflow/providers/amazon/aws/hooks/opensearch.py:
##########
@@ -0,0 +1,130 @@
+#
+# 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
+
+import json
+from typing import Any
+
+from opensearchpy import AWSV4SignerAuth, OpenSearch, RequestsHttpConnection
+
+from airflow.exceptions import AirflowException
+from airflow.providers.amazon.aws.hooks.base_aws import AwsBaseHook
+
+
+class OpenSearchHook(AwsBaseHook):
+    """
+    This Hook provides a thin wrapper around the OpenSearch client.

Review Comment:
   `AwsBaseHook`/`AwsGenericHook` uses only for `boto3` / `botocore` clients. 
Internals of this hook intend to use with this libraries and may work 
incorrectly if someone call public methods of `AwsBaseHook`/`AwsGenericHook`



##########
airflow/providers/amazon/aws/hooks/opensearch.py:
##########
@@ -0,0 +1,130 @@
+#
+# 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
+
+import json
+from typing import Any
+
+from opensearchpy import AWSV4SignerAuth, OpenSearch, RequestsHttpConnection
+
+from airflow.exceptions import AirflowException
+from airflow.providers.amazon.aws.hooks.base_aws import AwsBaseHook
+
+
+class OpenSearchHook(AwsBaseHook):
+    """
+    This Hook provides a thin wrapper around the OpenSearch client.
+
+    :param: open_search_conn_id: AWS Connection to use with Open Search
+    :param: log_query: Whether to log the query used for Open Search
+    """
+    conn_name_attr = "opensearch_conn_id"
+    default_conn_name = "opensearch_default"
+    conn_type = "opensearch"
+    hook_name = "AWS Open Search Hook"
+
+    def __init__(self, *args: Any, open_search_conn_id: str, log_query: bool, 
**kwargs: Any):
+        super().__init__(*args, **kwargs)
+        self.conn_id = open_search_conn_id
+        self.log_query = log_query
+
+        conn = self.get_connection(self.conn_id)
+        self.use_ssl = conn.extra_dejson.get("use_ssl", False)
+        self.verify_certs = conn.extra_dejson.get("verify_certs", False)
+
+        self.__SERVICE = "es"
+        self._credentials = self.get_credentials(self.region_name)
+        self._auth = AWSV4SignerAuth(self._credentials, self.region_name, 
self.__SERVICE)
+
+        self.client = OpenSearch(
+            hosts=[{"host": conn.host, "port": conn.port}],
+            http_auth=self._auth,
+            use_ssl=self.use_ssl,
+            verify_certs=self.verify_certs,
+            connection_class=RequestsHttpConnection,
+        )

Review Comment:
   We should avoid to call expensive call in Hook constructor, this might be 
move into the cached properties



##########
airflow/providers/amazon/aws/hooks/opensearch.py:
##########
@@ -0,0 +1,130 @@
+#
+# 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
+
+import json
+from typing import Any
+
+from opensearchpy import AWSV4SignerAuth, OpenSearch, RequestsHttpConnection
+
+from airflow.exceptions import AirflowException
+from airflow.providers.amazon.aws.hooks.base_aws import AwsBaseHook
+
+
+class OpenSearchHook(AwsBaseHook):
+    """
+    This Hook provides a thin wrapper around the OpenSearch client.
+
+    :param: open_search_conn_id: AWS Connection to use with Open Search
+    :param: log_query: Whether to log the query used for Open Search
+    """
+    conn_name_attr = "opensearch_conn_id"
+    default_conn_name = "opensearch_default"
+    conn_type = "opensearch"
+    hook_name = "AWS Open Search Hook"
+
+    def __init__(self, *args: Any, open_search_conn_id: str, log_query: bool, 
**kwargs: Any):

Review Comment:
   ```suggestion
       def __init__(self, *, open_search_conn_id: str, log_query: bool, 
**kwargs: Any):
   ```
   
   I would recommend to accept in hook constructor keyword only arguments, 
positional arguments prevent to do some changes in the future without breaking 
changes. 



##########
airflow/providers/amazon/provider.yaml:
##########


Review Comment:
   I think that we should create support of 
[OpenSearch](https://github.com/opensearch-project) (as product) in a separate 
provider. Otherwise this feature would be exclusively available only for AWS.
   
   And after that we could add support of AWS OpenSearch (as managed service) 
into Amazon provider.



##########
generated/provider_dependencies.json:
##########
@@ -28,6 +28,12 @@
       "boto3>=1.28.0",
       "botocore>=1.31.0",
       "jsonpath_ng>=1.5.3",
+      "mypy-boto3-appflow>=1.24.0",
+      "mypy-boto3-rds>=1.24.0",
+      "mypy-boto3-redshift-data>=1.24.0",
+      "mypy-boto3-s3>=1.24.0",

Review Comment:
   mypy packages moved out of the amazon-provider 
   
   ```suggestion
   ```



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