Module: Devices

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

Overview

Devices section of the Meraki Dashboard API

Author:

  • Joe Letizia

Instance Method Summary collapse

Instance Method Details

#claim_device_into_network(network_id, options) ⇒ Integer

Claim a single device into a network

Parameters:

  • network_id (String)

    dashboard network id to claim device into

  • options (Hash)

    hash containing :serial => ‘meraki device SN’ you want to claim

Returns:

  • (Integer)

    code returns the HTTP code of the API call



44
45
46
47
48
# File 'lib/devices.rb', line 44

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

Uplink information for a specified device

Parameters:

  • network_id (String)

    network id where the device exists

  • device_serial (String)

    meraki serial number of the device you want to check

Returns:

  • (Array)

    an array of hashes for each uplink and it’s attributes



24
25
26
# File 'lib/devices.rb', line 24

def get_device_uplink_stats(network_id, device_serial)
  self.make_api_call("/networks/#{network_id}/devices/#{device_serial}/uplink", 'GET')
end

#get_single_device(network_id, device_serial) ⇒ Hash

Device information for a specified device

Parameters:

  • network_id (String)

    the network id where the device exists

  • device_serial (String)

    the meraki serial number of the device you want to get information for

Returns:

  • (Hash)

    a hash containing all of the devices attributes



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

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

#list_devices_in_network(network_id) ⇒ Array

List all devices in a given network

Parameters:

  • network_id (String)

    network that you want to get devices for

Returns:

  • (Array)

    array of hashes containing device information for all devices in the network



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

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

#remove_device_from_network(network_id, device_serial) ⇒ Integer

Remove a single device from a network

Parameters:

  • network_id (String)

    dashboard network id to remove device from

  • device_serial (String)

    meraki serial number for device to remove

Returns:

  • (Integer)

    http_code HTTP code for API call



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

def remove_device_from_network(network_id, device_serial)
  self.make_api_call("/networks/#{network_id}/devices/#{device_serial}/remove", 'POST')
end

#update_device_attributes(network_id, device_serial, options) ⇒ Hash

Update a single devices attributes

Parameters:

  • network_id (String)

    dashboard network id where the device exists

  • device_serial (String)

    meraki serial number of the device you want to modify

  • options (Hash)

    hash containing the attributes you want to modify. such as name, tags, longitude, latitude. A full list is found on the official Meraki API Docs

Returns:

  • (Hash)

    a hash containing the devices new attribute set



34
35
36
37
38
# File 'lib/devices.rb', line 34

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