<commit_before>require 'fog/core/model'

module Fog
  module Compute
    class Google

      class Disk < Fog::Model

        identity :name

        attribute :kind, :aliases => 'kind'
        attribute :id, :aliases => 'id'
        attribute :creation_timestamp, :aliases => 'creationTimestamp'
        attribute :zone_name, :aliases => 'zone'
        attribute :status, :aliases => 'status'
        attribute :description, :aliases => 'description'
        attribute :size_gb, :aliases => 'sizeGb'
        attribute :self_link, :aliases => 'selfLink'
        attribute :source_image, :aliases => 'sourceImage'
        attribute :source_snapshot, :aliases => 'sourceSnapshot'
        attribute :source_snapshot_id, :aliases => 'sourceSnapshot'

        def save
          requires :name
          requires :zone_name

          options = {}
          if source_image.nil? && !source_snapshot.nil?
            options['sourceSnapshot'] = source_snapshot
          end

          options['sizeGb'] = size_gb

          data = service.insert_disk(name, zone_name, source_image, options).body
          data = service.backoff_if_unfound {service.get_disk(name, zone_name).body}
          service.disks.merge_attributes(data)
        end

        def destroy
          requires :name, :zone_name
          operation = service.delete_disk(name, zone_name)
          # wait until "RUNNING" or "DONE" to ensure the operation doesn't fail, raises exception on error<commit_msg>[google|compute] allow user to set disk description<commit_after>require 'fog/core/model'

module Fog
  module Compute
    class Google

      class Disk < Fog::Model

        identity :name

        attribute :kind, :aliases => 'kind'
        attribute :id, :aliases => 'id'
        attribute :creation_timestamp, :aliases => 'creationTimestamp'
        attribute :zone_name, :aliases => 'zone'
        attribute :status, :aliases => 'status'
        attribute :description, :aliases => 'description'
        attribute :size_gb, :aliases => 'sizeGb'
        attribute :self_link, :aliases => 'selfLink'
        attribute :source_image, :aliases => 'sourceImage'
        attribute :source_snapshot, :aliases => 'sourceSnapshot'
        attribute :source_snapshot_id, :aliases => 'sourceSnapshot'

        def save
          requires :name
          requires :zone_name

          options = {}
          my_description = "Created with fog"
          if !source_image.nil?
            my_description = "Created from image: #{source_image}"
          end
          if source_image.nil? && !source_snapshot.nil?
            options['sourceSnapshot'] = source_snapshot
            my_description = "Created from snapshot: #{source_snapshot}"
          end

          options['sizeGb'] = size_gb
          options['description'] = description || my_description

          data = service.insert_disk(name, zone_name, source_image, options).body
          data = service.backoff_if_unfound {service.get_disk(name, zone_name).body}
          service.disks.merge_attributes(data)
        end

        def destroy
          requires :name, :zone_name
          operation = service.delete_disk(name, zone_name)
          # wait until "RUNNING" or "DONE" to ensure the operation doesn't fail, raises exception on error
{'fraction_non_alphanumeric': 0.0983206106870229, 'fraction_numerical': 0.0, 'mean_word_length': 2.5647442872687702, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7042757', 'n_tokens_mistral': 899, 'n_tokens_neox': 882, 'n_words': 237}