dashboard-api 1.0.0 → 1.0.1
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.
- checksums.yaml +4 -4
- data/.codeclimate.yml +34 -0
- data/.gitignore +5 -4
- data/.travis.yml +20 -0
- data/Gemfile +9 -5
- data/Gemfile.lock +63 -31
- data/README.md +134 -138
- data/Rakefile +9 -7
- data/dashboard-api.gemspec +28 -28
- data/doc/Admins.html +603 -603
- data/doc/Clients.html +276 -276
- data/doc/DashboardAPI.html +603 -603
- data/doc/DashboardAPIVersion.html +159 -159
- data/doc/Devices.html +879 -879
- data/doc/Networks.html +1382 -1382
- data/doc/Organizations.html +1477 -1477
- data/doc/Phones.html +641 -641
- data/doc/SAML.html +758 -758
- data/doc/SSIDs.html +523 -523
- data/doc/Switchports.html +526 -526
- data/doc/Templates.html +378 -378
- data/doc/VLANs.html +762 -762
- data/doc/_index.html +235 -235
- data/doc/class_list.html +51 -51
- data/doc/css/full_list.css +58 -58
- data/doc/css/style.css +481 -481
- data/doc/file.README.html +248 -248
- data/doc/file_list.html +56 -56
- data/doc/frames.html +17 -17
- data/doc/index.html +248 -248
- data/doc/js/app.js +243 -243
- data/doc/js/full_list.js +216 -216
- data/doc/js/jquery.js +3 -3
- data/doc/method_list.html +523 -523
- data/doc/top-level-namespace.html +113 -113
- data/lib/admins.rb +37 -37
- data/lib/clients.rb +12 -12
- data/lib/dashboard-api.rb +82 -83
- data/lib/dashboard-api/version.rb +6 -6
- data/lib/devices.rb +57 -57
- data/lib/networks.rb +108 -108
- data/lib/organizations.rb +110 -115
- data/lib/phones.rb +40 -40
- data/lib/saml.rb +47 -47
- data/lib/ssids.rb +33 -33
- data/lib/switchports.rb +33 -33
- data/lib/templates.rb +18 -18
- data/lib/vlans.rb +49 -49
- metadata +7 -5
data/doc/file_list.html
CHANGED
@@ -1,56 +1,56 @@
|
|
1
|
-
<!DOCTYPE html>
|
2
|
-
<html>
|
3
|
-
<head>
|
4
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
5
|
-
<meta charset="utf-8" />
|
6
|
-
|
7
|
-
<link rel="stylesheet" href="css/full_list.css" type="text/css" media="screen" charset="utf-8" />
|
8
|
-
|
9
|
-
<link rel="stylesheet" href="css/common.css" type="text/css" media="screen" charset="utf-8" />
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
<script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
|
14
|
-
|
15
|
-
<script type="text/javascript" charset="utf-8" src="js/full_list.js"></script>
|
16
|
-
|
17
|
-
|
18
|
-
<title>File List</title>
|
19
|
-
<base id="base_target" target="_parent" />
|
20
|
-
</head>
|
21
|
-
<body>
|
22
|
-
<div id="content">
|
23
|
-
<div class="fixed_header">
|
24
|
-
<h1 id="full_list_header">File List</h1>
|
25
|
-
<div id="full_list_nav">
|
26
|
-
|
27
|
-
<span><a target="_self" href="class_list.html">
|
28
|
-
Classes
|
29
|
-
</a></span>
|
30
|
-
|
31
|
-
<span><a target="_self" href="method_list.html">
|
32
|
-
Methods
|
33
|
-
</a></span>
|
34
|
-
|
35
|
-
<span><a target="_self" href="file_list.html">
|
36
|
-
Files
|
37
|
-
</a></span>
|
38
|
-
|
39
|
-
</div>
|
40
|
-
|
41
|
-
<div id="search">Search: <input type="text" /></div>
|
42
|
-
</div>
|
43
|
-
|
44
|
-
<ul id="full_list" class="file">
|
45
|
-
|
46
|
-
|
47
|
-
<li id="object_README" class="odd">
|
48
|
-
<div class="item"><span class="object_link"><a href="index.html" title="README">README</a></span></div>
|
49
|
-
</li>
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
</ul>
|
54
|
-
</div>
|
55
|
-
</body>
|
56
|
-
</html>
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
5
|
+
<meta charset="utf-8" />
|
6
|
+
|
7
|
+
<link rel="stylesheet" href="css/full_list.css" type="text/css" media="screen" charset="utf-8" />
|
8
|
+
|
9
|
+
<link rel="stylesheet" href="css/common.css" type="text/css" media="screen" charset="utf-8" />
|
10
|
+
|
11
|
+
|
12
|
+
|
13
|
+
<script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
|
14
|
+
|
15
|
+
<script type="text/javascript" charset="utf-8" src="js/full_list.js"></script>
|
16
|
+
|
17
|
+
|
18
|
+
<title>File List</title>
|
19
|
+
<base id="base_target" target="_parent" />
|
20
|
+
</head>
|
21
|
+
<body>
|
22
|
+
<div id="content">
|
23
|
+
<div class="fixed_header">
|
24
|
+
<h1 id="full_list_header">File List</h1>
|
25
|
+
<div id="full_list_nav">
|
26
|
+
|
27
|
+
<span><a target="_self" href="class_list.html">
|
28
|
+
Classes
|
29
|
+
</a></span>
|
30
|
+
|
31
|
+
<span><a target="_self" href="method_list.html">
|
32
|
+
Methods
|
33
|
+
</a></span>
|
34
|
+
|
35
|
+
<span><a target="_self" href="file_list.html">
|
36
|
+
Files
|
37
|
+
</a></span>
|
38
|
+
|
39
|
+
</div>
|
40
|
+
|
41
|
+
<div id="search">Search: <input type="text" /></div>
|
42
|
+
</div>
|
43
|
+
|
44
|
+
<ul id="full_list" class="file">
|
45
|
+
|
46
|
+
|
47
|
+
<li id="object_README" class="odd">
|
48
|
+
<div class="item"><span class="object_link"><a href="index.html" title="README">README</a></span></div>
|
49
|
+
</li>
|
50
|
+
|
51
|
+
|
52
|
+
|
53
|
+
</ul>
|
54
|
+
</div>
|
55
|
+
</body>
|
56
|
+
</html>
|
data/doc/frames.html
CHANGED
@@ -1,17 +1,17 @@
|
|
1
|
-
<!DOCTYPE html>
|
2
|
-
<html>
|
3
|
-
<head>
|
4
|
-
<meta charset="utf-8">
|
5
|
-
<title>Documentation by YARD 0.9.5</title>
|
6
|
-
</head>
|
7
|
-
<script type="text/javascript" charset="utf-8">
|
8
|
-
var match = unescape(window.location.hash).match(/^#!(.+)/);
|
9
|
-
var name = match ? match[1] : 'index.html';
|
10
|
-
name = name.replace(/^(\w+):\/\//, '').replace(/^\/\//, '');
|
11
|
-
window.top.location = name;
|
12
|
-
</script>
|
13
|
-
<noscript>
|
14
|
-
<h1>Oops!</h1>
|
15
|
-
<h2>YARD requires JavaScript!</h2>
|
16
|
-
</noscript>
|
17
|
-
</html>
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<meta charset="utf-8">
|
5
|
+
<title>Documentation by YARD 0.9.5</title>
|
6
|
+
</head>
|
7
|
+
<script type="text/javascript" charset="utf-8">
|
8
|
+
var match = unescape(window.location.hash).match(/^#!(.+)/);
|
9
|
+
var name = match ? match[1] : 'index.html';
|
10
|
+
name = name.replace(/^(\w+):\/\//, '').replace(/^\/\//, '');
|
11
|
+
window.top.location = name;
|
12
|
+
</script>
|
13
|
+
<noscript>
|
14
|
+
<h1>Oops!</h1>
|
15
|
+
<h2>YARD requires JavaScript!</h2>
|
16
|
+
</noscript>
|
17
|
+
</html>
|
data/doc/index.html
CHANGED
@@ -1,249 +1,249 @@
|
|
1
|
-
<!DOCTYPE html>
|
2
|
-
<html>
|
3
|
-
<head>
|
4
|
-
<meta charset="UTF-8">
|
5
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
6
|
-
<title>
|
7
|
-
File: README
|
8
|
-
|
9
|
-
— Documentation by YARD 0.9.5
|
10
|
-
|
11
|
-
</title>
|
12
|
-
|
13
|
-
<link rel="stylesheet" href="css/style.css" type="text/css" charset="utf-8" />
|
14
|
-
|
15
|
-
<link rel="stylesheet" href="css/common.css" type="text/css" charset="utf-8" />
|
16
|
-
|
17
|
-
<script type="text/javascript" charset="utf-8">
|
18
|
-
pathId = "README";
|
19
|
-
relpath = '';
|
20
|
-
</script>
|
21
|
-
|
22
|
-
|
23
|
-
<script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
|
24
|
-
|
25
|
-
<script type="text/javascript" charset="utf-8" src="js/app.js"></script>
|
26
|
-
|
27
|
-
|
28
|
-
</head>
|
29
|
-
<body>
|
30
|
-
<div class="nav_wrap">
|
31
|
-
<iframe id="nav" src="class_list.html"></iframe>
|
32
|
-
<div id="resizer"></div>
|
33
|
-
</div>
|
34
|
-
|
35
|
-
<div id="main" tabindex="-1">
|
36
|
-
<div id="header">
|
37
|
-
<div id="menu">
|
38
|
-
|
39
|
-
<a href="_index.html">Index</a> »
|
40
|
-
<span class="title">File: README</span>
|
41
|
-
|
42
|
-
</div>
|
43
|
-
|
44
|
-
<div id="search">
|
45
|
-
|
46
|
-
<a class="full_list_link" id="class_list_link"
|
47
|
-
href="class_list.html">
|
48
|
-
|
49
|
-
<svg width="24" height="24">
|
50
|
-
<rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
|
51
|
-
<rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
|
52
|
-
<rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
|
53
|
-
</svg>
|
54
|
-
</a>
|
55
|
-
|
56
|
-
</div>
|
57
|
-
<div class="clear"></div>
|
58
|
-
</div>
|
59
|
-
|
60
|
-
<iframe id="search_frame" src="class_list.html"></iframe>
|
61
|
-
|
62
|
-
<div id="content"><div id='filecontents'>
|
63
|
-
<h1 id="label-Dashboard+API+v1.0.0">Dashboard API v1.0.0</h1>
|
64
|
-
|
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>
|
68
|
-
|
69
|
-
<h1 id="label-Description">Description</h1>
|
70
|
-
|
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>
|
74
|
-
|
75
|
-
<h1 id="label-Usage">Usage</h1>
|
76
|
-
|
77
|
-
<h2 id="label-Installation">Installation</h2>
|
78
|
-
|
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>
|
80
|
-
</code></pre>
|
81
|
-
|
82
|
-
<p>Once the gem is installed, you can use it by requiring
|
83
|
-
<code>dashboard-api</code> <code>ruby require 'dashboard-api'
|
84
|
-
</code></p>
|
85
|
-
|
86
|
-
<h2 id="label-Examples">Examples</h2>
|
87
|
-
|
88
|
-
<h3 id="label-Basic+implementation">Basic implementation</h3>
|
89
|
-
|
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>
|
91
|
-
|
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>
|
94
|
-
|
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>
|
98
|
-
|
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>
|
101
|
-
</code></pre>
|
102
|
-
|
103
|
-
<h4 id="label-Update+a+specific+network">Update a specific network</h4>
|
104
|
-
|
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>
|
112
|
-
|
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>
|
122
|
-
|
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>
|
143
|
-
|
144
|
-
<h2 id="label-Testing">Testing</h2>
|
145
|
-
|
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>
|
219
|
-
|
220
|
-
<pre class="code ruby"><code class="ruby">➜ dashboard-api git:(master) ✗ rake test
|
221
|
-
Started with run options --seed 42405
|
222
|
-
|
223
|
-
DashAPITest
|
224
|
-
test_snmp_returns_as_array PASS (0.01s)
|
225
|
-
test_license_state_returns_as_hash PASS (0.01s)
|
226
|
-
test_api_key_is_a_string PASS (0.00s)
|
227
|
-
test_get_an_organization PASS (0.01s)
|
228
|
-
test_it_returns_as_json PASS (0.00s)
|
229
|
-
test_get_inventory_for_an_org PASS (0.01s)
|
230
|
-
test_get_license_state_for_an_org PASS (0.00s)
|
231
|
-
test_third_party_peer_returns_as_array PASS (0.01s)
|
232
|
-
test_it_is_a_dash_api PASS (0.00s)
|
233
|
-
test_current_snmp_status PASS (0.00s)
|
234
|
-
test_inventory_returns_as_array PASS (0.00s)
|
235
|
-
test_third_party_vpn_peers PASS (0.00s)
|
236
|
-
|
237
|
-
Finished in 0.05813s
|
238
|
-
12 tests, 12 assertions, 0 failures, 0 errors, 0 skips</code></pre>
|
239
|
-
</div></div>
|
240
|
-
|
241
|
-
<div id="footer">
|
242
|
-
Generated on Thu Nov 17 22:15:38 2016 by
|
243
|
-
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
244
|
-
0.9.5 (ruby-2.3.0).
|
245
|
-
</div>
|
246
|
-
|
247
|
-
</div>
|
248
|
-
</body>
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<meta charset="UTF-8">
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
6
|
+
<title>
|
7
|
+
File: README
|
8
|
+
|
9
|
+
— Documentation by YARD 0.9.5
|
10
|
+
|
11
|
+
</title>
|
12
|
+
|
13
|
+
<link rel="stylesheet" href="css/style.css" type="text/css" charset="utf-8" />
|
14
|
+
|
15
|
+
<link rel="stylesheet" href="css/common.css" type="text/css" charset="utf-8" />
|
16
|
+
|
17
|
+
<script type="text/javascript" charset="utf-8">
|
18
|
+
pathId = "README";
|
19
|
+
relpath = '';
|
20
|
+
</script>
|
21
|
+
|
22
|
+
|
23
|
+
<script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
|
24
|
+
|
25
|
+
<script type="text/javascript" charset="utf-8" src="js/app.js"></script>
|
26
|
+
|
27
|
+
|
28
|
+
</head>
|
29
|
+
<body>
|
30
|
+
<div class="nav_wrap">
|
31
|
+
<iframe id="nav" src="class_list.html"></iframe>
|
32
|
+
<div id="resizer"></div>
|
33
|
+
</div>
|
34
|
+
|
35
|
+
<div id="main" tabindex="-1">
|
36
|
+
<div id="header">
|
37
|
+
<div id="menu">
|
38
|
+
|
39
|
+
<a href="_index.html">Index</a> »
|
40
|
+
<span class="title">File: README</span>
|
41
|
+
|
42
|
+
</div>
|
43
|
+
|
44
|
+
<div id="search">
|
45
|
+
|
46
|
+
<a class="full_list_link" id="class_list_link"
|
47
|
+
href="class_list.html">
|
48
|
+
|
49
|
+
<svg width="24" height="24">
|
50
|
+
<rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
|
51
|
+
<rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
|
52
|
+
<rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
|
53
|
+
</svg>
|
54
|
+
</a>
|
55
|
+
|
56
|
+
</div>
|
57
|
+
<div class="clear"></div>
|
58
|
+
</div>
|
59
|
+
|
60
|
+
<iframe id="search_frame" src="class_list.html"></iframe>
|
61
|
+
|
62
|
+
<div id="content"><div id='filecontents'>
|
63
|
+
<h1 id="label-Dashboard+API+v1.0.0">Dashboard API v1.0.0</h1>
|
64
|
+
|
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>
|
68
|
+
|
69
|
+
<h1 id="label-Description">Description</h1>
|
70
|
+
|
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>
|
74
|
+
|
75
|
+
<h1 id="label-Usage">Usage</h1>
|
76
|
+
|
77
|
+
<h2 id="label-Installation">Installation</h2>
|
78
|
+
|
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>
|
80
|
+
</code></pre>
|
81
|
+
|
82
|
+
<p>Once the gem is installed, you can use it by requiring
|
83
|
+
<code>dashboard-api</code> <code>ruby require 'dashboard-api'
|
84
|
+
</code></p>
|
85
|
+
|
86
|
+
<h2 id="label-Examples">Examples</h2>
|
87
|
+
|
88
|
+
<h3 id="label-Basic+implementation">Basic implementation</h3>
|
89
|
+
|
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>
|
91
|
+
|
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>
|
94
|
+
|
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>
|
98
|
+
|
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>
|
101
|
+
</code></pre>
|
102
|
+
|
103
|
+
<h4 id="label-Update+a+specific+network">Update a specific network</h4>
|
104
|
+
|
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>
|
112
|
+
|
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>
|
122
|
+
|
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>
|
143
|
+
|
144
|
+
<h2 id="label-Testing">Testing</h2>
|
145
|
+
|
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>
|
219
|
+
|
220
|
+
<pre class="code ruby"><code class="ruby">➜ dashboard-api git:(master) ✗ rake test
|
221
|
+
Started with run options --seed 42405
|
222
|
+
|
223
|
+
DashAPITest
|
224
|
+
test_snmp_returns_as_array PASS (0.01s)
|
225
|
+
test_license_state_returns_as_hash PASS (0.01s)
|
226
|
+
test_api_key_is_a_string PASS (0.00s)
|
227
|
+
test_get_an_organization PASS (0.01s)
|
228
|
+
test_it_returns_as_json PASS (0.00s)
|
229
|
+
test_get_inventory_for_an_org PASS (0.01s)
|
230
|
+
test_get_license_state_for_an_org PASS (0.00s)
|
231
|
+
test_third_party_peer_returns_as_array PASS (0.01s)
|
232
|
+
test_it_is_a_dash_api PASS (0.00s)
|
233
|
+
test_current_snmp_status PASS (0.00s)
|
234
|
+
test_inventory_returns_as_array PASS (0.00s)
|
235
|
+
test_third_party_vpn_peers PASS (0.00s)
|
236
|
+
|
237
|
+
Finished in 0.05813s
|
238
|
+
12 tests, 12 assertions, 0 failures, 0 errors, 0 skips</code></pre>
|
239
|
+
</div></div>
|
240
|
+
|
241
|
+
<div id="footer">
|
242
|
+
Generated on Thu Nov 17 22:15:38 2016 by
|
243
|
+
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
244
|
+
0.9.5 (ruby-2.3.0).
|
245
|
+
</div>
|
246
|
+
|
247
|
+
</div>
|
248
|
+
</body>
|
249
249
|
</html>
|