Hi, did anyone here wrote his own small client cod...
# ask-community
d
Hi, did anyone here wrote his own small client code to only 1. get a tenant 2. query for a flow ID 3. trigger the flow with parameter and depending only on python stdlib + urllib3? That would be quite handy for running via low latency on AWS lambda without the need to include the heavy prefect package with all its dependencies. Thanks!
k
Hey @Daniel Bast, I have a part of this.
Copy code
import requests
import json

query = """mutation {
  create_flow_run(input: { 
  flow_id: "5ac80adc-442a-4e53-bc01-d9d65bffd6aa"}) {
    id
  }
}"""

url = '<https://api.prefect.io>'
r = <http://requests.post|requests.post>(url, json={'query': query}, headers={"authorization": "Bearer insert_token"})
print(r.status_code)
print(r.text)
You might need to add this to the headers.
Copy code
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36"}
d
@Kevin Kho Thanks. Will try that later. Thought I need to do the get/login to tenant logic before, as mentioned here https://docs.prefect.io/orchestration/concepts/api.html#authenticating-the-client-with-cloud
k
For the Client yes, for the request, the token is in the header