I have set up the below in Apache Airflow Admin --> Connections.
How do I read these values programmatically inside my DAG?
def check_email_requests():
conn = Connection(conn_id="artnpics_api_calls")
print(conn)
hostname = conn.host
login_name = conn.login
login_password = conn.password
port_number = conn.port
print("hostname = " + hostname + "; Login name: " + login_name + "; password = " + login_password + " ; port number = " + port_number)
request_api = hostname + ":" + port_number
print("request api " + request_api)
result = requests.get(request_api, auth=(login_name, login_password)).json()
print(result)
print("done with check_email_requests")
return False
The above obviously did not work, and I couldn't find any information on how to read from the connections (there is numerous article on how to create one programmatically). My objective is to read API connection and authentication information programmatically and invoke the call, rather than hard coding them.
- Rhonald
