Bootstrap FreeKB - Kong Enterprise Edition (KongEE) - List workspaces using REST API
Kong Enterprise Edition (KongEE) - List workspaces using REST API


This assumes Kong has been secured with Role Based Access Control (RBAC) and you have created your Kong-Admin-Token. The following curl command can be used to list the endpoints that can be used with the API.

curl --header "Kong-Admin-Token: abc123" --request GET "https://kong.example.com/endpoints"

 

Something like this should be returned. Notice that the /workspaces endpoint can be used.

{
    "data": [
        "/",
        "/acls",
        "/acls/{acls}",
        "/acls/{acls}/consumer",
        "/workspaces",
        "/workspaces/{workspaces}",
        "/workspaces/{workspaces}/meta"
    ]
}

 

The following curl command can be used to list every workspace.

curl --header "Kong-Admin-Token: abc123" --request GET "https://kong.example.com/workspaces"

 

Something like this should be returned.

{
    "data": [
        {
            "comment": null,
            "config": {
                "meta": null,
                "portal": false,
                "portal_access_request_email": null,
                "portal_approved_email": null,
                "portal_auth": null,
                "portal_auth_conf": null,
                "portal_auto_approve": null,
                "portal_cors_origins": null,
                "portal_developer_meta_fields": "[{\"label\":\"Full Name\",\"title\":\"full_name\",\"validator\":{\"required\":true,\"type\":\"string\"}}]",
                "portal_emails_from": null,
                "portal_emails_reply_to": null,
                "portal_invite_email": null,
                "portal_is_legacy": null,
                "portal_reset_email": null,
                "portal_reset_success_email": null,
                "portal_session_conf": null,
                "portal_token_exp": null
            },
            "created_at": 1607443774,
            "id": "649b4959-5046-4862-9e0a-1aa8c14dc82c",
            "meta": {
                "color": null,
                "thumbnail": null
            },
            "name": "foo"
        }
    ]
}

 

Or, a specific workspace can be listed.

curl --header "Kong-Admin-Token: abc123" --request GET "https://kong.example.com/workspaces/foo"

 


100+ results

If you have more than 100 workspaces, the REST API will only return the first 100 workspaces and the output will include offset, like this.

"offset":"WyI2MTQ4ZDU5MC0zNzdhLTQ5MWItYjMxYS1lMTYwYzYwNDgwYTYiXQ"

 

You would then use the offset to return the next 100 workspaces.

curl --header "Kong-Admin-Token: abc123" --request GET "https://kong.example.com/workspaces?offset=WyI2MTQ4ZDU5MC0zNzdhLTQ5MWItYjMxYS1lMTYwYzYwNDgwYTYiXQ"

 




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee



Comments


Add a Comment


Please enter 0e990b in the box below so that we can be sure you are a human.