Passing an array to host_parameters_attributes api

I need help with updating a host with a new parameter, so far I have this:

curl -s -H "Accept:application/json" -H "Content-Type: application/json"
-k -u $USER:$PASS -X PUT \

'{"host":{"host_parameters_attributes":[{"name":"ntp_server"},{"value":"server.example.com"}]}}'

$FOREMAN_URL/api/hosts/$NAME

But I'm got getting the expected result, here's the log output.

Started PUT "/api/hosts/server123.example.com" for 10.120.134.134 at Wed
Jan 09 18:37:51 -0500 2013
Processing by Api::V1::HostsController#update as JSON
Parameters: {"id"=>"server123.example.com"}
Missing parameter host (Apipie::ParamMissing)
Rendered api/v1/errors/param_error.json.rabl (1.5ms)
Completed 400 Bad Request in 27ms (Views: 2.7ms | ActiveRecord: 8.4ms)

thanks

> I need help with updating a host with a new parameter, so far I have this:
>
> curl -s -H "Accept:application/json" -H "Content-Type: application/json"
> -k -u $USER:$PASS -X PUT
>
> '{"host":{"host_parameters_attributes":[{"name":"ntp_server"},{"value":"
> server.example.com"}]}}'
> $FOREMAN_URL/api/hosts/$NAME
>
> But I'm got getting the expected result, here's the log output.
>
> Started PUT "/api/hosts/server123.example.com" for 10.120.134.134 at Wed
> Jan 09 18:37:51 -0500 2013
> Processing by Api::V1::HostsController#update as JSON
> Parameters: {"id"=>"server123.example.com"}
> Missing parameter host (Apipie::ParamMissing)
> Rendered api/v1/errors/param_error.json.rabl (1.5ms)
> Completed 400 Bad Request in 27ms (Views: 2.7ms | ActiveRecord: 8.4ms)
>
>
see
https://groups.google.com/group/foreman-users/browse_thread/thread/2dbfdfb0d7502c3b/1a6f10a18f22e5ed?lnk=gst&q=api#1a6f10a18f22e5ed

as a side note, I'm now working on mergeing the new api v2 name space for
parameters, which would make simple crud such as

/host/server123.example.com/parameters <GET|POST/DELETE…>

Ohad

··· On Thu, Jan 10, 2013 at 1:41 AM, Rodrique Heron wrote:

thanks


You received this message because you are subscribed to the Google Groups
"Foreman users" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/foreman-users/-/1JklmMn1PJ0J.
To post to this group, send email to foreman-users@googlegroups.com.
To unsubscribe from this group, send email to
foreman-users+unsubscribe@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/foreman-users?hl=en.

Thanks for the Ruby script.

When is version two of the api expected? I'm using 1.1RC1 and have
generated the API doc.

··· On Thursday, January 10, 2013 3:33:31 AM UTC-5, ohad wrote: > > > > > On Thu, Jan 10, 2013 at 1:41 AM, Rodrique Heron <swy...@gmail.com > > wrote: > >> I need help with updating a host with a new parameter, so far I have this: >> >> curl -s -H "Accept:application/json" -H "Content-Type: application/json" \ >> -k -u $USER:$PASS -X PUT \ >> >> '{"host":{"host_parameters_attributes":[{"name":"ntp_server"},{"value":" >> server.example.com"}]}}' \ >> $FOREMAN_URL/api/hosts/$NAME >> >> But I'm got getting the expected result, here's the log output. >> >> Started PUT "/api/hosts/server123.example.com" for 10.120.134.134 at Wed >> Jan 09 18:37:51 -0500 2013 >> Processing by Api::V1::HostsController#update as JSON >> Parameters: {"id"=>"server123.example.com"} >> Missing parameter host (Apipie::ParamMissing) >> Rendered api/v1/errors/param_error.json.rabl (1.5ms) >> Completed 400 Bad Request in 27ms (Views: 2.7ms | ActiveRecord: 8.4ms) >> >> > see > https://groups.google.com/group/foreman-users/browse_thread/thread/2dbfdfb0d7502c3b/1a6f10a18f22e5ed?lnk=gst&q=api#1a6f10a18f22e5ed > > as a side note, I'm now working on mergeing the new api v2 name space for > parameters, which would make simple crud such as > > /host/server123.example.com/parameters > > Ohad > >> thanks >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Foreman users" group. >> To view this discussion on the web visit >> https://groups.google.com/d/msg/foreman-users/-/1JklmMn1PJ0J. >> To post to this group, send email to forema...@googlegroups.com >> . >> To unsubscribe from this group, send email to >> foreman-user...@googlegroups.com . >> For more options, visit this group at >> http://groups.google.com/group/foreman-users?hl=en. >> > >

The Foreman API v2 now supports CRUD operations on nested parameters for hosts, hostgroups, domains, and operatingsystems

GET /api/domains/:id/parameters
POST /api/hosts/:id/parameters
PUT /api/hostgroups/:id/parameters/:id
DELETE /api/operatingsystems/:id/parameters/:id

Some examples with curl

  1. GET list of parameters for domain.id = 6

curl -u admin:secret -H "Accept:application/json,version=2" http://0.0.0.0:3000/api/domains/6/parameters

  1. CREATE parameter for host.id = 541

curl -u admin:secret -H "Content-Type:application/json" -H "Accept:application/json,version=2" -X POST -d "{&quot;parameter&quot;:{&quot;name&quot;:&quot;sss&quot;,&quot;value&quot;:&quot;111&quot;}}" http://0.0.0.0:3000/api/hosts/541/parameters

  1. UPDATE parameter.id = 98 for hostgroup.id = 23

curl -u admin:secret -H "Content-Type:application/json" -H "Accept:application/json,version=2" -X PUT -d "{&quot;parameter&quot;:{&quot;value&quot;:&quot;333&quot;}}" http://0.0.0.0:3000/api/hostgroups/23/parameters/98

  1. DELETE parameter.id = 87 for operatingsystem.id = 16

curl -u admin:secret -H "Accept:application/json,version=2" -X DELETE http://0.0.0.0:3000/api/operatingsystems/16/parameters/87

The next step is to add similar functionality to the API v2 for nested puppetclasses and lookup_keys

Regards,

Joseph

··· ----- Original Message ----- From: "Rodrique Heron" To: foreman-users@googlegroups.com Sent: Thursday, January 10, 2013 3:35:34 PM Subject: Re: [foreman-users] Passing an array to host_parameters_attributes api

Thanks for the Ruby script.

When is version two of the api expected? I’m using 1.1RC1 and have
generated the API doc.

On Thursday, January 10, 2013 3:33:31 AM UTC-5, ohad wrote:

On Thu, Jan 10, 2013 at 1:41 AM, Rodrique Heron <swy...@gmail.com<javascript:> > > wrote:

I need help with updating a host with a new parameter, so far I have this:

curl -s -H “Accept:application/json” -H “Content-Type: application/json”
-k -u $USER:$PASS -X PUT \

‘{“host”:{“host_parameters_attributes”:[{“name”:“ntp_server”},{“value”:“
server.example.com”}]}}’
$FOREMAN_URL/api/hosts/$NAME

But I’m got getting the expected result, here’s the log output.

Started PUT “/api/hosts/server123.example.com” for 10.120.134.134 at Wed
Jan 09 18:37:51 -0500 2013
Processing by Api::V1::HostsController#update as JSON
Parameters: {“id”=>“server123.example.com”}
Missing parameter host (Apipie::ParamMissing)
Rendered api/v1/errors/param_error.json.rabl (1.5ms)
Completed 400 Bad Request in 27ms (Views: 2.7ms | ActiveRecord: 8.4ms)

see
https://groups.google.com/group/foreman-users/browse_thread/thread/2dbfdfb0d7502c3b/1a6f10a18f22e5ed?lnk=gst&q=api#1a6f10a18f22e5ed

as a side note, I’m now working on mergeing the new api v2 name space for
parameters, which would make simple crud such as

/host/server123.example.com/parameters <GET|POST/DELETE…>

Ohad

thanks


You received this message because you are subscribed to the Google Groups
"Foreman users" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/foreman-users/-/1JklmMn1PJ0J.
To post to this group, send email to forema...@googlegroups.com<javascript:>
.
To unsubscribe from this group, send email to
foreman-user...@googlegroups.com <javascript:>.
For more options, visit this group at
http://groups.google.com/group/foreman-users?hl=en.


You received this message because you are subscribed to the Google Groups “Foreman users” group.
To view this discussion on the web visit https://groups.google.com/d/msg/foreman-users/-/04Wt7juDh3sJ.
To post to this group, send email to foreman-users@googlegroups.com.
To unsubscribe from this group, send email to foreman-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/foreman-users?hl=en.