Search in sources :

Example 1 with KubevirtApiConfigAdminService

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();
}
Also used : KubevirtApiConfigAdminService(org.onosproject.kubevirtnode.api.KubevirtApiConfigAdminService) UriBuilder(javax.ws.rs.core.UriBuilder) KubevirtApiConfig(org.onosproject.kubevirtnode.api.KubevirtApiConfig) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces)

Example 2 with KubevirtApiConfigAdminService

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();
}
Also used : KubevirtApiConfigAdminService(org.onosproject.kubevirtnode.api.KubevirtApiConfigAdminService) KubevirtApiConfig(org.onosproject.kubevirtnode.api.KubevirtApiConfig) Path(javax.ws.rs.Path) DELETE(javax.ws.rs.DELETE) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces)

Aggregations

Consumes (javax.ws.rs.Consumes)2 Produces (javax.ws.rs.Produces)2 KubevirtApiConfig (org.onosproject.kubevirtnode.api.KubevirtApiConfig)2 KubevirtApiConfigAdminService (org.onosproject.kubevirtnode.api.KubevirtApiConfigAdminService)2 DELETE (javax.ws.rs.DELETE)1 POST (javax.ws.rs.POST)1 Path (javax.ws.rs.Path)1 UriBuilder (javax.ws.rs.core.UriBuilder)1