dashboard-api 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 04ea5ea741021389830cf259a44bb659c8145b12
4
+ data.tar.gz: 84d33231dac4bb879aee45f52038e84d48ff71b5
5
+ SHA512:
6
+ metadata.gz: 18d3f694804e18bed50f889c617e812ac64838603971130fb9d1356f054394c72369cb53eced3f9b1a2c96e6993545904431568da3643d6824789850cafd6ba8
7
+ data.tar.gz: 9cdf0c701c725bf2b554364abcb7e69687ab91bcb83200b85401c8f7c16cb28fa389cf7ff541fb7e69dbe6b0e139845a1ef30db6fb873e3c711bd06d531e7ce1
data/.gitignore ADDED
@@ -0,0 +1,4 @@
1
+ fixtures/
2
+ .yardoc
3
+ _Yardoc
4
+ .DS_Store
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ source "https://rubygems.org"
2
+ gem "httparty"
3
+ gem 'vcr'
4
+ gem 'webmock'
5
+ gem 'yard'
data/Gemfile.lock ADDED
@@ -0,0 +1,31 @@
1
+ GEM
2
+ remote: https://rubygems.org/
3
+ specs:
4
+ addressable (2.5.0)
5
+ public_suffix (~> 2.0, >= 2.0.2)
6
+ crack (0.4.3)
7
+ safe_yaml (~> 1.0.0)
8
+ hashdiff (0.3.0)
9
+ httparty (0.14.0)
10
+ multi_xml (>= 0.5.2)
11
+ multi_xml (0.5.5)
12
+ public_suffix (2.0.4)
13
+ safe_yaml (1.0.4)
14
+ vcr (3.0.3)
15
+ webmock (2.1.0)
16
+ addressable (>= 2.3.6)
17
+ crack (>= 0.3.2)
18
+ hashdiff
19
+ yard (0.9.5)
20
+
21
+ PLATFORMS
22
+ ruby
23
+
24
+ DEPENDENCIES
25
+ httparty
26
+ vcr
27
+ webmock
28
+ yard
29
+
30
+ BUNDLED WITH
31
+ 1.13.6
data/README.md ADDED
@@ -0,0 +1,103 @@
1
+ # Dashboard API v0.1.0
2
+ A ruby implementation of the [Meraki Dashboard API](https://documentation.meraki.com/zGeneral_Administration/Other_Topics/The_Cisco_Meraki_Dashboard_API)
3
+
4
+ Documentation [here](https://)
5
+
6
+ # Preface
7
+ The following readme is broken down into two sections:
8
+ * Installing / Usage of the gem
9
+ * Contributing to development of the gem
10
+
11
+ # Installation and Normal Usage
12
+ ## Usage
13
+ ```bash
14
+ gem install dashboard-api
15
+ ```
16
+ Once the gem is installed, you can use it by requiring `dashboard-api`
17
+ ```
18
+ require 'dashboard-api'
19
+ => true
20
+ ```
21
+
22
+ ## Examples
23
+ It is highly recommended that you utilize environment variables when dealing with things like API keys, tokens, etc. instead of utilizing them directly in a script. All examples will be shown with this convention.
24
+
25
+ ###Instantiating a new instance:
26
+ ```ruby
27
+ dapi = DashboardAPI.new(ENV['dashboard_api_key'])
28
+ ```
29
+
30
+ ###Listing details about a specific network:
31
+ ```ruby
32
+ dapi.get_single_network(ENV['vpn_network'])
33
+ => {"id"=>"N_<OMITTED>", "organizationId"=>"<OMITTED>", "type"=>"appliance", "name"=>"vpn_test_network", "timeZone"=>"America/Los_Angeles", "tags"=>""}
34
+ ```
35
+ There are many times where you need to actually pass data up to the Dashboard API, be it for creating new networks, updating device information, etc. In situations like these, an options hash is expected
36
+ to be passed alongside to the method call. The Dashboard-API gem documentation mentions what is expected in the option hash for methods that require it, but the offical [Meraki Dashboard API documentation](https://dashboard.meraki.com/manage/support/api_docs) is recommended for exact details.
37
+
38
+ ###Creating a new network:
39
+ ```ruby
40
+ options = {:name => 'new_test_network', :type => 'wireless'}
41
+ => {:name=>"new_test_network", :type=>"wireless"}
42
+ dapi.create_network(ENV['dashboard_org_id'], options)
43
+ => {"id"=>"N_<OMITTED>", "organizationId"=>"<OMITTED>", "type"=>"wireless", "name"=>"new_test_network", "timeZone"=>"America/Los_Angeles", "tags"=>""}
44
+ ```
45
+
46
+ Not every method call will return a Hash object. Some will return an Array, often containing a Hash in each element. Information about what is expected to be returned can be found in the Dashboard-API Documentation, as well as the official Meraki Dashboard API help documentation.
47
+
48
+ ```ruby
49
+ dapi.get_third_party_peers(ENV['dashboard_org_id'])
50
+ => [{"name"=>"test_api_peer", "publicIp"=>"10.0.0.1", "privateSubnets"=>["10.1.0.0/24"], "secret"=>"password", "tags"=>["all"]}, {"name"=>"second_api_peerr", "publicIp"=>"10.0.0.2", "privateSubnets"=>["10.2.0.0/24"], "secret"=>"password", "tags"=>["api_test"]}]
51
+ ```
52
+
53
+ # Development
54
+ ## Testing
55
+ To install the necessary dependencies run:
56
+ ```
57
+ bundle install
58
+ ```
59
+ If you do not use bundler, you can check out the gemfile, and install the dependencies individually as necessary.
60
+
61
+ The Meraki Dashboard API requires both an API key, as well as certain identifiers such as Organization, or Network IDs. If you would like to run the full current test suite, the following
62
+ ENV variables need to be set:
63
+
64
+ * `dashboard_api_key` Your Meraki Dashboard API key
65
+ * `dashboard_org_id` The Meraki Dashboard Organization ID you will be testing on
66
+ * `test_network_id` A test network ID that will be used to test renaming networks
67
+ * `vpn_network` A test MX network that will test modifying AutoVPN settings
68
+ * `switch_network` A test MS netwok that will test things like access policies, etc.
69
+ * `mx_serial` A test MX that has client traffic passing through it
70
+ * `spare_mr` A test MR used to claim in and out of networks
71
+
72
+ It is recommended that you set up a test organization with test devices in it when working with developing new functionality to this gem, as to not potentially disturb any of your production networks.
73
+
74
+ Once those are set and dependencies are installed, you can run the tests with
75
+ ```
76
+ rake test
77
+ ```
78
+
79
+ As the majority of the testing for this gem requires HTTP calls, testing is currently run with [VCR](https://github.com/vcr/vcr) to capture actual HTTP responses to run the tests off of. This requires that the environment variables you set up above are for a valid Meraki Dashboard Organization. After running the tests for the first time, subsequent tests will be ran off of the saved output. We would also expect subsequent test runs to be close to instantenous, as seen below:
80
+
81
+ ```bash
82
+ ➜ dashboard-api git:(master) ✗ rake test
83
+ Started with run options --seed 42405
84
+
85
+ DashAPITest
86
+ test_snmp_returns_as_array PASS (0.01s)
87
+ test_license_state_returns_as_hash PASS (0.01s)
88
+ test_api_key_is_a_string PASS (0.00s)
89
+ test_get_an_organization PASS (0.01s)
90
+ test_it_returns_as_json PASS (0.00s)
91
+ test_get_inventory_for_an_org PASS (0.01s)
92
+ test_get_license_state_for_an_org PASS (0.00s)
93
+ test_third_party_peer_returns_as_array PASS (0.01s)
94
+ test_it_is_a_dash_api PASS (0.00s)
95
+ test_current_snmp_status PASS (0.00s)
96
+ test_inventory_returns_as_array PASS (0.00s)
97
+ test_third_party_vpn_peers PASS (0.00s)
98
+
99
+ Finished in 0.05813s
100
+ 12 tests, 12 assertions, 0 failures, 0 errors, 0 skips
101
+ ```
102
+
103
+ All of the saved HTTP responses from VCR will be saved by default in `fixtures/vcr_cassettes/`. These **should not be added / comitted to git** as they will contain all of the keys / tokens we set as ENV variables above.
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require 'rake/testtask'
2
+
3
+ Rake::TestTask.new do |t|
4
+ t.test_files = FileList['test/test*.rb']
5
+ end
6
+
@@ -0,0 +1,28 @@
1
+ lib = File.expand_path('../lib', __FILE__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+
4
+ require 'dashboard-api/version'
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = 'dashboard-api'
8
+ s.version = DashboardAPIVersion::VERSION
9
+ s.authors = ['Joe Letizia']
10
+ s.email = ['letiziajm@gmail.com']
11
+
12
+ s.summary = %q{A Ruby implementation of the Meraki Dashboard API}
13
+ s.description = %q{A Ruby implementation of the Meraki Dashboard API. It allows you to interact and provision the Meraki Dashboard via their RESTful API}
14
+ s.homepage = "https://github.com/jletizia/dashboardapi"
15
+
16
+ s.files = `git ls-files -z`.split("\x0").reject do |f|
17
+ f.match(%r{^(test|spec|features)/})
18
+ end
19
+
20
+ s.require_paths = ['lib']
21
+ s.add_development_dependency "rake", "~> 10.0"
22
+ s.add_development_dependency "minitest", "~> 5.0"
23
+ s.add_development_dependency "yard", "~> 0.9.5"
24
+ s.add_development_dependency "vcr", ">= 3.0.3"
25
+ s.add_development_dependency "webmock", ">= 2.1.0"
26
+
27
+ s.add_runtime_dependency "httparty", "~> 0.14.0"
28
+ end
data/doc/Clients.html ADDED
@@ -0,0 +1,250 @@
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
+ Module: Clients
8
+
9
+ &mdash; 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 = "Clients";
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 (C)</a> &raquo;
40
+
41
+
42
+ <span class="title">Clients</span>
43
+
44
+ </div>
45
+
46
+ <div id="search">
47
+
48
+ <a class="full_list_link" id="class_list_link"
49
+ href="class_list.html">
50
+
51
+ <svg width="24" height="24">
52
+ <rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
53
+ <rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
54
+ <rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
55
+ </svg>
56
+ </a>
57
+
58
+ </div>
59
+ <div class="clear"></div>
60
+ </div>
61
+
62
+ <iframe id="search_frame" src="class_list.html"></iframe>
63
+
64
+ <div id="content"><h1>Module: Clients
65
+
66
+
67
+
68
+ </h1>
69
+ <div class="box_info">
70
+
71
+
72
+
73
+
74
+
75
+
76
+
77
+
78
+
79
+ <dl>
80
+ <dt>Included in:</dt>
81
+ <dd><span class='object_link'><a href="DashboardAPI.html" title="DashboardAPI (class)">DashboardAPI</a></span></dd>
82
+ </dl>
83
+
84
+
85
+
86
+ <dl>
87
+ <dt>Defined in:</dt>
88
+ <dd>lib/clients.rb</dd>
89
+ </dl>
90
+
91
+ </div>
92
+
93
+
94
+
95
+
96
+
97
+
98
+
99
+
100
+
101
+ <h2>
102
+ Instance Method Summary
103
+ <small><a href="#" class="summary_toggle">collapse</a></small>
104
+ </h2>
105
+
106
+ <ul class="summary">
107
+
108
+ <li class="public ">
109
+ <span class="summary_signature">
110
+
111
+ <a href="#get_client_info_for_device-instance_method" title="#get_client_info_for_device (instance method)">#<strong>get_client_info_for_device</strong>(serial, timespan) &#x21d2; Array </a>
112
+
113
+
114
+
115
+ </span>
116
+
117
+
118
+
119
+
120
+
121
+
122
+
123
+
124
+
125
+ <span class="summary_desc"><div class='inline'>
126
+ <p>Return client usage for a specific device.</p>
127
+ </div></span>
128
+
129
+ </li>
130
+
131
+
132
+ </ul>
133
+
134
+
135
+
136
+
137
+ <div id="instance_method_details" class="method_details_list">
138
+ <h2>Instance Method Details</h2>
139
+
140
+
141
+ <div class="method_details first">
142
+ <h3 class="signature first" id="get_client_info_for_device-instance_method">
143
+
144
+ #<strong>get_client_info_for_device</strong>(serial, timespan) &#x21d2; <tt>Array</tt>
145
+
146
+
147
+
148
+
149
+
150
+ </h3><div class="docstring">
151
+ <div class="discussion">
152
+
153
+ <p>Return client usage for a specific device</p>
154
+
155
+
156
+ </div>
157
+ </div>
158
+ <div class="tags">
159
+ <p class="tag_title">Parameters:</p>
160
+ <ul class="param">
161
+
162
+ <li>
163
+
164
+ <span class='name'>serial</span>
165
+
166
+
167
+ <span class='type'>(<tt>String</tt>)</span>
168
+
169
+
170
+
171
+ &mdash;
172
+ <div class='inline'>
173
+ <p>meraki serial number of the device</p>
174
+ </div>
175
+
176
+ </li>
177
+
178
+ <li>
179
+
180
+ <span class='name'>timespan</span>
181
+
182
+
183
+ <span class='type'>(<tt>Integer</tt>)</span>
184
+
185
+
186
+
187
+ &mdash;
188
+ <div class='inline'>
189
+ <p>timespan up to 1 month in seconds to get client usage for</p>
190
+ </div>
191
+
192
+ </li>
193
+
194
+ </ul>
195
+
196
+ <p class="tag_title">Returns:</p>
197
+ <ul class="return">
198
+
199
+ <li>
200
+
201
+
202
+ <span class='type'>(<tt>Array</tt>)</span>
203
+
204
+
205
+
206
+ &mdash;
207
+ <div class='inline'>
208
+ <p>an array of hashes for each client&#39;s usage</p>
209
+ </div>
210
+
211
+ </li>
212
+
213
+ </ul>
214
+
215
+ </div><table class="source_code">
216
+ <tr>
217
+ <td>
218
+ <pre class="lines">
219
+
220
+
221
+ 6
222
+ 7
223
+ 8
224
+ 9</pre>
225
+ </td>
226
+ <td>
227
+ <pre class="code"><span class="info file"># File 'lib/clients.rb', line 6</span>
228
+
229
+ <span class='kw'>def</span> <span class='id identifier rubyid_get_client_info_for_device'>get_client_info_for_device</span><span class='lparen'>(</span><span class='id identifier rubyid_serial'>serial</span><span class='comma'>,</span> <span class='id identifier rubyid_timespan'>timespan</span><span class='rparen'>)</span>
230
+ <span class='id identifier rubyid_raise'>raise</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>Timespan can not be larger than 2592000 seconds</span><span class='tstring_end'>&#39;</span></span> <span class='kw'>if</span> <span class='id identifier rubyid_timespan'>timespan</span><span class='period'>.</span><span class='id identifier rubyid_to_i'>to_i</span> <span class='op'>&gt;</span> <span class='int'>2592000</span>
231
+ <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_make_api_call'>make_api_call</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>/devices/</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_serial'>serial</span><span class='embexpr_end'>}</span><span class='tstring_content'>/clients?timespan=</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_timespan'>timespan</span><span class='embexpr_end'>}</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>GET</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span>
232
+ <span class='kw'>end</span></pre>
233
+ </td>
234
+ </tr>
235
+ </table>
236
+ </div>
237
+
238
+ </div>
239
+
240
+ </div>
241
+
242
+ <div id="footer">
243
+ Generated on Tue Nov 15 21:16:07 2016 by
244
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
245
+ 0.9.5 (ruby-2.3.0).
246
+ </div>
247
+
248
+ </div>
249
+ </body>
250
+ </html>
@@ -0,0 +1,532 @@
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
+ Class: DashboardAPI
8
+
9
+ &mdash; 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 = "DashboardAPI";
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 (D)</a> &raquo;
40
+
41
+
42
+ <span class="title">DashboardAPI</span>
43
+
44
+ </div>
45
+
46
+ <div id="search">
47
+
48
+ <a class="full_list_link" id="class_list_link"
49
+ href="class_list.html">
50
+
51
+ <svg width="24" height="24">
52
+ <rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
53
+ <rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
54
+ <rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
55
+ </svg>
56
+ </a>
57
+
58
+ </div>
59
+ <div class="clear"></div>
60
+ </div>
61
+
62
+ <iframe id="search_frame" src="class_list.html"></iframe>
63
+
64
+ <div id="content"><h1>Class: DashboardAPI
65
+
66
+
67
+
68
+ </h1>
69
+ <div class="box_info">
70
+
71
+ <dl>
72
+ <dt>Inherits:</dt>
73
+ <dd>
74
+ <span class="inheritName">Object</span>
75
+
76
+ <ul class="fullTree">
77
+ <li>Object</li>
78
+
79
+ <li class="next">DashboardAPI</li>
80
+
81
+ </ul>
82
+ <a href="#" class="inheritanceTree">show all</a>
83
+
84
+ </dd>
85
+ </dl>
86
+
87
+
88
+
89
+
90
+
91
+
92
+ <dl>
93
+ <dt>Includes:</dt>
94
+ <dd><span class='object_link'><a href="Clients.html" title="Clients (module)">Clients</a></span>, <span class='object_link'><a href="DashboardAPIVersion.html" title="DashboardAPIVersion (module)">DashboardAPIVersion</a></span>, <span class='object_link'><a href="Devices.html" title="Devices (module)">Devices</a></span>, HTTParty, <span class='object_link'><a href="Networks.html" title="Networks (module)">Networks</a></span>, <span class='object_link'><a href="Organizations.html" title="Organizations (module)">Organizations</a></span>, <span class='object_link'><a href="SSIDs.html" title="SSIDs (module)">SSIDs</a></span></dd>
95
+ </dl>
96
+
97
+
98
+
99
+
100
+
101
+
102
+ <dl>
103
+ <dt>Defined in:</dt>
104
+ <dd>lib/dashboard-api.rb</dd>
105
+ </dl>
106
+
107
+ </div>
108
+
109
+ <h2>Overview</h2><div class="docstring">
110
+ <div class="discussion">
111
+
112
+ <p>Ruby Implementation of the Meraki Dashboard api</p>
113
+
114
+
115
+ </div>
116
+ </div>
117
+ <div class="tags">
118
+
119
+ <p class="tag_title">Author:</p>
120
+ <ul class="author">
121
+
122
+ <li>
123
+
124
+
125
+
126
+
127
+
128
+ <div class='inline'>
129
+ <p>Joe Letizia</p>
130
+ </div>
131
+
132
+ </li>
133
+
134
+ </ul>
135
+
136
+ </div>
137
+
138
+
139
+ <h2>Constant Summary</h2>
140
+
141
+ <h3 class="inherited">Constants included
142
+ from <span class='object_link'><a href="DashboardAPIVersion.html" title="DashboardAPIVersion (module)">DashboardAPIVersion</a></span></h3>
143
+ <p class="inherited"><span class='object_link'><a href="DashboardAPIVersion.html#VERSION-constant" title="DashboardAPIVersion::VERSION (constant)">DashboardAPIVersion::VERSION</a></span></p>
144
+
145
+
146
+ <h2>Instance Attribute Summary <small><a href="#" class="summary_toggle">collapse</a></small></h2>
147
+ <ul class="summary">
148
+
149
+ <li class="public ">
150
+ <span class="summary_signature">
151
+
152
+ <a href="#key-instance_method" title="#key (instance method)">#<strong>key</strong> &#x21d2; Object </a>
153
+
154
+
155
+
156
+ </span>
157
+
158
+
159
+
160
+
161
+ <span class="note title readonly">readonly</span>
162
+
163
+
164
+
165
+
166
+
167
+
168
+
169
+
170
+
171
+ <span class="summary_desc"><div class='inline'>
172
+ <p>Returns the value of attribute key.</p>
173
+ </div></span>
174
+
175
+ </li>
176
+
177
+
178
+ </ul>
179
+
180
+
181
+
182
+
183
+
184
+ <h2>
185
+ Instance Method Summary
186
+ <small><a href="#" class="summary_toggle">collapse</a></small>
187
+ </h2>
188
+
189
+ <ul class="summary">
190
+
191
+ <li class="public ">
192
+ <span class="summary_signature">
193
+
194
+ <a href="#initialize-instance_method" title="#initialize (instance method)">#<strong>initialize</strong>(key) &#x21d2; DashboardAPI </a>
195
+
196
+
197
+
198
+ </span>
199
+
200
+
201
+ <span class="note title constructor">constructor</span>
202
+
203
+
204
+
205
+
206
+
207
+
208
+
209
+
210
+ <span class="summary_desc"><div class='inline'>
211
+ <p>A new instance of DashboardAPI.</p>
212
+ </div></span>
213
+
214
+ </li>
215
+
216
+
217
+ <li class="public ">
218
+ <span class="summary_signature">
219
+
220
+ <a href="#make_api_call-instance_method" title="#make_api_call (instance method)">#<strong>make_api_call</strong>(endpoint_url, http_method, options_hash = {}) &#x21d2; Object </a>
221
+
222
+
223
+
224
+ </span>
225
+
226
+
227
+
228
+
229
+
230
+
231
+
232
+
233
+
234
+ <span class="summary_desc"><div class='inline'>
235
+ <p>Inner function, not to be called directly.</p>
236
+ </div></span>
237
+
238
+ </li>
239
+
240
+
241
+ </ul>
242
+
243
+
244
+
245
+
246
+
247
+
248
+
249
+
250
+
251
+
252
+
253
+ <h3 class="inherited">Methods included from <span class='object_link'><a href="SSIDs.html" title="SSIDs (module)">SSIDs</a></span></h3>
254
+ <p class="inherited"><span class='object_link'><a href="SSIDs.html#get_single_ssid-instance_method" title="SSIDs#get_single_ssid (method)">#get_single_ssid</a></span>, <span class='object_link'><a href="SSIDs.html#list_ssids_in_network-instance_method" title="SSIDs#list_ssids_in_network (method)">#list_ssids_in_network</a></span>, <span class='object_link'><a href="SSIDs.html#update_single_ssid-instance_method" title="SSIDs#update_single_ssid (method)">#update_single_ssid</a></span></p>
255
+
256
+
257
+
258
+
259
+
260
+
261
+
262
+
263
+
264
+ <h3 class="inherited">Methods included from <span class='object_link'><a href="Devices.html" title="Devices (module)">Devices</a></span></h3>
265
+ <p class="inherited"><span class='object_link'><a href="Devices.html#claim_device_into_network-instance_method" title="Devices#claim_device_into_network (method)">#claim_device_into_network</a></span>, <span class='object_link'><a href="Devices.html#get_device_uplink_stats-instance_method" title="Devices#get_device_uplink_stats (method)">#get_device_uplink_stats</a></span>, <span class='object_link'><a href="Devices.html#get_single_device-instance_method" title="Devices#get_single_device (method)">#get_single_device</a></span>, <span class='object_link'><a href="Devices.html#list_devices_in_network-instance_method" title="Devices#list_devices_in_network (method)">#list_devices_in_network</a></span>, <span class='object_link'><a href="Devices.html#remove_device_from_network-instance_method" title="Devices#remove_device_from_network (method)">#remove_device_from_network</a></span>, <span class='object_link'><a href="Devices.html#update_device_attributes-instance_method" title="Devices#update_device_attributes (method)">#update_device_attributes</a></span></p>
266
+
267
+
268
+
269
+
270
+
271
+
272
+
273
+
274
+
275
+ <h3 class="inherited">Methods included from <span class='object_link'><a href="Clients.html" title="Clients (module)">Clients</a></span></h3>
276
+ <p class="inherited"><span class='object_link'><a href="Clients.html#get_client_info_for_device-instance_method" title="Clients#get_client_info_for_device (method)">#get_client_info_for_device</a></span></p>
277
+
278
+
279
+
280
+
281
+
282
+
283
+
284
+
285
+
286
+ <h3 class="inherited">Methods included from <span class='object_link'><a href="Networks.html" title="Networks (module)">Networks</a></span></h3>
287
+ <p class="inherited"><span class='object_link'><a href="Networks.html#create_network-instance_method" title="Networks#create_network (method)">#create_network</a></span>, <span class='object_link'><a href="Networks.html#delete_network-instance_method" title="Networks#delete_network (method)">#delete_network</a></span>, <span class='object_link'><a href="Networks.html#get_auto_vpn_settings-instance_method" title="Networks#get_auto_vpn_settings (method)">#get_auto_vpn_settings</a></span>, <span class='object_link'><a href="Networks.html#get_ms_access_policies-instance_method" title="Networks#get_ms_access_policies (method)">#get_ms_access_policies</a></span>, <span class='object_link'><a href="Networks.html#get_networks-instance_method" title="Networks#get_networks (method)">#get_networks</a></span>, <span class='object_link'><a href="Networks.html#get_single_network-instance_method" title="Networks#get_single_network (method)">#get_single_network</a></span>, <span class='object_link'><a href="Networks.html#update_auto_vpn_settings-instance_method" title="Networks#update_auto_vpn_settings (method)">#update_auto_vpn_settings</a></span>, <span class='object_link'><a href="Networks.html#update_network-instance_method" title="Networks#update_network (method)">#update_network</a></span></p>
288
+
289
+
290
+
291
+
292
+
293
+
294
+
295
+
296
+
297
+
298
+
299
+
300
+
301
+
302
+
303
+ <h3 class="inherited">Methods included from <span class='object_link'><a href="Organizations.html" title="Organizations (module)">Organizations</a></span></h3>
304
+ <p class="inherited"><span class='object_link'><a href="Organizations.html#get_inventory-instance_method" title="Organizations#get_inventory (method)">#get_inventory</a></span>, <span class='object_link'><a href="Organizations.html#get_license_state-instance_method" title="Organizations#get_license_state (method)">#get_license_state</a></span>, <span class='object_link'><a href="Organizations.html#get_organization-instance_method" title="Organizations#get_organization (method)">#get_organization</a></span>, <span class='object_link'><a href="Organizations.html#get_snmp_status-instance_method" title="Organizations#get_snmp_status (method)">#get_snmp_status</a></span>, <span class='object_link'><a href="Organizations.html#get_third_party_peers-instance_method" title="Organizations#get_third_party_peers (method)">#get_third_party_peers</a></span></p>
305
+
306
+ <div id="constructor_details" class="method_details_list">
307
+ <h2>Constructor Details</h2>
308
+
309
+ <div class="method_details first">
310
+ <h3 class="signature first" id="initialize-instance_method">
311
+
312
+ #<strong>initialize</strong>(key) &#x21d2; <tt><span class='object_link'><a href="" title="DashboardAPI (class)">DashboardAPI</a></span></tt>
313
+
314
+
315
+
316
+
317
+
318
+ </h3><div class="docstring">
319
+ <div class="discussion">
320
+
321
+ <p>Returns a new instance of DashboardAPI</p>
322
+
323
+
324
+ </div>
325
+ </div>
326
+ <div class="tags">
327
+
328
+
329
+ </div><table class="source_code">
330
+ <tr>
331
+ <td>
332
+ <pre class="lines">
333
+
334
+
335
+ 23
336
+ 24
337
+ 25</pre>
338
+ </td>
339
+ <td>
340
+ <pre class="code"><span class="info file"># File 'lib/dashboard-api.rb', line 23</span>
341
+
342
+ <span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='id identifier rubyid_key'>key</span><span class='rparen'>)</span>
343
+ <span class='ivar'>@key</span> <span class='op'>=</span> <span class='id identifier rubyid_key'>key</span>
344
+ <span class='kw'>end</span></pre>
345
+ </td>
346
+ </tr>
347
+ </table>
348
+ </div>
349
+
350
+ </div>
351
+
352
+ <div id="instance_attr_details" class="attr_details">
353
+ <h2>Instance Attribute Details</h2>
354
+
355
+
356
+ <span id=""></span>
357
+ <div class="method_details first">
358
+ <h3 class="signature first" id="key-instance_method">
359
+
360
+ #<strong>key</strong> &#x21d2; <tt>Object</tt> <span class="extras">(readonly)</span>
361
+
362
+
363
+
364
+
365
+
366
+ </h3><div class="docstring">
367
+ <div class="discussion">
368
+
369
+ <p>Returns the value of attribute key</p>
370
+
371
+
372
+ </div>
373
+ </div>
374
+ <div class="tags">
375
+
376
+
377
+ </div><table class="source_code">
378
+ <tr>
379
+ <td>
380
+ <pre class="lines">
381
+
382
+
383
+ 21
384
+ 22
385
+ 23</pre>
386
+ </td>
387
+ <td>
388
+ <pre class="code"><span class="info file"># File 'lib/dashboard-api.rb', line 21</span>
389
+
390
+ <span class='kw'>def</span> <span class='id identifier rubyid_key'>key</span>
391
+ <span class='ivar'>@key</span>
392
+ <span class='kw'>end</span></pre>
393
+ </td>
394
+ </tr>
395
+ </table>
396
+ </div>
397
+
398
+ </div>
399
+
400
+
401
+ <div id="instance_method_details" class="method_details_list">
402
+ <h2>Instance Method Details</h2>
403
+
404
+
405
+ <div class="method_details first">
406
+ <h3 class="signature first" id="make_api_call-instance_method">
407
+
408
+ #<strong>make_api_call</strong>(endpoint_url, http_method, options_hash = {}) &#x21d2; <tt>Object</tt>
409
+
410
+
411
+
412
+
413
+
414
+ </h3><div class="docstring">
415
+ <div class="discussion">
416
+
417
+ <div class="note todo">
418
+ <strong>TODO:</strong>
419
+ <div class='inline'>
420
+ <p>Eventually this will need to support POST, PUT and DELETE. It also needs to
421
+ be a bit more resillient, instead of relying on HTTParty for exception
422
+ handling</p>
423
+ </div>
424
+ </div>
425
+
426
+
427
+ <p>Inner function, not to be called directly</p>
428
+
429
+
430
+ </div>
431
+ </div>
432
+ <div class="tags">
433
+
434
+
435
+ </div><table class="source_code">
436
+ <tr>
437
+ <td>
438
+ <pre class="lines">
439
+
440
+
441
+ 32
442
+ 33
443
+ 34
444
+ 35
445
+ 36
446
+ 37
447
+ 38
448
+ 39
449
+ 40
450
+ 41
451
+ 42
452
+ 43
453
+ 44
454
+ 45
455
+ 46
456
+ 47
457
+ 48
458
+ 49
459
+ 50
460
+ 51
461
+ 52
462
+ 53
463
+ 54
464
+ 55
465
+ 56
466
+ 57
467
+ 58
468
+ 59
469
+ 60
470
+ 61
471
+ 62
472
+ 63
473
+ 64
474
+ 65
475
+ 66</pre>
476
+ </td>
477
+ <td>
478
+ <pre class="code"><span class="info file"># File 'lib/dashboard-api.rb', line 32</span>
479
+
480
+ <span class='kw'>def</span> <span class='id identifier rubyid_make_api_call'>make_api_call</span><span class='lparen'>(</span><span class='id identifier rubyid_endpoint_url'>endpoint_url</span><span class='comma'>,</span> <span class='id identifier rubyid_http_method'>http_method</span><span class='comma'>,</span> <span class='id identifier rubyid_options_hash'>options_hash</span><span class='op'>=</span><span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span>
481
+ <span class='id identifier rubyid_headers'>headers</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>X-Cisco-Meraki-API-Key</span><span class='tstring_end'>&quot;</span></span> <span class='op'>=&gt;</span> <span class='ivar'>@key</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>Content-Type</span><span class='tstring_end'>&#39;</span></span> <span class='op'>=&gt;</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>application/json</span><span class='tstring_end'>&#39;</span></span><span class='rbrace'>}</span>
482
+ <span class='id identifier rubyid_headers'>headers</span><span class='period'>.</span><span class='id identifier rubyid_merge!'>merge!</span><span class='lparen'>(</span><span class='id identifier rubyid_options_hash'>options_hash</span><span class='lbracket'>[</span><span class='symbol'>:headers</span><span class='rbracket'>]</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_options_hash'>options_hash</span><span class='lbracket'>[</span><span class='symbol'>:headers</span><span class='rbracket'>]</span>
483
+
484
+ <span class='id identifier rubyid_options'>options</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='symbol'>:headers</span> <span class='op'>=&gt;</span> <span class='id identifier rubyid_headers'>headers</span><span class='comma'>,</span> <span class='symbol'>:body</span> <span class='op'>=&gt;</span> <span class='id identifier rubyid_options_hash'>options_hash</span><span class='lbracket'>[</span><span class='symbol'>:body</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_to_json'>to_json</span><span class='rbrace'>}</span>
485
+ <span class='kw'>case</span> <span class='id identifier rubyid_http_method'>http_method</span>
486
+ <span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>GET</span><span class='tstring_end'>&#39;</span></span>
487
+ <span class='id identifier rubyid_res'>res</span> <span class='op'>=</span> <span class='const'>HTTParty</span><span class='period'>.</span><span class='id identifier rubyid_get'>get</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='embexpr_beg'>#{</span><span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_class'>class</span><span class='period'>.</span><span class='id identifier rubyid_base_uri'>base_uri</span><span class='embexpr_end'>}</span><span class='tstring_content'>/</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_endpoint_url'>endpoint_url</span><span class='embexpr_end'>}</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='id identifier rubyid_options'>options</span><span class='rparen'>)</span>
488
+ <span class='id identifier rubyid_raise'>raise</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>404 returned. Are you sure you are using the proper IDs?</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>if</span> <span class='id identifier rubyid_res'>res</span><span class='period'>.</span><span class='id identifier rubyid_code'>code</span> <span class='op'>==</span> <span class='int'>404</span>
489
+ <span class='kw'>return</span> <span class='const'>JSON</span><span class='period'>.</span><span class='id identifier rubyid_parse'>parse</span><span class='lparen'>(</span><span class='id identifier rubyid_res'>res</span><span class='period'>.</span><span class='id identifier rubyid_body'>body</span><span class='rparen'>)</span>
490
+ <span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>POST</span><span class='tstring_end'>&#39;</span></span>
491
+ <span class='id identifier rubyid_res'>res</span> <span class='op'>=</span> <span class='const'>HTTParty</span><span class='period'>.</span><span class='id identifier rubyid_post'>post</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='embexpr_beg'>#{</span><span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_class'>class</span><span class='period'>.</span><span class='id identifier rubyid_base_uri'>base_uri</span><span class='embexpr_end'>}</span><span class='tstring_content'>/</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_endpoint_url'>endpoint_url</span><span class='embexpr_end'>}</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='id identifier rubyid_options'>options</span><span class='rparen'>)</span>
492
+ <span class='id identifier rubyid_raise'>raise</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Bad Request due to the following error(s): </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_res'>res</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>errors</span><span class='tstring_end'>&#39;</span></span><span class='rbracket'>]</span><span class='embexpr_end'>}</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>if</span> <span class='id identifier rubyid_res'>res</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>errors</span><span class='tstring_end'>&#39;</span></span><span class='rbracket'>]</span>
493
+ <span class='id identifier rubyid_raise'>raise</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>404 returned. Are you sure you are using the proper IDs?</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>if</span> <span class='id identifier rubyid_res'>res</span><span class='period'>.</span><span class='id identifier rubyid_code'>code</span> <span class='op'>==</span> <span class='int'>404</span>
494
+ <span class='kw'>begin</span>
495
+ <span class='kw'>return</span> <span class='const'>JSON</span><span class='period'>.</span><span class='id identifier rubyid_parse'>parse</span><span class='lparen'>(</span><span class='id identifier rubyid_res'>res</span><span class='period'>.</span><span class='id identifier rubyid_body'>body</span><span class='rparen'>)</span>
496
+ <span class='kw'>rescue</span> <span class='const'>JSON</span><span class='op'>::</span><span class='const'>ParserError</span> <span class='op'>=&gt;</span> <span class='id identifier rubyid_e'>e</span>
497
+ <span class='kw'>return</span> <span class='id identifier rubyid_res'>res</span><span class='period'>.</span><span class='id identifier rubyid_code'>code</span>
498
+ <span class='kw'>rescue</span> <span class='const'>TypeError</span> <span class='op'>=&gt;</span> <span class='id identifier rubyid_e'>e</span>
499
+ <span class='kw'>return</span> <span class='id identifier rubyid_res'>res</span><span class='period'>.</span><span class='id identifier rubyid_code'>code</span>
500
+ <span class='kw'>end</span>
501
+ <span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>PUT</span><span class='tstring_end'>&#39;</span></span>
502
+ <span class='id identifier rubyid_res'>res</span> <span class='op'>=</span> <span class='const'>HTTParty</span><span class='period'>.</span><span class='id identifier rubyid_put'>put</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='embexpr_beg'>#{</span><span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_class'>class</span><span class='period'>.</span><span class='id identifier rubyid_base_uri'>base_uri</span><span class='embexpr_end'>}</span><span class='tstring_content'>/</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_endpoint_url'>endpoint_url</span><span class='embexpr_end'>}</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='id identifier rubyid_options'>options</span><span class='rparen'>)</span>
503
+ <span class='id identifier rubyid_raise'>raise</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Bad Request due to the following error(s): </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_res'>res</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>errors</span><span class='tstring_end'>&#39;</span></span><span class='rbracket'>]</span><span class='embexpr_end'>}</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>if</span> <span class='id identifier rubyid_res'>res</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>errors</span><span class='tstring_end'>&#39;</span></span><span class='rbracket'>]</span>
504
+ <span class='id identifier rubyid_raise'>raise</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>404 returned. Are you sure you are using the proper IDs?</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>if</span> <span class='id identifier rubyid_res'>res</span><span class='period'>.</span><span class='id identifier rubyid_code'>code</span> <span class='op'>==</span> <span class='int'>404</span>
505
+ <span class='kw'>return</span> <span class='const'>JSON</span><span class='period'>.</span><span class='id identifier rubyid_parse'>parse</span><span class='lparen'>(</span><span class='id identifier rubyid_res'>res</span><span class='period'>.</span><span class='id identifier rubyid_body'>body</span><span class='rparen'>)</span>
506
+ <span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>DELETE</span><span class='tstring_end'>&#39;</span></span>
507
+ <span class='id identifier rubyid_res'>res</span> <span class='op'>=</span> <span class='const'>HTTParty</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='embexpr_beg'>#{</span><span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_class'>class</span><span class='period'>.</span><span class='id identifier rubyid_base_uri'>base_uri</span><span class='embexpr_end'>}</span><span class='tstring_content'>/</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_endpoint_url'>endpoint_url</span><span class='embexpr_end'>}</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='id identifier rubyid_options'>options</span><span class='rparen'>)</span>
508
+ <span class='id identifier rubyid_raise'>raise</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Bad Request due to the following error(s): </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_res'>res</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>errors</span><span class='tstring_end'>&#39;</span></span><span class='rbracket'>]</span><span class='embexpr_end'>}</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>if</span> <span class='id identifier rubyid_res'>res</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>errors</span><span class='tstring_end'>&#39;</span></span><span class='rbracket'>]</span>
509
+ <span class='id identifier rubyid_raise'>raise</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>404 returned. Are you sure you are using the proper IDs?</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>if</span> <span class='id identifier rubyid_res'>res</span><span class='period'>.</span><span class='id identifier rubyid_code'>code</span> <span class='op'>==</span> <span class='int'>404</span>
510
+ <span class='kw'>return</span> <span class='id identifier rubyid_res'>res</span>
511
+ <span class='kw'>else</span>
512
+ <span class='id identifier rubyid_raise'>raise</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>Invalid HTTP Method. Only GET, POST, PUT and DELETE are supported.</span><span class='tstring_end'>&#39;</span></span>
513
+ <span class='kw'>end</span>
514
+ <span class='kw'>end</span></pre>
515
+ </td>
516
+ </tr>
517
+ </table>
518
+ </div>
519
+
520
+ </div>
521
+
522
+ </div>
523
+
524
+ <div id="footer">
525
+ Generated on Tue Nov 15 21:16:07 2016 by
526
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
527
+ 0.9.5 (ruby-2.3.0).
528
+ </div>
529
+
530
+ </div>
531
+ </body>
532
+ </html>