forked from ispyhumanfly/drone-deploy-experiments
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgraphql_test.py
executable file
·57 lines (51 loc) · 1 KB
/
graphql_test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!python
"""Testing connecting to Drone Deploy GraphQL API"""
import os
import json
import requests
from dotenv import load_dotenv
load_dotenv()
GRAPHQL_QUERY = """
{
projects {
edges {
node {
location {
lat
lng
}
name
plans {
edges {
node {
id
name
... on MapPlanTemplate {
id
name
geometry {
lat
lng
}
}
}
}
}
}
}
}
viewer {
id
}
}
"""
response = requests.post(
url="https://api.dronedeploy.com/graphql",
json={"query": GRAPHQL_QUERY},
headers={'Authorization': 'Bearer ' + os.getenv("DRONE_DEPLOY_API_KEY"), 'Content-Type': 'application/json'}, timeout=10)
if response.status_code == 200:
print("We succeeded")
print(json.loads(response.text))
else:
print(response.status_code)
print(response.text)