Sha256: 9ee750e1025543bf2fcb31b85b631497dd0eec65d47b246cece7c5a3bc393924

Contents?: true

Size: 1.31 KB

Versions: 53

Compression:

Stored size: 1.31 KB

Contents

module Fog
  module Compute
    class CloudSigma
      class Real
        def create_subscription(data)
          create_request("subscriptions/", data)
        end
      end

      class Mock
        def create_subscription(data)

          if data[:period] != '1 month' || data[:start_time] || data[:end_time]
            raise Fog::Errors::MockNotImplemented.new('Currently only mocks for subscriptions with period 1 month from now are implemented as mock')
          end

          id = Fog::Mock.random_numbers(3).to_i
          defaults = {'id' => id,
                      'start_time' => DateTime.now,
                      'end_time' => DateTime.now + 30 * 24 * 60 *60,
                      'auto_renew' => false,
                      'amount' => 1.0}

          if data[:resource] == 'vlan'
            vlan_uuid = self.class.random_uuid
            self.data[:vlans][vlan_uuid] = {'uuid' => vlan_uuid,
                                            'subscription' => {'id' => id},
                                            'servers' => [],
                                            'meta' => {},
                                            'tags' => []}
            defaults['subscribed_object'] = vlan_uuid
          end

          mock_create(:subscriptions, 200, data, id, defaults)
        end
      end

    end
  end
end

Version data entries

53 entries across 53 versions & 3 rubygems

Version Path
fog-1.22.0 lib/fog/cloudsigma/requests/create_subscription.rb
fog-1.21.0 lib/fog/cloudsigma/requests/create_subscription.rb
fog-maestrodev-1.20.0.20140305101839 lib/fog/cloudsigma/requests/create_subscription.rb
fog-maestrodev-1.20.0.20140305101305 lib/fog/cloudsigma/requests/create_subscription.rb
fog-maestrodev-1.19.0.20140212012611 lib/fog/cloudsigma/requests/create_subscription.rb
fog-1.20.0 lib/fog/cloudsigma/requests/create_subscription.rb
fog-maestrodev-1.19.0.20140110004459 lib/fog/cloudsigma/requests/create_subscription.rb
fog-maestrodev-1.19.0.20140110003812 lib/fog/cloudsigma/requests/create_subscription.rb
fog-maestrodev-1.19.0.20140109202555 lib/fog/cloudsigma/requests/create_subscription.rb
fog-maestrodev-1.19.0.20140107192102 lib/fog/cloudsigma/requests/create_subscription.rb
fog-maestrodev-1.19.0.20140107142106 lib/fog/cloudsigma/requests/create_subscription.rb
fog-maestrodev-1.19.0.20131219203941 lib/fog/cloudsigma/requests/create_subscription.rb
fog-maestrodev-1.18.0.20131219193542 lib/fog/cloudsigma/requests/create_subscription.rb
fog-1.19.0 lib/fog/cloudsigma/requests/create_subscription.rb
fog-maestrodev-1.18.0.20131219033443 lib/fog/cloudsigma/requests/create_subscription.rb
fog-maestrodev-1.18.0.20131219032002 lib/fog/cloudsigma/requests/create_subscription.rb
fog-maestrodev-1.18.0.20131219030716 lib/fog/cloudsigma/requests/create_subscription.rb
fog-maestrodev-1.18.0.20131219022322 lib/fog/cloudsigma/requests/create_subscription.rb
fog-maestrodev-1.18.0.20131218202447 lib/fog/cloudsigma/requests/create_subscription.rb
fog-maestrodev-1.18.0.20131209091424 lib/fog/cloudsigma/requests/create_subscription.rb