dashboard-api 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- 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
@@ -1,114 +1,114 @@
|
|
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
|
-
Top Level Namespace
|
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 = "";
|
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
|
-
|
41
|
-
|
42
|
-
<span class="title">Top Level Namespace</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>Top Level Namespace
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
</h1>
|
69
|
-
<div class="box_info">
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
</div>
|
82
|
-
|
83
|
-
<h2>Defined Under Namespace</h2>
|
84
|
-
<p class="children">
|
85
|
-
|
86
|
-
|
87
|
-
<strong class="modules">Modules:</strong> <span class='object_link'><a href="Admins.html" title="Admins (module)">Admins</a></span>, <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>, <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="Phones.html" title="Phones (module)">Phones</a></span>, <span class='object_link'><a href="SAML.html" title="SAML (module)">SAML</a></span>, <span class='object_link'><a href="SSIDs.html" title="SSIDs (module)">SSIDs</a></span>, <span class='object_link'><a href="Switchports.html" title="Switchports (module)">Switchports</a></span>, <span class='object_link'><a href="Templates.html" title="Templates (module)">Templates</a></span>, <span class='object_link'><a href="VLANs.html" title="VLANs (module)">VLANs</a></span>
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
<strong class="classes">Classes:</strong> <span class='object_link'><a href="DashboardAPI.html" title="DashboardAPI (class)">DashboardAPI</a></span>
|
92
|
-
|
93
|
-
|
94
|
-
</p>
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
</div>
|
105
|
-
|
106
|
-
<div id="footer">
|
107
|
-
Generated on Thu Nov 17 22:15:38 2016 by
|
108
|
-
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
109
|
-
0.9.5 (ruby-2.3.0).
|
110
|
-
</div>
|
111
|
-
|
112
|
-
</div>
|
113
|
-
</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
|
+
Top Level Namespace
|
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 = "";
|
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
|
+
|
41
|
+
|
42
|
+
<span class="title">Top Level Namespace</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>Top Level Namespace
|
65
|
+
|
66
|
+
|
67
|
+
|
68
|
+
</h1>
|
69
|
+
<div class="box_info">
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
|
80
|
+
|
81
|
+
</div>
|
82
|
+
|
83
|
+
<h2>Defined Under Namespace</h2>
|
84
|
+
<p class="children">
|
85
|
+
|
86
|
+
|
87
|
+
<strong class="modules">Modules:</strong> <span class='object_link'><a href="Admins.html" title="Admins (module)">Admins</a></span>, <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>, <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="Phones.html" title="Phones (module)">Phones</a></span>, <span class='object_link'><a href="SAML.html" title="SAML (module)">SAML</a></span>, <span class='object_link'><a href="SSIDs.html" title="SSIDs (module)">SSIDs</a></span>, <span class='object_link'><a href="Switchports.html" title="Switchports (module)">Switchports</a></span>, <span class='object_link'><a href="Templates.html" title="Templates (module)">Templates</a></span>, <span class='object_link'><a href="VLANs.html" title="VLANs (module)">VLANs</a></span>
|
88
|
+
|
89
|
+
|
90
|
+
|
91
|
+
<strong class="classes">Classes:</strong> <span class='object_link'><a href="DashboardAPI.html" title="DashboardAPI (class)">DashboardAPI</a></span>
|
92
|
+
|
93
|
+
|
94
|
+
</p>
|
95
|
+
|
96
|
+
|
97
|
+
|
98
|
+
|
99
|
+
|
100
|
+
|
101
|
+
|
102
|
+
|
103
|
+
|
104
|
+
</div>
|
105
|
+
|
106
|
+
<div id="footer">
|
107
|
+
Generated on Thu Nov 17 22:15:38 2016 by
|
108
|
+
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
109
|
+
0.9.5 (ruby-2.3.0).
|
110
|
+
</div>
|
111
|
+
|
112
|
+
</div>
|
113
|
+
</body>
|
114
114
|
</html>
|
data/lib/admins.rb
CHANGED
@@ -1,37 +1,37 @@
|
|
1
|
-
# Admins section of the Meraki Dashboard API
|
2
|
-
# @author Joe Letizia
|
3
|
-
module Admins
|
4
|
-
# List all of the administrators for a given org
|
5
|
-
# @param [String] org_id organization ID you want the list of administrators for
|
6
|
-
# @return [Array] an array of hashes containing each admin and their attributes
|
7
|
-
def list_admins(org_id)
|
8
|
-
self.make_api_call("/organizations/#{org_id}/admins", 'GET')
|
9
|
-
end
|
10
|
-
|
11
|
-
# Add an admin to a specific org
|
12
|
-
# @param [String] org_id organization ID you want to add an administrator to
|
13
|
-
# @param [Hash] options option hash containing attributes for the new admin. Can contain:
|
14
|
-
# email, name, orgAccess, tags and networks. See the Meraki API Documentation for more details.
|
15
|
-
def add_admin(org_id, options)
|
16
|
-
|
17
|
-
self.make_api_call("/organizations/#{org_id}/admins", 'POST', options)
|
18
|
-
end
|
19
|
-
|
20
|
-
# Update an administrator for a specific org
|
21
|
-
# @param [String] org_id organization ID you want to update an administrator on
|
22
|
-
# @param [String] admin_id ID of the admin you want to update
|
23
|
-
# @param [Hash] options hash containing the attributes and values you want to update. Can contain:
|
24
|
-
# email, name, orgAccess, tags and networks. See the Meraki API Documentation for more details.
|
25
|
-
def update_admin(org_id, admin_id, options)
|
26
|
-
|
27
|
-
self.make_api_call("/organizations/#{org_id}/admins/#{admin_id}", 'PUT', options)
|
28
|
-
end
|
29
|
-
|
30
|
-
# Revoke an administrator for a specific org
|
31
|
-
# @param [String] org_id organization ID you want to revoke access on
|
32
|
-
# @param [String] admin_id ID of the administrator you want to revoke
|
33
|
-
# @return [Integer] HTTP Code
|
34
|
-
def revoke_admin(org_id, admin_id)
|
35
|
-
self.make_api_call("/organizations/#{org_id}/admins/#{admin_id}", 'DELETE')
|
36
|
-
end
|
37
|
-
end
|
1
|
+
# Admins section of the Meraki Dashboard API
|
2
|
+
# @author Joe Letizia
|
3
|
+
module Admins
|
4
|
+
# List all of the administrators for a given org
|
5
|
+
# @param [String] org_id organization ID you want the list of administrators for
|
6
|
+
# @return [Array] an array of hashes containing each admin and their attributes
|
7
|
+
def list_admins(org_id)
|
8
|
+
self.make_api_call("/organizations/#{org_id}/admins", 'GET')
|
9
|
+
end
|
10
|
+
|
11
|
+
# Add an admin to a specific org
|
12
|
+
# @param [String] org_id organization ID you want to add an administrator to
|
13
|
+
# @param [Hash] options option hash containing attributes for the new admin. Can contain:
|
14
|
+
# email, name, orgAccess, tags and networks. See the Meraki API Documentation for more details.
|
15
|
+
def add_admin(org_id, options)
|
16
|
+
#
|
17
|
+
self.make_api_call("/organizations/#{org_id}/admins", 'POST', options)
|
18
|
+
end
|
19
|
+
|
20
|
+
# Update an administrator for a specific org
|
21
|
+
# @param [String] org_id organization ID you want to update an administrator on
|
22
|
+
# @param [String] admin_id ID of the admin you want to update
|
23
|
+
# @param [Hash] options hash containing the attributes and values you want to update. Can contain:
|
24
|
+
# email, name, orgAccess, tags and networks. See the Meraki API Documentation for more details.
|
25
|
+
def update_admin(org_id, admin_id, options)
|
26
|
+
#
|
27
|
+
self.make_api_call("/organizations/#{org_id}/admins/#{admin_id}", 'PUT', options)
|
28
|
+
end
|
29
|
+
|
30
|
+
# Revoke an administrator for a specific org
|
31
|
+
# @param [String] org_id organization ID you want to revoke access on
|
32
|
+
# @param [String] admin_id ID of the administrator you want to revoke
|
33
|
+
# @return [Integer] HTTP Code
|
34
|
+
def revoke_admin(org_id, admin_id)
|
35
|
+
self.make_api_call("/organizations/#{org_id}/admins/#{admin_id}", 'DELETE')
|
36
|
+
end
|
37
|
+
end
|
data/lib/clients.rb
CHANGED
@@ -1,12 +1,12 @@
|
|
1
|
-
# Clients section of the Meraki Dashboard API
|
2
|
-
# @author Joe Letizia
|
3
|
-
module Clients
|
4
|
-
# Return client usage for a specific device
|
5
|
-
# @param [String] serial meraki serial number of the device
|
6
|
-
# @param [Integer] timespan timespan up to 1 month in seconds to get client usage for
|
7
|
-
# @return [Array] an array of hashes for each client's usage
|
8
|
-
def get_client_info_for_device(serial, timespan)
|
9
|
-
raise 'Timespan can not be larger than 2592000 seconds' if timespan.to_i > 2592000
|
10
|
-
self.make_api_call("/devices/#{serial}/clients?timespan=#{timespan}", 'GET')
|
11
|
-
end
|
12
|
-
end
|
1
|
+
# Clients section of the Meraki Dashboard API
|
2
|
+
# @author Joe Letizia
|
3
|
+
module Clients
|
4
|
+
# Return client usage for a specific device
|
5
|
+
# @param [String] serial meraki serial number of the device
|
6
|
+
# @param [Integer] timespan timespan up to 1 month in seconds to get client usage for
|
7
|
+
# @return [Array] an array of hashes for each client's usage
|
8
|
+
def get_client_info_for_device(serial, timespan)
|
9
|
+
raise 'Timespan can not be larger than 2592000 seconds' if timespan.to_i > 2592000
|
10
|
+
self.make_api_call("/devices/#{serial}/clients?timespan=#{timespan}", 'GET')
|
11
|
+
end
|
12
|
+
end
|
data/lib/dashboard-api.rb
CHANGED
@@ -1,83 +1,82 @@
|
|
1
|
-
require 'httparty'
|
2
|
-
require 'json'
|
3
|
-
require_relative "dashboard-api/version"
|
4
|
-
require 'organizations'
|
5
|
-
require 'networks'
|
6
|
-
require 'admins'
|
7
|
-
require 'devices'
|
8
|
-
require 'templates'
|
9
|
-
require 'clients'
|
10
|
-
require 'phones'
|
11
|
-
require 'ssids'
|
12
|
-
require 'vlans'
|
13
|
-
require 'switchports'
|
14
|
-
require 'saml'
|
15
|
-
|
16
|
-
# Ruby Implementation of the Meraki Dashboard api
|
17
|
-
# @author Joe Letizia
|
18
|
-
class DashboardAPI
|
19
|
-
include HTTParty
|
20
|
-
include Organizations
|
21
|
-
include DashboardAPIVersion
|
22
|
-
include Networks
|
23
|
-
include Clients
|
24
|
-
include Devices
|
25
|
-
include SSIDs
|
26
|
-
include Admins
|
27
|
-
include Switchports
|
28
|
-
include VLANs
|
29
|
-
include Phones
|
30
|
-
include Templates
|
31
|
-
include SAML
|
32
|
-
base_uri "https://dashboard.meraki.com/api/v0"
|
33
|
-
|
34
|
-
attr_reader :key
|
35
|
-
|
36
|
-
def initialize(key)
|
37
|
-
@key = key
|
38
|
-
end
|
39
|
-
|
40
|
-
# @private
|
41
|
-
# Inner function, not to be called directly
|
42
|
-
# @todo Eventually this will need to support POST, PUT and DELETE. It also
|
43
|
-
# needs to be a bit more resillient, instead of relying on HTTParty for exception
|
44
|
-
# handling
|
45
|
-
def make_api_call(endpoint_url, http_method, options_hash={})
|
46
|
-
headers = {"X-Cisco-Meraki-API-Key" => @key, 'Content-Type' => 'application/json'}
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
raise "
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
raise "
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
#
|
70
|
-
|
71
|
-
raise "
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
raise "
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
end
|
1
|
+
require 'httparty'
|
2
|
+
require 'json'
|
3
|
+
require_relative "dashboard-api/version"
|
4
|
+
require 'organizations'
|
5
|
+
require 'networks'
|
6
|
+
require 'admins'
|
7
|
+
require 'devices'
|
8
|
+
require 'templates'
|
9
|
+
require 'clients'
|
10
|
+
require 'phones'
|
11
|
+
require 'ssids'
|
12
|
+
require 'vlans'
|
13
|
+
require 'switchports'
|
14
|
+
require 'saml'
|
15
|
+
|
16
|
+
# Ruby Implementation of the Meraki Dashboard api
|
17
|
+
# @author Joe Letizia
|
18
|
+
class DashboardAPI
|
19
|
+
include HTTParty
|
20
|
+
include Organizations
|
21
|
+
include DashboardAPIVersion
|
22
|
+
include Networks
|
23
|
+
include Clients
|
24
|
+
include Devices
|
25
|
+
include SSIDs
|
26
|
+
include Admins
|
27
|
+
include Switchports
|
28
|
+
include VLANs
|
29
|
+
include Phones
|
30
|
+
include Templates
|
31
|
+
include SAML
|
32
|
+
base_uri "https://dashboard.meraki.com/api/v0"
|
33
|
+
|
34
|
+
attr_reader :key
|
35
|
+
|
36
|
+
def initialize(key)
|
37
|
+
@key = key
|
38
|
+
end
|
39
|
+
|
40
|
+
# @private
|
41
|
+
# Inner function, not to be called directly
|
42
|
+
# @todo Eventually this will need to support POST, PUT and DELETE. It also
|
43
|
+
# needs to be a bit more resillient, instead of relying on HTTParty for exception
|
44
|
+
# handling
|
45
|
+
def make_api_call(endpoint_url, http_method, options_hash={})
|
46
|
+
headers = {"X-Cisco-Meraki-API-Key" => @key, 'Content-Type' => 'application/json'}
|
47
|
+
|
48
|
+
options = {:headers => headers, :body => options_hash.to_json}
|
49
|
+
case http_method
|
50
|
+
when 'GET'
|
51
|
+
res = HTTParty.get("#{self.class.base_uri}/#{endpoint_url}", options)
|
52
|
+
raise "404 returned. Are you sure you are using the proper IDs?" if res.code == 404
|
53
|
+
raise "Bad request due to the following error(s): #{JSON.parse(res.body)['errors']}" if res.body.include?('errors')
|
54
|
+
return JSON.parse(res.body)
|
55
|
+
when 'POST'
|
56
|
+
res = HTTParty.post("#{self.class.base_uri}/#{endpoint_url}", options)
|
57
|
+
raise "Bad Request due to the following error(s): #{res['errors']}" if res['errors']
|
58
|
+
raise "404 returned. Are you sure you are using the proper IDs?" if res.code == 404
|
59
|
+
begin
|
60
|
+
return JSON.parse(res.body)
|
61
|
+
rescue JSON::ParserError => e
|
62
|
+
return res.code
|
63
|
+
rescue TypeError => e
|
64
|
+
return res.code
|
65
|
+
end
|
66
|
+
when 'PUT'
|
67
|
+
res = HTTParty.put("#{self.class.base_uri}/#{endpoint_url}", options)
|
68
|
+
# needs to check for is an array, because when you update a 3rd party VPN peer, it returns as an array
|
69
|
+
# if you screw something up, it returns as a Hash, and will hit the normal if res['errors'
|
70
|
+
(raise "Bad Request due to the following error(s): #{res['errors']}" if res['errors']) unless JSON.parse(res.body).is_a? Array
|
71
|
+
raise "404 returned. Are you sure you are using the proper IDs?" if res.code == 404
|
72
|
+
return JSON.parse(res.body)
|
73
|
+
when 'DELETE'
|
74
|
+
res = HTTParty.delete("#{self.class.base_uri}/#{endpoint_url}", options)
|
75
|
+
raise "Bad Request due to the following error(s): #{res['errors']}" if res['errors']
|
76
|
+
raise "404 returned. Are you sure you are using the proper IDs?" if res.code == 404
|
77
|
+
return res
|
78
|
+
else
|
79
|
+
raise 'Invalid HTTP Method. Only GET, POST, PUT and DELETE are supported.'
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|