Module: Kongkit::Client::PluginObject

Included in:
Kongkit::Client
Defined in:
lib/kongkit/client/plugin_object.rb

Instance Method Summary collapse

Instance Method Details

#add_plugin(api_identifier, attributes) ⇒ Kongkit::Client::Resource

Add plugin

Parameters:

  • api_identifier (String)

    The unique identifier or the name of the API on which to add a plugin configuration

  • attributes (Hash)

    a customizable set of options

Options Hash (attributes):

  • :name (String)

    The name of the Plugin that's going to be added.

  • :consumer_id (String)

    The unique identifier of the consumer that overrides the existing settings for this specific consumer on incoming requests (optional)

  • :config.{property} (String)

    The configuration properties for the Plugin.

Returns:

See Also:


73
74
75
# 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 = {}) ⇒ Kongkit::Client::Resource

List Plugins per API

Parameters:

  • api_identifier (String)

    The unique identifier or the name of the API

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :id (String)

    A filter on the list based on the `id` field

  • :name (String)

    A filter on the list based on the `name` field

  • :api_id (String)

    A filter on the list based on the `api_id` field

  • :consumer_id (String)

    A filter on the list based on the `consumer_id` field

  • :size (Integer)

    A limit on the number of objects to be returned, default: 100

  • :offset (offset)

    A cursor used for pagination. offset is an object identifier that defines a place in the list.

Returns:

See Also:


61
62
63
# 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) ⇒ Kongkit::Client::Resource

Edit plugin

Parameters:

  • api_identifier (String)

    The unique identifier or the name of the API for which to update the plugin configuration

  • id (String)

    he unique identifier of the plugin configuration to update on this API

  • attributes (Hash)

    a customizable set of options

Options Hash (attributes):

  • :name (String)

    The name of the Plugin that's going to be added.

  • :consumer_id (String)

    The unique identifier of the consumer that overrides the existing settings for this specific consumer on incoming requests (optional)

  • :config.{property} (String)

    The configuration properties for the Plugin.

Returns:

See Also:


86
87
88
# 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_pluginsKongkit::Client::Resource

List enabled Plugins

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


24
25
26
# File 'lib/kongkit/client/plugin_object.rb', line 24

def enabled_plugins
  get('/plugins/enabled')
end

#plugin(id) ⇒ Kongkit::Client::Resource

Retrieve Plugin

Parameters:

  • id (String)

    The unique identifier of the plugin to retrieve

Returns:

See Also:


46
47
48
# File 'lib/kongkit/client/plugin_object.rb', line 46

def plugin(id)
  get("/plugins/#{id}")
end

#plugin_schema(name) ⇒ Kongkit::Client::Resource

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.

Parameters:

  • name (String)

    The name of the plugin to retrieve its schema

Returns:

See Also:


37
38
39
# File 'lib/kongkit/client/plugin_object.rb', line 37

def plugin_schema(name)
  get("/plugins/schema/#{name}")
end

#plugins(options = {}) ⇒ Kongkit::Client::Resource

List all Plugins

Parameters:

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :id (String)

    A filter on the list based on the `id` field

  • :name (String)

    A filter on the list based on the `name` field

  • :api_id (String)

    A filter on the list based on the `api_id` field

  • :consumer_id (String)

    A filter on the list based on the `consumer_id` field

  • :size (Integer)

    A limit on the number of objects to be returned, default: 100

  • :offset (offset)

    A cursor used for pagination. offset is an object identifier that defines a place in the list.

Returns:

See Also:


14
15
16
# File 'lib/kongkit/client/plugin_object.rb', line 14

def plugins(options = {})
  get('/plugins', options)
end

#remove_plugin(api_identifier, id) ⇒ Boolean

Remove plugin

Parameters:

  • api_identifier (String)

    The unique identifier or the name of the API for which to remove the plugin configuration

  • id (String)

    The unique identifier of the plugin configuration to update on this API

Returns:

  • (Boolean)

    `true` if successfully removed

See Also:


96
97
98
# File 'lib/kongkit/client/plugin_object.rb', line 96

def remove_plugin(api_identifier, id)
  delete(api_plugin_path(api_identifier, id))
end