forked from mafux777/Alation_Article
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapi_resource.py
198 lines (188 loc) · 6.11 KB
/
api_resource.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
# -*- coding: utf-8 -*-
import pandas as pd
from sudoku.bento import AlationInstance
import json
api_json = {
"path": [
"New Flightaware APIs",
"Weather",
"Post METAR"
],
"request_type": "POST",
"input_schema": {
"properties": {
"airport": {
"type": "string",
"examples": [
"KJFK"
],
"title" : "Airport ICAO (input)",
"description": "ICAO code of the airport for which you want the weather"
}
}
},
"resource_url": "https:/flightxml.flightaware.com/json/FlightXML2/MetarEx",
"output_schema": {
"type": "object",
"properties": {
"MetarExResult": {
"type": "object",
"properties": {
"metar": {
"items": {
"properties": {
"wind_speed": {
"title" : "Wind speed in knots",
"description" : "Wind speed in knots",
"type": "integer",
"examples": [
"11"
]
},
"cloud_type": {
"title" : "Cloud Type",
"description" : "a coded reference to cloud types",
"type": "string",
"examples": [
"SCT"
]
},
"cloud_altitude": {
"title" : "Cloud Altitude",
"description" : "Cloud altitude in feet above ground",
"Airport Continent" : "AS",
"type": "integer",
"examples": [
"1400"
]
},
"cloud_friendly": {
"type": "string",
"title" : "Clouds in plain english",
"description" : "A plain english explanation of cloud conditions",
"examples": [
"Scattered clouds"
]
},
"wind_direction": {
"title" : "Wind direction",
"description" : "Wind direction in degrees magnetic",
"type": "integer",
"examples": [
"200"
]
},
"temp_relhum": {
"title" : "Relative humidity of the air",
"description" : "This is a percentage",
"type": "integer",
"examples": [
"89"
]
},
"visibility": {
"title" : "Visibility",
"description" : "Visibility in km or sm",
"type": "integer",
"examples": [
"10"
]
},
"pressure": {
"title" : "Barometric Pressure",
"description" : "In inches or millibar",
"type": "number",
"examples": [
"30.1700000763"
]
},
"airport": {
"title" : "Airport code (ICAO)",
"description" : "Should be identical to the input",
"type": "string",
"examples": [
"KJFK"
]
},
"wind_speed_gust": {
"title" : "Wind speed of the gusts",
"description" : "If gusts are present",
"type": "integer",
"examples": [
"0"
]
},
"time": {
"title" : "Time of the observation",
"description" : "This is in seconds (Unix)",
"type": "integer",
"examples": [
"1533300660"
]
},
"raw_data": {
"title" : "Raw text of METAR",
"description" : "Raw data as provided by the Met Office",
"type": "string",
"examples": [
"KJFK 031251Z 20011KT 10SM SCT014 26/24 A3017 RMK AO2 SLP215 T02610239"
]
},
"wind_friendly": {
"title" : "Wind description",
"description" : "Strength of the wind in plain english",
"type": "string",
"examples": [
"Windy"
]
},
"conditions": {
"title" : "Runway conditions",
"description" : "Description of the runway, for example wet",
"type": "string"
},
"temp_dewpoint": {
"title" : "Temperature of Dewpoint",
"description" : "Relevant for visibility, given in (C)",
"type": "integer",
"examples": [
"24"
]
},
"temp_air": {
"title" : "Air Temperature",
"description" : "Given in Degrees Celsius (C)",
"type": "integer",
"examples": [
"26"
]
}
}
},
"type": "array"
},
"next_offset": {
"title" : "Next offset",
"description" : "Technical offset for Flightaware API (2)",
"My Rich Text" : "Amazing work",
"type": "integer",
"examples": [
"1"
]
}
}
}
}
}
}
import config
if __name__ == "__main__":
# -- API Resources
alation_1 = AlationInstance(config.args['host'],
config.args['username'], # not needed
config.args['password'], # not needed
config.args['refresh_token'],
config.args['user_id'],
)
r = alation_1.post_api_resource(api_json)
print (r)