class Kodmin::Plugins

Plugins of Kong.

Public Instance Methods

disable_plugin(id) click to toggle source
# File lib/kodmin/plugins.rb, line 32
def disable_plugin(id)
  delete("/plugins/#{id}")
end
enable_plugin(attributes) click to toggle source
# File lib/kodmin/plugins.rb, line 26
def enable_plugin(attributes)
  resp = post('/plugins', attributes)
  resp = JSON.parse(resp)
  plugin_from_hash(resp)
end
list_plugins(offset = '') click to toggle source
# File lib/kodmin/plugins.rb, line 11
def list_plugins(offset = '')
  params = offset.empty? ? {} : { offset: offset }
  resp = get('/plugins', params)
  resp = JSON.parse(resp)
  plugins = []
  resp['data'].each do |v|
    plugins << plugin_from_hash(v)
  end
  offset_token = nil
  unless resp['next'].nil? || resp['next'].empty?
    offset_token = resp['next'].split('=')[1]
  end
  { plugins: plugins, offset: offset_token }
end
plugin_from_hash(attributes) click to toggle source
# File lib/kodmin/plugins.rb, line 36
def plugin_from_hash(attributes)
  case attributes['name']
  when Kodmin::Plugins::HmacAuth::NAME then Kodmin::Plugins::HmacAuth.new(attributes)
  else Kodmin::Plugins::Plugin.new(attributes)
  end
end