Bug 1957070 - [RFE] add 'name' for the role filter in API
Summary: [RFE] add 'name' for the role filter in API
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Satellite
Classification: Red Hat
Component: Users & Roles
Version: 6.8.0
Hardware: Unspecified
OS: Unspecified
low
low
Target Milestone: 6.11.0
Assignee: Ondřej Ezr
QA Contact: sganar
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2021-05-05 00:53 UTC by Ashfaqur Rahaman
Modified: 2023-09-18 00:26 UTC (History)
7 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2022-07-05 14:28:51 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Foreman Issue Tracker 32650 0 Normal Closed Add 'resource_type' for the role filter in API 2021-07-22 18:34:48 UTC
Red Hat Product Errata RHSA-2022:5498 0 None None None 2022-07-05 14:29:21 UTC

Description Ashfaqur Rahaman 2021-05-05 00:53:41 UTC
Description of problem:

Currently API result for role filter only returns ID. as a FutureFeature, can we add "Name" field along with the ID. 

Version-Release number of selected component (if applicable):
6.8 

How reproducible:
100%

Description: 

Currently the roles API only returns the filter ID.

~~~~~~
# curl -vvv -H 'Content-Type: application/json' -X GET https://user:password@satellite.com/api/roles/11

{"builtin":0,"cloned_from_id":28,"name":"Group Admin","id":10,"description":"","origin":null,"filters":[{"id":142},{"id":150},{"id":111},{"id":151},{"id":154},{"id":155},{"id":156},{"id":157},{"id":158},{"id":159},{"id":160},{"id":161},{"id":162},{"id":161},{"id":164},{"id":165},{"id":166},{"id":167},{"id":168},{"id":169},{"id":170},{"id":171},{"id":172},{"id":171},{"id":541},{"id":544}],"locations":[{"id":8,"name":"city","title":"Brisbane/City ","description":""}],"organizations":[{"id":1,"name":"abcd","title":"abcd","description":""}]}
~~~~~~

The filters property within the role resource is expected to be represented in the same structure as locations and organizations.

Typically the apipie bindings returns a tuple for a resource reference that includes an id, name and (optional) title.  The debug output listed below is for a simple roles lookup, where the organizations and locations properties are returned in the expected form, whereas the filters property only returns the id.

```
I, [2021-04-26T12:09:11.220718 #10555]  INFO -- : GET /api/roles/10
D, [2021-04-26T12:09:11.220757 #10555] DEBUG -- : Params: {}
D, [2021-04-26T12:09:11.220772 #10555] DEBUG -- : Headers: {:params=>{}}
D, [2021-04-26T12:09:11.220802 #10555] DEBUG -- : Using authenticator: ApipieBindings::Authenticators::BasicAuth
D, [2021-04-26T12:09:19.405679 #10555] DEBUG -- : Response: {"builtin"=>0, "cloned_from_id"=>28, "name"=>"Group Admin", "id"=>10, "description"=>"", "origin"=>nil, "filters"=>[{"id"=>149}, {"id"=>150}, {"id"=>151}, {"id"=>151}, {"id"=>154}, {"id"=>155}, {"id"=>156}, {"id"=>157}, {"id"=>158}, {"id"=>159}, {"id"=>160}, {"id"=>161}, {"id"=>162}, {"id"=>161}, {"id"=>164}, {"id"=>165}, {"id"=>166}, {"id"=>167}, {"id"=>168}, {"id"=>169}, {"id"=>170}, {"id"=>171}, {"id"=>172}, {"id"=>171}, {"id"=>541}, {"id"=>544}], "locations"=>[{"id"=>8, "name"=>"CTI", "title"=>"Victoria/City West/CTI", "description"=>""}], "organizations"=>[{"id"=>1, "name"=>"abcd", "title"=>"abcd", "description"=>""}]}
```
The design pattern for nearly every other field is in line with the locations and organizations fields:

"locations"=>[{"id"=>1, "name"=>"City", "title"=>"Brisbane", "description"=>""}], "organizations"=>[{"id"=>1, "name"=>"abcd", "title"=>"abcd", "description"=>""}]}

As a Future Feature, returning the name of the filter along side the id would then be consistent with the other attributes as below :  

"filters"=>[{"id"=>149, "name"=>"Viewer" }, {"id"=>150, "name"=>"Manager"},....]

Comment 1 Ondřej Ezr 2021-05-23 12:31:46 UTC
Created redmine issue https://projects.theforeman.org/issues/32650 from this bug

Comment 3 Bryan Kearney 2021-05-28 10:21:05 UTC
Upstream bug assigned to oezr

Comment 4 Bryan Kearney 2021-05-28 10:21:09 UTC
Upstream bug assigned to oezr

Comment 8 Bryan Kearney 2021-06-10 16:05:01 UTC
Moving this bug to POST for triage into Satellite since the upstream issue https://projects.theforeman.org/issues/32650 has been resolved.

Comment 9 sganar 2022-03-10 09:15:58 UTC
Verified.

Tested on Satellite 7.0

Steps followed: 
1.curl -vvv -H 'Content-Type: application/json' -X GET https://user:password@satellite.com/api/roles/11

Observation: 
key "resource_type" has been added to "filters"

{
	"builtin": 0,
	"cloned_from_id": null,
	"name": "Auditor",
	"id": 11,
	"description": "Role granting permission to view only the Audit log and nothing else.",
	"origin": "foreman",
	"filters": [
		{
			"id": 141,
			"resource_type": "Audit"
		}
	],
	"locations": [],
	"organizations": []
}

Comment 12 errata-xmlrpc 2022-07-05 14:28:51 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (Moderate: Satellite 6.11 Release), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHSA-2022:5498

Comment 13 Red Hat Bugzilla 2023-09-18 00:26:24 UTC
The needinfo request[s] on this closed bug have been removed as they have been unresolved for 120 days


Note You need to log in before you can comment on or make changes to this bug.