dashboard-api 0.9.0 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -632,7 +632,7 @@ supports the name attribute.</p>
632
632
  </div>
633
633
 
634
634
  <div id="footer">
635
- Generated on Wed Nov 16 21:55:08 2016 by
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>
@@ -749,7 +749,7 @@ more information on these tags</p>
749
749
  </div>
750
750
 
751
751
  <div id="footer">
752
- Generated on Wed Nov 16 21:55:08 2016 by
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>
@@ -514,7 +514,7 @@ authMode, encryptionMode and psk</p>
514
514
  </div>
515
515
 
516
516
  <div id="footer">
517
- Generated on Wed Nov 16 21:55:08 2016 by
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>
@@ -517,7 +517,7 @@ official Meraki Dashboard API documentation.</p>
517
517
  </div>
518
518
 
519
519
  <div id="footer">
520
- Generated on Wed Nov 16 21:55:08 2016 by
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>
@@ -369,7 +369,7 @@ templates</p>
369
369
  </div>
370
370
 
371
371
  <div id="footer">
372
- Generated on Wed Nov 16 21:55:08 2016 by
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>
@@ -753,7 +753,7 @@ Documentation</p>
753
753
  </div>
754
754
 
755
755
  <div id="footer">
756
- Generated on Wed Nov 16 21:55:08 2016 by
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>
@@ -226,7 +226,7 @@
226
226
  </div>
227
227
 
228
228
  <div id="footer">
229
- Generated on Wed Nov 16 21:55:07 2016 by
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>
@@ -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+v0.9.0">Dashboard API v0.9.0</h1>
63
+ <h1 id="label-Dashboard+API+v1.0.0">Dashboard API v1.0.0</h1>
64
64
 
65
- <p>A ruby implementation of the <a
66
- href="https://documentation.meraki.com/zGeneral_Administration/Other_Topics/The_Cisco_Meraki_Dashboard_API">Meraki
67
- Dashboard API</a></p>
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-Preface">Preface</h1>
69
+ <h1 id="label-Description">Description</h1>
73
70
 
74
- <p>The following readme is broken down into two sections: * Installing /
75
- Usage of the gem * Contributing to development of the gem</p>
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-Installation+and+Normal+Usage">Installation and Normal Usage</h1>
75
+ <h1 id="label-Usage">Usage</h1>
78
76
 
79
- <h2 id="label-Usage">Usage</h2>
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 &#39;dashboard-api&#39; =&gt;
86
- true </code></p>
83
+ <code>dashboard-api</code> <code>ruby require &#39;dashboard-api&#39;
84
+ </code></p>
87
85
 
88
86
  <h2 id="label-Examples">Examples</h2>
89
87
 
90
- <p>It is highly recommended that you utilize environment variables when
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
- <h3 id="label-Instantiating+a+new+instance-3A">Instantiating a new instance:</h3>
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='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='const'>ENV</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>dashboard_api_key</span><span class='tstring_end'>&#39;</span></span><span class='rbracket'>]</span><span class='rparen'>)</span>
97
- </code></pre>
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'>&#39;</span><span class='tstring_content'>dashboard-api</span><span class='tstring_end'>&#39;</span></span>
98
94
 
99
- <h3 id="label-Listing+details+about+a+specific+network-3A">Listing details about a specific network:</h3>
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'>&#39;</span><span class='tstring_content'>dashboard_api_key</span><span class='tstring_end'>&#39;</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'>&#39;</span><span class='tstring_content'>dashboard_org_id</span><span class='tstring_end'>&#39;</span></span><span class='rbracket'>]</span>
100
98
 
101
- <pre class="code ruby"><code class="ruby">dapi.get_single_network(ENV[&#39;vpn_network&#39;])
102
- =&gt; {&quot;id&quot;=&gt;&quot;N_&lt;OMITTED&gt;&quot;, &quot;organizationId&quot;=&gt;&quot;&lt;OMITTED&gt;&quot;, &quot;type&quot;=&gt;&quot;appliance&quot;, &quot;name&quot;=&gt;&quot;vpn_test_network&quot;, &quot;timeZone&quot;=&gt;&quot;America/Los_Angeles&quot;, &quot;tags&quot;=&gt;&quot;&quot;}
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
- <p>There are many times where you need to actually pass data up to the
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 =&gt; &#39;new_test_network&#39;, :type =&gt; &#39;wireless&#39;}
117
- =&gt; {:name=&gt;&quot;new_test_network&quot;, :type=&gt;&quot;wireless&quot;}
118
- dapi.create_network(ENV[&#39;dashboard_org_id&#39;], options)
119
- =&gt; {&quot;id&quot;=&gt;&quot;N_&lt;OMITTED&gt;&quot;, &quot;organizationId&quot;=&gt;&quot;&lt;OMITTED&gt;&quot;, &quot;type&quot;=&gt;&quot;wireless&quot;, &quot;name&quot;=&gt;&quot;new_test_network&quot;, &quot;timeZone&quot;=&gt;&quot;America/Los_Angeles&quot;, &quot;tags&quot;=&gt;&quot;&quot;}
120
- </code></pre>
103
+ <h4 id="label-Update+a+specific+network">Update a specific network</h4>
121
104
 
122
- <p>Not every method call will return a Hash object. Some will return an Array,
123
- often containing a Hash in each element. Information about what is expected
124
- to be returned can be found in the Dashboard-API Documentation, as well as
125
- the official Meraki Dashboard API help documentation.</p>
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
- <pre class="code ruby"><code class="ruby">dapi.get_third_party_peers(ENV[&#39;dashboard_org_id&#39;])
128
- =&gt; [{&quot;name&quot;=&gt;&quot;test_api_peer&quot;, &quot;publicIp&quot;=&gt;&quot;10.0.0.1&quot;, &quot;privateSubnets&quot;=&gt;[&quot;10.1.0.0/24&quot;], &quot;secret&quot;=&gt;&quot;password&quot;, &quot;tags&quot;=&gt;[&quot;all&quot;]}, {&quot;name&quot;=&gt;&quot;second_api_peerr&quot;, &quot;publicIp&quot;=&gt;&quot;10.0.0.2&quot;, &quot;privateSubnets&quot;=&gt;[&quot;10.2.0.0/24&quot;], &quot;secret&quot;=&gt;&quot;password&quot;, &quot;tags&quot;=&gt;[&quot;api_test&quot;]}]
129
- </code></pre>
113
+ <h1 id="label-update_network.rb">update_network.rb</h1>
114
+
115
+ <p>require &#39;dashboard-api&#39;</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
- <h1 id="label-Development">Development</h1>
123
+ <p>dapi = DashboardAPI.new(@dashboard_api_key)</p>
124
+
125
+ <p>network_options = =&gt; @network_id, :name =&gt; &#39;New VPN
126
+ Spoke&#39; 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>To install the necessary dependencies run: <code> bundle install </code> If
136
- you do not use bundler, you can check out the gemfile, and install the
137
- dependencies individually as necessary.</p>
138
-
139
- <p>The Meraki Dashboard API requires both an API key, as well as certain
140
- identifiers such as Organization, or Network IDs. If you would like to run
141
- the full current test suite, the following ENV variables need to be set:</p>
142
- <ul><li>
143
- <p><code>dashboard_api_key</code> Your Meraki Dashboard API key</p>
144
- </li><li>
145
- <p><code>dashboard_org_id</code> The Meraki Dashboard Organization ID you will
146
- be testing on</p>
147
- </li><li>
148
- <p><code>test_network_id</code> A test network ID that will be used to test
149
- renaming networks</p>
150
- </li><li>
151
- <p><code>vpn_network</code> A test MX network that will test modifying AutoVPN
152
- settings</p>
153
- </li><li>
154
- <p><code>switch_network</code> A test MS netwok that will test things like
155
- access policies, etc.</p>
156
- </li><li>
157
- <p><code>mx_serial</code> A test MX that has client traffic passing through it</p>
158
- </li><li>
159
- <p><code>spare_mr</code> A test MR used to claim in and out of networks</p>
160
- </li><li>
161
- <p><code>test_admin_id</code> The ID of a test admin used to test updating and
162
- deleting admins</p>
163
- </li><li>
164
- <p><code>config_template_id</code> A test configuration template network ID
165
- used to test removing a template It is recommended that you set up a test
166
- organization with test devices in it when working with developing new
167
- functionality to this gem, as to not potentially disturb any of your
168
- production networks.</p>
169
- </li></ul>
170
-
171
- <p>Once those are set and dependencies are installed, you can run the tests
172
- with <code> rake test </code></p>
173
-
174
- <p>As the majority of the testing for this gem requires HTTP calls, testing is
175
- currently run with <a href="https://github.com/vcr/vcr">VCR</a> to capture
176
- actual HTTP responses to run the tests off of. This requires that the
177
- environment variables you set up above are for a valid Meraki Dashboard
178
- Organization. After running the tests for the first time, subsequent tests
179
- will be ran off of the saved output. We would also expect subsequent test
180
- runs to be close to instantenous, as seen below:</p>
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&#39;s
157
+ specifc set of tests: <code>ruby class OrganizationsTest &lt;
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&#39;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&#39;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 Wed Nov 16 21:55:08 2016 by
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>
@@ -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+v0.9.0">Dashboard API v0.9.0</h1>
63
+ <h1 id="label-Dashboard+API+v1.0.0">Dashboard API v1.0.0</h1>
64
64
 
65
- <p>A ruby implementation of the <a
66
- href="https://documentation.meraki.com/zGeneral_Administration/Other_Topics/The_Cisco_Meraki_Dashboard_API">Meraki
67
- Dashboard API</a></p>
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-Preface">Preface</h1>
69
+ <h1 id="label-Description">Description</h1>
73
70
 
74
- <p>The following readme is broken down into two sections: * Installing /
75
- Usage of the gem * Contributing to development of the gem</p>
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-Installation+and+Normal+Usage">Installation and Normal Usage</h1>
75
+ <h1 id="label-Usage">Usage</h1>
78
76
 
79
- <h2 id="label-Usage">Usage</h2>
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 &#39;dashboard-api&#39; =&gt;
86
- true </code></p>
83
+ <code>dashboard-api</code> <code>ruby require &#39;dashboard-api&#39;
84
+ </code></p>
87
85
 
88
86
  <h2 id="label-Examples">Examples</h2>
89
87
 
90
- <p>It is highly recommended that you utilize environment variables when
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
- <h3 id="label-Instantiating+a+new+instance-3A">Instantiating a new instance:</h3>
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='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='const'>ENV</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>dashboard_api_key</span><span class='tstring_end'>&#39;</span></span><span class='rbracket'>]</span><span class='rparen'>)</span>
97
- </code></pre>
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'>&#39;</span><span class='tstring_content'>dashboard-api</span><span class='tstring_end'>&#39;</span></span>
98
94
 
99
- <h3 id="label-Listing+details+about+a+specific+network-3A">Listing details about a specific network:</h3>
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'>&#39;</span><span class='tstring_content'>dashboard_api_key</span><span class='tstring_end'>&#39;</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'>&#39;</span><span class='tstring_content'>dashboard_org_id</span><span class='tstring_end'>&#39;</span></span><span class='rbracket'>]</span>
100
98
 
101
- <pre class="code ruby"><code class="ruby">dapi.get_single_network(ENV[&#39;vpn_network&#39;])
102
- =&gt; {&quot;id&quot;=&gt;&quot;N_&lt;OMITTED&gt;&quot;, &quot;organizationId&quot;=&gt;&quot;&lt;OMITTED&gt;&quot;, &quot;type&quot;=&gt;&quot;appliance&quot;, &quot;name&quot;=&gt;&quot;vpn_test_network&quot;, &quot;timeZone&quot;=&gt;&quot;America/Los_Angeles&quot;, &quot;tags&quot;=&gt;&quot;&quot;}
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
- <p>There are many times where you need to actually pass data up to the
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 =&gt; &#39;new_test_network&#39;, :type =&gt; &#39;wireless&#39;}
117
- =&gt; {:name=&gt;&quot;new_test_network&quot;, :type=&gt;&quot;wireless&quot;}
118
- dapi.create_network(ENV[&#39;dashboard_org_id&#39;], options)
119
- =&gt; {&quot;id&quot;=&gt;&quot;N_&lt;OMITTED&gt;&quot;, &quot;organizationId&quot;=&gt;&quot;&lt;OMITTED&gt;&quot;, &quot;type&quot;=&gt;&quot;wireless&quot;, &quot;name&quot;=&gt;&quot;new_test_network&quot;, &quot;timeZone&quot;=&gt;&quot;America/Los_Angeles&quot;, &quot;tags&quot;=&gt;&quot;&quot;}
120
- </code></pre>
103
+ <h4 id="label-Update+a+specific+network">Update a specific network</h4>
121
104
 
122
- <p>Not every method call will return a Hash object. Some will return an Array,
123
- often containing a Hash in each element. Information about what is expected
124
- to be returned can be found in the Dashboard-API Documentation, as well as
125
- the official Meraki Dashboard API help documentation.</p>
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
- <pre class="code ruby"><code class="ruby">dapi.get_third_party_peers(ENV[&#39;dashboard_org_id&#39;])
128
- =&gt; [{&quot;name&quot;=&gt;&quot;test_api_peer&quot;, &quot;publicIp&quot;=&gt;&quot;10.0.0.1&quot;, &quot;privateSubnets&quot;=&gt;[&quot;10.1.0.0/24&quot;], &quot;secret&quot;=&gt;&quot;password&quot;, &quot;tags&quot;=&gt;[&quot;all&quot;]}, {&quot;name&quot;=&gt;&quot;second_api_peerr&quot;, &quot;publicIp&quot;=&gt;&quot;10.0.0.2&quot;, &quot;privateSubnets&quot;=&gt;[&quot;10.2.0.0/24&quot;], &quot;secret&quot;=&gt;&quot;password&quot;, &quot;tags&quot;=&gt;[&quot;api_test&quot;]}]
129
- </code></pre>
113
+ <h1 id="label-update_network.rb">update_network.rb</h1>
114
+
115
+ <p>require &#39;dashboard-api&#39;</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
- <h1 id="label-Development">Development</h1>
123
+ <p>dapi = DashboardAPI.new(@dashboard_api_key)</p>
124
+
125
+ <p>network_options = =&gt; @network_id, :name =&gt; &#39;New VPN
126
+ Spoke&#39; 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>To install the necessary dependencies run: <code> bundle install </code> If
136
- you do not use bundler, you can check out the gemfile, and install the
137
- dependencies individually as necessary.</p>
138
-
139
- <p>The Meraki Dashboard API requires both an API key, as well as certain
140
- identifiers such as Organization, or Network IDs. If you would like to run
141
- the full current test suite, the following ENV variables need to be set:</p>
142
- <ul><li>
143
- <p><code>dashboard_api_key</code> Your Meraki Dashboard API key</p>
144
- </li><li>
145
- <p><code>dashboard_org_id</code> The Meraki Dashboard Organization ID you will
146
- be testing on</p>
147
- </li><li>
148
- <p><code>test_network_id</code> A test network ID that will be used to test
149
- renaming networks</p>
150
- </li><li>
151
- <p><code>vpn_network</code> A test MX network that will test modifying AutoVPN
152
- settings</p>
153
- </li><li>
154
- <p><code>switch_network</code> A test MS netwok that will test things like
155
- access policies, etc.</p>
156
- </li><li>
157
- <p><code>mx_serial</code> A test MX that has client traffic passing through it</p>
158
- </li><li>
159
- <p><code>spare_mr</code> A test MR used to claim in and out of networks</p>
160
- </li><li>
161
- <p><code>test_admin_id</code> The ID of a test admin used to test updating and
162
- deleting admins</p>
163
- </li><li>
164
- <p><code>config_template_id</code> A test configuration template network ID
165
- used to test removing a template It is recommended that you set up a test
166
- organization with test devices in it when working with developing new
167
- functionality to this gem, as to not potentially disturb any of your
168
- production networks.</p>
169
- </li></ul>
170
-
171
- <p>Once those are set and dependencies are installed, you can run the tests
172
- with <code> rake test </code></p>
173
-
174
- <p>As the majority of the testing for this gem requires HTTP calls, testing is
175
- currently run with <a href="https://github.com/vcr/vcr">VCR</a> to capture
176
- actual HTTP responses to run the tests off of. This requires that the
177
- environment variables you set up above are for a valid Meraki Dashboard
178
- Organization. After running the tests for the first time, subsequent tests
179
- will be ran off of the saved output. We would also expect subsequent test
180
- runs to be close to instantenous, as seen below:</p>
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&#39;s
157
+ specifc set of tests: <code>ruby class OrganizationsTest &lt;
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&#39;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&#39;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 Wed Nov 16 21:55:07 2016 by
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>