<commit_before>module Elasticfeed

  class Resource::Plugin < Resource

    attr_reader :name
    attr_reader :group
    attr_reader :version
    attr_reader :license
    attr_reader :status
    attr_reader :errors

    def table_row
      [@name, @id, @group, @version, @license, @status, @errors]
    end

    def table_section
      [table_row]
    end

    def self.table_header
      ['Name', 'PluginId', 'Group', 'Version', 'License', 'Status', 'Errors']
    end

    def self._find(client, id)
      client.get('/system/plugin/' + id)
    end

    def delete
      @client.delete('/system/plugin/' + @id)
    end

    def upload_binary(data)
      @client.put('/system/plugin/' + @id + '/upload', data, true)
    end

    private

    def _from_hash(data)
      @name = data['name'].empty? ? data['id'] : data['name']
      @group = data['group']
      @version = data['version']
      @license = data['license']
      @status = data['status']
      @errors = data['errors']
    end

    def _to_hash
      @data<commit_msg>Extended plugin resource with runtime status<commit_after>module Elasticfeed

  class Resource::Plugin < Resource

    attr_reader :name
    attr_reader :group
    attr_reader :version
    attr_reader :license
    attr_reader :status
    attr_reader :errors
    attr_reader :runtime

    def table_row
      [@name, @id, @group, @version, @license, @status, @errors, @runtime['workflowCurrent'], @runtime['workflowCrashed']]
    end

    def table_section
      [table_row]
    end

    def self.table_header
      ['Name', 'PluginId', 'Group', 'Version', 'License', 'Status', 'Errors', 'Workflow in use', 'Workflow crashed']
    end

    def self._find(client, id)
      client.get('/system/plugin/' + id)
    end

    def delete
      @client.delete('/system/plugin/' + @id)
    end

    def upload_binary(data)
      @client.put('/system/plugin/' + @id + '/upload', data, true)
    end

    private

    def _from_hash(data)
      @name = data['name'].empty? ? data['id'] : data['name']
      @group = data['group']
      @version = data['version']
      @license = data['license']
      @status = data['status']
      @errors = data['errors']
      @runtime = data['runtime']
    end

    def _to_hash
      @data
{'fraction_non_alphanumeric': 0.14101423487544484, 'fraction_numerical': 0.0, 'mean_word_length': 2.7235099337748343, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, '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': '2995642', 'n_tokens_mistral': 717, 'n_tokens_neox': 691, 'n_words': 177}