Project

General

Profile

Actions

Bug #5178

closed

Users API requires parameters to be wrapped

Added by Thomas McKay about 10 years ago. Updated almost 6 years ago.

Status:
Closed
Priority:
High
Assignee:
Category:
API
Target version:
Difficulty:
Triaged:
Fixed in Releases:
Found in Releases:

Description

Cloned from https://bugzilla.redhat.com/show_bug.cgi?id=1087372
Description of problem:
Calling
@api = ApipieBindings::API.new({
:uri => HammerCLI::Settings.get(:foreman, :host),
:username => HammerCLI::Settings.get(:foreman, :username),
:password => HammerCLI::Settings.get(:foreman, :password),
:api_version => 2
})
@api.resource(entity_type).call(:create, entity_hash)

expects different level of hash encapsulation for different entity_types:

  • for entity_type :organizations :
    @api.resource(:organizations).call(:create, entity_hash)
    the entity_hash is expected to be a simple hash of organization attributes {:description=>"Imported 'Red Hat IT' organization from Red Hat Satellite 5", :name=>"Red Hat IT"}
  • for entity_type :users :
    @api.resource(:users).call(:create, entity_hash)
    the entity_hash is expected to be a simple hash of user attributes embedded/wrapped into a extra higher level hash with a single :user key: {:user => user_hash} {:user=>{:location_ids=>[], :firstname=>"another", :role_ids=>[], :lastname=>"another", :login=>"another", :mail=>"root@localhost", :auth_source_id=>1, :organization_ids=>[5], :password=>"another_gfolvwxr"}}

Similarly the return values of these API calls are not consistent:

  • when creating an organization, the return value is an organization hash embedded in a higher level hash with one "organization" key {"organization" => organization_hash} {"organization"=>{"apply_info_task_id"=>nil, "updated_at"=>"2014-04-14T09:21:50Z", "description"=>"Imported 'Red Hat IT' organization from Red Hat Satellite 5", "default_info"=>{"system"=>[], "distributor"=>[]}, "id"=>2, "deletion_task_id"=>nil, "owner_auto_attach_all_systems_task_id"=>nil, "ancestry"=>nil, "created_at"=>"2014-04-14T09:21:49Z", "service_level"=>nil, "title"=>"Red Hat IT", "name"=>"Red Hat IT", "label"=>"Red_Hat_IT", "ignore_types"=>[], "service_levels"=>[]}}
  • when creating a new user, the API return value is a simple user_hash. {"locations"=>[], "lastname"=>"another", "firstname"=>"another", "roles"=>[{"name"=>"Anonymous", "id"=>8}], "updated_at"=>"2014-04-14T09:26:32Z", "admin"=>nil, "last_login_on"=>nil, "usergroups"=>[], "organizations"=>[{"title"=>"Red Hat IT", "name"=>"Red Hat IT", "id"=>5}], "created_at"=>"2014-04-14T09:26:32Z", "mail"=>"root@localhost", "id"=>4, "auth_source_id"=>1, "auth_source_name"=>"Internal", "login"=>"another", "auth_source_internal"=>{"type"=>"AuthSourceInternal", "name"=>"Internal", "id"=>1}}

Version-Release number of selected component (if applicable):
sat6-Satellite-6.0.3-RHEL-6-20140404.0-Satellite-x86_64-dvd1.iso

This is a request to unify to API parameter and return value encapsulation.


Related issues 4 (0 open4 closed)

Related to Foreman - Bug #6248: Some JSON responses are still nested in a root nodeClosedJoseph Magen06/17/2014Actions
Related to Foreman - Bug #4181: V2: Api docs in foreman should not specify a root node for POST/PUTRejectedJoseph Magen01/24/2014Actions
Related to Foreman - Bug #6674: Can't create a host via the API because params aren't correctly wrappedDuplicateThomas McKay07/17/2014Actions
Related to Foreman - Bug #6696: API v2 - specify the key in which the parameters would be wrapped rather than passing model nameClosedJoseph Magen07/20/2014Actions
Actions #1

Updated by Thomas McKay about 10 years ago

  • Project changed from Katello to Foreman
  • Category set to API

Incorrectly put in katello project; fix is predominantly required in foreman to bring apipie params into compliance with documented style.

Actions #2

Updated by Adam Price about 10 years ago

  • Priority changed from Normal to High
Actions #3

Updated by David Davis about 10 years ago

The first part of this bug (requiring params be nested) is the same as http://projects.theforeman.org/issues/4181.

The second part of this bug is a new issue.

Actions #4

Updated by Joseph Magen almost 10 years ago

  • Status changed from New to Ready For Testing
  • Assignee set to Joseph Magen

PR 4181 is docs only, so it's not related to this.

This bug was caused by password [filtered] attributes not being wrapped, so POST /users didn't work unless the Hash was wrapped. Now it should work.

https://github.com/theforeman/foreman/pull/1441

Actions #5

Updated by Joseph Magen almost 10 years ago

  • Target version set to 1.8.3
Actions #6

Updated by Anonymous almost 10 years ago

  • Target version changed from 1.8.3 to 1.8.2
Actions #8

Updated by Dominic Cleal almost 10 years ago

  • Subject changed from unify API parameters and return values to Users API requires parameters to be wrapped

Return value of the taxonomy controllers has been moved to #5580, it's an unrelated issue.

Actions #9

Updated by Bryan Kearney almost 10 years ago

  • Status changed from Ready For Testing to Closed

Downstream bug is fixed, closing this.

Actions #10

Updated by Dominic Cleal almost 10 years ago

  • Status changed from Closed to Ready For Testing

Please don't close issues that have open pull requests, irrespective of bugzilla states.

Actions #11

Updated by Anonymous almost 10 years ago

  • Target version changed from 1.8.2 to 1.8.1
Actions #12

Updated by Dominic Cleal almost 10 years ago

  • Related to Bug #6248: Some JSON responses are still nested in a root node added
Actions #13

Updated by Dominic Cleal almost 10 years ago

  • Related to Bug #4181: V2: Api docs in foreman should not specify a root node for POST/PUT added
Actions #14

Updated by Anonymous almost 10 years ago

  • Target version changed from 1.8.1 to 1.8.0
Actions #15

Updated by The Foreman Bot almost 10 years ago

  • Pull request https://github.com/theforeman/foreman/pull/1441 added
Actions #16

Updated by Joseph Magen almost 10 years ago

  • Status changed from Ready For Testing to Closed
  • % Done changed from 0 to 100
Actions #17

Updated by Dominic Cleal over 9 years ago

  • translation missing: en.field_release set to 10
Actions #18

Updated by Dominic Cleal over 9 years ago

  • Related to Bug #6674: Can't create a host via the API because params aren't correctly wrapped added
Actions #19

Updated by Dominic Cleal over 9 years ago

  • Related to Bug #6696: API v2 - specify the key in which the parameters would be wrapped rather than passing model name added
Actions

Also available in: Atom PDF