<commit_before>class Server < RightResource::Base
  class << self
    #TODO: refactor define_method or method_missing
    def action; end
    # server start(Starting created instance)
    # === Examples
    #   server_id = Server.index(:filter => "nickname=dev001").first.id
    #   Server.start(server_id)
    def start(id)
      connection.post(element_path(id, :start))
    end

    # server stop(Starting created instance)
    def stop(id)
      connection.post(element_path(id, :stop))
    end

    # server restart(Starting created instance)
    def reboot(id)
      connection.post(element_path(id, :reboot))
    end

    # Run rightscript
    # location header is status href
    def run_script(id, params={})
      raise NotImplementedError
    end

    def attach_volume(id, params={})
      raise NotImplementedError
    end

    def get_sketchy_data(id, params={})
      raise NotImplementedError
    end

    def settings(id)
      path = element_path(id, :settings)
      generate_attributes(format.decode(connection.get(path)))
    end
  end<commit_msg>add: Search server's tag support<commit_after>class Server < RightResource::Base
  class << self
    #TODO: refactor define_method or method_missing
    def action; end
    # server start(Starting created instance)
    # === Examples
    #   server_id = Server.index(:filter => "nickname=dev001").first.id
    #   Server.start(server_id)
    def start(id)
      connection.post(element_path(id, :start))
    end

    # server stop(Starting created instance)
    def stop(id)
      connection.post(element_path(id, :stop))
    end

    # server restart(Starting created instance)
    def reboot(id)
      connection.post(element_path(id, :reboot))
    end

    # Run rightscript
    # location header is status href
    def run_script(id, params={})
      raise NotImplementedError
    end

    def attach_volume(id, params={})
      raise NotImplementedError
    end

    def get_sketchy_data(id, params={})
      raise NotImplementedError
    end

    def settings(id)
      path = element_path(id, :settings)
      generate_attributes(format.decode(connection.get(path)))
    end

    def tags(resource_href)
      query_options={'resource_href'=>resource_href}
      path = "tags/search.#{format.extension}#{query_string(query_options)}"
      Hash[ *format.decode(connection.get( path )).collect { |tag|
        tag['name'].split('=')
      }.flatten ]
    end
  end
{'fraction_non_alphanumeric': 0.10500410172272355, 'fraction_numerical': 0.002461033634126333, 'mean_word_length': 3.1621160409556315, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 6, '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': '7363568', 'n_tokens_mistral': 781, 'n_tokens_neox': 744, 'n_words': 172}