[openstack-dev] [Keystone] Use JSON Schemas to validate API requests data

Ken'ichi Ohmichi oomichi at mxs.nes.nec.co.jp
Thu Jun 6 03:55:31 UTC 2013


Hi Doug,

On Wed, 5 Jun 2013 13:43:35 -0400
Doug Hellmann <doug.hellmann at dreamhost.com> wrote:
> >
> > == Nova "v2/os-fixed-ips/{fixed_ip}/action" ============================
> >   *** Schema implemented with WSME ***
> >   class FixedIpAction:
> >       _reserve = None
> >       _unreserve = None
> >
> >       def get_reserve(self):
> >           return self._reserve
> >
> >       def set_reserve(self, value):
> >           assert is_valid_ipv4(value), "invalid ipv4 data"
> >           assert _unreserve==None "Both reserve and unreserve should not
> > be specified"
> >           self._reserve = value
> >
> >       def get_unreserve(self):
> >           return self._unreserve
> >
> >       def set_unreserve(self, value):
> >           assert is_valid_ipv4(value), "invalid ipv4 data"
> >           assert _reserve==None "Both reserve and unreserve should not be
> > specified"
> >           self._unreserve = value
> >
> >       reserve = wsme.wsproperty(str, get_reserve, set_reserve)
> >       unreserve = wsme.wsproperty(str, get_unreserve, set_unreserve)
> >
> 
> This API looks odd to me. The "action" to take as part of the payload of
> the message, where I would have thought they should be separate endpoints.
> If there were separate reserve and unreserve endpoints in the API, then
> each would only need to declare that they took an IPv4 address as an
> argument, along with whatever else is needed (the instance id?).

interesting point.
but now it is better to discuss how to implement parameter dependencies,
because this case does not seem special for RESTful API.


> That IPv4
> address would be represented by new WSME user-defined type, which would be
> reusable throughout the APIs that work with network addresses. It would not
> be possible to specify both reserve and unreserve at the same time, so you
> wouldn't need that check at all.

Could you please show how to define new WSME user-defined type with
IPv4 address as sample code?
I'm sorry that I could not know it even if digging Ceilometer code.


Thanks
Ken'ichi Ohmichi



More information about the OpenStack-dev mailing list