Module: Switchports

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

Overview

Switchports section of the Meraki Dashboard API

Author:

  • Joe Letizia

Instance Method Summary collapse

Instance Method Details

#get_single_switch_port(device_serial, port_number) ⇒ Hash

Get configuration for a single switch port

Parameters:

  • device_serial (String)

    meraki serial number of the switch

  • port_number (Integer)

    port number you want to modify

Returns:

  • (Hash)

    hash of the switch ports attributes



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

def get_single_switch_port(device_serial, port_number)
  raise 'Invalid switchport provided' unless port_number.is_a?(Integer)
  self.make_api_call("/devices/#{device_serial}/switchPorts/#{port_number}", 'GET')
end

#get_switch_ports(device_serial) ⇒ Array

Get configuration for all switchports on a given switch

Parameters:

  • device_serial (String)

    meraki serial number of the switch

Returns:

  • (Array)

    an array of Hashes, each containing the switchports attributes / configuration



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

def get_switch_ports(device_serial)
  self.make_api_call("/devices/#{device_serial}/switchPorts", 'GET')
end

#update_switchport(device_serial, port_number, options) ⇒ Hash

Update the attributes for a given switchport

Parameters:

  • device_serial (String)

    meraki serial number of the switch

  • port_number (Integer)

    port number you want to modify

  • options (Hash)

    hash of attributes. Keys can include name, tags, enabled, type, vlan, voiceVlan allowedVlans, poeEnabled, isolationEnabled, rstpEnabled, stpGuard, accessPolicyNumber. For values to these keys, please refer to the official Meraki Dashboard API documentation.

Returns:

  • (Hash)

    hash of the update port attributes



26
27
28
29
30
31
32
# File 'lib/switchports.rb', line 26

def update_switchport(device_serial, port_number, options)
  raise 'Options were not passed as a Hash' if !options.is_a?(Hash)
  raise 'Invalid switchport provided' unless port_number.is_a?(Integer)
  
  
  self.make_api_call("/devices/#{device_serial}/switchPorts/#{port_number}", 'PUT', options)
end