Module: Devices

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

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



42
43
44
45
46
# File 'lib/devices.rb', line 42

def claim_device_into_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}/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



22
23
24
# File 'lib/devices.rb', line 22

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



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

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



5
6
7
# File 'lib/devices.rb', line 5

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

  • serial (String)

    meraki serial number for device to remove

Returns:

  • (Integer)

    http_code HTTP code for API call



52
53
54
# File 'lib/devices.rb', line 52

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



32
33
34
35
36
# File 'lib/devices.rb', line 32

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