dstandish commented on a change in pull request #6426: [AIRFLOW-5751] add 
get_uri method to Connection
URL: https://github.com/apache/airflow/pull/6426#discussion_r339255770
 
 

 ##########
 File path: airflow/models/connection.py
 ##########
 @@ -145,6 +145,38 @@ def parse_from_uri(self, uri):
         if uri_parts.query:
             self.extra = json.dumps(dict(parse_qsl(uri_parts.query, 
keep_blank_values=True)))
 
+    def get_uri(self) -> str:
+        uri = '{}://'.format(self.conn_type.replace('_', '-'))
+
+        authority_block = ''
+        if self.login is not None:
+            authority_block += quote(self.login, safe='')
+
+        if self.password is not None:
+            authority_block += ':' + quote(self.password)
+
+        if authority_block > '':
+            authority_block += '@'
+
+            uri += authority_block
+
+        host_block = ''
+        if self.host:
+            host_block += quote(self.host, safe='')
+
+            if self.port:
+                host_block += ':{}'.format(self.port)
+
+            if self.schema:
 
 Review comment:
   ok lastly (one can hope) i have added another set of tests verifying that 
when we create connection from init attributes (rather than uri) that 
everything still works consistently -- URIs generated still parse to an 
equivalent connection object.

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


With regards,
Apache Git Services

Reply via email to