Sha256: dba37602a33c9d5c05d722e34b970ee5e0abe33ede2d1389d638ef4cc3de029e

Contents?: true

Size: 1.3 KB

Versions: 4

Compression:

Stored size: 1.3 KB

Contents

require 'fog/volume/huaweicloud/models/snapshot'

module Fog
  module Volume
    class HuaweiCloud
      class V1
        class Snapshot < Fog::Volume::HuaweiCloud::Snapshot
          identity :id

          attribute :display_name
          attribute :status
          attribute :display_description
          attribute :metadata
          attribute :force
          attribute :size

          def save
            requires :display_name
            data = if id.nil?
                     service.create_snapshot(attributes[:volume_id], display_name, display_description, force)
                   else
                     service.update_snapshot(id, attributes.reject { |k, _v| k == :id })
                   end
            merge_attributes(data.body['snapshot'])
            true
          end

          def create
            requires :display_name

            # volume_id, name, description, force=false
            response = service.create_snapshot(attributes[:volume_id],
                                               attributes[:display_name],
                                               attributes[:display_description],
                                               attributes[:force])
            merge_attributes(response.body['snapshot'])

            self
          end
        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/v1/models/snapshot.rb
fog-huaweicloud-0.0.2 lib/fog/volume/huaweicloud/v1/models/snapshot.rb
fog-huaweicloud-0.1.3 lib/fog/volume/huaweicloud/v1/models/snapshot.rb
fog-huaweicloud-0.1.2 lib/fog/volume/huaweicloud/v1/models/snapshot.rb