Sha256: bea676f51ed59650591b1f5a71b9c442c5d765f42c9f8f1d81d7d2fd4dde52ae

Contents?: true

Size: 1.12 KB

Versions: 96

Compression:

Stored size: 1.12 KB

Contents

require 'fog/core/collection'
require 'fog/cloudsigma/models/subscription'

module Fog
  module Compute
    class CloudSigma
      class Subscriptions < Fog::Collection
        model Fog::Compute::CloudSigma::Subscription

        def all
          resp = service.list_subscriptions
          data = resp.body['objects']
          load(data)
        end

        def get(sub_id)
          resp = service.get_subscription(sub_id)
          data = resp.body
          new(data)
        rescue Fog::CloudSigma::Errors::NotFound
          return nil
        end

        def check_price(subscriptions_list)
          subscriptions_list = subscriptions_list.map {|s| s.kind_of?(Hash) ? s : s.attributes}

          resp = service.calculate_subscription_price(subscriptions_list)

          PriceCalculation.new(resp.body)
        end

        def create_multiple(subscriptions_list)
          subscriptions_list = subscriptions_list.map { |s| s.kind_of?(Hash) ? s : s.attributes }

          resp = service.create_subscription(subscriptions_list)
          resp.body['objects'].map { |s| Subscription.new(s) }
        end
      end
    end
  end
end

Version data entries

96 entries across 94 versions & 8 rubygems

Version Path
ns-fog-1.22.3 lib/fog/cloudsigma/models/subscriptions.rb
ns-fog-1.22.2 lib/fog/cloudsigma/models/subscriptions.rb
fog-1.22.1 lib/fog/cloudsigma/models/subscriptions.rb
fog-1.22.0 lib/fog/cloudsigma/models/subscriptions.rb
fog-1.21.0 lib/fog/cloudsigma/models/subscriptions.rb
fog-maestrodev-1.20.0.20140305101839 lib/fog/cloudsigma/models/subscriptions.rb
fog-maestrodev-1.20.0.20140305101305 lib/fog/cloudsigma/models/subscriptions.rb
fog-maestrodev-1.19.0.20140212012611 lib/fog/cloudsigma/models/subscriptions.rb
fog-1.20.0 lib/fog/cloudsigma/models/subscriptions.rb
fog-maestrodev-1.19.0.20140110004459 lib/fog/cloudsigma/models/subscriptions.rb
fog-maestrodev-1.19.0.20140110003812 lib/fog/cloudsigma/models/subscriptions.rb
fog-maestrodev-1.19.0.20140109202555 lib/fog/cloudsigma/models/subscriptions.rb
fog-maestrodev-1.19.0.20140107192102 lib/fog/cloudsigma/models/subscriptions.rb
fog-maestrodev-1.19.0.20140107142106 lib/fog/cloudsigma/models/subscriptions.rb
fog-maestrodev-1.19.0.20131219203941 lib/fog/cloudsigma/models/subscriptions.rb
fog-maestrodev-1.18.0.20131219193542 lib/fog/cloudsigma/models/subscriptions.rb
fog-1.19.0 lib/fog/cloudsigma/models/subscriptions.rb
fog-maestrodev-1.18.0.20131219033443 lib/fog/cloudsigma/models/subscriptions.rb
fog-maestrodev-1.18.0.20131219032002 lib/fog/cloudsigma/models/subscriptions.rb
fog-maestrodev-1.18.0.20131219030716 lib/fog/cloudsigma/models/subscriptions.rb