Bootstrap FreeKB - OpenShift - List groups using REST API
OpenShift - List groups using REST API

Updated:   |  OpenShift articles

This assumes you have used the REST API to obtain an OAuth bearer token. Let's say the bearer token is sha256~0Rs__hPuXmBD3TJTXNDisC7wRBN-nrFnYTxgdBrFT-U.

Here is how you would list every group. The oc config view or oc get apiserver commands can be used to display the API Server URL (api.openshift.example.com in this example).

curl
--insecure
--request GET
--header "Accept: application/json"
--header "Authorization: Bearer sha256~0Rs__hPuXmBD3TJTXNDisC7wRBN-nrFnYTxgdBrFT-U"
--url "https://api.openshift.example.com:6443/apis/user.openshift.io/v1/groups"

 

Or, to GET a specific group.

curl
--insecure
--request GET
--header "Accept: application/json"
--header "Authorization: Bearer sha256~0Rs__hPuXmBD3TJTXNDisC7wRBN-nrFnYTxgdBrFT-U"
--url "https://api.openshift.example.com:6443/apis/user.openshift.io/v1/groups/my-group"

 

Something like this should be returned.

{
  [
    {
      "metadata": {
        "name": "my-group",
        "uid": "613c1af0-bf13-42ec-be5b-f6f0c889fd12",
        "resourceVersion": "1050548501",
        "creationTimestamp": "2022-01-07T16:15:57Z",
        "managedFields": [
          {
            "manager": "python-requests",
            "operation": "Update",
            "apiVersion": "user.openshift.io/v1",
            "time": "2022-01-07T16:15:57Z",
            "fieldsType": "FieldsV1",
            "fieldsV1": {
              "f:users": {}
            }
          }
        ]
      },
      "users": [
        "john.doe",
        "jane.doe"
      ]
    }
  ]
}



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 dd27c6 in the box below so that we can be sure you are a human.