From ddb9b7da0390474aa15290deb33e16c8c2ef49e8 Mon Sep 17 00:00:00 2001 From: Amrith Kumar Date: Thu, 28 May 2015 22:13:16 -0400 Subject: [PATCH] correct api schema for instance patch The api schema specification for the patch oepration is in error and defined a parameter of "configuration_id" while the code (both in the server and the client, and also all the tests) used "configuration". A fix with fewer lines of code would have been to just embed the { "type": "null" } into the definition of configuration_id but I am going to be making additional changes to the way in which we signal (through a put call) that we want to detach a configuration_id so I've defined a null_configuration_id type which I can use there as well. To prevent this from reoccuring, additionalProperties has been set to False. Change-Id: Ic98050e487b0d8cd9a68e8c46169456a52e2b16c Closes-Bug: #1460174 --- trove/common/apischema.py | 11 +++++++++-- trove/instance/service.py | 4 +++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/trove/common/apischema.py b/trove/common/apischema.py index fdf01f2def..f9cca8636d 100644 --- a/trove/common/apischema.py +++ b/trove/common/apischema.py @@ -197,9 +197,14 @@ users_list = { } } +null_configuration_id = { + "type": "null" +} + configuration_id = { 'oneOf': [ - uuid + uuid, + null_configuration_id ] } @@ -301,10 +306,12 @@ instance = { "instance": { "type": "object", "required": [], + "additionalProperties": False, "properties": { "slave_of": {}, + "replica_of": {}, "name": non_empty_string, - "configuration_id": configuration_id, + "configuration": configuration_id, } } } diff --git a/trove/instance/service.py b/trove/instance/service.py index 12f73e691f..8e52d13cee 100644 --- a/trove/instance/service.py +++ b/trove/instance/service.py @@ -305,7 +305,9 @@ class InstanceController(wsgi.Controller): instance = models.Instance.load(context, id) args = {} - args['detach_replica'] = 'slave_of' in body['instance'] + args['detach_replica'] = ('replica_of' in body['instance'] or + 'slave_of' in body['instance']) + if 'name' in body['instance']: args['name'] = body['instance']['name'] if 'configuration' in body['instance']: