<commit_before>module Yao::Resources
  class ComputeServices < Base
    friendly_attributes  :status, :binary, :host, :zone, :state, :disabled_reason, :forced_down

    self.service        = "compute"
    self.resources_name = "os-services"
  end
end<commit_msg>add enable/disable methods<commit_after>module Yao::Resources
  class ComputeServices < Base
    friendly_attributes  :status, :binary, :host, :zone, :state, :disabled_reason, :forced_down

    self.service        = "compute"
    self.resource_name  = "service"
    self.resources_name = "os-services"

    class << self
      def enable(host, binary)
        params = {
          "host" => host,
          "binary" => binary,
        }
        put("enable", params)
      end

      def disable(host, binary, reason = nil)
        params = {
          "host" => host,
          "binary" => binary,
        }
        if reason
          params["disabled_reason"] = reason
          put("disable-log-reason", params)
        else
          put("disable", params)
        end
      end

      private
      def put(path, params)
        res = PUT(create_url([api_version, resources_path, path]), params) do |req|
          req.body = params.to_json
          req.headers['Content-Type'] = 'application/json'
        end
        return_resource(resource_from_json(res.body))
      end
    end

  end
end
{'fraction_non_alphanumeric': 0.11160058737151249, 'fraction_numerical': 0.0, 'mean_word_length': 2.2452380952380953, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '6597240', 'n_tokens_mistral': 401, 'n_tokens_neox': 392, 'n_words': 94}