You are correct if you enable a plugin on 5 different services that if you wish to remove the plugin you must delete it off each of the 5 services individually. Sure it does make extra work but imagine if you accidentally deleted a plugin off ALL services by mistake? Could cause your entire gateway to go into disarray . Maybe eventually they make a way to pass multiple service ids + plugin name or something for delete but I don’t think it follows the basic CRUD functionality they have intended on Kong resources for now (which you can write your own wrapper API’s on top of theirs to accomplish what you want if you so desire).
Documentation of the Admin API is available online at https://docs.konghq.com/latest/admin-api/ (and is versioned per major Kong version). You are free to write any wrapper you may want on top of the basic CRUD functionalities it offers.
Say there is an API Called deleteConsumer() and an API called getConsumers(), you want to make an API that deletes all consumers(which is not available). Then in sudo code you do this with your wrapper API logic:
Many thanks @jeremyjpj0916
This is helpful , but I was also looking as to where I need fit in this code in the Kong framework .
Recently I developed a custom Kong plugin , so is this API customization also deployed as a plugin or something else ?
Ah right, to do it like so an as API exposed off of your custom plugin for kong is slightly more challenging but totally doable, lets take this source code for example(yours will be similar):
So for instance your plugin you will put an api.lua script in your source plugin and create methods similarly to the plugin I linked you above, I suppose to wrap other API calls and logic you can include references to other plugins “api.lua” codebases like the one above and call their methods directly with the API you expose off your plugin. That way your plugins api.lua calls other existing methods within the kong codebase. A little more work than just writing an external client to call admin CRUD api endpoints but still doable if you study the Kong code and find the lua scripts/methods you need within kong. For instance create/delete consumers is not exposed in any plugins “api.lua” file but I am sure there is a different method in the core you can reference from your plugins api.lua.