mik-laj commented on a change in pull request #15425:
URL: https://github.com/apache/airflow/pull/15425#discussion_r625638195
##########
File path: airflow/models/connection.py
##########
@@ -364,3 +364,14 @@ def get_connection_from_secrets(cls, conn_id: str) ->
'Connection':
if conn:
return conn
raise AirflowNotFoundException(f"The conn_id `{conn_id}` isn't
defined")
+
+ @classmethod
+ def from_dict(cls, conn_dict: Dict) -> 'Connection':
+ """
+ Create a connection from a dictionary.
+
+ :param conn_dict: dictionary representing a connection's attributes
+ e.g., {'conn_id': '', 'conn_type': '', 'login': '', ...}
+ :return: connection
+ """
+ return Connection(**conn_dict)
Review comment:
We have a function that has a similar purpose but is more complex and
supports more input parameters. See:
airflow.secrets.local_filesystem._create_connection Can you move it here?
--
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.
For queries about this service, please contact Infrastructure at:
[email protected]