Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add access count to /roles/ and /roles/<uuid>/ endpoints #197

Conversation

coderbydesign
Copy link
Contributor

This adds an accessCount field to the /roles/ and /roles/<uuid>/ endpoints, to show the number of permission/access objects contained within each role.

To do so, we're annotating the base query for roles with the access count, and including it as a read-only value in the serializers.

New Response for /roles/

{
  "meta": {
    "count": 2508,
    "limit": 1,
    "offset": 0
  },
  "links": {
    "first": "/api/rbac/v1/roles/?limit=1&offset=0",
    "next": "/api/rbac/v1/roles/?limit=1&offset=1",
    "previous": null,
    "last": "/api/rbac/v1/roles/?limit=1&offset=2507"
  },
  "data": [
    {
      "uuid": "3ecac858-4f48-4393-a26b-914ba73477aa",
      "name": "Ansible Automation Access",
      "description": "An all access role which grants read and write permissions.",
      "created": "2020-01-31T16:44:43.919593Z",
      "modified": "2020-01-31T16:44:43.946095Z",
      "policyCount": 1,
      "accessCount": 2,
      "applications": [
        "inventory",
        "ansible-automation"
      ],
      "system": true,
      "platform_default": true
    }
  ]
}

Screen Shot 2020-02-04 at 12 41 25 PM

New Response for /roles/<uuid>/

{
  "uuid": "3ecac858-4f48-4393-a26b-914ba73477aa",
  "name": "Ansible Automation Access",
  "description": "An all access role which grants read and write permissions.",
  "access": [
    {
      "permission": "inventory:*:*",
      "resourceDefinitions": []
    },
    {
      "permission": "ansible-automation:*:*",
      "resourceDefinitions": []
    }
  ],
  "policyCount": 1,
  "accessCount": 2,
  "applications": null,
  "system": true,
  "platform_default": true,
  "created": "2020-01-31T16:44:43.919593Z",
  "modified": "2020-01-31T16:44:43.946095Z"
}

Screen Shot 2020-02-04 at 12 41 40 PM

Copy link
Contributor

@wcmitchell wcmitchell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@coderbydesign coderbydesign merged commit a55b610 into RedHatInsights:master Feb 5, 2020
@coderbydesign coderbydesign deleted the add-permissions-count-to-roles-endpoint branch February 5, 2020 20:50
lpichler pushed a commit that referenced this pull request Nov 8, 2023
Add OCP Advisor roles and perms for ci env
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants