Sha256: d67c119f2cf8e1bddcc92a4335f49be2c742c8111b6454a9e6ac680392a10f82

Contents?: true

Size: 1.15 KB

Versions: 4

Compression:

Stored size: 1.15 KB

Contents

module Fog
  module Volume
    class HuaweiCloud
      module Real
        def create_backup(attributes)
          desired_options = [
            :container,
            :name,
            :description,
            :volume_id,
            :incremental,
            :force,
          ]

          # Filter only allowed creation attributes
          data = {
            :backup => attributes.select { |key, _value| desired_options.include?(key.to_sym) }
          }

          request(
            :body => Fog::JSON.encode(data),
            :expects => [200, 202],
            :method => 'POST',
            :path => 'backups'
          )
        end
      end

      module Mock
        def create_backup(_options = {})
          response = Excon::Response.new
          response.status = 202
          response.body = {
            "backup" => {
              "id" => "1",
              "volume_id" => "2",
              "name" => "backup 1",
              "status" => "available",
              "size" => 1,
              "object_count" => 16,
              "container" => "testcontainer",
            }
          }
          response
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
fog-huaweicloud-0.0.3 lib/fog/volume/huaweicloud/requests/create_backup.rb
fog-huaweicloud-0.0.2 lib/fog/volume/huaweicloud/requests/create_backup.rb
fog-huaweicloud-0.1.3 lib/fog/volume/huaweicloud/requests/create_backup.rb
fog-huaweicloud-0.1.2 lib/fog/volume/huaweicloud/requests/create_backup.rb