o-nikolas commented on code in PR #46340:
URL: https://github.com/apache/airflow/pull/46340#discussion_r1939928344


##########
providers/src/airflow/providers/amazon/aws/links/ec2.py:
##########
@@ -0,0 +1,47 @@
+# 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 airflow.providers.amazon.aws.links.base_aws import BASE_AWS_CONSOLE_LINK, 
BaseAwsLink
+
+
+class EC2InstanceLink(BaseAwsLink):
+    """Helper class for constructing Amazon EC2 instance links."""
+
+    name = "Instance"
+    key = "_instance_id"
+    format_str = (
+        BASE_AWS_CONSOLE_LINK + 
"/ec2/home?region={region_name}#InstanceDetails:instanceId={instance_id}"
+    )
+
+
+class EC2InstanceDashboardLink(BaseAwsLink):
+    """
+    Helper class for constructing Amazon EC2 console links.
+
+    This is useful for displaying the list of EC2 instances, rather
+    than a single instance.
+    """
+
+    name = "EC2 Instances"
+    key = "_instance_dashboard"
+    format_str = BASE_AWS_CONSOLE_LINK + 
"/ec2/home?region={region_name}#Instances:instanceId=:{instance_ids}"
+    # Instances:instanceId=:

Review Comment:
   Stray comment from dev/test?



##########
providers/src/airflow/providers/amazon/aws/operators/ec2.py:
##########
@@ -23,6 +23,11 @@
 from airflow.exceptions import AirflowException
 from airflow.models import BaseOperator
 from airflow.providers.amazon.aws.hooks.ec2 import EC2Hook
+from airflow.providers.amazon.aws.links.ec2 import (
+    EC2InstanceDashboardLink,
+    EC2InstanceLink,
+    # format_instance_id_filter,

Review Comment:
   Stray comment from dev/test?



##########
providers/tests/amazon/aws/links/test_ec2.py:
##########
@@ -0,0 +1,60 @@
+# 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 airflow.providers.amazon.aws.links.ec2 import EC2InstanceDashboardLink, 
EC2InstanceLink
+
+from providers.tests.amazon.aws.links.test_base_aws import BaseAwsLinksTestCase
+
+
+class TestEC2InstanceLink(BaseAwsLinksTestCase):
+    link_class = EC2InstanceLink
+
+    INSTANCE_ID = "i-xxxxxxxxxxxx"
+
+    def test_extra_link(self):
+        self.assert_extra_link_url(
+            expected_url=(
+                "https://console.aws.amazon.com/ec2/home";
+                
f"?region=eu-west-1#InstanceDetails:instanceId={self.INSTANCE_ID}"
+            ),
+            region_name="eu-west-1",
+            aws_partition="aws",
+            instance_id=self.INSTANCE_ID,
+        )
+
+
+class TestEC2InstanceDashboardLink(BaseAwsLinksTestCase):
+    link_class = EC2InstanceDashboardLink
+
+    # STATE = "running"

Review Comment:
   Stray comment from dev/test?



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