dashboard-api 0.4.0 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -84,7 +84,7 @@
84
84
  <p class="children">
85
85
 
86
86
 
87
- <strong class="modules">Modules:</strong> <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="SSIDs.html" title="SSIDs (module)">SSIDs</a></span>, <span class='object_link'><a href="Switchports.html" title="Switchports (module)">Switchports</a></span>
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
88
 
89
89
 
90
90
 
@@ -104,7 +104,7 @@
104
104
  </div>
105
105
 
106
106
  <div id="footer">
107
- Generated on Tue Nov 15 22:02:45 2016 by
107
+ Generated on Wed Nov 16 21:55:08 2016 by
108
108
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
109
109
  0.9.5 (ruby-2.3.0).
110
110
  </div>
@@ -0,0 +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
+ options = {:body => options}
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
+ options = {:body => options}
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
@@ -3,10 +3,15 @@ require 'json'
3
3
  require_relative "dashboard-api/version"
4
4
  require 'organizations'
5
5
  require 'networks'
6
+ require 'admins'
6
7
  require 'devices'
8
+ require 'templates'
7
9
  require 'clients'
10
+ require 'phones'
8
11
  require 'ssids'
12
+ require 'vlans'
9
13
  require 'switchports'
14
+ require 'saml'
10
15
 
11
16
  # Ruby Implementation of the Meraki Dashboard api
12
17
  # @author Joe Letizia
@@ -18,7 +23,12 @@ class DashboardAPI
18
23
  include Clients
19
24
  include Devices
20
25
  include SSIDs
26
+ include Admins
21
27
  include Switchports
28
+ include VLANs
29
+ include Phones
30
+ include Templates
31
+ include SAML
22
32
  base_uri "https://dashboard.meraki.com/api/v0"
23
33
 
24
34
  attr_reader :key
@@ -41,6 +51,7 @@ class DashboardAPI
41
51
  when 'GET'
42
52
  res = HTTParty.get("#{self.class.base_uri}/#{endpoint_url}", options)
43
53
  raise "404 returned. Are you sure you are using the proper IDs?" if res.code == 404
54
+ raise "Bad request due to the following error(s): #{JSON.parse(res.body)['errors']}" if res.body.include?('errors')
44
55
  return JSON.parse(res.body)
45
56
  when 'POST'
46
57
  res = HTTParty.post("#{self.class.base_uri}/#{endpoint_url}", options)
@@ -2,5 +2,5 @@
2
2
  # @author Joe Letizia
3
3
  module DashboardAPIVersion
4
4
  # Current version number of the gem
5
- VERSION = "0.4.0"
5
+ VERSION = "0.9.0"
6
6
  end
@@ -77,4 +77,33 @@ module Networks
77
77
  res = self.make_api_call("/networks/#{network_id}/accessPolicies", 'GET')
78
78
  return res
79
79
  end
80
+
81
+ # Bind a single network to a configuration template
82
+ # @param [String] network_id the source network that you want to bind to a tempalte
83
+ # @param [Hash] options options hash that contains configTemplateId and autoBind values. Refer to the official
84
+ # Meraki Dashboard API documentation for more information on these.
85
+ # @return [Integer] HTTP Code
86
+ def bind_network_to_template(network_id, options)
87
+ raise 'Options were not passed as a Hash' if !options.is_a?(Hash)
88
+ options = {:body => options}
89
+
90
+ self.make_api_call("/networks/#{network_id}/bind", 'POST', options)
91
+ end
92
+
93
+ # Unbind a single network from a configuration template
94
+ # @param [String] network_id the network that you want to unbind from it's template
95
+ # @return [Integer] HTTP Code
96
+ def unbind_network_to_template(network_id)
97
+ self.make_api_call("/networks/#{network_id}/unbind", 'POST')
98
+ end
99
+
100
+ # Return traffic analysis data for a network
101
+ # @param [String] network_id network that you want data for
102
+ # @param [Hash] options options hash containing a timespan and deviceType. Refer to the official
103
+ # Meraki Dashboard API documentation for more information on these.
104
+ def traffic_analysis(network_id, options)
105
+ raise 'Options were not passed as a Hash' if !options.is_a?(Hash)
106
+ options = {:body => options}
107
+ self.make_api_call("/networks/#{network_id}/traffic", 'GET', options)
108
+ end
80
109
  end
@@ -0,0 +1,40 @@
1
+ # Phones section of the Meraki Dashboard API
2
+ # @author Joe Letizia
3
+ module Phones
4
+
5
+ # Get list of phone contacts
6
+ # @param [String] network_id the network id you want to list contacts for
7
+ # @return [Array] an array of hashes containing attribute information for each contact
8
+ def list_phone_contacts(network_id)
9
+ self.make_api_call("/networks/#{network_id}/phoneContacts", 'GET')
10
+ end
11
+
12
+ # Add a single phone contact
13
+ # @param [String] network_id the network id you want to add the contact to
14
+ # @param [Hash] options an options hash that contains the contact attributes. Currently only supports the name attribute.
15
+ # @return [Hash] returns the hash containing the contact attributes
16
+ def add_phone_contact(network_id, options)
17
+ raise 'Options were not passed as a Hash' if !options.is_a?(Hash)
18
+ options = {:body => options}
19
+ self.make_api_call("/networks/#{network_id}/phoneContacts", 'POST', options)
20
+ end
21
+
22
+ # Update a single phone contact
23
+ # @param [String] network_id the network id you want to update the contact in
24
+ # @param [String] contact_id the ID of the contact you want to update
25
+ # @param [Hash] options an options hash that contains the contact attributes. Currently only supports the name attribute.
26
+ # @return [Hash] returns the hash containing the contacts updated attributes
27
+ def update_phone_contact(network_id, contact_id, options)
28
+ raise 'Options were not passed as a Hash' if !options.is_a?(Hash)
29
+ options = {:body => options}
30
+ self.make_api_call("/networks/#{network_id}/phoneContacts/#{contact_id}", 'PUT', options)
31
+ end
32
+
33
+ # Delete a single phone contact
34
+ # @param [String] network_id the network id you want to delete the contact on
35
+ # @param [String] contact_id the ID of the contact you want to delete
36
+ # @return [Integer] HTTP Code
37
+ def delete_phone_contact(network_id, contact_id)
38
+ self.make_api_call("/networks/#{network_id}/phoneContacts/#{contact_id}", 'DELETE')
39
+ end
40
+ end
@@ -0,0 +1,47 @@
1
+ # SAML section of the Meraki Dashboard API
2
+ # @author Joe Letizia
3
+ module SAML
4
+ # List all SAML roles defined on an organization
5
+ # @param [String] org_id organization ID you want the SAML roles from
6
+ # @return [Array] an array of hashes containing each SAML role and it's attributes
7
+ def list_saml_roles(org_id)
8
+ self.make_api_call("/organizations/#{org_id}/samlRoles", 'GET')
9
+ end
10
+
11
+ # Create a new SAML role on an organization
12
+ # @param [String] org_id organization ID you want to create the SAML roles on
13
+ # @param [Hash] options an options hash containing the attributes for the SAML role. Can include role, orgAccess, tags, and networks.
14
+ # Refer to the Meraki Dashboard API for more information on these tags
15
+ # @return [Hash] returns the newly created SAML role
16
+ def create_saml_role(org_id, options)
17
+ options = {:body => options}
18
+ self.make_api_call("/organizations/#{org_id}/samlRoles", 'POST', options)
19
+ end
20
+
21
+ # Update an existing SAML role on an organization
22
+ # @param [String] org_id organization ID you want to update the SAML roles on
23
+ # @param [String] saml_id the ID of the SAML role that you want to update
24
+ # @param [Hash] options an options hash containing the attributes for the SAML role. Can include role, orgAccess, tags, and networks.
25
+ # Refer to the Meraki Dashboard API for more information on these tags
26
+ # @return [Hahs] returns the updated SAML role
27
+ def update_saml_role(org_id, saml_id, options)
28
+ options = {:body => options}
29
+ self.make_api_call("/organizations/#{org_id}/samlRoles/#{saml_id}", 'PUT', options)
30
+ end
31
+
32
+ # Return a single SAML role
33
+ # @param [String] org_id organization ID you want to return the SAML roles on
34
+ # @param [String] saml_id the ID of the SAML role that you want to return
35
+ # @return [Hash] returns the request SAML role
36
+ def return_saml_role(org_id, saml_id)
37
+ self.make_api_call("/organizations/#{org_id}/samlRoles/#{saml_id}", 'GET')
38
+ end
39
+
40
+ # Remove a single SAML role
41
+ # @param [String] org_id organization ID you want to remove the SAML roles on
42
+ # @param [String] saml_id the ID of the SAML role that you want to remove
43
+ # @return [Integer] HTTP Code
44
+ def remove_saml_role(org_id, saml_id)
45
+ self.make_api_call("/organizations/#{org_id}/samlRoles/#{saml_id}", 'DELETE')
46
+ end
47
+ end
@@ -0,0 +1,18 @@
1
+ # Templates section of the Meraki Dashboard API
2
+ # @author Joe Letizia
3
+ module Templates
4
+ # Return a list of all templates for a specific organization
5
+ # @param [String] org_id organization ID where that we want to list all of the templates from
6
+ # @return [Array] an array of hashes containing the attributes for all configuration templates
7
+ def list_templates(org_id)
8
+ self.make_api_call("/organizations/#{org_id}/configTemplates", 'GET')
9
+ end
10
+
11
+ # Remove a single configuration template
12
+ # @param [String] org_id organization ID where that we want to remove the templates from
13
+ # @param [String] template_id the template ID we want to delete
14
+ # @return [Integer] HTTP code
15
+ def remove_template(org_id, template_id)
16
+ self.make_api_call("/organizations/#{org_id}/configTemplates/#{template_id}", 'DELETE')
17
+ end
18
+ end
@@ -0,0 +1,49 @@
1
+ # VLANs section of the Meraki Dashboard API
2
+ # @author Joe Letizia
3
+ module VLANs
4
+ # Returns a list of the configured VLANs in a Dashboard network
5
+ # @param [String] network_id the network ID you want the VLANs for
6
+ # @return [Array] an array of hashes containing each VLAN and it's attributes
7
+ def list_vlans(network_id)
8
+ self.make_api_call("/networks/#{network_id}/vlans", 'GET')
9
+ end
10
+
11
+ # Return a single configured VLAN for a network
12
+ # @param [String] network_id the network ID the VLAN exists in
13
+ # @param [Integer] vlan_id the VLAN ID you want the attributes for
14
+ # @return [Hash] a hash of the VLAN's attributes
15
+ def return_vlan(network_id, vlan_id)
16
+ self.make_api_call("/networks/#{network_id}/vlans/#{vlan_id}", 'GET')
17
+ end
18
+
19
+ # Add a single VLAN to a network
20
+ # @param [String] network_id the network you want to add a VLAN to
21
+ # @param [Hash] options a hash containing the attributes of id, name, subnet and applianceIp
22
+ # additional details on these can be found in the official Meraki API Documentation
23
+ # @return [Hash] the attributes of the newly created vlan
24
+ def add_vlan(network_id, options)
25
+ raise 'Options were not passed as a Hash' if !options.is_a?(Hash)
26
+ options = {:body => options}
27
+ self.make_api_call("/networks/#{network_id}/vlans", 'POST', options)
28
+ end
29
+
30
+ # Update the attributes for a single VLAN
31
+ # @param [String] network_id the network ID for the VLAN you want to update
32
+ # @param [Integer] vlan_id the VLAN ID you want to update
33
+ # @param [Hash] options a hash containing the attributes of name, subnet and applianceIp.
34
+ # additional details on these can be found in the official Meraki API Documentation
35
+ # @return [Hash] the updated attributes for the VLAN
36
+ def update_vlan(network_id, vlan_id, options)
37
+ raise 'Options were not passed as a Hash' if !options.is_a?(Hash)
38
+ options = {:body => options}
39
+ self.make_api_call("/networks/#{network_id}/vlans/#{vlan_id}", 'PUT', options)
40
+ end
41
+
42
+ # Delete a single vlan
43
+ # @param [String] network_id the Network ID for the VLAN you want to delete
44
+ # @param [Integer] vlan_id the VLAN ID you want to delete
45
+ # @return [Integer] code HTTP return code
46
+ def delete_vlan(network_id, vlan_id)
47
+ self.make_api_call("/networks/#{network_id}/vlans/#{vlan_id}", 'DELETE')
48
+ end
49
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dashboard-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joe Letizia
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-11-16 00:00:00.000000000 Z
11
+ date: 2016-11-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -108,14 +108,19 @@ files:
108
108
  - README.md
109
109
  - Rakefile
110
110
  - dashboard-api.gemspec
111
+ - doc/Admins.html
111
112
  - doc/Clients.html
112
113
  - doc/DashboardAPI.html
113
114
  - doc/DashboardAPIVersion.html
114
115
  - doc/Devices.html
115
116
  - doc/Networks.html
116
117
  - doc/Organizations.html
118
+ - doc/Phones.html
119
+ - doc/SAML.html
117
120
  - doc/SSIDs.html
118
121
  - doc/Switchports.html
122
+ - doc/Templates.html
123
+ - doc/VLANs.html
119
124
  - doc/_index.html
120
125
  - doc/class_list.html
121
126
  - doc/css/common.css
@@ -130,14 +135,19 @@ files:
130
135
  - doc/js/jquery.js
131
136
  - doc/method_list.html
132
137
  - doc/top-level-namespace.html
138
+ - lib/admins.rb
133
139
  - lib/clients.rb
134
140
  - lib/dashboard-api.rb
135
141
  - lib/dashboard-api/version.rb
136
142
  - lib/devices.rb
137
143
  - lib/networks.rb
138
144
  - lib/organizations.rb
145
+ - lib/phones.rb
146
+ - lib/saml.rb
139
147
  - lib/ssids.rb
140
148
  - lib/switchports.rb
149
+ - lib/templates.rb
150
+ - lib/vlans.rb
141
151
  homepage: https://github.com/jletizia/dashboardapi
142
152
  licenses: []
143
153
  metadata: {}