Sha256: f5da49cedc8cd74658a53d2d979511f27c730b5fd889abd36c6bbcd069dc2105

Contents?: true

Size: 1.26 KB

Versions: 6

Compression:

Stored size: 1.26 KB

Contents

module Fog
  module Compute
    class DigitalOcean
      # noinspection RubyStringKeysInHashInspection
      class Real

        def create_volume(options={})
          create_options = {
            :name        => "name",
            :region      => "nyc1",
            :size_gigabytes => 1
          }.merge(options)

          encoded_body = Fog::JSON.encode(create_options)

          request(
            :expects => [201],
            :headers => {
              'Content-Type' => "application/json; charset=UTF-8",
            },
            :method  => 'POST',
            :path    => '/v2/volumes',
            :body    => encoded_body,
          )
        end
      end

      # noinspection RubyStringKeysInHashInspection
      class Mock
        def create_volume(options)
          response        = Excon::Response.new
          response.status = 201

          response.body ={
            'volume' => {
              "id" => Fog::Mock.random_numbers(6).to_i,
              "fingerprint" => (["00"] * 16).join(':'),
              "region" => options[:region], 
              "size_gigabytes" => 10,
              "description" => options[:description],
              "name" => options[:name]
            }
          }

          response
        end
      end
    end
  end
end

Version data entries

6 entries across 4 versions & 2 rubygems

Version Path
fog-digitalocean-0.4.0 lib/fog/compute/digitalocean/requests/create_volume.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.3.0/gems/fog-digitalocean-0.3.0/lib/fog/digitalocean/requests/compute/create_volume.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.4.0/gems/fog-digitalocean-0.3.0/lib/fog/digitalocean/requests/compute/create_volume.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.5.0/gems/fog-digitalocean-0.3.0/lib/fog/digitalocean/requests/compute/create_volume.rb
fog-digitalocean-0.3.0 lib/fog/digitalocean/requests/compute/create_volume.rb
fog-digitalocean-0.2.0 lib/fog/digitalocean/requests/compute/create_volume.rb