Class: RubyPhpipam::Address
- Inherits:
-
Object
- Object
- RubyPhpipam::Address
- Defined in:
- lib/ruby_phpipam/address.rb
Instance Attribute Summary collapse
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#deviceId ⇒ Object
readonly
Returns the value of attribute deviceId.
-
#editDate ⇒ Object
readonly
Returns the value of attribute editDate.
-
#excludePing ⇒ Object
readonly
Returns the value of attribute excludePing.
-
#hostname ⇒ Object
readonly
Returns the value of attribute hostname.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#ip ⇒ Object
readonly
Returns the value of attribute ip.
-
#is_gateway ⇒ Object
readonly
Returns the value of attribute is_gateway.
-
#lastSeen ⇒ Object
readonly
Returns the value of attribute lastSeen.
-
#mac ⇒ Object
readonly
Returns the value of attribute mac.
-
#note ⇒ Object
readonly
Returns the value of attribute note.
-
#owner ⇒ Object
readonly
Returns the value of attribute owner.
-
#port ⇒ Object
readonly
Returns the value of attribute port.
-
#PTR ⇒ Object
readonly
Returns the value of attribute PTR.
-
#PTRignore ⇒ Object
readonly
Returns the value of attribute PTRignore.
-
#subnetId ⇒ Object
readonly
Returns the value of attribute subnetId.
-
#tag ⇒ Object
readonly
Returns the value of attribute tag.
Class Method Summary collapse
- .first_free(subnetId) ⇒ Object
- .get(id) ⇒ Object
- .get_by_tag(tagId) ⇒ Object
- .ping(id) ⇒ Object
- .search(ip: nil, hostname: nil, subnetId: nil) ⇒ Object
Instance Method Summary collapse
-
#initialize(json) ⇒ Address
constructor
A new instance of Address.
- #online? ⇒ Boolean
Constructor Details
#initialize(json) ⇒ Address
Returns a new instance of Address.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# 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 |
Instance Attribute Details
#description ⇒ Object (readonly)
Returns the value of attribute description.
3 4 5 |
# File 'lib/ruby_phpipam/address.rb', line 3 def description @description end |
#deviceId ⇒ Object (readonly)
Returns the value of attribute deviceId.
3 4 5 |
# File 'lib/ruby_phpipam/address.rb', line 3 def deviceId @deviceId end |
#editDate ⇒ Object (readonly)
Returns the value of attribute editDate.
3 4 5 |
# File 'lib/ruby_phpipam/address.rb', line 3 def editDate @editDate end |
#excludePing ⇒ Object (readonly)
Returns the value of attribute excludePing.
3 4 5 |
# File 'lib/ruby_phpipam/address.rb', line 3 def excludePing @excludePing end |
#hostname ⇒ Object (readonly)
Returns the value of attribute hostname.
3 4 5 |
# File 'lib/ruby_phpipam/address.rb', line 3 def hostname @hostname end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
3 4 5 |
# File 'lib/ruby_phpipam/address.rb', line 3 def id @id end |
#ip ⇒ Object (readonly)
Returns the value of attribute ip.
3 4 5 |
# File 'lib/ruby_phpipam/address.rb', line 3 def ip @ip end |
#is_gateway ⇒ Object (readonly)
Returns the value of attribute is_gateway.
3 4 5 |
# File 'lib/ruby_phpipam/address.rb', line 3 def is_gateway @is_gateway end |
#lastSeen ⇒ Object (readonly)
Returns the value of attribute lastSeen.
3 4 5 |
# File 'lib/ruby_phpipam/address.rb', line 3 def lastSeen @lastSeen end |
#mac ⇒ Object (readonly)
Returns the value of attribute mac.
3 4 5 |
# File 'lib/ruby_phpipam/address.rb', line 3 def mac @mac end |
#note ⇒ Object (readonly)
Returns the value of attribute note.
3 4 5 |
# File 'lib/ruby_phpipam/address.rb', line 3 def note @note end |
#owner ⇒ Object (readonly)
Returns the value of attribute owner.
3 4 5 |
# File 'lib/ruby_phpipam/address.rb', line 3 def owner @owner end |
#port ⇒ Object (readonly)
Returns the value of attribute port.
3 4 5 |
# File 'lib/ruby_phpipam/address.rb', line 3 def port @port end |
#PTR ⇒ Object (readonly)
Returns the value of attribute PTR.
3 4 5 |
# File 'lib/ruby_phpipam/address.rb', line 3 def PTR @PTR end |
#PTRignore ⇒ Object (readonly)
Returns the value of attribute PTRignore.
3 4 5 |
# File 'lib/ruby_phpipam/address.rb', line 3 def PTRignore @PTRignore end |
#subnetId ⇒ Object (readonly)
Returns the value of attribute subnetId.
3 4 5 |
# File 'lib/ruby_phpipam/address.rb', line 3 def subnetId @subnetId end |
#tag ⇒ Object (readonly)
Returns the value of attribute tag.
3 4 5 |
# File 'lib/ruby_phpipam/address.rb', line 3 def tag @tag end |
Class Method Details
.first_free(subnetId) ⇒ Object
66 67 68 |
# File 'lib/ruby_phpipam/address.rb', line 66 def self.first_free(subnetId) RubyPhpipam::Query.get("/addresses/first_free/#{subnetId}/") end |
.get(id) ⇒ Object
27 28 29 |
# File 'lib/ruby_phpipam/address.rb', line 27 def self.get(id) Address.new(RubyPhpipam::Query.get("/addresses/#{id}/")) end |
.get_by_tag(tagId) ⇒ Object
31 32 33 34 35 36 |
# 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 |
.ping(id) ⇒ Object
38 39 40 41 42 43 44 45 46 |
# 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) ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# 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 |
Instance Method Details
#online? ⇒ Boolean
70 71 72 |
# File 'lib/ruby_phpipam/address.rb', line 70 def online? RubyPhpipam::Address.ping(@id) end |