Bug 1957070

Summary: [RFE] add 'name' for the role filter in API
Product: Red Hat Satellite Reporter: Ashfaqur Rahaman <arahaman>
Component: Users & RolesAssignee: Ondřej Ezr <oezr>
Status: CLOSED ERRATA QA Contact: sganar
Severity: low Docs Contact:
Priority: low    
Version: 6.8.0CC: ehelms, mhulan, mmccune, oezr, pcreech, sganar, sshtein
Target Milestone: 6.11.0Keywords: FutureFeature, Triaged
Target Release: Unused   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2022-07-05 14:28:51 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

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