Module: VLANs

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

Overview

VLANs section of the Meraki Dashboard API

Author:

  • Joe Letizia

Instance Method Summary collapse

Instance Method Details

#add_vlan(network_id, options) ⇒ Hash

Add a single VLAN to a network

Parameters:

  • network_id (String)

    the network you want to add a VLAN to

  • options (Hash)

    a hash containing the attributes of id, name, subnet and applianceIp additional details on these can be found in the official Meraki API Documentation

Returns:

  • (Hash)

    the attributes of the newly created vlan



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

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

#delete_vlan(network_id, vlan_id) ⇒ Integer

Delete a single vlan

Parameters:

  • network_id (String)

    the Network ID for the VLAN you want to delete

  • vlan_id (Integer)

    the VLAN ID you want to delete

Returns:

  • (Integer)

    code HTTP return code



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

def delete_vlan(network_id, vlan_id)
  self.make_api_call("/networks/#{network_id}/vlans/#{vlan_id}", 'DELETE')
end

#list_vlans(network_id) ⇒ Array

Returns a list of the configured VLANs in a Dashboard network

Parameters:

  • network_id (String)

    the network ID you want the VLANs for

Returns:

  • (Array)

    an array of hashes containing each VLAN and it’s attributes



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

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

#return_vlan(network_id, vlan_id) ⇒ Hash

Return a single configured VLAN for a network

Parameters:

  • network_id (String)

    the network ID the VLAN exists in

  • vlan_id (Integer)

    the VLAN ID you want the attributes for

Returns:

  • (Hash)

    a hash of the VLAN’s attributes



15
16
17
# File 'lib/vlans.rb', line 15

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

#update_vlan(network_id, vlan_id, options) ⇒ Hash

Update the attributes for a single VLAN

Parameters:

  • network_id (String)

    the network ID for the VLAN you want to update

  • vlan_id (Integer)

    the VLAN ID you want to update

  • options (Hash)

    a hash containing the attributes of name, subnet and applianceIp. additional details on these can be found in the official Meraki API Documentation

Returns:

  • (Hash)

    the updated attributes for the VLAN



36
37
38
39
40
# File 'lib/vlans.rb', line 36

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