class Dashbeautiful::Network

description TODO

Attributes

id[R]
name[R]
organization[R]
tags[R]

Public Class Methods

all(organization) click to toggle source
# File lib/dashbeautiful/network.rb, line 18
def self.all(organization)
  raise ArgumentError, 'must pass an Organization' if organization.nil?

  organization.networks
end
create(*args, **kwargs) click to toggle source
# File lib/dashbeautiful/network.rb, line 6
def self.create(*args, **kwargs)
  type = case kwargs[:type]
         when 'camera' then CameraNetwork
         when 'switch' then SwitchNetwork
         when 'wireless' then WirelessNetwork
         when 'appliance' then ApplianceNetwork
         when 'combined' then CombinedNetwork
         else Network
         end
  type.new(*args, **kwargs)
end
find(organization, &block) click to toggle source
# File lib/dashbeautiful/network.rb, line 24
def self.find(organization, &block)
  all(organization).find(&block)
end
find_by_id(id, organization) click to toggle source
# File lib/dashbeautiful/network.rb, line 28
def self.find_by_id(id, organization)
  find(organization) { |network| network.id == id }
end
find_by_name(name, organization) click to toggle source
# File lib/dashbeautiful/network.rb, line 32
def self.find_by_name(name, organization)
  find(organization) { |network| network.name == name }
end
new(organization, **attributes) click to toggle source
# File lib/dashbeautiful/network.rb, line 36
def initialize(organization, **attributes)
  @organization = organization
  @id = attributes[:id]
  @name = attributes[:name]
  @tags = attributes[:tags]

  raise ArgumentError if @id.nil? || @name.nil? || @tags.nil?

  @tags = @tags.split.uniq
end

Public Instance Methods

devices() click to toggle source
# File lib/dashbeautiful/network.rb, line 47
def devices
  @devices ||= organization.api.devices(id).map { |device| Device.create(self, **device) }
end
devices!() click to toggle source
# File lib/dashbeautiful/network.rb, line 51
def devices!
  @devices = nil
  devices
end