// sorting not supported
) {
INeutronBgpvpnCRUD bgpvpnInterface = getNeutronCRUD();
- List<NeutronBgpvpn> allBgpvpns = bgpvpnInterface.getAllBgpvpns();
+ List<NeutronBgpvpn> allBgpvpns = bgpvpnInterface.getAll();
List<NeutronBgpvpn> ans = new ArrayList<NeutronBgpvpn>();
Iterator<NeutronBgpvpn> i = allBgpvpns.iterator();
while (i.hasNext()) {
// return fields
@QueryParam("fields") List<String> fields
) {
- INeutronBgpvpnCRUD bgpvpnInterface = getNeutronCRUD();
- if (!bgpvpnInterface.bgpvpnExists(bgpvpnUUID)) {
- throw new ResourceNotFoundException(uuidNoExist());
- }
- if (fields.size() > 0) {
- NeutronBgpvpn ans = bgpvpnInterface.getBgpvpn(bgpvpnUUID);
- return Response.status(HttpURLConnection.HTTP_OK).entity(
- new NeutronBgpvpnRequest(extractFields(ans, fields))).build();
- } else {
- return Response.status(HttpURLConnection.HTTP_OK).entity(
- new NeutronBgpvpnRequest(bgpvpnInterface.getBgpvpn(bgpvpnUUID))).build();
- }
+ return show(bgpvpnUUID, fields);
}
/**
@ResponseCode(code = HttpURLConnection.HTTP_CREATED, condition = "Created"),
@ResponseCode(code = HttpURLConnection.HTTP_UNAVAILABLE, condition = "No providers available") })
public Response createBgpvpns(final NeutronBgpvpnRequest input) {
- INeutronBgpvpnCRUD bgpvpnInterface = getNeutronCRUD();
- if (input.isSingleton()) {
- NeutronBgpvpn singleton = input.getSingleton();
-
- // add bgpvpn to MDSAL
- singleton.initDefaults();
- bgpvpnInterface.addBgpvpn(singleton);
- } else {
- // add items to MDSAL
- for (NeutronBgpvpn test : input.getBulk()) {
- test.initDefaults();
- bgpvpnInterface.addBgpvpn(test);
- }
- }
- return Response.status(HttpURLConnection.HTTP_CREATED).entity(input).build();
+ return create(input);
}
/**
* Updates a Bgpvpn */
+ @Override
+ protected void updateDelta(String uuid,
+ NeutronBgpvpn delta, NeutronBgpvpn original) {
+ //Fill in defaults if they're missing in update
+ delta.initDefaults();
+ delta.setID(uuid);
+ delta.setTenantID(original.getTenantID());
+ }
+
@Path("{bgpvpnUUID}")
@PUT
@Produces({ MediaType.APPLICATION_JSON })
public Response updateBgpvpn(
@PathParam("bgpvpnUUID") String bgpvpnUUID, final NeutronBgpvpnRequest input
) {
- INeutronBgpvpnCRUD bgpvpnInterface = getNeutronCRUD();
-
- NeutronBgpvpn updatedObject = input.getSingleton();
- NeutronBgpvpn original = bgpvpnInterface.getBgpvpn(bgpvpnUUID);
-
- /*
- * note: what we get appears to not be a delta but
- * rather an incomplete updated object. So we need to set
- * the ID to complete the object and then send that down
- * for folks to check
- */
-
- updatedObject.setID(bgpvpnUUID);
- updatedObject.setTenantID(original.getTenantID());
- //Fill in defaults if they're missing in update
- updatedObject.initDefaults();
-
- // update bgpvpn object
- bgpvpnInterface.updateBgpvpn(bgpvpnUUID, updatedObject);
-
- return Response.status(HttpURLConnection.HTTP_OK).entity(
- new NeutronBgpvpnRequest(bgpvpnInterface.getBgpvpn(bgpvpnUUID))).build();
+ return update(bgpvpnUUID, input);
}
/**
@ResponseCode(code = HttpURLConnection.HTTP_UNAVAILABLE, condition = "No providers available") })
public Response deleteBgpvpn(
@PathParam("bgpvpnUUID") String bgpvpnUUID) {
- INeutronBgpvpnCRUD bgpvpnInterface = getNeutronCRUD();
-
- if (!bgpvpnInterface.removeBgpvpn(bgpvpnUUID)) {
- throw new InternalServerErrorException("Could not delete bgpvpn");
- }
- return Response.status(HttpURLConnection.HTTP_NO_CONTENT).build();
+ return delete(bgpvpnUUID);
}
}