dashboard-api 0.9.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +77 -43
- data/Rakefile +1 -0
- data/doc/Admins.html +1 -1
- data/doc/Clients.html +1 -1
- data/doc/DashboardAPI.html +8 -4
- data/doc/DashboardAPIVersion.html +2 -2
- data/doc/Devices.html +1 -1
- data/doc/Networks.html +20 -22
- data/doc/Organizations.html +867 -61
- data/doc/Phones.html +1 -1
- data/doc/SAML.html +1 -1
- data/doc/SSIDs.html +1 -1
- data/doc/Switchports.html +1 -1
- data/doc/Templates.html +1 -1
- data/doc/VLANs.html +1 -1
- data/doc/_index.html +1 -1
- data/doc/file.README.html +132 -99
- data/doc/index.html +132 -99
- data/doc/method_list.html +80 -24
- data/doc/top-level-namespace.html +1 -1
- data/lib/dashboard-api.rb +3 -1
- data/lib/dashboard-api/version.rb +1 -1
- data/lib/networks.rb +7 -8
- data/lib/organizations.rb +77 -1
- metadata +2 -2
data/doc/Phones.html
CHANGED
@@ -632,7 +632,7 @@ supports the name attribute.</p>
|
|
632
632
|
</div>
|
633
633
|
|
634
634
|
<div id="footer">
|
635
|
-
Generated on
|
635
|
+
Generated on Thu Nov 17 22:15:39 2016 by
|
636
636
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
637
637
|
0.9.5 (ruby-2.3.0).
|
638
638
|
</div>
|
data/doc/SAML.html
CHANGED
@@ -749,7 +749,7 @@ more information on these tags</p>
|
|
749
749
|
</div>
|
750
750
|
|
751
751
|
<div id="footer">
|
752
|
-
Generated on
|
752
|
+
Generated on Thu Nov 17 22:15:39 2016 by
|
753
753
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
754
754
|
0.9.5 (ruby-2.3.0).
|
755
755
|
</div>
|
data/doc/SSIDs.html
CHANGED
@@ -514,7 +514,7 @@ authMode, encryptionMode and psk</p>
|
|
514
514
|
</div>
|
515
515
|
|
516
516
|
<div id="footer">
|
517
|
-
Generated on
|
517
|
+
Generated on Thu Nov 17 22:15:39 2016 by
|
518
518
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
519
519
|
0.9.5 (ruby-2.3.0).
|
520
520
|
</div>
|
data/doc/Switchports.html
CHANGED
@@ -517,7 +517,7 @@ official Meraki Dashboard API documentation.</p>
|
|
517
517
|
</div>
|
518
518
|
|
519
519
|
<div id="footer">
|
520
|
-
Generated on
|
520
|
+
Generated on Thu Nov 17 22:15:39 2016 by
|
521
521
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
522
522
|
0.9.5 (ruby-2.3.0).
|
523
523
|
</div>
|
data/doc/Templates.html
CHANGED
@@ -369,7 +369,7 @@ templates</p>
|
|
369
369
|
</div>
|
370
370
|
|
371
371
|
<div id="footer">
|
372
|
-
Generated on
|
372
|
+
Generated on Thu Nov 17 22:15:39 2016 by
|
373
373
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
374
374
|
0.9.5 (ruby-2.3.0).
|
375
375
|
</div>
|
data/doc/VLANs.html
CHANGED
@@ -753,7 +753,7 @@ Documentation</p>
|
|
753
753
|
</div>
|
754
754
|
|
755
755
|
<div id="footer">
|
756
|
-
Generated on
|
756
|
+
Generated on Thu Nov 17 22:15:39 2016 by
|
757
757
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
758
758
|
0.9.5 (ruby-2.3.0).
|
759
759
|
</div>
|
data/doc/_index.html
CHANGED
@@ -226,7 +226,7 @@
|
|
226
226
|
</div>
|
227
227
|
|
228
228
|
<div id="footer">
|
229
|
-
Generated on
|
229
|
+
Generated on Thu Nov 17 22:15:38 2016 by
|
230
230
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
231
231
|
0.9.5 (ruby-2.3.0).
|
232
232
|
</div>
|
data/doc/file.README.html
CHANGED
@@ -60,124 +60,162 @@
|
|
60
60
|
<iframe id="search_frame" src="file_list.html"></iframe>
|
61
61
|
|
62
62
|
<div id="content"><div id='filecontents'>
|
63
|
-
<h1 id="label-Dashboard+API+
|
63
|
+
<h1 id="label-Dashboard+API+v1.0.0">Dashboard API v1.0.0</h1>
|
64
64
|
|
65
|
-
<p>
|
66
|
-
href="
|
67
|
-
|
68
|
-
|
69
|
-
<p>Documentation <a
|
70
|
-
href="http://www.rubydoc.info/gems/dashboard-api/0.3.0">here</a></p>
|
65
|
+
<p>Documentation: <a
|
66
|
+
href="http://www.rubydoc.info/gems/dashboard-api/1.0.0">here</a> Issues: <a
|
67
|
+
href="https://github.com/jletizia/dashboardapi/issues">here</a></p>
|
71
68
|
|
72
|
-
<h1 id="label-
|
69
|
+
<h1 id="label-Description">Description</h1>
|
73
70
|
|
74
|
-
<p>
|
75
|
-
|
71
|
+
<p>A ruby implementation of the entire <a
|
72
|
+
href="https://documentation.meraki.com/zGeneral_Administration/Other_Topics/The_Cisco_Meraki_Dashboard_API">Meraki
|
73
|
+
Dashboard API</a></p>
|
76
74
|
|
77
|
-
<h1 id="label-
|
75
|
+
<h1 id="label-Usage">Usage</h1>
|
78
76
|
|
79
|
-
<h2 id="label-
|
77
|
+
<h2 id="label-Installation">Installation</h2>
|
80
78
|
|
81
79
|
<pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_gem'>gem</span> <span class='id identifier rubyid_install'>install</span> <span class='id identifier rubyid_dashboard'>dashboard</span><span class='op'>-</span><span class='id identifier rubyid_api'>api</span>
|
82
80
|
</code></pre>
|
83
81
|
|
84
82
|
<p>Once the gem is installed, you can use it by requiring
|
85
|
-
<code>dashboard-api</code> <code> require 'dashboard-api'
|
86
|
-
|
83
|
+
<code>dashboard-api</code> <code>ruby require 'dashboard-api'
|
84
|
+
</code></p>
|
87
85
|
|
88
86
|
<h2 id="label-Examples">Examples</h2>
|
89
87
|
|
90
|
-
<
|
91
|
-
dealing with things like API keys, tokens, etc. instead of utilizing them
|
92
|
-
directly in a script. All examples will be shown with this convention.</p>
|
88
|
+
<h3 id="label-Basic+implementation">Basic implementation</h3>
|
93
89
|
|
94
|
-
<
|
90
|
+
<h4 id="label-Get+a+list+of+networks+for+a+specific+Dashboard+Organization">Get a list of networks for a specific Dashboard Organization</h4>
|
95
91
|
|
96
|
-
<pre class="code ruby"><code class="ruby"><span class='
|
97
|
-
</
|
92
|
+
<pre class="code ruby"><code class="ruby"><span class='comment'># get_networks.rb
|
93
|
+
</span><span class='id identifier rubyid_require'>require</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>dashboard-api</span><span class='tstring_end'>'</span></span>
|
98
94
|
|
99
|
-
<
|
95
|
+
<span class='comment'># read in API key and Org ID from Environment variables
|
96
|
+
</span><span class='ivar'>@dashboard_api_key</span> <span class='op'>=</span> <span class='const'>ENV</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>dashboard_api_key</span><span class='tstring_end'>'</span></span><span class='rbracket'>]</span>
|
97
|
+
<span class='ivar'>@dashboard_org_id</span> <span class='op'>=</span> <span class='const'>ENV</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>dashboard_org_id</span><span class='tstring_end'>'</span></span><span class='rbracket'>]</span>
|
100
98
|
|
101
|
-
<
|
102
|
-
|
99
|
+
<span class='id identifier rubyid_dapi'>dapi</span> <span class='op'>=</span> <span class='const'>DashboardAPI</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='ivar'>@dashboard_api_key</span><span class='rparen'>)</span>
|
100
|
+
<span class='id identifier rubyid_dapi'>dapi</span><span class='period'>.</span><span class='id identifier rubyid_get_networks'>get_networks</span><span class='lparen'>(</span><span class='ivar'>@dashboard_org_id</span><span class='rparen'>)</span>
|
103
101
|
</code></pre>
|
104
102
|
|
105
|
-
<
|
106
|
-
Dashboard API, be it for creating new networks, updating device
|
107
|
-
information, etc. In situations like these, an options hash is expected to
|
108
|
-
be passed alongside to the method call. The Dashboard-API gem documentation
|
109
|
-
mentions what is expected in the option hash for methods that require it,
|
110
|
-
but the offical <a
|
111
|
-
href="https://dashboard.meraki.com/manage/support/api_docs">Meraki
|
112
|
-
Dashboard API documentation</a> is recommended for exact details.</p>
|
113
|
-
|
114
|
-
<h3 id="label-Creating+a+new+network-3A">Creating a new network:</h3>
|
115
|
-
|
116
|
-
<pre class="code ruby"><code class="ruby">options = {:name => 'new_test_network', :type => 'wireless'}
|
117
|
-
=> {:name=>"new_test_network", :type=>"wireless"}
|
118
|
-
dapi.create_network(ENV['dashboard_org_id'], options)
|
119
|
-
=> {"id"=>"N_<OMITTED>", "organizationId"=>"<OMITTED>", "type"=>"wireless", "name"=>"new_test_network", "timeZone"=>"America/Los_Angeles", "tags"=>""}
|
120
|
-
</code></pre>
|
103
|
+
<h4 id="label-Update+a+specific+network">Update a specific network</h4>
|
121
104
|
|
122
|
-
<p>
|
123
|
-
|
124
|
-
|
125
|
-
|
105
|
+
<p>This will update a specific network to have the new name of <code>New VPN
|
106
|
+
Spoke</code>. Note the options hash, <code>network_options</code>. Whenever
|
107
|
+
making a call to something that updates Dashboard, an options hash will be
|
108
|
+
used, with all necessary attributes as keys. Specifics about these keys can
|
109
|
+
be found in the official <a
|
110
|
+
href="https://dashboard.meraki.com/manage/support/api_docs">Meraki API
|
111
|
+
Documentation</a>. “`ruby</p>
|
126
112
|
|
127
|
-
<
|
128
|
-
|
129
|
-
|
113
|
+
<h1 id="label-update_network.rb">update_network.rb</h1>
|
114
|
+
|
115
|
+
<p>require 'dashboard-api'</p>
|
116
|
+
|
117
|
+
<h1 id="label-read+in+API+key+and+Org+ID+from+Environment+variables">read in API key and Org ID from Environment variables</h1>
|
118
|
+
|
119
|
+
<p>@dashboard_api_key = <a href="'dashboard_api_key'">ENV</a>
|
120
|
+
@dashboard_org_id = <a href="'dashboard_org_id'">ENV</a> @network_id = <a
|
121
|
+
href="'combined_network'">ENV</a></p>
|
130
122
|
|
131
|
-
<
|
123
|
+
<p>dapi = DashboardAPI.new(@dashboard_api_key)</p>
|
124
|
+
|
125
|
+
<p>network_options = => @network_id, :name => 'New VPN
|
126
|
+
Spoke' dapi.update_network(@network_id, network_options) “`</p>
|
127
|
+
|
128
|
+
<h1 id="label-Contributing">Contributing</h1>
|
129
|
+
|
130
|
+
<p>If you feel like contributing, information about the testing environment
|
131
|
+
can be found below. If you just want to use the gem to help interact with
|
132
|
+
the Meraki Dashboard, you only need to read the above sections.</p>
|
133
|
+
|
134
|
+
<h2 id="label-Dependencies">Dependencies</h2>
|
135
|
+
|
136
|
+
<p>To install the necessary dependencies run: <code>bash bundle install
|
137
|
+
</code> or</p>
|
138
|
+
|
139
|
+
<pre class="code ruby"><code class="ruby">gem install --dev dashboard-api</code></pre>
|
140
|
+
|
141
|
+
<p>or look in the <code>Gemfile</code> and install each dependency
|
142
|
+
individually.</p>
|
132
143
|
|
133
144
|
<h2 id="label-Testing">Testing</h2>
|
134
145
|
|
135
|
-
<p>
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
<
|
144
|
-
|
145
|
-
<p
|
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
|
-
|
146
|
+
<p>Because the Dashboard API needs actual Dashboard resources to hit against,
|
147
|
+
there is a decent amount of pre-configuring that needs to go into place.
|
148
|
+
This includes not only setting your API key, a default organization ID,
|
149
|
+
etc. but also setting up test devices that will be modified, removed,
|
150
|
+
claimed, etc. on Dashboard. It is recommended to use a completely separate
|
151
|
+
test organization, with separate test devices if possible, as to not
|
152
|
+
potentially disturb a production organization.</p>
|
153
|
+
|
154
|
+
<h3 id="label-Environment+Variables">Environment Variables</h3>
|
155
|
+
|
156
|
+
<p>Each test file will read in the necessary ENV variables for it's
|
157
|
+
specifc set of tests: <code>ruby class OrganizationsTest <
|
158
|
+
Minitest::Test def setup @dashboard_api_key =
|
159
|
+
ENV['dashboard_api_key'] @org_id = ENV['dashboard_org_id']
|
160
|
+
@network_id = ENV['test_network_id'] @dapi =
|
161
|
+
DashboardAPI.new(@dashboard_api_key) end </code> The full list of
|
162
|
+
necessary ENV variables is: * <code>dashboard_api_key</code> Your Meraki
|
163
|
+
Dashboard API key * <code>dashboard_org_id</code> The Meraki Dashboard
|
164
|
+
Organization ID you will be testing on * <code>test_network_id</code> A
|
165
|
+
test network ID that will be used to test renaming networks *
|
166
|
+
<code>vpn_network</code> A test MX network that will test modifying AutoVPN
|
167
|
+
settings * <code>switch_network</code> A test MS netwok that will test
|
168
|
+
things like access policies, etc. * <code>mx_serial</code> A test MX that
|
169
|
+
has client traffic passing through it * <code>spare_mr</code> A test MR
|
170
|
+
used to claim in and out of networks * <code>test_admin_id</code> The ID of
|
171
|
+
a test admin used to test updating and deleting admins *
|
172
|
+
<code>config_template_id</code> A test configuration template network ID
|
173
|
+
used to test removing a template * <code>unclaimed_device</code> A device
|
174
|
+
that can be used to test claiming * <code>phone_network</code> Test phone
|
175
|
+
network * <code>phone_contact_id</code> Test contact for your phone network
|
176
|
+
* <code>saml_id</code> ID of a test SAML user *
|
177
|
+
<code>config_template_id</code> ID of the template you will bind the test
|
178
|
+
network to * <code>config_bind_network</code> network you want to bind to a
|
179
|
+
template</p>
|
180
|
+
|
181
|
+
<h3 id="label-Running+a+test">Running a test</h3>
|
182
|
+
|
183
|
+
<p>As this is an wrapper gem for an RESTful API, the vast majority of methods
|
184
|
+
make some sort of HTTP call. To reduce the amount of time testing takes,
|
185
|
+
and ensure that we have good data to work against at all times, we utilize
|
186
|
+
<a href="https://github.com/vcr/vcr">VCR</a>. This will capture the HTTP
|
187
|
+
interaction the first time a test is ran, save them as fixtures, and then
|
188
|
+
replay that fixture on each subsequent call to that method during tests.</p>
|
189
|
+
|
190
|
+
<h4 id="label-First+test+run+issues">First test run issues</h4>
|
191
|
+
|
192
|
+
<p>Due to the HTTP interactions containing private data we are trying to
|
193
|
+
obscure with environment variables in the first place (API key,
|
194
|
+
organization IDs, etc.), the fixtures used to initially test this gem can
|
195
|
+
not be provided here. This means that you will need to generate your own
|
196
|
+
fixtures. Luckily, this is as easy as just running the tests in the first
|
197
|
+
place. Unluckily, due to Minitest randomizing the order of it's tests,
|
198
|
+
you may run into situations where the test to delete a network runs for the
|
199
|
+
first time, before that network ever exists (remember, with VCR, only the
|
200
|
+
first test run's HTTP interaction is saved, and used for each later
|
201
|
+
test). When this happens, a 404 will be received, VCR will save it, and the
|
202
|
+
test will fail.</p>
|
203
|
+
|
204
|
+
<h4 id="label-What+this+means">What this means</h4>
|
205
|
+
|
206
|
+
<p>Getting all of the tests to a point where they all pass will not be a
|
207
|
+
trivial task, due to the workflow of: running the tests, finding the tests
|
208
|
+
that failed due to a prerequisite not having happened at some point before
|
209
|
+
that test run, fixing the prerequisite, deleting the fixture (they live in
|
210
|
+
<code>fixtures/vcr_cassettes/</code>), and rerunning the tests.</p>
|
211
|
+
|
212
|
+
<h4 id="label-How+to+actually+run+the+tests">How to actually run the tests</h4>
|
213
|
+
|
214
|
+
<pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_rake'>rake</span> <span class='id identifier rubyid_test'>test</span>
|
215
|
+
</code></pre>
|
216
|
+
|
217
|
+
<p>After the first completely successful, all green run, tests will be almost
|
218
|
+
instantenous:</p>
|
181
219
|
|
182
220
|
<pre class="code ruby"><code class="ruby">➜ dashboard-api git:(master) ✗ rake test
|
183
221
|
Started with run options --seed 42405
|
@@ -198,15 +236,10 @@ DashAPITest
|
|
198
236
|
|
199
237
|
Finished in 0.05813s
|
200
238
|
12 tests, 12 assertions, 0 failures, 0 errors, 0 skips</code></pre>
|
201
|
-
|
202
|
-
<p>All of the saved HTTP responses from VCR will be saved by default in
|
203
|
-
<code>fixtures/vcr_cassettes/</code>. These <strong>should not be added /
|
204
|
-
comitted to git</strong> as they will contain all of the keys / tokens we
|
205
|
-
set as ENV variables above.</p>
|
206
239
|
</div></div>
|
207
240
|
|
208
241
|
<div id="footer">
|
209
|
-
Generated on
|
242
|
+
Generated on Thu Nov 17 22:15:38 2016 by
|
210
243
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
211
244
|
0.9.5 (ruby-2.3.0).
|
212
245
|
</div>
|
data/doc/index.html
CHANGED
@@ -60,124 +60,162 @@
|
|
60
60
|
<iframe id="search_frame" src="class_list.html"></iframe>
|
61
61
|
|
62
62
|
<div id="content"><div id='filecontents'>
|
63
|
-
<h1 id="label-Dashboard+API+
|
63
|
+
<h1 id="label-Dashboard+API+v1.0.0">Dashboard API v1.0.0</h1>
|
64
64
|
|
65
|
-
<p>
|
66
|
-
href="
|
67
|
-
|
68
|
-
|
69
|
-
<p>Documentation <a
|
70
|
-
href="http://www.rubydoc.info/gems/dashboard-api/0.3.0">here</a></p>
|
65
|
+
<p>Documentation: <a
|
66
|
+
href="http://www.rubydoc.info/gems/dashboard-api/1.0.0">here</a> Issues: <a
|
67
|
+
href="https://github.com/jletizia/dashboardapi/issues">here</a></p>
|
71
68
|
|
72
|
-
<h1 id="label-
|
69
|
+
<h1 id="label-Description">Description</h1>
|
73
70
|
|
74
|
-
<p>
|
75
|
-
|
71
|
+
<p>A ruby implementation of the entire <a
|
72
|
+
href="https://documentation.meraki.com/zGeneral_Administration/Other_Topics/The_Cisco_Meraki_Dashboard_API">Meraki
|
73
|
+
Dashboard API</a></p>
|
76
74
|
|
77
|
-
<h1 id="label-
|
75
|
+
<h1 id="label-Usage">Usage</h1>
|
78
76
|
|
79
|
-
<h2 id="label-
|
77
|
+
<h2 id="label-Installation">Installation</h2>
|
80
78
|
|
81
79
|
<pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_gem'>gem</span> <span class='id identifier rubyid_install'>install</span> <span class='id identifier rubyid_dashboard'>dashboard</span><span class='op'>-</span><span class='id identifier rubyid_api'>api</span>
|
82
80
|
</code></pre>
|
83
81
|
|
84
82
|
<p>Once the gem is installed, you can use it by requiring
|
85
|
-
<code>dashboard-api</code> <code> require 'dashboard-api'
|
86
|
-
|
83
|
+
<code>dashboard-api</code> <code>ruby require 'dashboard-api'
|
84
|
+
</code></p>
|
87
85
|
|
88
86
|
<h2 id="label-Examples">Examples</h2>
|
89
87
|
|
90
|
-
<
|
91
|
-
dealing with things like API keys, tokens, etc. instead of utilizing them
|
92
|
-
directly in a script. All examples will be shown with this convention.</p>
|
88
|
+
<h3 id="label-Basic+implementation">Basic implementation</h3>
|
93
89
|
|
94
|
-
<
|
90
|
+
<h4 id="label-Get+a+list+of+networks+for+a+specific+Dashboard+Organization">Get a list of networks for a specific Dashboard Organization</h4>
|
95
91
|
|
96
|
-
<pre class="code ruby"><code class="ruby"><span class='
|
97
|
-
</
|
92
|
+
<pre class="code ruby"><code class="ruby"><span class='comment'># get_networks.rb
|
93
|
+
</span><span class='id identifier rubyid_require'>require</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>dashboard-api</span><span class='tstring_end'>'</span></span>
|
98
94
|
|
99
|
-
<
|
95
|
+
<span class='comment'># read in API key and Org ID from Environment variables
|
96
|
+
</span><span class='ivar'>@dashboard_api_key</span> <span class='op'>=</span> <span class='const'>ENV</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>dashboard_api_key</span><span class='tstring_end'>'</span></span><span class='rbracket'>]</span>
|
97
|
+
<span class='ivar'>@dashboard_org_id</span> <span class='op'>=</span> <span class='const'>ENV</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>dashboard_org_id</span><span class='tstring_end'>'</span></span><span class='rbracket'>]</span>
|
100
98
|
|
101
|
-
<
|
102
|
-
|
99
|
+
<span class='id identifier rubyid_dapi'>dapi</span> <span class='op'>=</span> <span class='const'>DashboardAPI</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='ivar'>@dashboard_api_key</span><span class='rparen'>)</span>
|
100
|
+
<span class='id identifier rubyid_dapi'>dapi</span><span class='period'>.</span><span class='id identifier rubyid_get_networks'>get_networks</span><span class='lparen'>(</span><span class='ivar'>@dashboard_org_id</span><span class='rparen'>)</span>
|
103
101
|
</code></pre>
|
104
102
|
|
105
|
-
<
|
106
|
-
Dashboard API, be it for creating new networks, updating device
|
107
|
-
information, etc. In situations like these, an options hash is expected to
|
108
|
-
be passed alongside to the method call. The Dashboard-API gem documentation
|
109
|
-
mentions what is expected in the option hash for methods that require it,
|
110
|
-
but the offical <a
|
111
|
-
href="https://dashboard.meraki.com/manage/support/api_docs">Meraki
|
112
|
-
Dashboard API documentation</a> is recommended for exact details.</p>
|
113
|
-
|
114
|
-
<h3 id="label-Creating+a+new+network-3A">Creating a new network:</h3>
|
115
|
-
|
116
|
-
<pre class="code ruby"><code class="ruby">options = {:name => 'new_test_network', :type => 'wireless'}
|
117
|
-
=> {:name=>"new_test_network", :type=>"wireless"}
|
118
|
-
dapi.create_network(ENV['dashboard_org_id'], options)
|
119
|
-
=> {"id"=>"N_<OMITTED>", "organizationId"=>"<OMITTED>", "type"=>"wireless", "name"=>"new_test_network", "timeZone"=>"America/Los_Angeles", "tags"=>""}
|
120
|
-
</code></pre>
|
103
|
+
<h4 id="label-Update+a+specific+network">Update a specific network</h4>
|
121
104
|
|
122
|
-
<p>
|
123
|
-
|
124
|
-
|
125
|
-
|
105
|
+
<p>This will update a specific network to have the new name of <code>New VPN
|
106
|
+
Spoke</code>. Note the options hash, <code>network_options</code>. Whenever
|
107
|
+
making a call to something that updates Dashboard, an options hash will be
|
108
|
+
used, with all necessary attributes as keys. Specifics about these keys can
|
109
|
+
be found in the official <a
|
110
|
+
href="https://dashboard.meraki.com/manage/support/api_docs">Meraki API
|
111
|
+
Documentation</a>. “`ruby</p>
|
126
112
|
|
127
|
-
<
|
128
|
-
|
129
|
-
|
113
|
+
<h1 id="label-update_network.rb">update_network.rb</h1>
|
114
|
+
|
115
|
+
<p>require 'dashboard-api'</p>
|
116
|
+
|
117
|
+
<h1 id="label-read+in+API+key+and+Org+ID+from+Environment+variables">read in API key and Org ID from Environment variables</h1>
|
118
|
+
|
119
|
+
<p>@dashboard_api_key = <a href="'dashboard_api_key'">ENV</a>
|
120
|
+
@dashboard_org_id = <a href="'dashboard_org_id'">ENV</a> @network_id = <a
|
121
|
+
href="'combined_network'">ENV</a></p>
|
130
122
|
|
131
|
-
<
|
123
|
+
<p>dapi = DashboardAPI.new(@dashboard_api_key)</p>
|
124
|
+
|
125
|
+
<p>network_options = => @network_id, :name => 'New VPN
|
126
|
+
Spoke' dapi.update_network(@network_id, network_options) “`</p>
|
127
|
+
|
128
|
+
<h1 id="label-Contributing">Contributing</h1>
|
129
|
+
|
130
|
+
<p>If you feel like contributing, information about the testing environment
|
131
|
+
can be found below. If you just want to use the gem to help interact with
|
132
|
+
the Meraki Dashboard, you only need to read the above sections.</p>
|
133
|
+
|
134
|
+
<h2 id="label-Dependencies">Dependencies</h2>
|
135
|
+
|
136
|
+
<p>To install the necessary dependencies run: <code>bash bundle install
|
137
|
+
</code> or</p>
|
138
|
+
|
139
|
+
<pre class="code ruby"><code class="ruby">gem install --dev dashboard-api</code></pre>
|
140
|
+
|
141
|
+
<p>or look in the <code>Gemfile</code> and install each dependency
|
142
|
+
individually.</p>
|
132
143
|
|
133
144
|
<h2 id="label-Testing">Testing</h2>
|
134
145
|
|
135
|
-
<p>
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
<
|
144
|
-
|
145
|
-
<p
|
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
|
-
|
146
|
+
<p>Because the Dashboard API needs actual Dashboard resources to hit against,
|
147
|
+
there is a decent amount of pre-configuring that needs to go into place.
|
148
|
+
This includes not only setting your API key, a default organization ID,
|
149
|
+
etc. but also setting up test devices that will be modified, removed,
|
150
|
+
claimed, etc. on Dashboard. It is recommended to use a completely separate
|
151
|
+
test organization, with separate test devices if possible, as to not
|
152
|
+
potentially disturb a production organization.</p>
|
153
|
+
|
154
|
+
<h3 id="label-Environment+Variables">Environment Variables</h3>
|
155
|
+
|
156
|
+
<p>Each test file will read in the necessary ENV variables for it's
|
157
|
+
specifc set of tests: <code>ruby class OrganizationsTest <
|
158
|
+
Minitest::Test def setup @dashboard_api_key =
|
159
|
+
ENV['dashboard_api_key'] @org_id = ENV['dashboard_org_id']
|
160
|
+
@network_id = ENV['test_network_id'] @dapi =
|
161
|
+
DashboardAPI.new(@dashboard_api_key) end </code> The full list of
|
162
|
+
necessary ENV variables is: * <code>dashboard_api_key</code> Your Meraki
|
163
|
+
Dashboard API key * <code>dashboard_org_id</code> The Meraki Dashboard
|
164
|
+
Organization ID you will be testing on * <code>test_network_id</code> A
|
165
|
+
test network ID that will be used to test renaming networks *
|
166
|
+
<code>vpn_network</code> A test MX network that will test modifying AutoVPN
|
167
|
+
settings * <code>switch_network</code> A test MS netwok that will test
|
168
|
+
things like access policies, etc. * <code>mx_serial</code> A test MX that
|
169
|
+
has client traffic passing through it * <code>spare_mr</code> A test MR
|
170
|
+
used to claim in and out of networks * <code>test_admin_id</code> The ID of
|
171
|
+
a test admin used to test updating and deleting admins *
|
172
|
+
<code>config_template_id</code> A test configuration template network ID
|
173
|
+
used to test removing a template * <code>unclaimed_device</code> A device
|
174
|
+
that can be used to test claiming * <code>phone_network</code> Test phone
|
175
|
+
network * <code>phone_contact_id</code> Test contact for your phone network
|
176
|
+
* <code>saml_id</code> ID of a test SAML user *
|
177
|
+
<code>config_template_id</code> ID of the template you will bind the test
|
178
|
+
network to * <code>config_bind_network</code> network you want to bind to a
|
179
|
+
template</p>
|
180
|
+
|
181
|
+
<h3 id="label-Running+a+test">Running a test</h3>
|
182
|
+
|
183
|
+
<p>As this is an wrapper gem for an RESTful API, the vast majority of methods
|
184
|
+
make some sort of HTTP call. To reduce the amount of time testing takes,
|
185
|
+
and ensure that we have good data to work against at all times, we utilize
|
186
|
+
<a href="https://github.com/vcr/vcr">VCR</a>. This will capture the HTTP
|
187
|
+
interaction the first time a test is ran, save them as fixtures, and then
|
188
|
+
replay that fixture on each subsequent call to that method during tests.</p>
|
189
|
+
|
190
|
+
<h4 id="label-First+test+run+issues">First test run issues</h4>
|
191
|
+
|
192
|
+
<p>Due to the HTTP interactions containing private data we are trying to
|
193
|
+
obscure with environment variables in the first place (API key,
|
194
|
+
organization IDs, etc.), the fixtures used to initially test this gem can
|
195
|
+
not be provided here. This means that you will need to generate your own
|
196
|
+
fixtures. Luckily, this is as easy as just running the tests in the first
|
197
|
+
place. Unluckily, due to Minitest randomizing the order of it's tests,
|
198
|
+
you may run into situations where the test to delete a network runs for the
|
199
|
+
first time, before that network ever exists (remember, with VCR, only the
|
200
|
+
first test run's HTTP interaction is saved, and used for each later
|
201
|
+
test). When this happens, a 404 will be received, VCR will save it, and the
|
202
|
+
test will fail.</p>
|
203
|
+
|
204
|
+
<h4 id="label-What+this+means">What this means</h4>
|
205
|
+
|
206
|
+
<p>Getting all of the tests to a point where they all pass will not be a
|
207
|
+
trivial task, due to the workflow of: running the tests, finding the tests
|
208
|
+
that failed due to a prerequisite not having happened at some point before
|
209
|
+
that test run, fixing the prerequisite, deleting the fixture (they live in
|
210
|
+
<code>fixtures/vcr_cassettes/</code>), and rerunning the tests.</p>
|
211
|
+
|
212
|
+
<h4 id="label-How+to+actually+run+the+tests">How to actually run the tests</h4>
|
213
|
+
|
214
|
+
<pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_rake'>rake</span> <span class='id identifier rubyid_test'>test</span>
|
215
|
+
</code></pre>
|
216
|
+
|
217
|
+
<p>After the first completely successful, all green run, tests will be almost
|
218
|
+
instantenous:</p>
|
181
219
|
|
182
220
|
<pre class="code ruby"><code class="ruby">➜ dashboard-api git:(master) ✗ rake test
|
183
221
|
Started with run options --seed 42405
|
@@ -198,15 +236,10 @@ DashAPITest
|
|
198
236
|
|
199
237
|
Finished in 0.05813s
|
200
238
|
12 tests, 12 assertions, 0 failures, 0 errors, 0 skips</code></pre>
|
201
|
-
|
202
|
-
<p>All of the saved HTTP responses from VCR will be saved by default in
|
203
|
-
<code>fixtures/vcr_cassettes/</code>. These <strong>should not be added /
|
204
|
-
comitted to git</strong> as they will contain all of the keys / tokens we
|
205
|
-
set as ENV variables above.</p>
|
206
239
|
</div></div>
|
207
240
|
|
208
241
|
<div id="footer">
|
209
|
-
Generated on
|
242
|
+
Generated on Thu Nov 17 22:15:38 2016 by
|
210
243
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
211
244
|
0.9.5 (ruby-2.3.0).
|
212
245
|
</div>
|