Root node on PUT and POST requests

It looks like currently the foreman V2 API code uses a root node for PUT/POST requests while the Katello code does not. We'd like to unify that though and either decide whether to use a root node for POST/PUT. I know the v2 spec says no root node but I am not sure if we considered having a root node for just create/update but not show? Is there anybody for or against this?

Thanks.

David

I don't much care whether it's wrapped or not, but the other two factors
that I'd consider are:

  1. the symmetry between no wrapping on the response from GET and the
    PUT/POST is nice.

  2. we're just releasing Foreman 1.4 with APIv2 as experimental, having
    publicised in the release notes about this change to v2 users (of which
    there are many, because it's more functional and new APIs are only added
    there). I don't really want to annoy API users again by reverting it in
    the subsequent release.

··· On 24/01/14 13:52, David Davis wrote: > It looks like currently the foreman V2 API code uses a root node for PUT/POST requests while the Katello code does not. We'd like to unify that though and either decide whether to use a root node for POST/PUT. I know the v2 spec says no root node but I am not sure if we considered having a root node for just create/update but not show? Is there anybody for or against this?


Dominic Cleal
Red Hat Engineering

I still vote for no root node for consistency and for ease of consumption.

Cheers,
Walden

··· ----- Original Message ----- From: "Dominic Cleal" To: foreman-dev@googlegroups.com Sent: Friday, January 24, 2014 9:05:32 AM Subject: Re: [foreman-dev] Root node on PUT and POST requests

On 24/01/14 13:52, David Davis wrote:

It looks like currently the foreman V2 API code uses a root node for PUT/POST requests while the Katello code does not. We’d like to unify that though and either decide whether to use a root node for POST/PUT. I know the v2 spec says no root node but I am not sure if we considered having a root node for just create/update but not show? Is there anybody for or against this?

I don’t much care whether it’s wrapped or not, but the other two factors
that I’d consider are:

  1. the symmetry between no wrapping on the response from GET and the
    PUT/POST is nice.

  2. we’re just releasing Foreman 1.4 with APIv2 as experimental, having
    publicised in the release notes about this change to v2 users (of which
    there are many, because it’s more functional and new APIs are only added
    there). I don’t really want to annoy API users again by reverting it in
    the subsequent release.


Dominic Cleal
Red Hat Engineering


You received this message because you are subscribed to the Google Groups “foreman-dev” group.
To unsubscribe from this group and stop receiving emails from it, send an email to foreman-dev+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

What is there now? Can I GET and the POST the same data? Is the api
today wrapping or not?

– kb

··· On 01/24/2014 09:05 AM, Dominic Cleal wrote: > On 24/01/14 13:52, David Davis wrote: >> It looks like currently the foreman V2 API code uses a root node for PUT/POST requests while the Katello code does not. We'd like to unify that though and either decide whether to use a root node for POST/PUT. I know the v2 spec says no root node but I am not sure if we considered having a root node for just create/update but not show? Is there anybody for or against this? > > I don't much care whether it's wrapped or not, but the other two factors > that I'd consider are: > > 1. the symmetry between no wrapping on the response from GET and the > PUT/POST is nice. > > 2. we're just releasing Foreman 1.4 with APIv2 as experimental, having > publicised in the release notes about this change to v2 users (of which > there are many, because it's more functional and new APIs are only added > there). I don't really want to annoy API users again by reverting it in > the subsequent release. >

Here's the api doc so you can see for yourself (Foreman) but to summarize, GET requests have no root node, but POST and PUT requests do in foreman. In Katello, there are no root nodes for GET/POST/PUT.

If you're submitting json, then you can POST/PUT without a root node as wrap_parameters will catch it. However, if you submit form data (as hammer is doing) then wrap_parameters will not build the root node and it'll fail (at least in Katello).

David

··· ----- Original Message ----- > From: "Bryan Kearney" > To: foreman-dev@googlegroups.com > Sent: Friday, January 24, 2014 9:12:34 AM > Subject: Re: [foreman-dev] Root node on PUT and POST requests > > On 01/24/2014 09:05 AM, Dominic Cleal wrote: > > On 24/01/14 13:52, David Davis wrote: > >> It looks like currently the foreman V2 API code uses a root node for > >> PUT/POST requests while the Katello code does not. We'd like to unify > >> that though and either decide whether to use a root node for POST/PUT. I > >> know the v2 spec says no root node but I am not sure if we considered > >> having a root node for just create/update but not show? Is there anybody > >> for or against this? > > > > I don't much care whether it's wrapped or not, but the other two factors > > that I'd consider are: > > > > 1. the symmetry between no wrapping on the response from GET and the > > PUT/POST is nice. > > > > 2. we're just releasing Foreman 1.4 with APIv2 as experimental, having > > publicised in the release notes about this change to v2 users (of which > > there are many, because it's more functional and new APIs are only added > > there). I don't really want to annoy API users again by reverting it in > > the subsequent release. > > > > What is there now? Can I GET and the POST the same data? Is the api > today wrapping or not? > > -- kb > > > -- > You received this message because you are subscribed to the Google Groups > "foreman-dev" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to foreman-dev+unsubscribe@googlegroups.com. > For more options, visit https://groups.google.com/groups/opt_out. >

Today you can GET and POST the same data. It's unwrapped for JSON, but
wrapped for form data (which I'd consider to be a bug, #4180).

The specification says it's unwrapped, the Foreman apidoc says it's
wrapped (also a bug IMO), the Katello apidoc says it's unwrapped.

··· On 24/01/14 14:12, Bryan Kearney wrote: > On 01/24/2014 09:05 AM, Dominic Cleal wrote: >> On 24/01/14 13:52, David Davis wrote: >>> It looks like currently the foreman V2 API code uses a root node for PUT/POST requests while the Katello code does not. We'd like to unify that though and either decide whether to use a root node for POST/PUT. I know the v2 spec says no root node but I am not sure if we considered having a root node for just create/update but not show? Is there anybody for or against this? >> >> I don't much care whether it's wrapped or not, but the other two factors >> that I'd consider are: >> >> 1. the symmetry between no wrapping on the response from GET and the >> PUT/POST is nice. >> >> 2. we're just releasing Foreman 1.4 with APIv2 as experimental, having >> publicised in the release notes about this change to v2 users (of which >> there are many, because it's more functional and new APIs are only added >> there). I don't really want to annoy API users again by reverting it in >> the subsequent release. >> > > What is there now? Can I GET and the POST the same data? Is the api > today wrapping or not?


Dominic Cleal
Red Hat Engineering

If a user is doing a standard create/update POST/PUT of a record with NO associated relationships, then with OR without a root node will work in Foreman.

The issue is is when there are relationships. It depends on whether the associations are passed at child nodes or as an array of [ids] using the "magic" setter field in Rails field_name_ids. I started a thread last month with subject:

[foreman-dev] API v2 adding/removing associations: to wrap parameters or not?

Joseph

··· ----- Original Message ----- > From: "David Davis" > To: foreman-dev@googlegroups.com > Sent: Friday, January 24, 2014 4:16:42 PM > Subject: Re: [foreman-dev] Root node on PUT and POST requests > > Here's the api doc so you can see for yourself > (http://theforeman.org/api_v2.html) but to summarize, GET requests have no > root node, but POST and PUT requests do in foreman. In Katello, there are no > root nodes for GET/POST/PUT. > > If you're submitting json, then you can POST/PUT without a root node as > wrap_parameters will catch it. However, if you submit form data (as hammer > is doing) then wrap_parameters will not build the root node and it'll fail > (at least in Katello). > > David > > ----- Original Message ----- > > From: "Bryan Kearney" > > To: foreman-dev@googlegroups.com > > Sent: Friday, January 24, 2014 9:12:34 AM > > Subject: Re: [foreman-dev] Root node on PUT and POST requests > > > > On 01/24/2014 09:05 AM, Dominic Cleal wrote: > > > On 24/01/14 13:52, David Davis wrote: > > >> It looks like currently the foreman V2 API code uses a root node for > > >> PUT/POST requests while the Katello code does not. We'd like to unify > > >> that though and either decide whether to use a root node for POST/PUT. I > > >> know the v2 spec says no root node but I am not sure if we considered > > >> having a root node for just create/update but not show? Is there anybody > > >> for or against this? > > > > > > I don't much care whether it's wrapped or not, but the other two factors > > > that I'd consider are: > > > > > > 1. the symmetry between no wrapping on the response from GET and the > > > PUT/POST is nice. > > > > > > 2. we're just releasing Foreman 1.4 with APIv2 as experimental, having > > > publicised in the release notes about this change to v2 users (of which > > > there are many, because it's more functional and new APIs are only added > > > there). I don't really want to annoy API users again by reverting it in > > > the subsequent release. > > > > > > > What is there now? Can I GET and the POST the same data? Is the api > > today wrapping or not? > > > > -- kb > > > > > > -- > > You received this message because you are subscribed to the Google Groups > > "foreman-dev" group. > > To unsubscribe from this group and stop receiving emails from it, send an > > email to foreman-dev+unsubscribe@googlegroups.com. > > For more options, visit https://groups.google.com/groups/opt_out. > > > > -- > You received this message because you are subscribed to the Google Groups > "foreman-dev" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to foreman-dev+unsubscribe@googlegroups.com. > For more options, visit https://groups.google.com/groups/opt_out. >

ok… so we are saying converge on unwrapped?

– bk

··· On 01/24/2014 09:15 AM, Dominic Cleal wrote: > On 24/01/14 14:12, Bryan Kearney wrote: >> On 01/24/2014 09:05 AM, Dominic Cleal wrote: >>> On 24/01/14 13:52, David Davis wrote: >>>> It looks like currently the foreman V2 API code uses a root node for PUT/POST requests while the Katello code does not. We'd like to unify that though and either decide whether to use a root node for POST/PUT. I know the v2 spec says no root node but I am not sure if we considered having a root node for just create/update but not show? Is there anybody for or against this? >>> >>> I don't much care whether it's wrapped or not, but the other two factors >>> that I'd consider are: >>> >>> 1. the symmetry between no wrapping on the response from GET and the >>> PUT/POST is nice. >>> >>> 2. we're just releasing Foreman 1.4 with APIv2 as experimental, having >>> publicised in the release notes about this change to v2 users (of which >>> there are many, because it's more functional and new APIs are only added >>> there). I don't really want to annoy API users again by reverting it in >>> the subsequent release. >>> >> >> What is there now? Can I GET and the POST the same data? Is the api >> today wrapping or not? > > Today you can GET and POST the same data. It's unwrapped for JSON, but > wrapped for form data (which I'd consider to be a bug, #4180). > > The specification says it's unwrapped, the Foreman apidoc says it's > wrapped (also a bug IMO), the Katello apidoc says it's unwrapped. >

Yes, that's our default stance as it's in the manual. The alternative
is to revise that as David's suggested to wrap POST/PUT and leave GET
unwrapped.

··· On 24/01/14 14:16, Bryan Kearney wrote: > On 01/24/2014 09:15 AM, Dominic Cleal wrote: >> On 24/01/14 14:12, Bryan Kearney wrote: >>> On 01/24/2014 09:05 AM, Dominic Cleal wrote: >>>> On 24/01/14 13:52, David Davis wrote: >>>>> It looks like currently the foreman V2 API code uses a root node for PUT/POST requests while the Katello code does not. We'd like to unify that though and either decide whether to use a root node for POST/PUT. I know the v2 spec says no root node but I am not sure if we considered having a root node for just create/update but not show? Is there anybody for or against this? >>>> >>>> I don't much care whether it's wrapped or not, but the other two factors >>>> that I'd consider are: >>>> >>>> 1. the symmetry between no wrapping on the response from GET and the >>>> PUT/POST is nice. >>>> >>>> 2. we're just releasing Foreman 1.4 with APIv2 as experimental, having >>>> publicised in the release notes about this change to v2 users (of which >>>> there are many, because it's more functional and new APIs are only added >>>> there). I don't really want to annoy API users again by reverting it in >>>> the subsequent release. >>>> >>> >>> What is there now? Can I GET and the POST the same data? Is the api >>> today wrapping or not? >> >> Today you can GET and POST the same data. It's unwrapped for JSON, but >> wrapped for form data (which I'd consider to be a bug, #4180). >> >> The specification says it's unwrapped, the Foreman apidoc says it's >> wrapped (also a bug IMO), the Katello apidoc says it's unwrapped. >> > ok.. so we are saying converge on unwrapped?


Dominic Cleal
Red Hat Engineering

naw… that seems bad. I would put in whatever bugs/changes needed to
converge on unwrapped.

– bk

··· On 01/24/2014 09:20 AM, Dominic Cleal wrote: > On 24/01/14 14:16, Bryan Kearney wrote: >> On 01/24/2014 09:15 AM, Dominic Cleal wrote: >>> On 24/01/14 14:12, Bryan Kearney wrote: >>>> On 01/24/2014 09:05 AM, Dominic Cleal wrote: >>>>> On 24/01/14 13:52, David Davis wrote: >>>>>> It looks like currently the foreman V2 API code uses a root node for PUT/POST requests while the Katello code does not. We'd like to unify that though and either decide whether to use a root node for POST/PUT. I know the v2 spec says no root node but I am not sure if we considered having a root node for just create/update but not show? Is there anybody for or against this? >>>>> >>>>> I don't much care whether it's wrapped or not, but the other two factors >>>>> that I'd consider are: >>>>> >>>>> 1. the symmetry between no wrapping on the response from GET and the >>>>> PUT/POST is nice. >>>>> >>>>> 2. we're just releasing Foreman 1.4 with APIv2 as experimental, having >>>>> publicised in the release notes about this change to v2 users (of which >>>>> there are many, because it's more functional and new APIs are only added >>>>> there). I don't really want to annoy API users again by reverting it in >>>>> the subsequent release. >>>>> >>>> >>>> What is there now? Can I GET and the POST the same data? Is the api >>>> today wrapping or not? >>> >>> Today you can GET and POST the same data. It's unwrapped for JSON, but >>> wrapped for form data (which I'd consider to be a bug, #4180). >>> >>> The specification says it's unwrapped, the Foreman apidoc says it's >>> wrapped (also a bug IMO), the Katello apidoc says it's unwrapped. >>> >> ok.. so we are saying converge on unwrapped? > > Yes, that's our default stance as it's in the manual. The alternative > is to revise that as David's suggested to wrap POST/PUT and leave GET > unwrapped. >

Done.

http://projects.theforeman.org/issues/4181

David

··· ----- Original Message ----- > From: "Bryan Kearney" > To: foreman-dev@googlegroups.com > Sent: Friday, January 24, 2014 9:21:34 AM > Subject: Re: [foreman-dev] Root node on PUT and POST requests > > On 01/24/2014 09:20 AM, Dominic Cleal wrote: > > On 24/01/14 14:16, Bryan Kearney wrote: > >> On 01/24/2014 09:15 AM, Dominic Cleal wrote: > >>> On 24/01/14 14:12, Bryan Kearney wrote: > >>>> On 01/24/2014 09:05 AM, Dominic Cleal wrote: > >>>>> On 24/01/14 13:52, David Davis wrote: > >>>>>> It looks like currently the foreman V2 API code uses a root node for > >>>>>> PUT/POST requests while the Katello code does not. We'd like to unify > >>>>>> that though and either decide whether to use a root node for > >>>>>> POST/PUT. I know the v2 spec says no root node but I am not sure if > >>>>>> we considered having a root node for just create/update but not show? > >>>>>> Is there anybody for or against this? > >>>>> > >>>>> I don't much care whether it's wrapped or not, but the other two > >>>>> factors > >>>>> that I'd consider are: > >>>>> > >>>>> 1. the symmetry between no wrapping on the response from GET and the > >>>>> PUT/POST is nice. > >>>>> > >>>>> 2. we're just releasing Foreman 1.4 with APIv2 as experimental, having > >>>>> publicised in the release notes about this change to v2 users (of which > >>>>> there are many, because it's more functional and new APIs are only > >>>>> added > >>>>> there). I don't really want to annoy API users again by reverting it > >>>>> in > >>>>> the subsequent release. > >>>>> > >>>> > >>>> What is there now? Can I GET and the POST the same data? Is the api > >>>> today wrapping or not? > >>> > >>> Today you can GET and POST the same data. It's unwrapped for JSON, but > >>> wrapped for form data (which I'd consider to be a bug, #4180). > >>> > >>> The specification says it's unwrapped, the Foreman apidoc says it's > >>> wrapped (also a bug IMO), the Katello apidoc says it's unwrapped. > >>> > >> ok.. so we are saying converge on unwrapped? > > > > Yes, that's our default stance as it's in the manual. The alternative > > is to revise that as David's suggested to wrap POST/PUT and leave GET > > unwrapped. > > > naw.. that seems bad. I would put in whatever bugs/changes needed to > converge on unwrapped. > > -- bk > > -- > You received this message because you are subscribed to the Google Groups > "foreman-dev" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to foreman-dev+unsubscribe@googlegroups.com. > For more options, visit https://groups.google.com/groups/opt_out. >