summaryrefslogtreecommitdiffstats
path: root/openecomp-be/api/openecomp-sdc-rest-webapp/togglz-rest/togglz-rest-services/src/main/java
diff options
context:
space:
mode:
authorayalaben <Ayala.Benzvi@Amdocs.Com>2018-02-12 17:11:42 +0200
committerayalaben <ayala.benzvi@amdocs.com>2018-02-13 10:33:36 +0200
commit332f0679fbd23532a058f0ff6a7cffaed3b5424e (patch)
tree09476357022653d47a7ff28bca7cf8a72886c775 /openecomp-be/api/openecomp-sdc-rest-webapp/togglz-rest/togglz-rest-services/src/main/java
parentf6784900012e11850d8e98bbf198f04bd0e411c7 (diff)
Enable/Disable toggle feature REST
Change-Id: I2b62aa3129772cc81e4356941f86104fbfd19dbb Issue-ID: SDC-1033 Signed-off-by: ayalaben <ayala.benzvi@amdocs.com>
Diffstat (limited to 'openecomp-be/api/openecomp-sdc-rest-webapp/togglz-rest/togglz-rest-services/src/main/java')
-rw-r--r--openecomp-be/api/openecomp-sdc-rest-webapp/togglz-rest/togglz-rest-services/src/main/java/org/openecomp/sdcrests/togglz/rest/TogglzFeatures.java24
-rw-r--r--openecomp-be/api/openecomp-sdc-rest-webapp/togglz-rest/togglz-rest-services/src/main/java/org/openecomp/sdcrests/togglz/rest/services/TogglzFeaturesImpl.java22
2 files changed, 41 insertions, 5 deletions
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/togglz-rest/togglz-rest-services/src/main/java/org/openecomp/sdcrests/togglz/rest/TogglzFeatures.java b/openecomp-be/api/openecomp-sdc-rest-webapp/togglz-rest/togglz-rest-services/src/main/java/org/openecomp/sdcrests/togglz/rest/TogglzFeatures.java
index 9a1fde3d9c..6158421246 100644
--- a/openecomp-be/api/openecomp-sdc-rest-webapp/togglz-rest/togglz-rest-services/src/main/java/org/openecomp/sdcrests/togglz/rest/TogglzFeatures.java
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/togglz-rest/togglz-rest-services/src/main/java/org/openecomp/sdcrests/togglz/rest/TogglzFeatures.java
@@ -18,20 +18,23 @@ package org.openecomp.sdcrests.togglz.rest;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
+import org.openecomp.sdcrests.common.RestConstants;
+import org.openecomp.sdcrests.togglz.types.FeatureDto;
import org.openecomp.sdcrests.togglz.types.FeatureSetDto;
import org.springframework.validation.annotation.Validated;
-import javax.ws.rs.Consumes;
-import javax.ws.rs.GET;
-import javax.ws.rs.Path;
-import javax.ws.rs.Produces;
+import javax.validation.Valid;
+import javax.validation.constraints.NotNull;
+import javax.ws.rs.*;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
+import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG;
+
@Path("/v1.0/togglz")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
-@Api(value = "TOGGLZ")
@Validated
public interface TogglzFeatures {
@@ -41,4 +44,15 @@ public interface TogglzFeatures {
responseContainer = "List")
Response getFeatures();
+
+ @PUT
+ @Path("/{featureName}/state/{state}")
+ @ApiOperation(value = "Update feature toggle state")
+ Response setFeatureState(@PathParam("featureName") String featureName, @PathParam("state") boolean state);
+
+ @GET
+ @Path("/{featureName}/state")
+ @ApiOperation(value = "Get feature toggle state",
+ response = FeatureDto.class)
+ Response getFeatureState(@PathParam("featureName") String featureName);
}
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/togglz-rest/togglz-rest-services/src/main/java/org/openecomp/sdcrests/togglz/rest/services/TogglzFeaturesImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/togglz-rest/togglz-rest-services/src/main/java/org/openecomp/sdcrests/togglz/rest/services/TogglzFeaturesImpl.java
index 5b7240be54..fd1c4dbd0c 100644
--- a/openecomp-be/api/openecomp-sdc-rest-webapp/togglz-rest/togglz-rest-services/src/main/java/org/openecomp/sdcrests/togglz/rest/services/TogglzFeaturesImpl.java
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/togglz-rest/togglz-rest-services/src/main/java/org/openecomp/sdcrests/togglz/rest/services/TogglzFeaturesImpl.java
@@ -19,9 +19,14 @@ package org.openecomp.sdcrests.togglz.rest.services;
import org.openecomp.sdc.common.togglz.ToggleableFeature;
import org.openecomp.sdcrests.togglz.rest.TogglzFeatures;
import org.openecomp.sdcrests.togglz.rest.mapping.MapToggleableFeatureToDto;
+import org.openecomp.sdcrests.togglz.types.FeatureDto;
import org.openecomp.sdcrests.togglz.types.FeatureSetDto;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;
+import org.togglz.core.Feature;
+import org.togglz.core.context.FeatureContext;
+import org.togglz.core.repository.FeatureState;
+import org.togglz.core.util.NamedFeature;
import javax.inject.Named;
import javax.ws.rs.core.Response;
@@ -38,5 +43,22 @@ public class TogglzFeaturesImpl implements TogglzFeatures {
new MapToggleableFeatureToDto().doMapping(Arrays.asList(ToggleableFeature.values()), featureSetDto);
return Response.ok(featureSetDto).build();
}
+
+ @Override
+ public Response setFeatureState(String featureName, boolean state) {
+ Feature feature = new NamedFeature(featureName);
+ FeatureState featureState = new FeatureState(feature,state);
+ FeatureContext.getFeatureManager().setFeatureState(featureState);
+ return Response.ok().build();
+ }
+
+ @Override
+ public Response getFeatureState(String featureName) {
+ boolean active = ToggleableFeature.valueOf(featureName).isActive();
+ FeatureDto featureDto = new FeatureDto(featureName,active);
+
+ return Response.ok(featureDto).build();
+ }
+
}