import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.util.Assert;
-import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import io.swagger.annotations.ApiParam;
/**
- * Provides methods to manage policies of the Admission Control xApp. All
- * messages go via the A1 Mediatior.
+ * Provides methods to manage policies of the Admission Control xApp, which
+ * initially defines just one. All requests go via the A1 Mediatior.
*/
@RestController
@RequestMapping(value = DashboardConstants.ENDPOINT_PREFIX + "/xapp/ac", produces = MediaType.APPLICATION_JSON_VALUE)
private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
- private static final String POLICY_NAME = "policyname";
+ // A "control" is an element in the XApp descriptor
+ private static final String AC_CONTROL_NAME = "admission_control_policy";
// Populated by the autowired constructor
private final A1MediatorApi a1MediatorApi;
@ApiOperation(value = "Gets the A1 client library MANIFEST.MF property Implementation-Version.", response = SuccessTransport.class)
@RequestMapping(value = DashboardConstants.VERSION_PATH, method = RequestMethod.GET)
- public SuccessTransport getVersion() {
- logger.debug("getVersion enter");
+ public SuccessTransport getA1MediatorClientVersion() {
return new SuccessTransport(200, DashboardApplication.getImplementationVersion(A1MediatorApi.class));
}
- @ApiOperation(value = "Gets the named policy for AC xApp via the A1 Mediator")
- @RequestMapping(value = "policy/{" + POLICY_NAME + "}", method = RequestMethod.GET)
- public Object getPolicy(@PathVariable(POLICY_NAME) String policyName) {
- logger.debug("getPolicy: policy {}", policyName);
- a1MediatorApi.a1ControllerGetHandler(policyName);
+ /*
+ * GET policy is not supported at present by A1 Mediator! Always returns 501.
+ */
+ @ApiOperation(value = "Gets the admission control policy for AC xApp via the A1 Mediator")
+ @RequestMapping(value = "admctrl", method = RequestMethod.GET)
+ public Object getAdmissionControlPolicy() {
+ logger.debug("getAdmissionControlPolicy");
+ a1MediatorApi.a1ControllerGetHandler(AC_CONTROL_NAME);
return null;
}
- @ApiOperation(value = "Sets the named policy for AC xApp via the A1 Mediator")
- @RequestMapping(value = "policy/{" + POLICY_NAME + "}", method = RequestMethod.PUT)
- public void putPolicy(@PathVariable(POLICY_NAME) String policyName, //
- @ApiParam(value = "JSON formatted policy") @RequestBody JsonNode policy, //
+ /*
+ * This controller is deliberately kept ignorant of the
+ * ACAdmissionIntervalControl Typescript interface.
+ */
+ @ApiOperation(value = "Sets the admission control policy for AC xApp via the A1 Mediator")
+ @RequestMapping(value = "admctrl", method = RequestMethod.PUT)
+ public void setAdmissionControlPolicy(@ApiParam(value = "Admission control policy") @RequestBody JsonNode acPolicy, //
HttpServletResponse response) {
- logger.debug("putPolicy: policy {}", policyName);
- a1MediatorApi.a1ControllerPutHandler(policyName, policy);
+ logger.debug("setAdmissionControlPolicy {}", acPolicy);
+ a1MediatorApi.a1ControllerPutHandler(AC_CONTROL_NAME, acPolicy);
response.setStatus(a1MediatorApi.getApiClient().getStatusCode().value());
}