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
fog-2.3.0 lib/fog/cloudsigma/models/subscriptions.rb
fog-ifeel-2.2.0 lib/fog/cloudsigma/models/subscriptions.rb
fog-2.2.0 lib/fog/cloudsigma/models/subscriptions.rb
fog-2.1.0 lib/fog/cloudsigma/models/subscriptions.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.5.0/gems/fog-1.42.1/lib/fog/cloudsigma/models/subscriptions.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.3.0/gems/fog-1.42.1/lib/fog/cloudsigma/models/subscriptions.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.4.0/gems/fog-1.42.1/lib/fog/cloudsigma/models/subscriptions.rb
fog-1.42.1 lib/fog/cloudsigma/models/subscriptions.rb
fog-2.0.0 lib/fog/cloudsigma/models/subscriptions.rb
fog-1.42.0 lib/fog/cloudsigma/models/subscriptions.rb
fog-1.41.0 lib/fog/cloudsigma/models/subscriptions.rb
fog-1.40.0 lib/fog/cloudsigma/models/subscriptions.rb
fog-1.39.0 lib/fog/cloudsigma/models/subscriptions.rb
fog-1.38.0 lib/fog/cloudsigma/models/subscriptions.rb
fog-1.37.0 lib/fog/cloudsigma/models/subscriptions.rb
fog-1.36.0 lib/fog/cloudsigma/models/subscriptions.rb
fog-1.35.0 lib/fog/cloudsigma/models/subscriptions.rb
fog-2.0.0.pre.0 lib/fog/cloudsigma/models/subscriptions.rb
vagrant-cloudstack-1.2.0 vendor/bundle/gems/fog-1.32.0/lib/fog/cloudsigma/models/subscriptions.rb
fog-1.34.0 lib/fog/cloudsigma/models/subscriptions.rb