deltacloud-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Lutterkort <>
Subject Re: CIMI and attribute validation
Date Wed, 06 Feb 2013 22:38:13 GMT
On Wed, 2013-02-06 at 14:37 +0100, Michal Fojtik wrote:
> I'm thinking how we can do a better job in validating the attributes
> for CIMI entities when we creating them.
> Some attributes are required in CIMI spec, like a 'name' (etc). So I'm
> thinking how we can handle this in Deltacloud.
> I come up with these possible sulutions:
> 1. Teach sinatra-rabbit to check the request body for :create operations.
>    Then the 'param' method as we do in Deltacloud to check if the required
>    attribute is present in the request body. The problem is that I don't
>    know how to handle JSON vs XML. The syntax of the 'param' method must be
>    smart enough to understand xpath and also the JSON.
>    operation :create do
>      body_param :name, :xpath => '/MachineTemplateCreate/name', :json => 'name'
>      ...
>    end
> 2. Add ':required => true' parameter to attributes in the CIMI models and
>    then add '.validate(format, body)' method and do all the validation on
>    the model level.
>    class MachineTemplate
>      text :name, :required => true
>    end
> What you think? Anyone have some better idea/thoughts?

I think door #2 is the right answer - we want to keep the amount of work
we do on raw XML/JSON representations to a raw minimum.


View raw message