Sha256: 97b3fc82f394f1f5eb854fdc52fdffbdcf3d1bda0353a5609ab027e6e84851a2

Contents?: true

Size: 1.43 KB

Versions: 1

Compression:

Stored size: 1.43 KB

Contents

require File.expand_path('../../helpers/compute/data_helper', __dir__)

module Fog
  module Compute
    class ProfitBricks
      class IpBlock < Fog::Models::ProfitBricks::Base
        include Fog::Helpers::ProfitBricks::DataHelper

        identity  :id

        # properties
        attribute :ips
        attribute :location
        attribute :size
        attribute :name

        # metadata
        attribute :created_date,       :aliases => 'createdDate', :type => :time
        attribute :created_by, 	       :aliases => 'createdBy'
        attribute :last_modified_date, :aliases => 'lastModifiedDate', :type => :time
        attribute :last_modified_by,   :aliases => 'lastModifiedBy'
        attribute :request_id,         :aliases => 'requestId'
        attribute :state

        def initialize(attributes = {})
          super
        end

        def save
          requires :location, :size

          properties = {}
          properties[:location] = location if location
          properties[:size]     = size if size
          properties[:name]     = name if name

          data = service.create_ip_block(properties)
          merge_attributes(flatten(data.body))
          true
        end

        def delete
          requires :id
          service.delete_ip_block(id)
          true
        end

        def ready?
          state == 'AVAILABLE'
        end

        def failed?
          state == 'ERROR'
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fog-profitbricks-2.0.1 lib/fog/profitbricks/models/compute/ip_block.rb