module Kongkit::Client::PluginObject

Public Instance Methods

add_plugin(api_identifier, attributes) click to toggle source

Add plugin

@see getkong.org/docs/0.8.x/admin-api/#add-plugin @param api_identifier [String] The unique identifier or the name of the API on which to add a plugin configuration @option attributes [String] :name The name of the Plugin that's going to be added. @option attributes [String] :consumer_id The unique identifier of the consumer that overrides the existing settings for this specific consumer on incoming requests (optional) @option attributes [String] :config.{property} The configuration properties for the Plugin. @return [Kongkit::Client::Resource] Plugin Object

# File lib/kongkit/client/plugin_object.rb, line 73
def add_plugin(api_identifier, attributes)
  post(api_plugins_path(api_identifier), body: attributes)
end
api_plugins(api_identifier, options = {}) click to toggle source

List Plugins per API

@see getkong.org/docs/0.8.x/admin-api/#list-plugins-per-api @param api_identifier [String] The unique identifier or the name of the API @option options [String] :id A filter on the list based on the `id` field @option options [String] :name A filter on the list based on the `name` field @option options [String] :api_id A filter on the list based on the `api_id` field @option options [String] :consumer_id A filter on the list based on the `consumer_id` field @option options [Integer] :size A limit on the number of objects to be returned, default: 100 @option options [offset] :offset A cursor used for pagination. offset is an object identifier that defines a place in the list. @return [Kongkit::Client::Resource] Plugin Objects

# File lib/kongkit/client/plugin_object.rb, line 61
def api_plugins(api_identifier, options = {})
  get(api_plugins_path(api_identifier), options)
end
edit_plugin(api_identifier, id, attributes) click to toggle source

Edit plugin

@see getkong.org/docs/0.8.x/admin-api/#update-plugin @param api_identifier [String] The unique identifier or the name of the API for which to update the plugin configuration @param id [String] he unique identifier of the plugin configuration to update on this API @option attributes [String] :name The name of the Plugin that's going to be added. @option attributes [String] :consumer_id The unique identifier of the consumer that overrides the existing settings for this specific consumer on incoming requests (optional) @option attributes [String] :config.{property} The configuration properties for the Plugin. @return [Kongkit::Client::Resource] Plugin Object

# File lib/kongkit/client/plugin_object.rb, line 86
def edit_plugin(api_identifier, id, attributes)
  patch(api_plugin_path(api_identifier, id), body: attributes)
end
enabled_plugins() click to toggle source

List enabled Plugins

Retrieve a list of all installed plugins on the Kong node.

@see getkong.org/docs/0.8.x/admin-api/#list-enabled-plugins @return [Kongkit::Client::Resource] Plugin Objects

# File lib/kongkit/client/plugin_object.rb, line 24
def enabled_plugins
  get('/plugins/enabled')
end
plugin(id) click to toggle source

Retrieve Plugin

@see getkong.org/docs/0.8.x/admin-api/#retrieve-plugin @param id [String] The unique identifier of the plugin to retrieve @return [Kongkit::Client::Resource] Plugin Object

# File lib/kongkit/client/plugin_object.rb, line 46
def plugin(id)
  get("/plugins/#{id}")
end
plugin_schema(name) click to toggle source

Retrieve Plugin Schema

Retrieve the schema of a plugin's configuration. This is useful to understand what fields a plugin accepts, and can be used for building third-party integrations to the Kong's plugin system.

@see getkong.org/docs/0.8.x/admin-api/#list-enabled-plugins @param name [String] The name of the plugin to retrieve its schema @return [Kongkit::Client::Resource] Plugin Objects

# File lib/kongkit/client/plugin_object.rb, line 37
def plugin_schema(name)
  get("/plugins/schema/#{name}")
end
plugins(options = {}) click to toggle source

List all Plugins

@see getkong.org/docs/0.8.x/admin-api/#list-all-plugins @option options [String] :id A filter on the list based on the `id` field @option options [String] :name A filter on the list based on the `name` field @option options [String] :api_id A filter on the list based on the `api_id` field @option options [String] :consumer_id A filter on the list based on the `consumer_id` field @option options [Integer] :size A limit on the number of objects to be returned, default: 100 @option options [offset] :offset A cursor used for pagination. offset is an object identifier that defines a place in the list. @return [Kongkit::Client::Resource] Plugin Objects

# File lib/kongkit/client/plugin_object.rb, line 14
def plugins(options = {})
  get('/plugins', options)
end
remove_plugin(api_identifier, id) click to toggle source

Remove plugin

@see getkong.org/docs/0.8.x/admin-api/#delete-plugin @param api_identifier [String] The unique identifier or the name of the API for which to remove the plugin configuration @param id [String] The unique identifier of the plugin configuration to update on this API @return [Boolean] `true` if successfully removed

# File lib/kongkit/client/plugin_object.rb, line 96
def remove_plugin(api_identifier, id)
  delete(api_plugin_path(api_identifier, id))
end

Private Instance Methods

api_plugin_path(api_identifier, id) click to toggle source
# File lib/kongkit/client/plugin_object.rb, line 106
def api_plugin_path(api_identifier, id)
  "#{api_plugins_path(api_identifier)}/#{id}"
end
api_plugins_path(api_identifier) click to toggle source
# File lib/kongkit/client/plugin_object.rb, line 102
def api_plugins_path(api_identifier)
  "/apis/#{api_identifier}/plugins"
end