On Wed, 2012-06-20 at 12:02 -0700, Dan Wendlandt wrote: > > For example, if port was just: > > > { 'id' : XYZ, > 'network_id': "ABC" > 'fixed_ips': [ "10.0.0.2" ] > } > > > We could do a query that specified filter network_id=ABC, but it was > already a bit wonky to do something like fixed_ips=10.0.0.2 because > fixed_ip was really a list, not a string. Were you envisioning a > model where a filter on a list was implicitly converted to a ORed > comparison against each list item?
I would compare it to the 'in' test in python. And I'm going to go back on my previous email and say it should be: GET /ports?fixed_ip=10.0.0.2 To be explicit that you are searching for match of an element in the collection. > If thats the case, then the same trick could still be used, if we have > a way of referring to nested keys. One option would be to do > something like: > > > { 'id' : XYZ, > 'network_id': "ABC" > 'fixed_ips': [ { "address": "10.0.0.2", "subnet_id": "DEF"} ] > } > > > and allow filters like fixed_ips.address=10.0.0.2 . Essentially, > nested keys are joined by some delimiter, like ".". Right, we'd have to invent and document a "SQL over HTTP" system for filtering inside a collection of resources. > Another option would be to just define a filter key that does not > directly map to a top-level attribute (e.g. > fixed_ip_address=10.0.0.2). We could, I'm +/-0 on just inventing our own query semantics just so we can get something working. My original goal was to have it as straight forward as possible for the API consumer. "I want to filter for a fixed_ip, so that's what I'd pass in". Not "I want to filter for fixed_ip, let me look up in the document what the semantics are for reaching into that collection of resources, ok in this case its fixed_ip_address". > On the plus side, I think the idea of passing in the subnet-id handles > the other issue you mentioned previously, in that it gives us a clean > way to add an IP to a port even if the user wants that IP to be > allocated from a pool, since the user can add an entry to the fixed > ips list, but only specify the subnet. > > > any other ideas on this front? POST /ips?subnet_id=<UUID>&port_id=<UUID> For allocate out of the pool and POST /ips?subnet_id<UUID>&port_id=<UUID>&address=10.0.0.3 For a specific address. (swap out the query string for a body if it seems particularly nasty, but either should be supported in my opinion) I see the query string as the selector to determine the parameters of the operation. Happy Hacking! 7-11 -- Mailing list: https://launchpad.net/~netstack Post to : netstack@lists.launchpad.net Unsubscribe : https://launchpad.net/~netstack More help : https://help.launchpad.net/ListHelp