You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by GitBox <gi...@apache.org> on 2021/04/20 19:48:35 UTC

[GitHub] [camel-quarkus] aldettinger commented on a change in pull request #2497: Add integration tests #2388

aldettinger commented on a change in pull request #2497:
URL: https://github.com/apache/camel-quarkus/pull/2497#discussion_r616986605



##########
File path: integration-tests/digitalocean/src/main/java/org/apache/camel/quarkus/component/digitalocean/it/DigitaloceanResource.java
##########
@@ -184,35 +194,362 @@ private Action doAction(int id, DigitalOceanOperations operation) {
     }
 
     @GET
-    @Path("backups/{id}")
+    @Path("droplet/backups/{id}")
     public List<Backup> getBackups(@PathParam("id") int id) {
-        LOG.infof("getting backups's droplet with id %s", id);
+        LOG.infof("getting backup's droplet with id %s", id);
         Map<String, Object> headers = new HashMap<>();
         headers.put(DigitalOceanHeaders.OPERATION, DigitalOceanOperations.listBackups);
         headers.put(DigitalOceanHeaders.ID, id);
-        List<Backup> backups = producerTemplate.requestBodyAndHeaders("direct:droplet", null, headers, List.class);
-        return backups;
+        return producerTemplate.requestBodyAndHeaders("direct:droplet", null, headers, List.class);
     }
 
     @GET
-    @Path("neighbors/{id}")
+    @Path("droplet/neighbors/{id}")
     public List<Droplet> getNeighbors(@PathParam("id") int id) {
-        LOG.infof("getting neighbors's droplet with id %s", id);
+        LOG.infof("getting neighbor's droplet with id %s", id);
         Map<String, Object> headers = new HashMap<>();
         headers.put(DigitalOceanHeaders.OPERATION, DigitalOceanOperations.listNeighbors);
         headers.put(DigitalOceanHeaders.ID, id);
-        List<Droplet> neighbors = producerTemplate.requestBodyAndHeaders("direct:droplet", null, headers, List.class);
-        return neighbors;
+        return producerTemplate.requestBodyAndHeaders("direct:droplet", null, headers, List.class);
     }
 
     @GET
-    @Path("neighbors")
+    @Path("droplet/neighbors")
     public List<Droplet> getAllNeighbors() {
         LOG.infof("getting all neighbors");
         Map<String, Object> headers = new HashMap<>();
         headers.put(DigitalOceanHeaders.OPERATION, DigitalOceanOperations.listAllNeighbors);
-        List<Droplet> neighbors = producerTemplate.requestBodyAndHeaders("direct:droplet", null, headers, List.class);
-        return neighbors;
+        return producerTemplate.requestBodyAndHeaders("direct:droplet", null, headers, List.class);
+    }
+
+    @GET
+    @Path("account")
+    public Account getAccount() {
+        LOG.infof("getting the account");
+        return producerTemplate.requestBody("direct:account", null, Account.class);
+    }
+
+    @GET
+    @Path("action/{id}")
+    public Action getAction(@PathParam("id") Integer id) {
+        LOG.infof("getting the action %s", id);
+        Map<String, Object> headers = new HashMap<>();
+        headers.put(DigitalOceanHeaders.ID, id);
+        headers.put(DigitalOceanHeaders.OPERATION, DigitalOceanOperations.get);
+        return producerTemplate.requestBodyAndHeaders("direct:actions", null, headers, Action.class);
+    }
+
+    @GET
+    @Path("actions")
+    public List<Action> getActions() {
+        LOG.infof("getting all account's actions");
+        return producerTemplate.requestBodyAndHeader("direct:actions", null, DigitalOceanHeaders.OPERATION,
+                DigitalOceanOperations.list, List.class);
+    }
+
+    @GET
+    @Path("images")
+    public List<Image> getImages() {
+        LOG.infof("getting all account's images");
+        return producerTemplate.requestBodyAndHeader("direct:images", null, DigitalOceanHeaders.OPERATION,
+                DigitalOceanOperations.list, List.class);
+    }
+
+    @GET
+    @Path("images/{id}")
+    public Image getImageById(@PathParam("id") Integer id) {
+        LOG.infof("getting an image by id %s", id);
+        Map<String, Object> headers = new HashMap<>();
+        headers.put(DigitalOceanHeaders.ID, id);
+        headers.put(DigitalOceanHeaders.OPERATION, DigitalOceanOperations.get);
+        return producerTemplate.requestBodyAndHeaders("direct:images", null, headers, Image.class);
+    }
+
+    @GET
+    @Path("images/user")
+    public List<Image> getUserImages() {
+        LOG.infof("getting user's images");
+        return producerTemplate.requestBodyAndHeader("direct:images", null, DigitalOceanHeaders.OPERATION,
+                DigitalOceanOperations.ownList, List.class);
+    }
+
+    @GET
+    @Path("snapshots")
+    public List<Snapshot> getSnapshots() {
+        LOG.infof("getting all account's snapshots");
+        return producerTemplate.requestBodyAndHeader("direct:snapshots", null, DigitalOceanHeaders.OPERATION,
+                DigitalOceanOperations.list, List.class);
+    }
+
+    @GET
+    @Path("snapshots/{id}")
+    public Snapshot getSnapshotById(@PathParam("id") Integer id) {
+        LOG.infof("getting an snapshot by id %s", id);
+        Map<String, Object> headers = new HashMap<>();
+        headers.put(DigitalOceanHeaders.ID, id);
+        headers.put(DigitalOceanHeaders.OPERATION, DigitalOceanOperations.get);
+        return producerTemplate.requestBodyAndHeaders("direct:snapshots", null, headers, Snapshot.class);
     }
 
+    @DELETE
+    @Path("snapshots/{id}")
+    public Response deleteSnapshot(@PathParam("id") Integer id) {
+        LOG.infof("delete snapshot %s", id);
+        Map<String, Object> headers = new HashMap<>();
+        headers.put(DigitalOceanHeaders.OPERATION, DigitalOceanOperations.delete);
+        headers.put(DigitalOceanHeaders.ID, id);
+        producerTemplate.sendBodyAndHeaders("direct:snapshots", null, headers);
+        return Response.ok().build();
+    }
+
+    @GET
+    @Path("sizes")
+    public List<Size> getSizes() {
+        LOG.infof("getting all available sizes");
+        return producerTemplate.requestBody("direct:sizes", null, List.class);
+    }
+
+    @GET
+    @Path("regions")
+    public List<Region> getRegions() {
+        LOG.infof("getting all available regions");
+        return producerTemplate.requestBody("direct:regions", null, List.class);
+    }
+
+    @PUT
+    @Path("floatingIP")
+    public String createFloatingIP(Integer dropletId) {
+        LOG.infof("create floating IP for droplet %s", dropletId);
+        Map<String, Object> headers = new HashMap<>();
+        headers.put(DigitalOceanHeaders.OPERATION, DigitalOceanOperations.create);
+        headers.put(DigitalOceanHeaders.DROPLET_ID, dropletId);
+        // if pending task on droplet : API returns an exception. There should be a retry later
+        try {
+            FloatingIP floatingIP = producerTemplate.requestBodyAndHeaders("direct:floatingIPs", null, headers,
+                    FloatingIP.class);
+            return floatingIP.getIp();
+        } catch (Exception e) {
+            LOG.errorf("Enable to create and assign Floating IP - Please retry - error message : %s" + e.getMessage());
+        }
+        return "";
+    }
+
+    @GET
+    @Path("floatingIP/{id}")
+    public FloatingIP getFloatingIpById(@PathParam("id") String id) {
+        LOG.infof("get floating IP %s", id);
+        Map<String, Object> headers = new HashMap<>();
+        headers.put(DigitalOceanHeaders.OPERATION, DigitalOceanOperations.get);
+        headers.put(DigitalOceanHeaders.FLOATING_IP_ADDRESS, id);
+        return producerTemplate.requestBodyAndHeaders("direct:floatingIPs", null, headers, FloatingIP.class);
+    }
+
+    @GET
+    @Path("floatingIP")
+    public List<FloatingIP> getAllFloatingIps() {
+        LOG.infof("get all floating IPs");
+        return producerTemplate.requestBodyAndHeader("direct:floatingIPs", null,
+                DigitalOceanHeaders.OPERATION, DigitalOceanOperations.list, List.class);
+    }
+
+    @GET
+    @Path("floatingIP/unassign/{id}")
+    public Action unassignFloatingIp(@PathParam("id") String id) {
+        LOG.infof("unassign floating IP %s");
+        Map<String, Object> headers = new HashMap<>();
+        headers.put(DigitalOceanHeaders.OPERATION, DigitalOceanOperations.unassign);
+        headers.put(DigitalOceanHeaders.FLOATING_IP_ADDRESS, id);
+        // if pending task on droplet : API returns an exception. There should be a retry later
+        try {
+            return producerTemplate.requestBodyAndHeaders("direct:floatingIPs", null, headers, Action.class);
+        } catch (Exception e) {
+            LOG.errorf("Enable to unassign Floating IP - Please retry - error message : %s" + e.getMessage());
+        }
+        return new Action();
+    }
+
+    @DELETE
+    @Path("floatingIP/{id}")
+    public Delete deleteFloatingIp(@PathParam("id") String id) {
+        LOG.infof("delete floating IP %s", id);
+        Map<String, Object> headers = new HashMap<>();
+        headers.put(DigitalOceanHeaders.OPERATION, DigitalOceanOperations.delete);
+        headers.put(DigitalOceanHeaders.FLOATING_IP_ADDRESS, id);
+        // if pending task on droplet : API returns an exception. There should be a retry later
+        try {
+            return producerTemplate.requestBodyAndHeaders("direct:floatingIPs", null, headers, Delete.class);
+        } catch (Exception e) {
+            LOG.errorf("Enable to delete Floating IP - Please retry - error message : %s" + e.getMessage());
+        }
+        return new Delete(false);
+
+    }
+
+    @GET
+    @Path("floatingIP/actions/{id}")
+    public List<Action> getFloatingIpsActions(@PathParam("id") String id) {
+        LOG.infof("get all floating IPs actions %s", id);
+        Map<String, Object> headers = new HashMap<>();
+        headers.put(DigitalOceanHeaders.OPERATION, DigitalOceanOperations.listActions);
+        headers.put(DigitalOceanHeaders.FLOATING_IP_ADDRESS, id);
+        return (List<Action>) producerTemplate.requestBodyAndHeaders("direct:floatingIPs", null, headers, List.class);
+    }
+
+    @PUT
+    @Path("blockStorages")
+    public String createVolume(String name) {
+        LOG.infof("create volume for region %s with size %s named %s", REGION_FRANKFURT, VOLUME_SIZE_5_GB, name);
+        Map<String, Object> headers = new HashMap<>();
+        headers.put(DigitalOceanHeaders.OPERATION, DigitalOceanOperations.create);
+        headers.put(DigitalOceanHeaders.REGION, REGION_FRANKFURT);
+        headers.put(DigitalOceanHeaders.VOLUME_SIZE_GIGABYTES, VOLUME_SIZE_5_GB);
+        headers.put(DigitalOceanHeaders.NAME, name);
+        headers.put(DigitalOceanHeaders.DESCRIPTION, "volume_" + name);
+        Volume volume = producerTemplate.requestBodyAndHeaders("direct:blockStorages", null, headers, Volume.class);
+        return volume.getId();
+    }
+
+    @GET
+    @Path("blockStorages/{id}")
+    public Volume getVolumeById(@PathParam("id") String volumeId) {
+        LOG.infof("getting volume %s", volumeId);
+        Map<String, Object> headers = new HashMap<>();
+        headers.put(DigitalOceanHeaders.OPERATION, DigitalOceanOperations.get);
+        headers.put(DigitalOceanHeaders.ID, volumeId);
+        headers.put(DigitalOceanHeaders.REGION, REGION_FRANKFURT);
+        return producerTemplate.requestBodyAndHeaders("direct:blockStorages", null, headers, Volume.class);
+    }
+
+    @POST
+    @Path("blockStorages/attach/{name}")
+    public Action attachVolumeToDroplet(@PathParam("name") String volumeName, String dropletId) {
+        LOG.infof("attache volume %s to droplet %s in region %s", volumeName, dropletId, REGION_FRANKFURT);

Review comment:
       Minor typo 'attache'




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org