Bug 1398637 - API: operatingsystems_ids options for architectures in PUT/POST does not work at all
Summary: API: operatingsystems_ids options for architectures in PUT/POST does not work...
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Red Hat Satellite
Classification: Red Hat
Component: API
Version: 6.3.0
Hardware: Unspecified
OS: Unspecified
medium
medium vote
Target Milestone: Unspecified
Assignee: satellite6-bugs
QA Contact: Roman Plevka
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2016-11-25 12:55 UTC by Roman Plevka
Modified: 2017-04-25 16:21 UTC (History)
4 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2016-11-30 10:14:30 UTC
Target Upstream Version:


Attachments (Terms of Use)

Description Roman Plevka 2016-11-25 12:55:51 UTC
Description of problem:
operatingsystems_ids: [list_of_ids] has no effects in /architectures API endpoint and it looks there's actually a no way of associating OSes to arch via API:

$ curl -sku admin:changeme https://sat63.com/api/v2/operatingsystems/1 | jq
{
  "description": "RHEL Server 7.2",
  "major": "7",
...}

$ curl -sku admin:changeme -X PUT -H 'content-type: application/json' -d '{"name": "rplevka_arch",  "operatingsystem_ids": [1]}' https://sat63.com/api/v2/architectures/15 | jq
{
  "created_at": "2016-11-25 12:45:58 UTC",
  "updated_at": "2016-11-25 12:45:58 UTC",
  "name": "rplevka_arch",
  "id": 15,
  "operatingsystems": [],
  "images": []
}
$ curl -sku admin:changeme -X PUT -H 'content-type: application/json' -d '{"name": "rplevka_arch",  "operatingsystem_ids": [1]}' https://sat63.com/api/v2/architectures/15 | jq
{
  "created_at": "2016-11-25 12:45:58 UTC",
  "updated_at": "2016-11-25 12:45:58 UTC",
  "name": "rplevka_arch",
  "id": 15,
  "operatingsystems": [],
  "images": []
}



Version-Release number of selected component (if applicable):
satellite-6.3.0-6.1.beta.el7sat.noarch


Actual results:
operatingsystems not associated

Expected results:
operatingsystems associated

Comment 2 Roman Plevka 2016-11-25 13:07:26 UTC
This seems to be a regression since as this works on the recent 6.2

Comment 3 Marek Hulan 2016-11-28 11:42:46 UTC
I don't think this is a correct way of doing such call. Could you please let me know where you found it? This seems to work fine

    curl -X PUT -H 'content-type: application/json' -d '{"architecture": {"operatingsystem_ids": [1], "name": "i386"}}' https://admin:changeme@sat63.example.tst/api/v2/architectures/2

In Satellite 6.2 API documentation I see example with architectures using wrapped attributes. Also 6.2 live documentation at /apidoc/v2/architectures.html shows the wrapped variant.

You're right it worked in 6.2 and no longer works in 6.3. It seems that there might be some issue with automatic wrapping which was the layer that should unify Katello and Foreman differences. The right solution would be unifying both APIs and introducing new version of API for that.

Comment 5 Roman Plevka 2016-11-29 09:38:45 UTC
Thanks Marek,
It only accepts the hash now.
I've filed this BZ based on our automation results, which does not use the wrapping, so it looks like it relies on it.

Could you investigate on the automatic wrapping? If it is by design, I would update our automation.

thanks

Comment 6 Marek Hulan 2016-11-29 16:34:29 UTC
I'm unable to find what changed this behavior, my guess would be something with strong params. Anyway I don't think we want to support this way. The example I provided in comment 3 should be used. There's an alternative to specify array of identifiers, e.g.

         curl -X PUT -H 'content-type: application/json' -d '{"operatingsystems": [{"name": "CentOS 6.7"}, {"id": 1}], "name": "i386"}' https://admin:changeme@sat63.example.tst/api/v2/architectures/2

but note that the key must be plural form of the resource (operatingsystems), not operatingsystem_ids. Both and id would work. Still, I'd recommend testing the documented way.

I think we can close this BZ.

Comment 7 Roman Plevka 2016-11-30 10:14:30 UTC
@mhulan, thanks for the explanation.
based on the further discussion on irc i'm closing this and removing the test from our automation as no longer supported


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