|
15 | 15 | }, |
16 | 16 | { |
17 | 17 | "cell_type": "code", |
18 | | - "execution_count": 25, |
| 18 | + "execution_count": null, |
19 | 19 | "metadata": {}, |
20 | | - "outputs": [ |
21 | | - { |
22 | | - "name": "stdout", |
23 | | - "output_type": "stream", |
24 | | - "text": [ |
25 | | - "👉🏽 \u001b[1;34mResource group name : apim-infra-simple-apim-1\u001b[0m \n", |
26 | | - "\n", |
27 | | - "✅ \u001b[1;32mNotebook initialized\u001b[0m ⌚ 22:31:28.796962 \n" |
28 | | - ] |
29 | | - } |
30 | | - ], |
| 20 | + "outputs": [], |
31 | 21 | "source": [ |
32 | | - "import subprocess\n", |
33 | 22 | "import utils\n", |
34 | 23 | "from apimtypes import *\n", |
35 | 24 | "\n", |
|
55 | 44 | "map_geocode_v2_aad_get_xml = utils.read_policy_xml('./map_geocode_v2_aad_get.xml')\n", |
56 | 45 | "\n", |
57 | 46 | "# Map API \n", |
58 | | - "mapApi_v2_default_get = GET_APIOperation2('get-default-route','Get default route','/*','This is the default route that will allow all requests to go through to the backend api',map_default_route_v2_aad_get_xml)\n", |
| 47 | + "mapApi_v2_default_get = GET_APIOperation2('get-default-route','Get default route','/default/*','This is the default route that will allow all requests to go through to the backend api',map_default_route_v2_aad_get_xml)\n", |
59 | 48 | "mapApi_v1_async_post = APIOperation('async-geocode-batch','Async Geocode Batch','/geocode/batch/async',HTTP_VERB.POST, 'Post geocode batch async endpoint',map_async_geocode_batch_v1_keyauth_post_xml)\n", |
60 | 49 | "mapApi_v2_geocode_get = GET_APIOperation2('get-geocode','Get Geocode','/geocode','Get geocode endpoint',map_geocode_v2_aad_get_xml)\n", |
61 | 50 | "api1 = API('map-api', 'Map API', '/map', 'This is the proxy for Azure Maps', operations=[mapApi_v2_default_get, mapApi_v1_async_post,mapApi_v2_geocode_get], tags = tags, serviceUrl=azure_maps_url)\n", |
|
69 | 58 | "\n", |
70 | 59 | "# 4) Set up the named values\n", |
71 | 60 | "nvs: List[NamedValue] = [\n", |
| 61 | + " NamedValue('azure-maps-arm-api-version','2023-06-01')\n", |
72 | 62 | "]\n", |
73 | 63 | "\n", |
74 | 64 | "utils.print_ok('Notebook initialized')" |
|
85 | 75 | }, |
86 | 76 | { |
87 | 77 | "cell_type": "code", |
88 | | - "execution_count": 27, |
| 78 | + "execution_count": null, |
89 | 79 | "metadata": {}, |
90 | | - "outputs": [ |
91 | | - { |
92 | | - "name": "stdout", |
93 | | - "output_type": "stream", |
94 | | - "text": [ |
95 | | - "⚙️ \u001b[1;34maz group show --name apim-infra-simple-apim-1\u001b[0m \n", |
96 | | - "⚙️ \u001b[1;34maz group show --name apim-infra-simple-apim-1\u001b[0m \n", |
97 | | - "📝 Updated the policy XML in the bicep parameters file 'params.json'\n", |
98 | | - "⚙️ \u001b[1;34maz deployment group create --name simple-apim --resource-group apim-infra-simple-apim-1 --template-file main.bicep --parameters params.json --query \"properties.outputs\"\u001b[0m \n", |
99 | | - "👉🏽 \u001b[1;34mAPIM API Gateway URL : https://apim-w6pw4mtuew6ga.azure-api.net\u001b[0m \n", |
100 | | - "\n", |
101 | | - "✅ \u001b[1;32mDeployment completed\u001b[0m ⌚ 22:44:24.722798 \n" |
102 | | - ] |
103 | | - } |
104 | | - ], |
| 80 | + "outputs": [], |
105 | 81 | "source": [ |
106 | 82 | "import utils\n", |
107 | 83 | "\n", |
|
142 | 118 | }, |
143 | 119 | { |
144 | 120 | "cell_type": "code", |
145 | | - "execution_count": 28, |
| 121 | + "execution_count": null, |
146 | 122 | "metadata": {}, |
147 | | - "outputs": [ |
148 | | - { |
149 | | - "name": "stdout", |
150 | | - "output_type": "stream", |
151 | | - "text": [ |
152 | | - "\n", |
153 | | - "ℹ️ \u001b[1;32mCalling Hello World (Root) API\u001b[0m ⌚ 22:50:43.490816 \n", |
154 | | - "👉🏽 \u001b[1;34mGET https://apim-w6pw4mtuew6ga.azure-api.net/\u001b[0m \n", |
155 | | - "👉🏽 \u001b[1;34mResponse status : \u001b[1;32m200 - OK\u001b[0m\u001b[0m \n", |
156 | | - "👉🏽 \u001b[1;34mResponse headers :\n", |
157 | | - "{'Content-Length': '32', 'Date': 'Thu, 12 Jun 2025 03:50:44 GMT', 'Request-Context': 'appId=cid-v1:788e87f2-9135-4c09-896d-02870631a447'}\u001b[0m \n", |
158 | | - "👉🏽 \u001b[1;34mResponse body :\n", |
159 | | - "Hello World from API Management!\u001b[0m \n", |
160 | | - "\n", |
161 | | - "ℹ️ \u001b[1;32mCalling Default Route with AAD Auth API\u001b[0m ⌚ 22:50:44.075994 \n", |
162 | | - "👉🏽 \u001b[1;34mGET https://apim-w6pw4mtuew6ga.azure-api.net/map/default/geocode?query=15127%20NE%2024th%20Street%20Redmond%20WA/\u001b[0m \n", |
163 | | - "👉🏽 \u001b[1;34mResponse status : \u001b[1;32m200 - OK\u001b[0m\u001b[0m \n", |
164 | | - "👉🏽 \u001b[1;34mResponse headers :\n", |
165 | | - "{'Content-Type': 'application/json; charset=utf-8', 'Date': 'Thu, 12 Jun 2025 03:50:46 GMT', 'Content-Encoding': 'gzip', 'Transfer-Encoding': 'chunked', 'Vary': 'Accept-Encoding', 'Strict-Transport-Security': 'max-age=31536000; includeSubDomains', 'x-ms-azuremaps-region': 'East US', 'X-Content-Type-Options': 'nosniff', 'X-Cache': 'CONFIG_NOCACHE', 'X-MSEdge-Ref': 'Ref A: 3E47F785F9DE487E9C530EC0D2124173 Ref B: BL2AA2030110019 Ref C: 2025-06-12T03:50:46Z', 'Request-Context': 'appId=cid-v1:788e87f2-9135-4c09-896d-02870631a447'}\u001b[0m \n", |
166 | | - "👉🏽 \u001b[1;34mResponse body :\n", |
167 | | - "{\n", |
168 | | - " \"type\": \"FeatureCollection\",\n", |
169 | | - " \"features\": [\n", |
170 | | - " {\n", |
171 | | - " \"type\": \"Feature\",\n", |
172 | | - " \"geometry\": {\n", |
173 | | - " \"type\": \"Point\",\n", |
174 | | - " \"coordinates\": [\n", |
175 | | - " -122.138669,\n", |
176 | | - " 47.630359\n", |
177 | | - " ]\n", |
178 | | - " },\n", |
179 | | - " \"bbox\": [\n", |
180 | | - " -122.14631082421619,\n", |
181 | | - " 47.62649628242932,\n", |
182 | | - " -122.1310271757838,\n", |
183 | | - " 47.634221717570675\n", |
184 | | - " ],\n", |
185 | | - " \"properties\": {\n", |
186 | | - " \"type\": \"Address\",\n", |
187 | | - " \"confidence\": \"High\",\n", |
188 | | - " \"matchCodes\": [\n", |
189 | | - " \"Good\"\n", |
190 | | - " ],\n", |
191 | | - " \"geocodePoints\": [\n", |
192 | | - " {\n", |
193 | | - " \"calculationMethod\": \"Rooftop\",\n", |
194 | | - " \"usageTypes\": [\n", |
195 | | - " \"Display\"\n", |
196 | | - " ],\n", |
197 | | - " \"geometry\": {\n", |
198 | | - " \"type\": \"Point\",\n", |
199 | | - " \"coordinates\": [\n", |
200 | | - " -122.138669,\n", |
201 | | - " 47.630359\n", |
202 | | - " ]\n", |
203 | | - " }\n", |
204 | | - " },\n", |
205 | | - " {\n", |
206 | | - " \"calculationMethod\": \"Rooftop\",\n", |
207 | | - " \"usageTypes\": [\n", |
208 | | - " \"Route\"\n", |
209 | | - " ],\n", |
210 | | - " \"geometry\": {\n", |
211 | | - " \"type\": \"Point\",\n", |
212 | | - " \"coordinates\": [\n", |
213 | | - " -122.1386667,\n", |
214 | | - " 47.630218\n", |
215 | | - " ]\n", |
216 | | - " }\n", |
217 | | - " }\n", |
218 | | - " ],\n", |
219 | | - " \"address\": {\n", |
220 | | - " \"addressLine\": \"15127 NE 24th St\",\n", |
221 | | - " \"streetName\": \"NE 24th St\",\n", |
222 | | - " \"streetNumber\": \"15127\",\n", |
223 | | - " \"postalCode\": \"98052\",\n", |
224 | | - " \"locality\": \"Redmond\",\n", |
225 | | - " \"formattedAddress\": \"15127 NE 24th St, Redmond, WA 98052\",\n", |
226 | | - " \"countryRegion\": {\n", |
227 | | - " \"name\": \"United States\",\n", |
228 | | - " \"ISO\": \"US\"\n", |
229 | | - " },\n", |
230 | | - " \"adminDistricts\": [\n", |
231 | | - " {\n", |
232 | | - " \"shortName\": \"WA\"\n", |
233 | | - " },\n", |
234 | | - " {\n", |
235 | | - " \"shortName\": \"King County\"\n", |
236 | | - " }\n", |
237 | | - " ]\n", |
238 | | - " }\n", |
239 | | - " }\n", |
240 | | - " }\n", |
241 | | - " ]\n", |
242 | | - "}\u001b[0m \n", |
243 | | - "\n", |
244 | | - "ℹ️ \u001b[1;32mCalling Hello World (ACA Backend 2) API\u001b[0m ⌚ 22:50:47.215265 \n", |
245 | | - "👉🏽 \u001b[1;34mGET https://apim-w6pw4mtuew6ga.azure-api.net/aca-2/\u001b[0m \n", |
246 | | - "👉🏽 \u001b[1;34mResponse status : \u001b[1;31m404 - Resource Not Found\u001b[0m\u001b[0m \n", |
247 | | - "👉🏽 \u001b[1;34mResponse headers :\n", |
248 | | - "{'Content-Length': '54', 'Content-Type': 'application/json', 'Date': 'Thu, 12 Jun 2025 03:50:47 GMT', 'Request-Context': 'appId=cid-v1:788e87f2-9135-4c09-896d-02870631a447'}\u001b[0m \n", |
249 | | - "👉🏽 \u001b[1;34mResponse body :\n", |
250 | | - "{ \"statusCode\": 404, \"message\": \"Resource not found\" }\u001b[0m \n", |
251 | | - "\n", |
252 | | - "ℹ️ \u001b[1;32mCalling Hello World (ACA Backend Pool) API\u001b[0m ⌚ 22:50:47.865951 \n", |
253 | | - "👉🏽 \u001b[1;34mGET https://apim-w6pw4mtuew6ga.azure-api.net/aca-pool/\u001b[0m \n", |
254 | | - "👉🏽 \u001b[1;34m▶️ Run 1/3:\u001b[0m \n", |
255 | | - "👉🏽 \u001b[1;34m⌚ 0.39 seconds\u001b[0m \n", |
256 | | - "👉🏽 \u001b[1;34mResponse status : \u001b[1;31m404 - Resource Not Found\u001b[0m\u001b[0m \n", |
257 | | - "👉🏽 \u001b[1;34m▶️ Run 2/3:\u001b[0m \n", |
258 | | - "👉🏽 \u001b[1;34m⌚ 0.07 seconds\u001b[0m \n", |
259 | | - "👉🏽 \u001b[1;34mResponse status : \u001b[1;31m404 - Resource Not Found\u001b[0m\u001b[0m \n", |
260 | | - "👉🏽 \u001b[1;34m▶️ Run 3/3:\u001b[0m \n", |
261 | | - "👉🏽 \u001b[1;34m⌚ 0.07 seconds\u001b[0m \n", |
262 | | - "👉🏽 \u001b[1;34mResponse status : \u001b[1;31m404 - Resource Not Found\u001b[0m\u001b[0m \n", |
263 | | - "\n", |
264 | | - "✅ \u001b[1;32mAll done!\u001b[0m ⌚ 22:50:48.559041 \n" |
265 | | - ] |
266 | | - } |
267 | | - ], |
| 123 | + "outputs": [], |
268 | 124 | "source": [ |
269 | 125 | "import utils\n", |
270 | 126 | "from apimrequests import ApimRequests\n", |
|
287 | 143 | "reqs = ApimRequests(apim_gateway_url)\n", |
288 | 144 | "\n", |
289 | 145 | "reqs.singleGet('/', msg = 'Calling Hello World (Root) API')\n", |
290 | | - "reqs.singleGet('/map/default/geocode?query=15127%20NE%2024th%20Street%20Redmond%20WA/', msg = 'Calling Default Route with AAD Auth API')\n", |
291 | | - "reqs.singleGet('/aca-2/', msg = 'Calling Hello World (ACA Backend 2) API')\n", |
292 | | - "reqs.multiGet('/aca-pool/', 3, msg = 'Calling Hello World (ACA Backend Pool) API')\n", |
| 146 | + "reqs.singleGet('/map/default/geocode?query=15127%20NE%2024th%20Street%20Redmond%20WA', msg = 'Calling Default Route API with AAD Auth')\n", |
| 147 | + "reqs.singleGet('/map/geocode?query=15127%20NE%2024th%20Street%20Redmond%20WA', msg = 'Calling Geocode v2 API with AAD Auth')\n", |
| 148 | + "reqs.singlePost('/map/geocode/batch/async', data={\n", |
| 149 | + " \"batchItems\": [\n", |
| 150 | + " {\"query\": \"?query=400 Broad St, Seattle, WA 98109&limit=3\"},\n", |
| 151 | + " {\"query\": \"?query=One, Microsoft Way, Redmond, WA 98052&limit=3\"},\n", |
| 152 | + " {\"query\": \"?query=350 5th Ave, New York, NY 10118&limit=1\"},\n", |
| 153 | + " {\"query\": \"?query=Pike Pl, Seattle, WA 98101&lat=47.610970&lon=-122.342469&radius=1000\"},\n", |
| 154 | + " {\"query\": \"?query=Champ de Mars, 5 Avenue Anatole France, 75007 Paris, France&limit=1\"}\n", |
| 155 | + " ]\n", |
| 156 | + "}, msg = 'Calling Async Geocode Batch v1 API with Key Auth')\n", |
| 157 | + "\n", |
293 | 158 | "utils.print_ok('All done!')" |
294 | 159 | ] |
295 | 160 | } |
|
0 commit comments