use of org.onosproject.kubevirtnode.api.KubevirtApiConfigAdminService in project onos by opennetworkinglab.
the class KubevirtApiConfigWebResource method createApiConfigs.
/**
* Creates a set of KubeVirt API config from the JSON input stream.
*
* @param input KubeVirt API configs JSON input stream
* @return 201 CREATED if the JSON is correct, 400 BAD_REQUEST if the JSON
* is malformed
* @onos.rsModel KubevirtApiConfig
*/
@POST
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Response createApiConfigs(InputStream input) {
log.trace(String.format(MESSAGE_CONFIG, CREATE));
KubevirtApiConfig config = readApiConfig(input);
KubevirtApiConfigAdminService service = get(KubevirtApiConfigAdminService.class);
if (config != null) {
service.createApiConfig(config);
}
UriBuilder locationBuilder = uriInfo.getBaseUriBuilder().path(API_CONFIG);
return created(locationBuilder.build()).build();
}
use of org.onosproject.kubevirtnode.api.KubevirtApiConfigAdminService in project onos by opennetworkinglab.
the class KubevirtApiConfigWebResource method deleteApiConfig.
/**
* Removes a KubeVirt API config.
*
* @param endpoint KubeVirt API endpoint
* @return 204 NO_CONTENT, 400 BAD_REQUEST if the JSON is malformed
*/
@DELETE
@Path("{endpoint : .+}")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Response deleteApiConfig(@PathParam("endpoint") String endpoint) {
log.trace(String.format(MESSAGE_CONFIG, REMOVE));
KubevirtApiConfigAdminService service = get(KubevirtApiConfigAdminService.class);
KubevirtApiConfig existing = service.apiConfig();
if (existing == null) {
log.warn("There is no API configuration to delete");
return Response.notModified().build();
} else {
if (endpoint.equals(endpoint(existing))) {
service.removeApiConfig(endpoint);
} else {
log.warn("There is no API configuration to delete for endpoint {}", endpoint);
}
}
return Response.noContent().build();
}
Aggregations