module KongSchema::Client
Public Class Methods
connect(config) { |Client| ... }
click to toggle source
Configure Kong::Client to use the host specified in config for the duration of a proc.
Example:
KongSchema::Schema.connect({ 'admin_host' => '127.0.0.1:8001' }) do Kong::Api.all() end
# File lib/kong_schema/client.rb, line 15 def self.connect(config, &_) api_url = Kong::Client.api_url admin_host = config['admin_host'] if admin_host.nil? fail "Missing 'admin_host' property; can not connect to Kong admin!" end Kong::Client.api_url = "http://#{admin_host}" yield Kong::Client ensure Kong::Client.api_url = api_url end
purge(config)
click to toggle source
Reset Kong's database by removing all objects through the API.
# File lib/kong_schema/client.rb, line 31 def self.purge(config) connect(config) do KongSchema::Resource::Plugin.all.each(&:delete) KongSchema::Resource::Upstream.all.each do |upstream| upstream.targets.each(&:delete) upstream.delete end KongSchema::Resource::Api.all.each(&:delete) end end