class Profitbricks::IpBlock
Attributes
ips[R]
Public Class Methods
all()
click to toggle source
Returns a list of all public IP blocks reserved by the user, including the reserved IPs and connected NICs.
@return [Array<IpBlock>] List of all IpBlocks
# File lib/profitbricks/ip_block.rb, line 29 def all response = Profitbricks.request :get_all_public_ip_blocks [response].flatten.compact.collect do |block| PB::IpBlock.new(block) end end
new(hash, parent=nil)
click to toggle source
Calls superclass method
Profitbricks::Model::new
# File lib/profitbricks/ip_block.rb, line 5 def initialize(hash, parent=nil) if hash[:public_ips] @ips = [hash.delete(:public_ips)].flatten.compact.collect { |ip| ip[:ip] } end super(hash) @ips = [@ips] if @ips.class != Array end
reserve(amount)
click to toggle source
Reserves a specific amount of public IPs which can be manually assigned to a NIC by the user.
@param [Fixnum] Block size / amount of IPs to reserve @return [IpBlock] The reserved IpBlock
# File lib/profitbricks/ip_block.rb, line 40 def reserve(amount) response = Profitbricks.request :reserve_public_ip_block, block_size: amount return PB::IpBlock.new(response) end
Public Instance Methods
id()
click to toggle source
# File lib/profitbricks/ip_block.rb, line 13 def id @block_id end
release()
click to toggle source
Releases an existing block of reserved public IPs.
@return [Boolean] true on success, false otherwise
# File lib/profitbricks/ip_block.rb, line 20 def release response = Profitbricks.request :release_public_ip_block, block_id: self.id return true end