Sha256: 6ba253d522191735b868bca71cb1fe3ba29f4af9d14d4833b1c8e01049eb0a37

Contents?: true

Size: 1.22 KB

Versions: 4

Compression:

Stored size: 1.22 KB

Contents

require File.expand_path("../internet_service", __FILE__)

module Fog
  module Compute
    class Ecloud
      class InternetServices < Fog::Ecloud::Collection
        identity :href

        model Fog::Compute::Ecloud::InternetService

        def all
          data = service.get_internet_services(href).body[:InternetServices]
          if data.is_a?(Hash)
            load(data[:InternetService])
          elsif data.is_a?(String) && data.empty?
            load([])
          end
        end

        def get(uri)
          data = service.get_internet_service(uri).body
          new(data)
        rescue ServiceError => e
          raise e unless e.status_code == 404
          nil
        end

        def create(options)
          options[:uri] = "#{service.base_path}/internetServices/publicIps/#{public_ip_id}/action/createInternetService"
          options[:protocol] ||= "TCP"
          options[:enabled] ||= true
          options[:description] ||= ""
          options[:persistence] ||= {}
          options[:persistence][:type] ||= "None"
          data = service.internet_service_create(options).body
          new(data)
        end

        def public_ip_id
          href.scan(/\d+/)[0]
        end
      end
    end
  end
end

Version data entries

4 entries across 2 versions & 2 rubygems

Version Path
vagrant-packet-0.1.1 vendor/bundle/ruby/2.3.0/gems/fog-ecloud-0.3.0/lib/fog/compute/ecloud/models/internet_services.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.4.0/gems/fog-ecloud-0.3.0/lib/fog/compute/ecloud/models/internet_services.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.5.0/gems/fog-ecloud-0.3.0/lib/fog/compute/ecloud/models/internet_services.rb
fog-ecloud-0.3.0 lib/fog/compute/ecloud/models/internet_services.rb