@Override public boolean deleteImage(String id) { String imageId = ImageInRegion.extractImageId(id); Integer numericId = Ints.tryParse(imageId); // User images don't have a slug, so we expect a numeric id here if (numericId != null) { try { logger.debug(">> deleting image %s...", id); api.imageApi().delete(numericId); return true; } catch (Exception ex) { logger.error(ex, ">> error deleting image %s", id); } } else { logger.warn(">> image %s is not a user image and cannot be deleted", id); } return false; } }
@Override public boolean deleteImage(String id) { String imageId = ImageInRegion.extractImageId(id); Integer numericId = Ints.tryParse(imageId); // User images don't have a slug, so we expect a numeric id here if (numericId != null) { try { logger.debug(">> deleting image %s...", id); api.imageApi().delete(numericId); return true; } catch (Exception ex) { logger.error(ex, ">> error deleting image %s", id); } } else { logger.warn(">> image %s is not a user image and cannot be deleted", id); } return false; } }
@Override public boolean deleteImage(String id) { String imageId = ImageInRegion.extractImageId(id); Integer numericId = Ints.tryParse(imageId); // User images don't have a slug, so we expect a numeric id here if (numericId != null) { try { logger.debug(">> deleting image %s...", id); api.imageApi().delete(numericId); return true; } catch (Exception ex) { logger.error(ex, ">> error deleting image %s", id); } } else { logger.warn(">> image %s is not a user image and cannot be deleted", id); } return false; } }
public void testDeleteImageReturns404() throws InterruptedException { server.enqueue(response404()); api.imageApi().delete(1); assertEquals(server.getRequestCount(), 1); assertSent(server, "DELETE", "/images/1"); }
@Test(groups = "live", dependsOnMethods = "testPowerOn") public void testSnapshots() { Action action = api().snapshot(dropletId, prefix + dropletId + "-snapshot"); assertActionCompleted(action.id()); List<Snapshot> snapshots = api().listSnapshots(dropletId).concat().toList(); assertEquals(snapshots.size(), 1, "Must contain 1 snapshot"); for (Snapshot snapshot : snapshots) { try { api.imageApi().delete(snapshot.id()); } catch (Exception ex) { getAnonymousLogger().warning("Could not delete snapshot: " + snapshot.id()); } } }
public void testDeleteImage() throws InterruptedException { server.enqueue(response204()); api.imageApi().delete(1); assertEquals(server.getRequestCount(), 1); assertSent(server, "DELETE", "/images/1"); }