john-jac commented on code in PR #65968:
URL: https://github.com/apache/airflow/pull/65968#discussion_r3154450657


##########
providers/amazon/src/airflow/providers/amazon/aws/operators/s3vectors.py:
##########
@@ -0,0 +1,76 @@
+# 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.
+"""Amazon S3 Vectors operators."""
+
+from __future__ import annotations
+
+from typing import TYPE_CHECKING, Any
+
+from airflow.providers.amazon.aws.hooks.base_aws import AwsBaseHook
+from airflow.providers.amazon.aws.operators.base_aws import AwsBaseOperator
+
+if TYPE_CHECKING:
+    from airflow.sdk import Context
+
+
+class S3VectorsCreateVectorBucketOperator(AwsBaseOperator[AwsBaseHook]):
+    """
+    Create an Amazon S3 Vectors vector bucket.
+
+    .. seealso::
+        For more information on how to use this operator, take a look at the 
guide:
+        :ref:`howto/operator:S3VectorsCreateVectorBucketOperator`
+
+    :param vector_bucket_name: The name of the vector bucket to create (3-63 
chars).
+    :param encryption_configuration: Optional encryption config dict with keys
+        ``sseType`` (``AES256`` or ``aws:kms``) and optionally ``kmsKeyArn``.
+    :param tags: Optional dict of tags to apply to the vector bucket.
+    """
+
+    aws_hook_class = AwsBaseHook
+    template_fields: tuple[str, ...] = (
+        *AwsBaseOperator.template_fields,
+        "vector_bucket_name",
+    )
+
+    def __init__(
+        self,
+        *,
+        vector_bucket_name: str,
+        encryption_configuration: dict[str, Any] | None = None,
+        tags: dict[str, str] | None = None,
+        **kwargs,
+    ) -> None:
+        super().__init__(**kwargs)
+        self.vector_bucket_name = vector_bucket_name
+        self.encryption_configuration = encryption_configuration
+        self.tags = tags
+
+    @property
+    def _hook_parameters(self) -> dict[str, Any]:
+        return {**super()._hook_parameters, "client_type": "s3vectors"}
+
+    def execute(self, context: Context) -> str:
+        kwargs: dict[str, Any] = {"vectorBucketName": self.vector_bucket_name}
+        if self.encryption_configuration is not None:
+            kwargs["encryptionConfiguration"] = self.encryption_configuration
+        if self.tags is not None:
+            kwargs["tags"] = self.tags
+        response = self.hook.conn.create_vector_bucket(**kwargs)

Review Comment:
   Thanks Kaxil.  Fixed.



##########
providers/amazon/tests/unit/amazon/aws/operators/test_s3_vectors.py:
##########
@@ -0,0 +1,69 @@
+# 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 unittest.mock import MagicMock
+
+from airflow.providers.amazon.aws.operators.s3vectors import 
S3VectorsCreateVectorBucketOperator
+
+BUCKET_NAME = "test-vector-bucket"
+BUCKET_ARN = 
"arn:aws:s3vectors:us-east-1:123456789012:bucket/test-vector-bucket"
+
+
+class TestS3VectorsCreateVectorBucketOperator:
+    def test_execute(self):
+        op = S3VectorsCreateVectorBucketOperator(
+            task_id="create_vector_bucket",
+            vector_bucket_name=BUCKET_NAME,
+        )
+        mock_conn = MagicMock()
+        mock_conn.create_vector_bucket.return_value = {"vectorBucketArn": 
BUCKET_ARN}
+        op.hook.conn = mock_conn
+
+        result = op.execute({})
+
+        
mock_conn.create_vector_bucket.assert_called_once_with(vectorBucketName=BUCKET_NAME)
+        assert result == BUCKET_ARN
+
+    def test_execute_with_encryption(self):
+        encryption = {"sseType": "aws:kms", "kmsKeyArn": 
"arn:aws:kms:us-east-1:123456789012:key/abc"}
+        op = S3VectorsCreateVectorBucketOperator(
+            task_id="create_vector_bucket",
+            vector_bucket_name=BUCKET_NAME,
+            encryption_configuration=encryption,
+            tags={"env": "test"},
+        )
+        mock_conn = MagicMock()
+        mock_conn.create_vector_bucket.return_value = {"vectorBucketArn": 
BUCKET_ARN}
+        op.hook.conn = mock_conn
+
+        result = op.execute({})
+
+        mock_conn.create_vector_bucket.assert_called_once_with(
+            vectorBucketName=BUCKET_NAME,
+            encryptionConfiguration=encryption,
+            tags={"env": "test"},
+        )
+        assert result == BUCKET_ARN
+
+    def test_template_fields(self):

Review Comment:
   Thanks should be fixed 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: [email protected]

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

Reply via email to