[katello-devel] Foreman-api

Ivan Nečas inecas at redhat.com
Mon Aug 27 09:27:27 UTC 2012


On 08/24/2012 04:58 PM, Dmitri Dolguikh wrote:
> On 24/08/12 03:57 PM, Bryan Kearney wrote:
>> On 08/24/2012 10:52 AM, Jason Rist wrote:
>>> On 08/24/2012 10:50 AM, Dmitri Dolguikh wrote:
>>>> On 24/08/12 03:38 PM, Lukas Zapletal wrote:
>>>>> On Fri, Aug 24, 2012 at 11:01:16AM +0100, Dmitri Dolguikh wrote:
>>>>>> Hey guys,
>>>>>>
>>>>>> I'm about to add api bindings for environments to Foreman API, but
>>>>>> was wondering about the goals of that [sub]-project. In particular,
>>>>>> why did we choose to create our own code instead of using Rails
>>>>>> ActiveResource (did anyone looked if there are still issues with
>>>>>> Oauth when using ActiveResource)? Another one is why do we perform
>>>>>> client side validation of parameters?
>>>>> The right question is maybe - why we started coding 
>>>>> resource/pulp.rb and
>>>>> resource/candlepin.rb huge files with all the methods there? ;-)
>>>> They started small. It's pretty easy to break them up (we should) - 
>>>> each
>>>> file is a collection of classes corresponding to resources on
>>>> pulp/candlepin server. I'd like to see if we can switch to
>>>> ActiveResource though - perhaps it's viable now. Ohad - have you 
>>>> looked
>>>> at this lately?
>>>>
>>>> -d
>>>>>
>>>>> Any outcomes so far?
>>>>>
>>>>> LZ
>>>>>
>>>>
>>>>
>>>> _______________________________________________
>>>> katello-devel mailing list
>>>> katello-devel at redhat.com
>>>> https://www.redhat.com/mailman/listinfo/katello-devel
>>>
>>>
>>> OpenShift is primarily using ActiveResource.
>>
>> If I recall, ActiveResource assumes a rather rails centric json view. 
>> It it works, rgeat. If not, you end up monkey patching alot.
> Hmm. I remember issues with OAuth and not-very-restful urls (I don't 
> remember any json issues though). Perhaps those have been solved/made 
> manageable?
What advantage does it bring us?

ActiveResource works well only if you strictly follow the Rails 
conventions. Take an example from the client library for Katello based 
on ActiveResources [1]. It doesn't work well (forcing you to do hacks), 
because for security reasons, Katello does allow you only subset of 
attributes. So from this code, I know nothing about what arguments I can 
pass in (I see only arguments I can't update, which is quite useless).

If you take a look at the generated code [2] for Foreman, you 
immediately see, how you can use that. No hacks needed. Another fact is 
that this approach forces you to document you API. ActiveResource 
without sufficient documentation of your API is unusable.

Me as a developer, I find it much easier to use the code that I 
immediately see what it expects from me.

[1] - 
https://github.com/calfonso/deadwood/blob/master/lib/deadwood/model/environment.rb
[2] - 
https://github.com/mbacovsky/foreman_api/blob/master/lib/foreman_api/resources/architecture.rb
>
> -d
>>
>> -- bk
>>
>>
>> _______________________________________________
>> katello-devel mailing list
>> katello-devel at redhat.com
>> https://www.redhat.com/mailman/listinfo/katello-devel
>
>
> _______________________________________________
> katello-devel mailing list
> katello-devel at redhat.com
> https://www.redhat.com/mailman/listinfo/katello-devel


-- 
Ivan




More information about the katello-devel mailing list