Module: Networks

Included in:
DashboardAPI
Defined in:
lib/networks.rb

Overview

Networks section of the Meraki Dashboard API

Author:

  • Joe Letizia

Instance Method Summary collapse

Instance Method Details

#bind_network_to_template(network_id, options) ⇒ Integer

Bind a single network to a configuration template

Parameters:

  • network_id (String)

    the source network that you want to bind to a tempalte

  • options (Hash)

    options hash that contains configTemplateId and autoBind values. Refer to the official Meraki Dashboard API documentation for more information on these.

Returns:

  • (Integer)

    HTTP Code



85
86
87
88
89
90
# File 'lib/networks.rb', line 85

def bind_network_to_template(network_id, options)
  raise 'Options were not passed as a Hash' if !options.is_a?(Hash)
  

  self.make_api_call("/networks/#{network_id}/bind", 'POST', options)
end

#create_network(org_id, options) ⇒ Hash

Create a new Dashboard network

Parameters:

  • org_id (String)

    dashboard organization ID

  • options (Hash)

    a hash containing the following options: name: the network name (REQUIRED) type: the type of network (wireless, switch, appliance, or phone) (REQUIRED) tags: tags for the network (NOT REQUIRED)

Returns:

  • (Hash)

    a hash containing the new networks details



37
38
39
40
41
# File 'lib/networks.rb', line 37

def create_network(org_id, options)
  raise 'Options were not passed as a Hash' if !options.is_a?(Hash)
  
  self.make_api_call("/organizations/#{org_id}/networks", 'POST', options)
end

#delete_network(network_id) ⇒ Bool

Delete an existing Dashboard network

Parameters:

  • network_id (String)

    dashboard netwok ID to delete

Returns:

  • (Bool)

    status true if the network was deleted, false if not



46
47
48
49
# File 'lib/networks.rb', line 46

def delete_network(network_id)
  res = self.make_api_call("/networks/#{network_id}", 'DELETE')
  return res.code == 204 ? true : false
end

#get_auto_vpn_settings(network_id) ⇒ Hash

Get AutoVPN settings for a specific network

Parameters:

  • network_id (String)

    dashboard network ID to get AutoVPN settings for

Returns:

  • (Hash)

    a hash containing the AutoVPN details for the network



54
55
56
# File 'lib/networks.rb', line 54

def get_auto_vpn_settings(network_id)
  res = self.make_api_call("/networks/#{network_id}/siteToSiteVpn", 'GET')
end

#get_ms_access_policies(network_id) ⇒ Array

Get all MS access policies configured for a specific Dashboard network

Parameters:

  • network_id (String)

    dashboard network ID to get MS policies for

Returns:

  • (Array)

    an array of hashes for containing the policy information



75
76
77
78
# File 'lib/networks.rb', line 75

def get_ms_access_policies(network_id)
  res = self.make_api_call("/networks/#{network_id}/accessPolicies", 'GET')
  return res
end

#get_networks(org_id) ⇒ Array

Returns the list of networks for a given organization

Parameters:

  • org_id (String)

    dashboard organization ID

Returns:

  • (Array)

    an array of hashes containing the network details



7
8
9
# File 'lib/networks.rb', line 7

def get_networks(org_id)
  self.make_api_call("/organizations/#{org_id}/networks", 'GET')
end

#get_single_network(network_id) ⇒ Hash

Returns the network details for a single network

Parameters:

  • network_id (String)

    dashboard network ID

Returns:

  • (Hash)

    a hash containing the network details of the specific network



14
15
16
# File 'lib/networks.rb', line 14

def get_single_network(network_id)
  self.make_api_call("/networks/#{network_id}", 'GET')
end

#traffic_analysis(network_id, options) ⇒ Object

Return traffic analysis data for a network

Parameters:

  • network_id (String)

    network that you want data for

  • options (Hash)

    options hash containing a timespan and deviceType. Refer to the official Meraki Dashboard API documentation for more information on these.



103
104
105
106
107
# File 'lib/networks.rb', line 103

def traffic_analysis(network_id, options)
  raise 'Options were not passed as a Hash' if !options.is_a?(Hash)
  
  self.make_api_call("/networks/#{network_id}/traffic", 'GET', options)
end

#unbind_network_to_template(network_id) ⇒ Integer

Unbind a single network from a configuration template

Parameters:

  • network_id (String)

    the network that you want to unbind from it’s template

Returns:

  • (Integer)

    HTTP Code



95
96
97
# File 'lib/networks.rb', line 95

def unbind_network_to_template(network_id)
  self.make_api_call("/networks/#{network_id}/unbind", 'POST')
end

#update_auto_vpn_settings(network_id, options) ⇒ Hash

Update AutoVPN for a specific network

Parameters:

  • network_id (String)

    dashboard network ID to update AutoVPN settings for

  • options (Hash)

    options hash containing the following options: mode: hub, spoke or none hubs: an array of Hashes containing the hubId and a true or false for useDefaultRoute subnets: an array of Hashes containing localSubnet and useVPN

Returns:

  • (Hash)


65
66
67
68
69
70
# File 'lib/networks.rb', line 65

def update_auto_vpn_settings(network_id, options)
  raise 'Options were not passed as a Hash' if !options.is_a?(Hash)

  
  res = self.make_api_call("/networks/#{network_id}/siteToSiteVpn", 'PUT', options)
end

#update_network(network_id, options) ⇒ Hash

Updates a network’s details

Parameters:

  • network_id (String)

    dashboard network ID

  • options (Hash)

    a hash containing any of the following keys: name: the network name tags: tags assigned to the network

Returns:

  • (Hash)

    a hash containing the updated network details



24
25
26
27
28
# File 'lib/networks.rb', line 24

def update_network(network_id, options)
  raise 'Options were not passed as a Hash' if !options.is_a?(Hash)
  
  self.make_api_call("/networks/#{network_id}",'PUT', options)
end