<commit_before>require 'fog/core/model'

module Fog
  module Joyent
    class Analytics
      class Instrumentation < Fog::Model
        identity :id
        attribute :joyent_module, :aliases => 'module'
        attribute :stat
        attribute :predicate
        attribute :decomposition, :type => :array
        attribute :value_dimension, aliases: 'value-dimension', :type => :integer
        attribute :value_arity, aliases: 'value-arity'
        attribute :retention_time, aliases: 'retention-time', :type => :integer
        attribute :granularity, :type => :integer
        attribute :idle_max, aliases: 'idle-max', :type => :integer
        attribute :transformations, :type => :array
        attribute :persist_data, aliases: 'persist-data', :type => :boolean
        attribute :crtime, :type => :integer
        attribute :value_scope, aliases: 'value-scope'
        attribute :uris, :type => :array

        def save
          requires :joyent_module, :stat
          munged_attributes = attributes.dup
          munged_attributes[:module] = munged_attributes.delete(:joyent_module)
          data = service.create_instrumentation(munged_attributes)
          merge_attributes(data.body)
          true
        end

        def destroy
          requires :id
          service.delete_instrumentation(self.identity)
          true
        end

      end
    end
  end
end
<commit_msg>map internal attribute names to those used on the remote service before making api call to persist the data.<commit_after>require 'fog/core/model'

module Fog
  module Joyent
    class Analytics
      class Instrumentation < Fog::Model
        identity :id
        attribute :joyent_module, :aliases => 'module'
        attribute :stat
        attribute :predicate
        attribute :decomposition, :type => :array
        attribute :value_dimension, aliases: 'value-dimension', :type => :integer
        attribute :value_arity, aliases: 'value-arity'
        attribute :retention_time, aliases: 'retention-time', :type => :integer
        attribute :granularity, :type => :integer
        attribute :idle_max, aliases: 'idle-max', :type => :integer
        attribute :transformations, :type => :array
        attribute :persist_data, aliases: 'persist-data', :type => :boolean
        attribute :crtime
        attribute :value_scope, aliases: 'value-scope'
        attribute :uris, :type => :array

        def crtime=(new_crtime)
          attributes[:crtime] = Time.at(new_crtime.to_i / 1000)
        end

        def save
          requires :joyent_module, :stat
          munged_attributes = attributes.dup
          munged_attributes[:module] = munged_attributes.delete(:joyent_module)
          munged_attributes[:'value-dimension'] = munged_attributes.delete(:value_dimension) || (self.decomposition.size + 1)
          munged_attributes[:'value-arity'] = munged_attributes.delete(:value_arity) || 'scalar'
          munged_attributes[:'retention-time'] = munged_attributes.delete(:retention_time) || 600
          munged_attributes[:'idle-max'] = munged_attributes.delete(:idle_max) || 3600
          munged_attributes[:'persist-data'] = munged_attributes.delete(:persist_data) || false
          munged_attributes[:'value-scope'] = munged_attributes.delete(:value_scope) || 'interval'
          data = service.create_instrumentation(munged_attributes)
          merge_attributes(data.body)
          true
        end

        def destroy
          requires :id
          service.delete_instrumentation(self.identity)
          true
        end

      end
    end
  end
end

{'fraction_non_alphanumeric': 0.09972067039106146, 'fraction_numerical': 0.0033519553072625698, 'mean_word_length': 2.757607555089192, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 22, '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': '7053167', 'n_tokens_mistral': 1028, 'n_tokens_neox': 993, 'n_words': 237}