Class: Profitbricks::IpBlock
- Defined in:
- lib/profitbricks/ip_block.rb
Instance Attribute Summary collapse
-
#ips ⇒ Object
readonly
Returns the value of attribute ips.
Class Method Summary collapse
-
.all ⇒ Array<IpBlock>
Returns a list of all public IP blocks reserved by the user, including the reserved IPs and connected NICs.
-
.reserve(amount) ⇒ IpBlock
Reserves a specific amount of public IPs which can be manually assigned to a NIC by the user.
Instance Method Summary collapse
- #id ⇒ Object
-
#initialize(hash, parent = nil) ⇒ IpBlock
constructor
A new instance of IpBlock.
-
#release ⇒ Boolean
Releases an existing block of reserved public IPs.
Methods inherited from Model
#attributes, belongs_to, has_many, #reload
Constructor Details
#initialize(hash, parent = nil) ⇒ IpBlock
Returns a new instance of IpBlock.
5 6 7 8 9 10 11 |
# 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 |
Instance Attribute Details
#ips ⇒ Object (readonly)
Returns the value of attribute ips.
3 4 5 |
# File 'lib/profitbricks/ip_block.rb', line 3 def ips @ips end |
Class Method Details
.all ⇒ Array<IpBlock>
Returns a list of all public IP blocks reserved by the user, including the reserved IPs and connected NICs.
29 30 31 32 33 34 |
# 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 |
.reserve(amount) ⇒ IpBlock
Reserves a specific amount of public IPs which can be manually assigned to a NIC by the user.
40 41 42 43 |
# 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 |
Instance Method Details
#id ⇒ Object
13 14 15 |
# File 'lib/profitbricks/ip_block.rb', line 13 def id @block_id end |
#release ⇒ Boolean
Releases an existing block of reserved public IPs.
20 21 22 23 |
# File 'lib/profitbricks/ip_block.rb', line 20 def release response = Profitbricks.request :release_public_ip_block, block_id: self.id return true end |