Sha256: f561aec8a5f8d4d3e39d29ff10a81200f40f6b0636e37ca48bc9452491cca7f8

Contents?: true

Size: 1.12 KB

Versions: 4

Compression:

Stored size: 1.12 KB

Contents

module Fog
  module SharedFileSystem
    class HuaweiCloud
      class Real
        def create_snapshot(share_id, options = {})
          data = {
            'share_id' => share_id
          }

          vanilla_options = [
            :name, :description, :display_name, :display_description, :force
          ]

          vanilla_options.select { |o| options[o] }.each do |key|
            data[key] = options[key]
          end

          request(
            :body    => Fog::JSON.encode('snapshot' => data),
            :expects => 202,
            :method  => 'POST',
            :path    => 'snapshots'
          )
        end
      end

      class Mock
        def create_snapshot(share_id, options = {})
          # stringify keys
          options = Hash[options.map { |k, v| [k.to_s, v] }]

          response = Excon::Response.new
          response.status = 202

          snapshot = data[:snapshots_detail].first.dup

          snapshot['share_id'] = share_id
          snapshot['status']   = 'creating'

          response.body = {'snapshot' => snapshot.merge(options)}
          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/shared_file_system/huaweicloud/requests/create_snapshot.rb
fog-huaweicloud-0.0.2 lib/fog/shared_file_system/huaweicloud/requests/create_snapshot.rb
fog-huaweicloud-0.1.3 lib/fog/shared_file_system/huaweicloud/requests/create_snapshot.rb
fog-huaweicloud-0.1.2 lib/fog/shared_file_system/huaweicloud/requests/create_snapshot.rb