diff options
author | Øyvind Grønnesby <oyving@verizonmedia.com> | 2020-11-17 09:13:44 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-17 09:13:44 +0100 |
commit | b4dc184e1e22ac91b6aa6f7be53808782142d2d2 (patch) | |
tree | 726aa67fc90f37308cff1a3f96eacc43262354f7 | |
parent | 18ca0c8d0913bd4ac558c6e1fd6c40035b2aa9b5 (diff) | |
parent | dc6d6b6e19c2e718770571794bdae63fa8981276 (diff) |
Merge pull request #15355 from vespa-engine/ogronnesby/patch-collection-method
Update field names we accept for collection method
2 files changed, 9 insertions, 2 deletions
diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/billing/BillingApiHandler.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/billing/BillingApiHandler.java index dbe342340ee..34601240c7f 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/billing/BillingApiHandler.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/billing/BillingApiHandler.java @@ -149,7 +149,9 @@ public class BillingApiHandler extends LoggingRequestHandler { private HttpResponse patchCollectionMethod(HttpRequest request, String tenant) { var tenantName = TenantName.from(tenant); var slime = inspectorOrThrow(request); - String newMethod = slime.field("collectionMethod").asString().toUpperCase(); + var newMethod = slime.field("collection").valid() ? + slime.field("collection").asString().toUpperCase() : + slime.field("collectionMethod").asString().toUpperCase(); if (newMethod.isEmpty()) return ErrorResponse.badRequest("No collection method specified"); try { diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/billing/BillingApiHandlerTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/billing/BillingApiHandlerTest.java index fde619adfa4..8493250d9a3 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/billing/BillingApiHandlerTest.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/billing/BillingApiHandlerTest.java @@ -189,8 +189,13 @@ public class BillingApiHandlerTest extends ControllerContainerCloudTest { @Test public void patch_collection_method() { + test_patch_collection_with_field_name("collectionMethod"); + test_patch_collection_with_field_name("collection"); + } + + private void test_patch_collection_with_field_name(String fieldName) { var planRequest = request("/billing/v1/tenant/tenant1/collection", PATCH) - .data("{\"collectionMethod\": \"invoice\"}") + .data("{\"" + fieldName + "\": \"invoice\"}") .roles(financeAdmin); tester.assertResponse(planRequest, "Collection method updated to INVOICE"); assertEquals(CollectionMethod.INVOICE, billingController.getCollectionMethod(tenant)); |