This is an automated email from the ASF dual-hosted git repository.
onikolas pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/main by this push:
new 015673658c1 Create connection with API instead of directly through
Session (#53161)
015673658c1 is described below
commit 015673658c1e0f8753d02ab09b81202439b30bc9
Author: Niko Oliveira <[email protected]>
AuthorDate: Thu Jul 10 14:58:51 2025 -0700
Create connection with API instead of directly through Session (#53161)
Now that we're using Task SDk we should use the api to create the
connection we need instead of creating it directly through a session
object within the task.
---
.../tests/system/amazon/aws/example_http_to_s3.py | 23 +++++++++++-----------
1 file changed, 11 insertions(+), 12 deletions(-)
diff --git a/providers/amazon/tests/system/amazon/aws/example_http_to_s3.py
b/providers/amazon/tests/system/amazon/aws/example_http_to_s3.py
index 8dd31ce3500..89c4e051230 100644
--- a/providers/amazon/tests/system/amazon/aws/example_http_to_s3.py
+++ b/providers/amazon/tests/system/amazon/aws/example_http_to_s3.py
@@ -19,25 +19,23 @@ from __future__ import annotations
from datetime import datetime
from typing import TYPE_CHECKING
-from airflow import settings
from airflow.providers.amazon.aws.operators.s3 import S3CreateBucketOperator,
S3DeleteBucketOperator
from airflow.providers.amazon.aws.transfers.http_to_s3 import HttpToS3Operator
from airflow.providers.standard.operators.bash import BashOperator
+from tests_common.test_utils.api_client_helpers import
make_authenticated_rest_api_request
from tests_common.test_utils.version_compat import AIRFLOW_V_3_0_PLUS
if TYPE_CHECKING:
from airflow.decorators import task
- from airflow.models import Connection
from airflow.models.baseoperator import chain
from airflow.models.dag import DAG
else:
if AIRFLOW_V_3_0_PLUS:
- from airflow.sdk import DAG, Connection, chain, task
+ from airflow.sdk import DAG, chain, task
else:
# Airflow 2.10 compat
from airflow.decorators import task
- from airflow.models import Connection
from airflow.models.baseoperator import chain
from airflow.models.dag import DAG
from airflow.utils.trigger_rule import TriggerRule
@@ -65,15 +63,16 @@ exit 0
@task
def create_connection(conn_id_name: str):
- conn = Connection(
- conn_id=conn_id_name,
- conn_type="http",
- host="localhost",
- port=8083,
+ make_authenticated_rest_api_request(
+ path="/api/v2/connections",
+ method="POST",
+ body={
+ "connection_id": conn_id_name,
+ "conn_type": "http",
+ "host": "localhost",
+ "port": 8083,
+ },
)
- session = settings.Session()
- session.add(conn)
- session.commit()
with DAG(