class RubyPhpipam::Address
Attributes
PTR[R]
PTRignore[R]
description[R]
deviceId[R]
editDate[R]
excludePing[R]
hostname[R]
id[R]
ip[R]
is_gateway[R]
lastSeen[R]
mac[R]
note[R]
owner[R]
port[R]
subnetId[R]
tag[R]
Public Class Methods
first_free(subnetId)
click to toggle source
# File lib/ruby_phpipam/address.rb, line 66 def self.first_free(subnetId) RubyPhpipam::Query.get("/addresses/first_free/#{subnetId}/") end
get(id)
click to toggle source
# File lib/ruby_phpipam/address.rb, line 27 def self.get(id) Address.new(RubyPhpipam::Query.get("/addresses/#{id}/")) end
get_by_tag(tagId)
click to toggle source
# File lib/ruby_phpipam/address.rb, line 31 def self.get_by_tag(tagId) addresses = RubyPhpipam::Query.get_array("/addresses/tags/#{tagId}/addresses/") addresses.map do |address| self.new(address) end end
new(json)
click to toggle source
# File lib/ruby_phpipam/address.rb, line 7 def initialize(json) @id = RubyPhpipam::Helper.to_type(json[:id], :int) @subnetId = RubyPhpipam::Helper.to_type(json[:subnetId], :int) @ip = json[:ip] @is_gateway = RubyPhpipam::Helper.to_type(json[:is_gateway], :binary) @description = json[:description] @hostname = json[:hostname] @mac = json[:mac] @owner = json[:owner] @tag = RubyPhpipam::Helper.to_type(json[:tag], :int) @PTRignore = RubyPhpipam::Helper.to_type(json[:PTRignore], :binary) @PTR = RubyPhpipam::Helper.to_type(json[:PTR], :int) @deviceId = RubyPhpipam::Helper.to_type(json[:deviceId], :int) @port = json[:port] @note = json[:note] @lastSeen = RubyPhpipam::Helper.to_type(json[:lastSeen], :date) @excludePing = RubyPhpipam::Helper.to_type(json[:excludePing], :binary) @editDate = RubyPhpipam::Helper.to_type(json[:editDate], :date) end
ping(id)
click to toggle source
# File lib/ruby_phpipam/address.rb, line 38 def self.ping(id) response = RubyPhpipam::Query.get("/addresses/#{id}/ping/") if response[:exit_code] == 0 return true else return false end end
search(ip:nil, hostname:nil, subnetId:nil)
click to toggle source
# File lib/ruby_phpipam/address.rb, line 48 def self.search(ip:nil, hostname:nil, subnetId:nil) if !ip.nil? if subnetId.nil? addresses = RubyPhpipam::Query.get_array("/addresses/search/#{ip}/") else address = RubyPhpipam::Query.get("/addresses/#{ip}/#{subnetId}/") end else addresses = RubyPhpipam::Query.get_array("/addresses/search_hostname/#{hostname}/") end return (address ? self.new(address) : nil) if subnetId addresses.map do |address| self.new(address) end end
Public Instance Methods
online?()
click to toggle source
# File lib/ruby_phpipam/address.rb, line 70 def online? RubyPhpipam::Address.ping(@id) end