Module: Networks

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

Overview

Networks section of the Meraki Dashboard API

Instance Method Summary collapse

Instance Method Details

#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)
  options = {:body => options}
  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
50
# File 'lib/networks.rb', line 46

def delete_network(network_id)
  res = self.make_api_call("/networks/#{network_id}", 'DELETE')
  puts res
  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



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

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



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

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

#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)


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

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

  options = {:body => options}
  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)
  options = {:body => options}
  self.make_api_call("/networks/#{network_id}",'PUT', options)
end