utkarsharma2 commented on a change in pull request #9907:
URL: https://github.com/apache/airflow/pull/9907#discussion_r466072294
##########
File path: airflow/cli/commands/connection_command.py
##########
@@ -153,3 +155,93 @@ def connections_delete(args):
msg = '\n\tSuccessfully deleted `conn_id`={conn_id}\n'
msg = msg.format(conn_id=deleted_conn_id)
print(msg)
+
+
+DIS_RESTRICT = 'restrict'
+DIS_OVERWRITE = 'overwrite'
+DIS_IGNORE = 'ignore'
+CREATED = 'created'
+DISPOSITIONS = [DIS_RESTRICT, DIS_OVERWRITE, DIS_IGNORE]
+
+
+def prep_import_status_msgs(conn_status_map):
+ msg = "\n"
+ for status, conn_list in conn_status_map.items():
+ if len(conn_list) > 0:
+ msg = msg + status + " : \n\t"
+ for conn in conn_list:
+ msg = msg + '\n\t`conn_id`={conn_id} : {uri}\n'
+ msg = msg.format(conn_id=conn.conn_id,
+ uri=conn.get_uri() or
+ urlunparse((conn.conn_type,
+ '{login}:{password}@{host}:{port}'
+ .format(login=conn.conn_login or
'',
+ password='******' if
conn.conn_password else '',
+ host=conn.conn_host or '',
+ port=conn.conn_port or
''),
+ conn.conn_schema or '', '', '',
'')))
+ return msg
+
+
+@cli_utils.action_logging
+def connections_import(args):
+ """Import new connections"""
+ # check for the file path in arguments
+ missing_args = []
+ if not args.file:
+ missing_args.append('file')
+
+ if missing_args:
+ msg = ('The following args are required to import connections:' +
+ ' {missing!r}'.format(missing=missing_args))
+ raise SystemExit(msg)
+
+ try:
+ conns_map = load_connections(args.file)
+ except AirflowException as e:
+ return print(e)
Review comment:
Updated code accordingly.
----------------------------------------------------------------
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]