class RubyPhpipam::Subnet

Attributes

DNSrecords[R]

Subnet attributes

DNSrecursive[R]

Subnet attributes

allowResquests[R]

Subnet attributes

description[R]

Subnet attributes

discoverSubnet[R]

Subnet attributes

editDate[R]

Subnet attributes

freehosts[R]

Subnet usage attributes

freehosts_percent[R]

Subnet usage attributes

id[R]

Subnet attributes

isFolder[R]

Subnet attributes

isFull[R]

Subnet attributes

linked_subnet[R]

Subnet attributes

location[R]

Subnet attributes

mask[R]

Subnet attributes

masterSubnetId[R]

Subnet attributes

maxhosts[R]

Subnet usage attributes

namerServerId[R]

Subnet attributes

permissions[R]

Subnet attributes

pingSubnet[R]

Subnet attributes

scanAgent[R]

Subnet attributes

sectionId[R]

Subnet attributes

showName[R]

Subnet attributes

state[R]

Subnet attributes

subnet[R]

Subnet attributes

threshold[R]

Subnet attributes

used[R]

Subnet usage attributes

vlanId[R]

Subnet attributes

vrfId[R]

Subnet attributes

Public Class Methods

get(id) click to toggle source
# File lib/ruby_phpipam/subnet.rb, line 40
def self.get(id)
  Subnet.new(RubyPhpipam::Query.get("/subnets/#{id}/"))
end
new(json) click to toggle source
# File lib/ruby_phpipam/subnet.rb, line 13
def initialize(json)
  @id = RubyPhpipam::Helper.to_type(json[:id], :int)
  @subnet = json[:subnet]
  @mask = RubyPhpipam::Helper.to_type(json[:mask], :int)
  @description = json[:description]
  @sectionId = RubyPhpipam::Helper.to_type(json[:sectionId], :int)
  @linked_subnet = RubyPhpipam::Helper.to_type(json[:linked_subnet], :int)
  @vlanId = RubyPhpipam::Helper.to_type(json[:vlanId], :int)
  @vrfId = RubyPhpipam::Helper.to_type(json[:vrfId], :int)
  @masterSubnetId = RubyPhpipam::Helper.to_type(json[:masterSubnetId], :int)
  @namerServerId = RubyPhpipam::Helper.to_type(json[:namerServerId], :int)
  @showName = RubyPhpipam::Helper.to_type(json[:showName], :binary)
  @permissions = RubyPhpipam::Helper.to_type(json[:permissions], :json)
  @DNSrecursive = RubyPhpipam::Helper.to_type(json[:DNSrecursive], :binary)
  @DNSrecords = RubyPhpipam::Helper.to_type(json[:DNSrecords], :binary)
  @allowResquests = RubyPhpipam::Helper.to_type(json[:allowResquests], :binary)
  @scanAgent = RubyPhpipam::Helper.to_type(json[:scanAgent], :binary)
  @pingSubnet = RubyPhpipam::Helper.to_type(json[:pingSubnet], :binary)
  @discoverSubnet = RubyPhpipam::Helper.to_type(json[:discoverSubnet], :binary)
  @isFolder = RubyPhpipam::Helper.to_type(json[:isFolder], :binary)
  @isFull = RubyPhpipam::Helper.to_type(json[:isFull], :binary)
  @state = RubyPhpipam::Helper.to_type(json[:state], :int)
  @threshold = RubyPhpipam::Helper.to_type(json[:threshold], :int)
  @location = RubyPhpipam::Helper.to_type(json[:location], :int)
  @editDate = RubyPhpipam::Helper.to_type(json[:editDate], :date)
end

Public Instance Methods

addresses() click to toggle source
# File lib/ruby_phpipam/subnet.rb, line 73
def addresses
  data = RubyPhpipam::Query.get_array("/subnets/#{id}/addresses/")

  data.map do |addr|
    RubyPhpipam::Address.new(addr)
  end
end
all_subnets(slave_mask) click to toggle source
# File lib/ruby_phpipam/subnet.rb, line 116
def all_subnets(slave_mask)
  RubyPhpipam::Query.get_array("/subnets/#{id}/all_subnets/#{slave_mask}/")
end
first_free_ip() click to toggle source
RubyPhpipam::Address.new(data)

end

# File lib/ruby_phpipam/subnet.rb, line 89
def first_free_ip
  # Should this raise an exception if no address available or return nil?
  # Currently it returns nil
  RubyPhpipam::Query.get("/subnets/#{id}/first_free/")
end
first_subnet(slave_mask) click to toggle source
# File lib/ruby_phpipam/subnet.rb, line 111
def first_subnet(slave_mask)
  # nil when no available subnet exists
  RubyPhpipam::Query.get("/subnets/#{id}/first_subnet/#{slave_mask}/")
end
slaves() click to toggle source
# File lib/ruby_phpipam/subnet.rb, line 95
def slaves
  data = RubyPhpipam::Query.get_array("/subnets/#{id}/slaves/")

  data.map do |subnet|
    RubyPhpipam::Subnet.new(subnet)
  end
end
slaves_recursive() click to toggle source
# File lib/ruby_phpipam/subnet.rb, line 103
def slaves_recursive
  data = RubyPhpipam::Query.get_array("/subnets/#{id}/slaves_recursive/")

  data.map do |subnet|
    RubyPhpipam::Subnet.new(subnet)
  end
end
usage!() click to toggle source
# File lib/ruby_phpipam/subnet.rb, line 62
def usage!
  data = RubyPhpipam::Query.get("/subnets/#{id}/usage/")

  @used = RubyPhpipam::Helper.to_type(data[:used], :int)
  @maxhosts = RubyPhpipam::Helper.to_type(data[:maxhosts], :int)
  @freehosts = RubyPhpipam::Helper.to_type(data[:freehosts], :int)
  @freehosts_percent = data[:freehosts_percent]

  return self
end