Sha256: 3c29a1e4bcad8dfb97442a94849a67cc5ecf7832a4a722e7d3ed5dc8f3ebcd23

Contents?: true

Size: 1.45 KB

Versions: 4

Compression:

Stored size: 1.45 KB

Contents

module Squall
  # Handles IP assignments for virtual machines
  class IpAddressJoin < Base

    # Get the list of IP address assignments for a particular virtual machine
    #
    # ==== Params
    #
    # * +virtual_machine_id*+ - Virtual machine ID to lookup
    def list(virtual_machine_id)
      response = request(:get, "/virtual_machines/#{virtual_machine_id}/ip_addresses.json")
      response.collect { |ip| ip['ip_address_join'] }
    end

    # Assigns an IP address to a VM
    #
    # ==== Params
    #
    # * +virtual_machine_id*+ - Virtual machine ID to assign IP to
    # * +options+ - Params for IP assignment
    #
    # ==== Options
    #
    # * +ip_address_id*+ - ID of the IP address
    # * +network_interface_id*+ - ID of the network interface id
    def assign(virtual_machine_id, options = {})
      params.required(:ip_address_id, :network_interface_id).validate!(options)
      response = request(:post, "/virtual_machines/#{virtual_machine_id}/ip_addresses.json", default_params(options))
      response['ip_address_join']
    end

    # Deletes an IP address assignment from a VM
    #
    # ==== Params
    #
    # * +virtual_machine_id+ - Virtual machine ID to remove IP join from
    # * +ip_address_id+ - IP Address ID to remove
    #
    # ==== Options
    #
    # See #assign
    def delete(virtual_machine_id, ip_address_id)
      request(:delete, "/virtual_machines/#{virtual_machine_id}/ip_addresses/#{ip_address_id}.json")
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
squall-1.3.0 lib/squall/ip_address_join.rb
squall-1.2.1beta1 lib/squall/ip_address_join.rb
squall-1.2.0beta1 lib/squall/ip_address_join.rb
squall-1.1.0 lib/squall/ip_address_join.rb