Hi,
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?
-- Michal
--
Michal Fojtik <[email protected]>
Deltacloud API, CloudForms