Bug 1275960

Summary: Inconsistent and Duplicate API for attaching subscriptions to activation keys
Product: Red Hat Satellite Reporter: Peter Vreman <peter.vreman>
Component: APIAssignee: satellite6-bugs <satellite6-bugs>
Status: CLOSED CURRENTRELEASE QA Contact: Jitendra Yejare <jyejare>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 6.1.3CC: xdmoon
Target Milestone: UnspecifiedKeywords: Triaged
Target Release: Unused   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-12-01 13:00:18 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:
Bug Depends On:    
Bug Blocks: 1122832    

Description Peter Vreman 2015-10-28 08:15:04 UTC
Description of problem:
The API is inconsistent regrading attaching subscriptions:
 1. add_subscriptions in the acitvation keys controller vs the susbcription controller that is generic
 2. activation keys controller has add_susbcriptions and remove_subscriptions, but the systems does not have it
 3. The wording Add vs Attach

    api :POST, "/systems/:system_id/subscriptions", N_("Add a subscription to a system"), :deprecated => true
    api :POST, "/activation_keys/:activation_key_id/subscriptions", N_("Add a subscription to an activation key")


    api :DELETE, "/systems/:system_id/subscriptions/:id", N_("Unattach a subscription"), :deprecated => true
    api :DELETE, "/activation_keys/:activation_key_id/subscriptions/:id", N_("Unattach a subscription")


vs.

    api :PUT, "/activation_keys/:id/add_subscriptions", N_("Attach a subscription")
    api :PUT, "/activation_keys/:id/remove_subscriptions", N_("Unattach a subscription")


Proposal:
- Remove the add_subscriptions and remove_subscriptions from the activation keys controller. The add_ and remove_ prefixes are inconsistent with other parts of the API. Secondly yt is not available in the systems controller. Third it is not really RESTful with having PUT for adding and deleting
- Change the wording of Add to Attach in the subscriptions controller


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


How reproducible:


Steps to Reproduce:
1.
2.
3.

Actual results:


Expected results:
Consistent API for adding subscriptions, see proposal above


Additional info:

Comment 1 Peter Vreman 2015-10-28 15:36:55 UTC
Another issue with the DELETE, in the apidoc is lists the the :id shall be part of the URL _and_ it shall also be provided in a subscriptions[] array. this is duplicate information.


DELETE /katello/api/systems/:system_id/subscriptions/:id DEPRECATED
Unattach a subscription
DELETE /katello/api/activation_keys/:activation_key_id/subscriptions/:id
Unattach a subscription
Params
Param name 	Description
id
optional 	

Subscription ID

Value: String
system_id
optional 	

UUID of the system

Value: String
activation_key_id
optional 	

activation key ID

Value: String
subscriptions
optional 	

Array of subscriptions to add

Value: Must be an Array of nested elements
subscriptions[id]
optional 	

Subscription Pool uuid

Value: String

Comment 2 Bryan Kearney 2016-07-26 19:10:46 UTC
Moving 6.2 bugs out to sat-backlog.

Comment 3 Peter Vreman 2016-12-01 13:00:18 UTC
Closing this is now consistent in Sat6.2 with the non-deprecated API calls:

PUT /katello/api/activation_keys/:id/add_subscriptions
PUT /katello/api/activation_keys/:id/remove_subscriptions

PUT /api/hosts/:host_id/subscriptions/remove_subscriptions 	
PUT /api/hosts/:host_id/subscriptions/add_subscriptions