summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorØyvind Grønnesby <oyving@verizonmedia.com>2020-11-16 12:41:11 +0100
committerØyvind Grønnesby <oyving@verizonmedia.com>2020-11-16 12:41:11 +0100
commitdc6d6b6e19c2e718770571794bdae63fa8981276 (patch)
treefaa764a0efa16a697c227d421466f5f4a7117081
parent1375c8aded9eb18aa8496518948730e28a01224b (diff)
Update field names we accept for collection method
-rw-r--r--controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/billing/BillingApiHandler.java4
-rw-r--r--controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/billing/BillingApiHandlerTest.java7
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));