|
22 | 22 | }, |
23 | 23 | { |
24 | 24 | "cell_type": "code", |
25 | | - "execution_count": 1, |
| 25 | + "execution_count": null, |
26 | 26 | "metadata": { |
27 | 27 | "tags": [] |
28 | 28 | }, |
29 | | - "outputs": [ |
30 | | - { |
31 | | - "output_type": "stream", |
32 | | - "name": "stdout", |
33 | | - "text": "Requirement already satisfied: meraki==1.0.0b15 in c:\\users\\john.kuchta\\appdata\\local\\programs\\python\\python38-32\\lib\\site-packages (1.0.0b15)\nRequirement already satisfied: aiohttp in c:\\users\\john.kuchta\\appdata\\local\\programs\\python\\python38-32\\lib\\site-packages (from meraki==1.0.0b15) (3.6.2)\nRequirement already satisfied: requests in c:\\users\\john.kuchta\\appdata\\local\\programs\\python\\python38-32\\lib\\site-packages (from meraki==1.0.0b15) (2.24.0)Note: you may need to restart the kernel to use updated packages.\nRequirement already satisfied: attrs>=17.3.0 in c:\\users\\john.kuchta\\appdata\\local\\programs\\python\\python38-32\\lib\\site-packages (from aiohttp->meraki==1.0.0b15) (19.3.0)\nRequirement already satisfied: multidict<5.0,>=4.5 in c:\\users\\john.kuchta\\appdata\\local\\programs\\python\\python38-32\\lib\\site-packages (from aiohttp->meraki==1.0.0b15) (4.7.6)\nRequirement already satisfied: chardet<4.0,>=2.0 in c:\\users\\john.kuchta\\appdata\\local\\programs\\python\\python38-32\\lib\\site-packages (from aiohttp->meraki==1.0.0b15) (3.0.4)\nRequirement already satisfied: async-timeout<4.0,>=3.0 in c:\\users\\john.kuchta\\appdata\\local\\programs\\python\\python38-32\\lib\\site-packages (from aiohttp->meraki==1.0.0b15) (3.0.1)\nRequirement already satisfied: yarl<2.0,>=1.0 in c:\\users\\john.kuchta\\appdata\\local\\programs\\python\\python38-32\\lib\\site-packages (from aiohttp->meraki==1.0.0b15) (1.4.2)\nRequirement already satisfied: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in c:\\users\\john.kuchta\\appdata\\local\\programs\\python\\python38-32\\lib\\site-packages (from requests->meraki==1.0.0b15) (1.25.9)\nRequirement already satisfied: certifi>=2017.4.17 in c:\\users\\john.kuchta\\appdata\\local\\programs\\python\\python38-32\\lib\\site-packages (from requests->meraki==1.0.0b15) (2020.6.20)\nRequirement already satisfied: idna<3,>=2.5 in c:\\users\\john.kuchta\\appdata\\local\\programs\\python\\python38-32\\lib\\site-packages (from requests->meraki==1.0.0b15) (2.10)\n\nWARNING: You are using pip version 20.1.1; however, version 20.2.1 is available.\nYou should consider upgrading via the 'C:\\Users\\john.kuchta\\AppData\\Local\\Programs\\Python\\Python38-32\\python.exe -m pip install --upgrade pip' command.\nWARNING: You are using pip version 20.1.1; however, version 20.2.1 is available.\nYou should consider upgrading via the 'C:\\Users\\john.kuchta\\AppData\\Local\\Programs\\Python\\Python38-32\\python.exe -m pip install --upgrade pip' command.\nRequirement already satisfied: tablib in c:\\users\\john.kuchta\\appdata\\local\\programs\\python\\python38-32\\lib\\site-packages (2.0.0)\nNote: you may need to restart the kernel to use updated packages.\n meraki: INFO > Meraki dashboard API session initialized with these parameters: {'version': '1.0.0b15', 'api_key': '************************************dfb9', 'base_url': 'https://api.meraki.com/api/v1', 'single_request_timeout': 60, 'certificate_path': '', 'requests_proxy': '', 'wait_on_rate_limit': True, 'nginx_429_retry_wait_time': 60, 'action_batch_retry_wait_time': 60, 'retry_4xx_error': False, 'retry_4xx_error_wait_time': 60, 'maximum_retries': 2, 'simulate': False, 'be_geo_id': None, 'caller': None}\n" |
34 | | - } |
35 | | - ], |
| 29 | + "outputs": [], |
36 | 30 | "source": [ |
37 | 31 | "# Install the relevant modules. If you are using a local editor (e.g. VS Code, rather than Colab) you can run these commands, without the preceding %, via a terminal. NB: Run `pip install meraki==` to find the latest version of the Meraki SDK.\n", |
38 | | - "%pip install meraki==1.0.0b15\n", |
| 32 | + "%pip install meraki\n", |
39 | 33 | "%pip install tablib\n", |
40 | 34 | "\n", |
41 | 35 | "# If you are using Google Colab, please ensure you have set up your environment variables as linked above, then delete the two lines of ''' to activate the following code:\n", |
|
71 | 65 | }, |
72 | 66 | { |
73 | 67 | "cell_type": "code", |
74 | | - "execution_count": 2, |
| 68 | + "execution_count": null, |
75 | 69 | "metadata": {}, |
76 | 70 | "outputs": [], |
77 | 71 | "source": [ |
|
92 | 86 | }, |
93 | 87 | { |
94 | 88 | "cell_type": "code", |
95 | | - "execution_count": 3, |
| 89 | + "execution_count": null, |
96 | 90 | "metadata": { |
97 | 91 | "tags": [] |
98 | 92 | }, |
99 | | - "outputs": [ |
100 | | - { |
101 | | - "output_type": "stream", |
102 | | - "name": "stderr", |
103 | | - "text": "meraki: INFO > organizations, getOrganizations - 200 OK\nOrganizations:\n[\n {\n \"id\": \"102908\",\n \"name\": \"Olympus\",\n \"url\": \"https://n80.meraki.com/o/99uSJa/manage/organization/overview\"\n }\n]\n\nThe firstOrganizationId is 102908, and its name is Olympus.\n" |
104 | | - } |
105 | | - ], |
| 93 | + "outputs": [], |
106 | 94 | "source": [ |
107 | 95 | "# Let's make it easier to call this data later\n", |
108 | 96 | "# getOrganizations will return all orgs to which the supplied API key has access\n", |
|
128 | 116 | }, |
129 | 117 | { |
130 | 118 | "cell_type": "code", |
131 | | - "execution_count": 4, |
| 119 | + "execution_count": null, |
132 | 120 | "metadata": { |
133 | 121 | "tags": [] |
134 | 122 | }, |
135 | | - "outputs": [ |
136 | | - { |
137 | | - "output_type": "stream", |
138 | | - "name": "stderr", |
139 | | - "text": "meraki: INFO > organizations, getOrganizationNetworks; page 1 - 200 OK\nNetworks:\n[\n {\n \"enrollmentString\": null,\n \"id\": \"L_607985949695028290\",\n \"name\": \"Edgehill2\",\n \"organizationId\": \"102908\",\n \"productTypes\": [\n \"appliance\",\n \"camera\",\n \"cellularGateway\",\n \"switch\",\n \"wireless\"\n ],\n \"tags\": [],\n \"timeZone\": \"America/Los_Angeles\",\n \"url\": \"https://n80.meraki.com/Edgehill2-applia/n/wyTiUcqb/manage/usage/list\"\n },\n {\n \"enrollmentString\": null,\n \"id\": \"L_607985949695028346\",\n \"name\": \"Virtual\",\n \"organizationId\": \"102908\",\n \"productTypes\": [\n \"appliance\",\n \"camera\",\n \"switch\",\n \"wireless\"\n ],\n \"tags\": [],\n \"timeZone\": \"America/Los_Angeles\",\n \"url\": \"https://n80.meraki.com/Virtual-camera/n/mlMVmcqb/manage/usage/list\"\n },\n {\n \"enrollmentString\": null,\n \"id\": \"L_607985949695028380\",\n \"name\": \"Western\",\n \"organizationId\": \"102908\",\n \"productTypes\": [\n \"appliance\",\n \"cellularGateway\",\n \"switch\",\n \"wireless\"\n ],\n \"tags\": [],\n \"timeZone\": \"America/Los_Angeles\",\n \"url\": \"https://n80.meraki.com/Western-wireless/n/nQiaYbqb/manage/usage/list\"\n },\n {\n \"enrollmentString\": null,\n \"id\": \"L_607985949695028389\",\n \"name\": \"Edgehill\",\n \"organizationId\": \"102908\",\n \"productTypes\": [\n \"appliance\",\n \"cellularGateway\"\n ],\n \"tags\": [],\n \"timeZone\": \"America/Los_Angeles\",\n \"url\": \"https://n80.meraki.com/Edgehill-cellula/n/SXmkodqb/manage/usage/list\"\n },\n {\n \"enrollmentString\": null,\n \"id\": \"N_607985949695061056\",\n \"name\": \"Switch\",\n \"organizationId\": \"102908\",\n \"productTypes\": [\n \"switch\"\n ],\n \"tags\": [],\n \"timeZone\": \"America/Los_Angeles\",\n \"url\": \"https://n80.meraki.com/Switch/n/4QMMjbqb/manage/usage/list\"\n }\n]\n\nThe firstNetworkId is L_607985949695028290, and its name is Edgehill2.\n" |
140 | | - } |
141 | | - ], |
| 123 | + "outputs": [], |
142 | 124 | "source": [ |
143 | 125 | "networks = dashboard.organizations.getOrganizationNetworks(organizationId=firstOrganizationId)\n", |
144 | 126 | "print('Networks:')\n", |
|
168 | 150 | }, |
169 | 151 | { |
170 | 152 | "cell_type": "code", |
171 | | - "execution_count": 5, |
| 153 | + "execution_count": null, |
172 | 154 | "metadata": { |
173 | 155 | "tags": [] |
174 | 156 | }, |
175 | | - "outputs": [ |
176 | | - { |
177 | | - "output_type": "stream", |
178 | | - "name": "stderr", |
179 | | - "text": "meraki: INFO > organizations, getOrganizationDevices; page 1 - 200 OK\n meraki: INFO > organizations, getOrganizationDevicesStatuses; page 1 - 200 OK\nThese are the switches:\n[\n {\n \"address\": \"4111 Edgehill Dr, Los Angeles, CA 90008\",\n \"configurationUpdatedAt\": \"2020-07-21T01:57:44Z\",\n \"firmware\": \"switch-12-17\",\n \"lanIp\": \"172.17.0.4\",\n \"lat\": 34.00968,\n \"lng\": -118.33069,\n \"mac\": \"34:56:fe:cc:b9:84\",\n \"model\": \"MS120-8LP\",\n \"name\": \"Edgehill MS120-8LP\",\n \"networkId\": \"L_607985949695028290\",\n \"notes\": \"\",\n \"serial\": \"Q2BX-DEZ3-LGMD\",\n \"tags\": [],\n \"url\": \"https://n80.meraki.com/Edgehill2-switch/n/V3nOZcqb/manage/nodes/new_list/57548246661508\"\n },\n {\n \"address\": \"\",\n \"configurationUpdatedAt\": \"2020-07-07T00:08:05Z\",\n \"firmware\": \"Not running configured version\",\n \"lanIp\": null,\n \"lat\": 37.4180951010362,\n \"lng\": -122.098531723022,\n \"mac\": \"4c:c8:a1:06:00:f8\",\n \"model\": \"MS250-24\",\n \"name\": \"\",\n \"networkId\": \"L_607985949695028346\",\n \"notes\": \"\",\n \"serial\": \"QBSB-AK7F-URKC\",\n \"tags\": [],\n \"url\": \"https://n80.meraki.com/Virtual-switch/n/IItm2bqb/manage/nodes/new_list/84424578695416\"\n },\n {\n \"address\": \"\",\n \"configurationUpdatedAt\": \"2020-07-07T23:36:50Z\",\n \"firmware\": \"Not running configured version\",\n \"lanIp\": null,\n \"lat\": 37.4180951010362,\n \"lng\": -122.098531723022,\n \"mac\": \"4c:c8:a1:08:00:09\",\n \"model\": \"MS410-16\",\n \"name\": \"\",\n \"networkId\": \"L_607985949695028346\",\n \"notes\": \"\",\n \"serial\": \"QBSB-BDX9-8AZP\",\n \"tags\": [],\n \"url\": \"https://n80.meraki.com/Virtual-switch/n/IItm2bqb/manage/nodes/new_list/84424578826249\"\n },\n {\n \"address\": \"\",\n \"configurationUpdatedAt\": \"2020-07-07T00:08:05Z\",\n \"firmware\": \"Not running configured version\",\n \"lanIp\": null,\n \"lat\": 37.4180951010362,\n \"lng\": -122.098531723022,\n \"mac\": \"4c:c8:a1:09:00:f8\",\n \"model\": \"MS425-32\",\n \"name\": \"\",\n \"networkId\": \"L_607985949695028346\",\n \"notes\": \"\",\n \"serial\": \"QBSB-DD84-RCQS\",\n \"tags\": [],\n \"url\": \"https://n80.meraki.com/Virtual-switch/n/IItm2bqb/manage/nodes/new_list/84424578892024\"\n },\n {\n \"address\": \"\",\n \"configurationUpdatedAt\": \"2020-07-07T23:36:50Z\",\n \"firmware\": \"Not running configured version\",\n \"lanIp\": null,\n \"lat\": 37.4180951010362,\n \"lng\": -122.098531723022,\n \"mac\": \"4c:c8:a1:08:00:0a\",\n \"model\": \"MS410-16\",\n \"name\": \"\",\n \"networkId\": \"L_607985949695028346\",\n \"notes\": \"\",\n \"serial\": \"QBSB-DLV3-235C\",\n \"tags\": [\n \"APIness\"\n ],\n \"url\": \"https://n80.meraki.com/Virtual-switch/n/IItm2bqb/manage/nodes/new_list/84424578826250\"\n },\n {\n \"address\": \"\",\n \"configurationUpdatedAt\": \"2020-07-07T00:08:05Z\",\n \"firmware\": \"Not running configured version\",\n \"lanIp\": null,\n \"lat\": 37.4180951010362,\n \"lng\": -122.098531723022,\n \"mac\": \"4c:c8:a1:07:00:f8\",\n \"model\": \"MS350-48LP\",\n \"name\": \"\",\n \"networkId\": \"L_607985949695028346\",\n \"notes\": \"\",\n \"serial\": \"QBSB-E3LG-VEQZ\",\n \"tags\": [],\n \"url\": \"https://n80.meraki.com/Virtual-switch/n/IItm2bqb/manage/nodes/new_list/84424578760952\"\n },\n {\n \"address\": \"\",\n \"configurationUpdatedAt\": \"2020-07-07T23:36:50Z\",\n \"firmware\": \"Not running configured version\",\n \"lanIp\": null,\n \"lat\": 37.4180951010362,\n \"lng\": -122.098531723022,\n \"mac\": \"4c:c8:a1:08:00:f8\",\n \"model\": \"MS410-16\",\n \"name\": \"\",\n \"networkId\": \"L_607985949695028346\",\n \"notes\": \"\",\n \"serial\": \"QBSB-HXH8-6N32\",\n \"tags\": [],\n \"url\": \"https://n80.meraki.com/Virtual-switch/n/IItm2bqb/manage/nodes/new_list/84424578826488\"\n },\n {\n \"address\": \"\",\n \"configurationUpdatedAt\": \"2020-07-07T00:08:05Z\",\n \"firmware\": \"Not running configured version\",\n \"lanIp\": null,\n \"lat\": 37.4180951010362,\n \"lng\": -122.098531723022,\n \"mac\": \"4c:c8:a1:05:00:f8\",\n \"model\": \"MS120-8FP\",\n \"name\": \"\",\n \"networkId\": \"L_607985949695028346\",\n \"notes\": \"\",\n \"serial\": \"QBSB-PP5Z-HJ84\",\n \"tags\": [],\n \"url\": \"https://n80.meraki.com/Virtual-switch/n/IItm2bqb/manage/nodes/new_list/84424578629880\"\n },\n {\n \"address\": \"\",\n \"configurationUpdatedAt\": \"2020-07-07T23:36:50Z\",\n \"firmware\": \"Not running configured version\",\n \"lanIp\": null,\n \"lat\": 37.4180951010362,\n \"lng\": -122.098531723022,\n \"mac\": \"4c:c8:a1:08:00:0b\",\n \"model\": \"MS410-16\",\n \"name\": \"\",\n \"networkId\": \"L_607985949695028346\",\n \"notes\": \"\",\n \"serial\": \"QBSB-YYWS-RCY7\",\n \"tags\": [\n \"APIness\"\n ],\n \"url\": \"https://n80.meraki.com/Virtual-switch/n/IItm2bqb/manage/nodes/new_list/84424578826251\"\n }\n]\n" |
180 | | - } |
181 | | - ], |
| 157 | + "outputs": [], |
182 | 158 | "source": [ |
183 | 159 | "devices = dashboard.organizations.getOrganizationDevices(organizationId=firstOrganizationId)\n", |
184 | 160 | "devices_statuses = dashboard.organizations.getOrganizationDevicesStatuses(organizationId=firstOrganizationId)\n", |
|
201 | 177 | }, |
202 | 178 | { |
203 | 179 | "cell_type": "code", |
204 | | - "execution_count": 6, |
| 180 | + "execution_count": null, |
205 | 181 | "metadata": { |
206 | 182 | "tags": [] |
207 | 183 | }, |
208 | | - "outputs": [ |
209 | | - { |
210 | | - "output_type": "stream", |
211 | | - "name": "stdout", |
212 | | - "text": "We can list out the statuses (and whatever metadata we need) for these switches:\nSwitch statuses are:\n[\n {\n \"serial\": \"Q2BX-DEZ3-LGMD\",\n \"status\": \"offline\"\n },\n {\n \"serial\": \"QBSB-AK7F-URKC\",\n \"status\": \"offline\"\n },\n {\n \"serial\": \"QBSB-BDX9-8AZP\",\n \"status\": \"offline\"\n },\n {\n \"serial\": \"QBSB-DD84-RCQS\",\n \"status\": \"offline\"\n },\n {\n \"serial\": \"QBSB-DLV3-235C\",\n \"status\": \"offline\"\n },\n {\n \"serial\": \"QBSB-E3LG-VEQZ\",\n \"status\": \"offline\"\n },\n {\n \"serial\": \"QBSB-HXH8-6N32\",\n \"status\": \"offline\"\n },\n {\n \"serial\": \"QBSB-PP5Z-HJ84\",\n \"status\": \"offline\"\n },\n {\n \"serial\": \"QBSB-YYWS-RCY7\",\n \"status\": \"offline\"\n }\n]\n\nWe can narrow it down to the ones that are offline:\nOffline switches are:\n[\n {\n \"serial\": \"Q2BX-DEZ3-LGMD\",\n \"status\": \"offline\"\n },\n {\n \"serial\": \"QBSB-AK7F-URKC\",\n \"status\": \"offline\"\n },\n {\n \"serial\": \"QBSB-BDX9-8AZP\",\n \"status\": \"offline\"\n },\n {\n \"serial\": \"QBSB-DD84-RCQS\",\n \"status\": \"offline\"\n },\n {\n \"serial\": \"QBSB-DLV3-235C\",\n \"status\": \"offline\"\n },\n {\n \"serial\": \"QBSB-E3LG-VEQZ\",\n \"status\": \"offline\"\n },\n {\n \"serial\": \"QBSB-HXH8-6N32\",\n \"status\": \"offline\"\n },\n {\n \"serial\": \"QBSB-PP5Z-HJ84\",\n \"status\": \"offline\"\n },\n {\n \"serial\": \"QBSB-YYWS-RCY7\",\n \"status\": \"offline\"\n }\n]\n" |
213 | | - } |
214 | | - ], |
| 184 | + "outputs": [], |
215 | 185 | "source": [ |
216 | 186 | "# Now we can list out the statuses (and whatever metadata we need) for these switches\n", |
217 | 187 | "print('We can list out the statuses (and whatever metadata we need) for these switches:')\n", |
|
238 | 208 | }, |
239 | 209 | { |
240 | 210 | "cell_type": "code", |
241 | | - "execution_count": 7, |
| 211 | + "execution_count": null, |
242 | 212 | "metadata": { |
243 | 213 | "tags": [] |
244 | 214 | }, |
245 | | - "outputs": [ |
246 | | - { |
247 | | - "output_type": "stream", |
248 | | - "name": "stdout", |
249 | | - "text": "[\n {\n \"lastReportedAt\": \"2020-07-22 20:14:17.501\",\n \"serial\": \"Q2BX-DEZ3-LGMD\"\n },\n {\n \"lastReportedAt\": null,\n \"serial\": \"QBSB-AK7F-URKC\"\n },\n {\n \"lastReportedAt\": null,\n \"serial\": \"QBSB-BDX9-8AZP\"\n },\n {\n \"lastReportedAt\": null,\n \"serial\": \"QBSB-DD84-RCQS\"\n },\n {\n \"lastReportedAt\": null,\n \"serial\": \"QBSB-DLV3-235C\"\n },\n {\n \"lastReportedAt\": null,\n \"serial\": \"QBSB-E3LG-VEQZ\"\n },\n {\n \"lastReportedAt\": null,\n \"serial\": \"QBSB-HXH8-6N32\"\n },\n {\n \"lastReportedAt\": null,\n \"serial\": \"QBSB-PP5Z-HJ84\"\n },\n {\n \"lastReportedAt\": null,\n \"serial\": \"QBSB-YYWS-RCY7\"\n }\n]\n" |
250 | | - } |
251 | | - ], |
| 215 | + "outputs": [], |
252 | 216 | "source": [ |
253 | 217 | "# Another list comprehension!\n", |
254 | 218 | "devices_last_reported_times = [{'serial': i['serial'], 'lastReportedAt': i['lastReportedAt']} for i in devices_statuses if i['serial'] in devices_switches_serials]\n", |
|
267 | 231 | }, |
268 | 232 | { |
269 | 233 | "cell_type": "code", |
270 | | - "execution_count": 13, |
| 234 | + "execution_count": null, |
271 | 235 | "metadata": { |
272 | 236 | "tags": [] |
273 | 237 | }, |
274 | | - "outputs": [ |
275 | | - { |
276 | | - "output_type": "stream", |
277 | | - "name": "stdout", |
278 | | - "text": "serial |lastReportedAt \n--------------|-----------------------\nQ2BX-DEZ3-LGMD|2020-07-22 20:14:17.501\nQBSB-AK7F-URKC|None \nQBSB-BDX9-8AZP|None \nQBSB-DD84-RCQS|None \nQBSB-DLV3-235C|None \nQBSB-E3LG-VEQZ|None \nQBSB-HXH8-6N32|None \nQBSB-PP5Z-HJ84|None \nQBSB-YYWS-RCY7|None \n" |
279 | | - } |
280 | | - ], |
| 238 | + "outputs": [], |
281 | 239 | "source": [ |
282 | 240 | "# Let's convert that JSON-formatted data to a tabular dataset. You can copy/paste this into Excel, or write additional Python to create a new Excel file entirely!\n", |
283 | 241 | "excel_formatted = tablib.import_set(json.dumps(devices_last_reported_times), format = 'json')\n", |
|
0 commit comments