Right the wrong: Get rid of partially deleted APIs in WSO2 APIM

[Source: https://s3.amazonaws.com/lowres.cartoonstock.com/education-teaching-complaint-grammar_mistake-spelling_mistake-grammar-linguistics-tcrn2348_low.jpg]

Make the wrong

A person who never made a mistake never tried anything new!

Partially deleted APIs in WSO2 APIM

[Source: https://media3.giphy.com/media/3ohzAx8NSdzfHvaFsk/giphy.gif]

Solve the struggle!

[Source: https://64.media.tumblr.com/71505989e0561597fa4a90131a86b808/tumblr_pbuihv55WA1ue7ulto1_500.gifv]
1. The API should not have any active subscriptions
2. The API data should be removed from the registry
3. The API related data should be deleted from the corresponding database tables
4. The API details should be removed from any external stores if exist

1. Deleting an API through Publisher Portal

  • Access the Publisher portal via https://<host_name>:<port>/publisher
  • If an API is in the published state then it should be checked for any existing subscriptions. These details can be checked in the API’s thumbnail or by clicking on the API thumbnail these details can be viewed in a more descriptive manner.
  • If the API has any subscriptions then access the Store portal via https://<host_name>:<port>/store and remove the subscriptions.
  • The subscription should be removed by navigating through API-Store → Applications → Select the subscribed Application → Click on Subscribes tab → click on the Unsubscribe option for the selected API
  • Now go to the Publisher Portal and delete the relevant API as shown in the below image.
Fig 1: Delete the API via Publisher portal

✅ Recommendation

2. Deleting an API from the registry through carbon management console and databases

  • Access the carbon management console via https://<host_name>:<port>/carbon
  • On the left side of the Home menu, under the “Resources” tab, click on the “Browse” option.
  • Then navigate to /_system/governance/apimgt/applicationdata/provider/admin/<api_name>
  • You will be directed to the following UI
Fig 2: Delete the API resources from the registry in the carbon management console
  • If you have created multiple versions with the same API name you will get multiple folders with the version number as the name.
  • Click on the relevant version folder’s “Action” button.
  • The “Delete” button will be displayed.
  • Click on the Delete button and the relevant API will be deleted from the registry browse.

b. Deleting API information from the relevant database tables

  • As the initial step get all the details of the deleted API from the database (AM_DB) by executing the following query. This will return you all the relevant details which you will be needing later to completely delete all the API-related details from the database. From this, we will be mainly needing the API_ID in order to execute the upcoming queries.
SELECT * FROM AM_API WHERE API_NAME='?';
  • Next, execute the following DELETE queries one by one.
DELETE FROM AM_API_LC_EVENT WHERE API_ID=? DELETE FROM AM_API_COMMENTS WHERE API_ID=? DELETE FROM AM_API_RATINGS WHERE API_ID=? DELETE FROM AM_SUBSCRIPTION WHERE API_ID=?DELETE FROM AM_EXTERNAL_STORES WHERE API_ID=?DELETE FROM AM_API WHERE API_PROVIDER=? AND API_NAME=? AND API_VERSION=? DELETE FROM AM_API_URL_MAPPING WHERE API_ID = ?;
  • Provide the relevant values instead of “?” in the required places.

c. Deleting the API synapse-config

  • Once the queries got executed next delete the relevant API synapse-config which is located in the <APIM_Home>/repository/deployment/server/synapse-configs/default/api folder if exists.

Wrap Up!

[Source: https://media1.giphy.com/media/cn8IzVrxNLw40IsfBd/giphy.gif]

--

--

Inquisitive | Senior Software Engineer @ WSO2

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store