You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ac...@apache.org on 2017/03/27 07:49:19 UTC
[01/20] camel git commit: initial commit
Repository: camel
Updated Branches:
refs/heads/master 002908264 -> 4ed4ea9ae
http://git-wip-us.apache.org/repos/asf/camel/blob/1d57f7b0/components/camel-digitalocean/src/main/java/com/viwilo/camel/producer/DigitalOceanDropletsProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-digitalocean/src/main/java/com/viwilo/camel/producer/DigitalOceanDropletsProducer.java b/components/camel-digitalocean/src/main/java/com/viwilo/camel/producer/DigitalOceanDropletsProducer.java
new file mode 100644
index 0000000..5529851
--- /dev/null
+++ b/components/camel-digitalocean/src/main/java/com/viwilo/camel/producer/DigitalOceanDropletsProducer.java
@@ -0,0 +1,405 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.viwilo.camel.producer;
+
+import com.myjeeva.digitalocean.common.ResourceType;
+import com.myjeeva.digitalocean.pojo.*;
+import com.myjeeva.digitalocean.pojo.Response;
+import com.viwilo.camel.DigitalOceanConfiguration;
+import com.viwilo.camel.constants.DigitalOceanHeaders;
+import com.viwilo.camel.DigitalOceanEndpoint;
+import com.viwilo.camel.constants.DigitalOceanOperations;
+import org.apache.camel.Exchange;
+import org.apache.camel.Message;
+import org.apache.camel.util.ObjectHelper;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.stream.Collectors;
+
+/**
+ * The DigitalOcean producer for Droplets API.
+ */
+public class DigitalOceanDropletsProducer extends DigitalOceanProducer {
+
+ public DigitalOceanDropletsProducer(DigitalOceanEndpoint endpoint, DigitalOceanConfiguration configuration) {
+ super(endpoint, configuration);
+ }
+
+ private Integer dropletId;
+
+ public void process(Exchange exchange) throws Exception {
+
+ DigitalOceanOperations op = determineOperation(exchange);
+ if (op != DigitalOceanOperations.create && op != DigitalOceanOperations.list && op != DigitalOceanOperations.listAllNeighbors) {
+ dropletId = exchange.getIn().getHeader(DigitalOceanHeaders.ID, Integer.class);
+ if (ObjectHelper.isEmpty(dropletId))
+ throw new IllegalArgumentException(DigitalOceanHeaders.ID + " must be specified");
+ }
+
+ switch (op) {
+ case create:
+ createDroplet(exchange);
+ break;
+ case list:
+ getDroplets(exchange);
+ break;
+ case delete:
+ deleteDroplet(exchange);
+ break;
+ case get:
+ getDroplet(exchange);
+ break;
+ case listActions:
+ getDropletActions(exchange);
+ break;
+ case listSnapshots:
+ getDropletSnapshots(exchange);
+ break;
+ case listKernels:
+ getDropletKernels(exchange);
+ break;
+ case listBackups:
+ getDropletBackups(exchange);
+ break;
+ case listNeighbors:
+ getDropletNeighbors(exchange);
+ break;
+ case listAllNeighbors:
+ getAllDropletNeighbors(exchange);
+ break;
+ case enableBackups:
+ enableDropletBackups(exchange);
+ break;
+ case disableBackups:
+ disableDropletBackups(exchange);
+ break;
+ case reboot:
+ rebootDroplet(exchange);
+ break;
+ case powerCycle:
+ powerCycleDroplet(exchange);
+ break;
+ case shutdown:
+ shutdownDroplet(exchange);
+ break;
+ case powerOn:
+ powerOnDroplet(exchange);
+ break;
+ case powerOff:
+ powerOffDroplet(exchange);
+ break;
+ case restore:
+ restoreDroplet(exchange);
+ break;
+ case resetPassword:
+ resetDropletPassword(exchange);
+ break;
+ case resize:
+ resizeDroplet(exchange);
+ break;
+ case rebuild:
+ rebuildDroplet(exchange);
+ break;
+ case rename:
+ renameDroplet(exchange);
+ break;
+ case changeKernel:
+ changeDropletKernel(exchange);
+ break;
+ case enableIpv6:
+ enableDropletIpv6(exchange);
+ break;
+ case enablePrivateNetworking:
+ enableDropletPrivateNetworking(exchange);
+ break;
+ case takeSnapshot:
+ takeDropletSnapshot(exchange);
+ break;
+ case tag:
+ tagDroplet(exchange);
+ break;
+ case untag:
+ untagDroplet(exchange);
+ break;
+ default:
+ throw new IllegalArgumentException("Unsupported operation");
+ }
+ }
+
+
+
+ private void getDroplet(Exchange exchange) throws Exception {
+ Droplet droplet = getEndpoint().getDigitalOceanClient().getDropletInfo(dropletId);
+ LOG.trace("Droplet {} ", droplet);
+ exchange.getOut().setBody(droplet);
+ }
+
+
+ private void getDroplets(Exchange exchange) throws Exception {
+ Droplets droplets = getEndpoint().getDigitalOceanClient().getAvailableDroplets(configuration.getPage(), configuration.getPerPage());
+ LOG.trace("All Droplets : page {} / {} per page [{}] ", configuration.getPage(), configuration.getPerPage(), droplets.getDroplets());
+ exchange.getOut().setBody(droplets.getDroplets());
+ }
+
+
+ private void getDropletActions(Exchange exchange) throws Exception {
+ Actions actions = getEndpoint().getDigitalOceanClient().getAvailableDropletActions(dropletId, configuration.getPage(), configuration.getPerPage());
+ LOG.trace("Actions for Droplet {} : page {} / {} per page [{}] ", dropletId, configuration.getPage(), configuration.getPerPage(), actions.getActions());
+ exchange.getOut().setBody(actions.getActions());
+ }
+
+ private void getDropletKernels(Exchange exchange) throws Exception {
+ Kernels kernels = getEndpoint().getDigitalOceanClient().getDropletKernels(dropletId, configuration.getPage(), configuration.getPerPage());
+ LOG.trace("Kernels for Droplet {} : page {} / {} per page [{}] ", dropletId, configuration.getPage(), configuration.getPerPage(), kernels.getKernels());
+ exchange.getOut().setBody(kernels.getKernels());
+ }
+
+ private void getDropletBackups(Exchange exchange) throws Exception {
+ Backups backups = getEndpoint().getDigitalOceanClient().getDropletBackups(dropletId, configuration.getPage(), configuration.getPerPage());
+ LOG.trace("Backups for Droplet {} : page {} / {} per page [{}] ", dropletId, configuration.getPage(), configuration.getPerPage(), backups.getBackups());
+ exchange.getOut().setBody(backups.getBackups());
+ }
+
+ private void getDropletSnapshots(Exchange exchange) throws Exception {
+ Snapshots snapshots = getEndpoint().getDigitalOceanClient().getDropletSnapshots(dropletId, configuration.getPage(), configuration.getPerPage());
+ LOG.trace("Snapshots for Droplet {} : page {} / {} per page [{}] ", dropletId, configuration.getPage(), configuration.getPerPage(), snapshots.getSnapshots());
+ exchange.getOut().setBody(snapshots.getSnapshots());
+ }
+
+ private void getDropletNeighbors(Exchange exchange) throws Exception {
+ Droplets droplets = getEndpoint().getDigitalOceanClient().getDropletNeighbors(dropletId, configuration.getPage());
+ LOG.trace("Neighbors for Droplet {} : page {} [{}] ", dropletId, configuration.getPage(), droplets.getDroplets());
+ exchange.getOut().setBody(droplets.getDroplets());
+ }
+
+ private void getAllDropletNeighbors(Exchange exchange) throws Exception {
+ Neighbors neighbors = getEndpoint().getDigitalOceanClient().getAllDropletNeighbors(configuration.getPage());
+ LOG.trace("All Neighbors : page {} [{}] ", configuration.getPage(), neighbors.getNeighbors());
+ exchange.getOut().setBody(neighbors.getNeighbors());
+ }
+
+ private void deleteDroplet(Exchange exchange) throws Exception {
+ Delete delete = getEndpoint().getDigitalOceanClient().deleteDroplet(dropletId);
+ LOG.trace("Delete Droplet {} ", delete);
+ exchange.getOut().setBody(delete);
+ }
+
+ @SuppressWarnings("unchecked")
+ private void createDroplet(Exchange exchange) throws Exception {
+ Message in = exchange.getIn();
+
+ Droplet droplet = new Droplet();
+
+ if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(DigitalOceanHeaders.REGION)))
+ droplet.setRegion(new Region(in.getHeader(DigitalOceanHeaders.REGION, String.class)));
+ else
+ throw new IllegalArgumentException(DigitalOceanHeaders.REGION + " must be specified");
+
+ if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(DigitalOceanHeaders.DROPLET_SIZE)))
+ droplet.setSize(in.getHeader(DigitalOceanHeaders.DROPLET_SIZE, String.class));
+ else
+ throw new IllegalArgumentException(DigitalOceanHeaders.DROPLET_SIZE + " must be specified");
+
+ if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(DigitalOceanHeaders.DROPLET_IMAGE)))
+ droplet.setImage(new Image(in.getHeader(DigitalOceanHeaders.DROPLET_IMAGE, String.class)));
+ else
+ throw new IllegalArgumentException(DigitalOceanHeaders.DROPLET_IMAGE + " must be specified");
+
+ if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(DigitalOceanHeaders.DROPLET_KEYS))) {
+ List<String> keys = (List<String>) exchange.getIn().getHeader(DigitalOceanHeaders.DROPLET_KEYS);
+ droplet.setKeys(keys.stream().map(Key::new).collect(Collectors.toList()));
+ }
+
+ if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(DigitalOceanHeaders.DROPLET_ENABLE_BACKUPS)))
+ droplet.setEnableBackup(in.getHeader(DigitalOceanHeaders.DROPLET_ENABLE_BACKUPS, Boolean.class));
+
+ if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(DigitalOceanHeaders.DROPLET_ENABLE_IPV6)))
+ droplet.setEnableIpv6(in.getHeader(DigitalOceanHeaders.DROPLET_ENABLE_IPV6, Boolean.class));
+
+ if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(DigitalOceanHeaders.DROPLET_ENABLE_PRIVATE_NETWORKING)))
+ droplet.setEnablePrivateNetworking(in.getHeader(DigitalOceanHeaders.DROPLET_ENABLE_PRIVATE_NETWORKING, Boolean.class));
+
+ if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(DigitalOceanHeaders.DROPLET_USER_DATA)))
+ droplet.setUserData(in.getHeader(DigitalOceanHeaders.DROPLET_USER_DATA, String.class));
+
+ if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(DigitalOceanHeaders.DROPLET_VOLUMES)))
+ droplet.setVolumeIds((List<String>) exchange.getIn().getHeader(DigitalOceanHeaders.DROPLET_VOLUMES));
+
+ if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(DigitalOceanHeaders.DROPLET_TAGS)))
+ droplet.setTags((List<String>) exchange.getIn().getHeader(DigitalOceanHeaders.DROPLET_TAGS));
+
+ if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(DigitalOceanHeaders.NAMES))) {
+ droplet.setNames((List<String>) in.getHeader(DigitalOceanHeaders.NAMES));
+ Droplets droplets = getEndpoint().getDigitalOceanClient().createDroplets(droplet);
+ LOG.trace("Droplets created {} ", droplets);
+ exchange.getOut().setBody(droplets.getDroplets());
+ } else if(ObjectHelper.isNotEmpty(exchange.getIn().getHeader(DigitalOceanHeaders.NAME))) {
+ droplet.setName(in.getHeader(DigitalOceanHeaders.NAME, String.class));
+ droplet = getEndpoint().getDigitalOceanClient().createDroplet(droplet);
+ LOG.trace("Droplet created {} ", droplet);
+ exchange.getOut().setBody(droplet);
+ } else
+ throw new IllegalArgumentException(DigitalOceanHeaders.NAMES + " or " + DigitalOceanHeaders.NAME + " must be specified");
+
+ }
+
+ private void restoreDroplet(Exchange exchange) throws Exception {
+ if (ObjectHelper.isEmpty(exchange.getIn().getHeader(DigitalOceanHeaders.IMAGE_ID)))
+ throw new IllegalArgumentException(DigitalOceanHeaders.IMAGE_ID + " must be specified");
+
+ Action action = getEndpoint().getDigitalOceanClient().restoreDroplet(dropletId, exchange.getIn().getHeader(DigitalOceanHeaders.IMAGE_ID, Integer.class));
+ LOG.trace("DropletAction Restore [{}] ", action);
+ exchange.getOut().setBody(action);
+
+ }
+
+ private void resizeDroplet(Exchange exchange) throws Exception {
+ if (ObjectHelper.isEmpty(exchange.getIn().getHeader(DigitalOceanHeaders.DROPLET_SIZE)))
+ throw new IllegalArgumentException(DigitalOceanHeaders.DROPLET_SIZE + " must be specified");
+
+ Action action = getEndpoint().getDigitalOceanClient().resizeDroplet(dropletId, exchange.getIn().getHeader(DigitalOceanHeaders.DROPLET_SIZE, String.class));
+ LOG.trace("DropletAction Resize [{}] ", action);
+ exchange.getOut().setBody(action);
+ }
+
+
+ private void rebuildDroplet(Exchange exchange) throws Exception {
+ if (ObjectHelper.isEmpty(exchange.getIn().getHeader(DigitalOceanHeaders.IMAGE_ID)))
+ throw new IllegalArgumentException(DigitalOceanHeaders.IMAGE_ID + " must be specified");
+
+ Action action = getEndpoint().getDigitalOceanClient().rebuildDroplet(dropletId, exchange.getIn().getHeader(DigitalOceanHeaders.IMAGE_ID, Integer.class));
+ LOG.trace("Rebuild Droplet {} : [{}] ", dropletId, action);
+ exchange.getOut().setBody(action);
+ }
+
+ private void renameDroplet(Exchange exchange) throws Exception {
+ if (ObjectHelper.isEmpty(exchange.getIn().getHeader(DigitalOceanHeaders.NAME)))
+ throw new IllegalArgumentException(DigitalOceanHeaders.NAME + " must be specified");
+
+ Action action = getEndpoint().getDigitalOceanClient().renameDroplet(dropletId, exchange.getIn().getHeader(DigitalOceanHeaders.NAME, String.class));
+ LOG.trace("Rename Droplet {} : [{}] ", dropletId, action);
+ exchange.getOut().setBody(action);
+ }
+
+
+ private void changeDropletKernel(Exchange exchange) throws Exception {
+ if (ObjectHelper.isEmpty(exchange.getIn().getHeader(DigitalOceanHeaders.KERNEL_ID)))
+ throw new IllegalArgumentException(DigitalOceanHeaders.KERNEL_ID + " must be specified");
+
+ Action action = getEndpoint().getDigitalOceanClient().changeDropletKernel(dropletId, exchange.getIn().getHeader(DigitalOceanHeaders.KERNEL_ID, Integer.class));
+ LOG.trace("Rename Droplet {} : [{}] ", dropletId, action);
+ exchange.getOut().setBody(action);
+ }
+
+ private void resetDropletPassword(Exchange exchange) throws Exception {
+ Action action = getEndpoint().getDigitalOceanClient().resetDropletPassword(dropletId);
+ LOG.trace("Reset password Droplet {} : [{}] ", dropletId, action);
+ exchange.getOut().setBody(action);
+ }
+
+
+ private void powerOnDroplet(Exchange exchange) throws Exception {
+ Action action = getEndpoint().getDigitalOceanClient().powerOnDroplet(dropletId);
+ LOG.trace("Power on Droplet {} : [{}] ", dropletId, action);
+ exchange.getOut().setBody(action);
+ }
+
+ private void powerOffDroplet(Exchange exchange) throws Exception {
+ Action action = getEndpoint().getDigitalOceanClient().powerOffDroplet(dropletId);
+ LOG.trace("Power off Droplet {} : [{}] ", dropletId, action);
+ exchange.getOut().setBody(action);
+ }
+
+ private void shutdownDroplet(Exchange exchange) throws Exception {
+ Action action = getEndpoint().getDigitalOceanClient().shutdownDroplet(dropletId);
+ LOG.trace("Shutdown Droplet {} : [{}] ", dropletId, action);
+ exchange.getOut().setBody(action);
+ }
+
+ private void powerCycleDroplet(Exchange exchange) throws Exception {
+ Action action = getEndpoint().getDigitalOceanClient().powerCycleDroplet(dropletId);
+ LOG.trace("Power cycle Droplet {} : [{}] ", dropletId, action);
+ exchange.getOut().setBody(action);
+ }
+
+ private void enableDropletBackups(Exchange exchange) throws Exception {
+ Action action = getEndpoint().getDigitalOceanClient().enableDropletBackups(dropletId);
+ LOG.trace("Enable backups Droplet {} : [{}] ", dropletId, action);
+ exchange.getOut().setBody(action);
+ }
+
+ private void disableDropletBackups(Exchange exchange) throws Exception {
+ Action action = getEndpoint().getDigitalOceanClient().disableDropletBackups(dropletId);
+ LOG.trace("Disable backups for Droplet {} : [{}] ", dropletId, action);
+ exchange.getOut().setBody(action);
+ }
+
+ private void enableDropletIpv6(Exchange exchange) throws Exception {
+ Action action = getEndpoint().getDigitalOceanClient().enableDropletIpv6(dropletId);
+ LOG.trace("Enable IP v6 for Droplet {} : [{}] ", dropletId, action);
+ exchange.getOut().setBody(action);
+ }
+
+ private void enableDropletPrivateNetworking(Exchange exchange) throws Exception {
+ Action action = getEndpoint().getDigitalOceanClient().enableDropletPrivateNetworking(dropletId);
+ LOG.trace("Enable private networking for Droplet {} : [{}] ", dropletId, action);
+ exchange.getOut().setBody(action);
+ }
+
+
+ private void rebootDroplet(Exchange exchange) throws Exception {
+ Action action = getEndpoint().getDigitalOceanClient().rebootDroplet(dropletId);
+ LOG.trace("Reboot Droplet {} : [{}] ", dropletId, action);
+ exchange.getOut().setBody(action);
+ }
+
+ private void takeDropletSnapshot(Exchange exchange) throws Exception {
+ Action action;
+
+ if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(DigitalOceanHeaders.NAME)))
+ action = getEndpoint().getDigitalOceanClient().takeDropletSnapshot(dropletId, exchange.getIn().getHeader(DigitalOceanHeaders.NAME, String.class));
+ else
+ action = getEndpoint().getDigitalOceanClient().takeDropletSnapshot(dropletId);
+
+ LOG.trace("Take Snapshot for Droplet {} : [{}] ", dropletId, action);
+ exchange.getOut().setBody(action);
+ }
+
+ private void tagDroplet(Exchange exchange) throws Exception {
+ if (ObjectHelper.isEmpty(exchange.getIn().getHeader(DigitalOceanHeaders.NAME)))
+ throw new IllegalArgumentException(DigitalOceanHeaders.NAME + " must be specified");
+
+ ArrayList<Resource> resources = new ArrayList<>(1);
+ resources.add(new Resource(dropletId.toString(), ResourceType.DROPLET));
+ Response response = getEndpoint().getDigitalOceanClient().tagResources(dropletId.toString(), resources);
+ LOG.trace("Tag Droplet {} : [{}] ", dropletId, response);
+ exchange.getOut().setBody(response);
+ }
+
+ private void untagDroplet(Exchange exchange) throws Exception {
+ if (ObjectHelper.isEmpty(exchange.getIn().getHeader(DigitalOceanHeaders.NAME)))
+ throw new IllegalArgumentException(DigitalOceanHeaders.NAME + " must be specified");
+
+ ArrayList<Resource> resources = new ArrayList<>(1);
+ resources.add(new Resource(dropletId.toString(), ResourceType.DROPLET));
+ Response response = getEndpoint().getDigitalOceanClient().untagResources(dropletId.toString(), resources);
+ LOG.trace("Untag Droplet {} : [{}] ", dropletId, response);
+ exchange.getOut().setBody(response);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/1d57f7b0/components/camel-digitalocean/src/main/java/com/viwilo/camel/producer/DigitalOceanFloatingIPsProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-digitalocean/src/main/java/com/viwilo/camel/producer/DigitalOceanFloatingIPsProducer.java b/components/camel-digitalocean/src/main/java/com/viwilo/camel/producer/DigitalOceanFloatingIPsProducer.java
new file mode 100644
index 0000000..ed08b25
--- /dev/null
+++ b/components/camel-digitalocean/src/main/java/com/viwilo/camel/producer/DigitalOceanFloatingIPsProducer.java
@@ -0,0 +1,151 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.viwilo.camel.producer;
+
+import com.myjeeva.digitalocean.pojo.*;
+import com.viwilo.camel.DigitalOceanConfiguration;
+import com.viwilo.camel.constants.DigitalOceanHeaders;
+import com.viwilo.camel.DigitalOceanEndpoint;
+import org.apache.camel.Exchange;
+import org.apache.camel.util.ObjectHelper;
+
+/**
+ * The DigitalOcean producer for FloatingIps API.
+ */
+public class DigitalOceanFloatingIPsProducer extends DigitalOceanProducer {
+
+ public DigitalOceanFloatingIPsProducer(DigitalOceanEndpoint endpoint, DigitalOceanConfiguration configuration) {
+ super(endpoint, configuration);
+ }
+
+ public void process(Exchange exchange) throws Exception {
+ switch(determineOperation(exchange)) {
+
+ case list:
+ getFloatingIPs(exchange);
+ break;
+ case create:
+ createFloatingIp(exchange);
+ break;
+ case get:
+ getFloatingIP(exchange);
+ break;
+ case delete:
+ deleteFloatingIP(exchange);
+ break;
+ case assign:
+ assignFloatingIPToDroplet(exchange);
+ break;
+ case unassign:
+ unassignFloatingIP(exchange);
+ break;
+ case listActions:
+ getFloatingIPActions(exchange);
+ break;
+ default:
+ throw new IllegalArgumentException("Unsupported operation");
+ }
+ }
+
+ private void createFloatingIp(Exchange exchange) throws Exception {
+ Integer dropletId = exchange.getIn().getHeader(DigitalOceanHeaders.DROPLET_ID, Integer.class);
+ String region = exchange.getIn().getHeader(DigitalOceanHeaders.REGION, String.class);
+ FloatingIP ip;
+
+ if (ObjectHelper.isNotEmpty(dropletId))
+ ip = getEndpoint().getDigitalOceanClient().createFloatingIP(dropletId);
+ else if (ObjectHelper.isNotEmpty(region))
+ ip = getEndpoint().getDigitalOceanClient().createFloatingIP(region);
+ else
+ throw new IllegalArgumentException(DigitalOceanHeaders.DROPLET_ID + " or " + DigitalOceanHeaders.REGION + " must be specified");
+
+ LOG.trace("FloatingIP [{}] ", ip);
+ exchange.getOut().setBody(ip);
+ }
+
+
+ private void getFloatingIPs(Exchange exchange) throws Exception {
+ FloatingIPs ips = getEndpoint().getDigitalOceanClient().getAvailableFloatingIPs(configuration.getPage(), configuration.getPerPage());
+ LOG.trace("All Floating IPs : page {} / {} per page [{}] ", configuration.getPage(), configuration.getPerPage(), ips.getFloatingIPs());
+ exchange.getOut().setBody(ips.getFloatingIPs());
+ }
+
+
+ private void getFloatingIP(Exchange exchange) throws Exception {
+ String ipAddress = exchange.getIn().getHeader(DigitalOceanHeaders.FLOATING_IP_ADDRESS, String.class);
+
+ if (ObjectHelper.isEmpty(ipAddress))
+ throw new IllegalArgumentException(DigitalOceanHeaders.FLOATING_IP_ADDRESS + " must be specified");
+
+
+ FloatingIP ip = getEndpoint().getDigitalOceanClient().getFloatingIPInfo(ipAddress);
+ LOG.trace("Floating IP {} ", ip);
+ exchange.getOut().setBody(ip);
+ }
+
+
+ private void deleteFloatingIP(Exchange exchange) throws Exception {
+ String ipAddress = exchange.getIn().getHeader(DigitalOceanHeaders.FLOATING_IP_ADDRESS, String.class);
+
+ if (ObjectHelper.isEmpty(ipAddress))
+ throw new IllegalArgumentException(DigitalOceanHeaders.FLOATING_IP_ADDRESS + " must be specified");
+
+
+ Delete delete = getEndpoint().getDigitalOceanClient().deleteFloatingIP(ipAddress);
+ LOG.trace("Delete Floating IP {} ", delete);
+ exchange.getOut().setBody(delete);
+ }
+
+ private void assignFloatingIPToDroplet(Exchange exchange) throws Exception {
+ Integer dropletId = exchange.getIn().getHeader(DigitalOceanHeaders.DROPLET_ID, Integer.class);
+
+ if(ObjectHelper.isEmpty(dropletId))
+ throw new IllegalArgumentException(DigitalOceanHeaders.DROPLET_ID + " must be specified");
+
+ String ipAddress = exchange.getIn().getHeader(DigitalOceanHeaders.FLOATING_IP_ADDRESS, String.class);
+
+ if (ObjectHelper.isEmpty(ipAddress))
+ throw new IllegalArgumentException(DigitalOceanHeaders.FLOATING_IP_ADDRESS + " must be specified");
+
+ Action action = getEndpoint().getDigitalOceanClient().assignFloatingIP(dropletId, ipAddress);
+ LOG.trace("Assign Floating IP to Droplet {} ", action);
+ exchange.getOut().setBody(action);
+ }
+
+ private void unassignFloatingIP(Exchange exchange) throws Exception {
+ String ipAddress = exchange.getIn().getHeader(DigitalOceanHeaders.FLOATING_IP_ADDRESS, String.class);
+
+ if (ObjectHelper.isEmpty(ipAddress))
+ throw new IllegalArgumentException(DigitalOceanHeaders.FLOATING_IP_ADDRESS + " must be specified");
+
+ Action action = getEndpoint().getDigitalOceanClient().unassignFloatingIP(ipAddress);
+ LOG.trace("Unassign Floating IP {} ", action);
+ exchange.getOut().setBody(action);
+ }
+
+ private void getFloatingIPActions(Exchange exchange) throws Exception {
+ String ipAddress = exchange.getIn().getHeader(DigitalOceanHeaders.FLOATING_IP_ADDRESS, String.class);
+
+ if (ObjectHelper.isEmpty(ipAddress))
+ throw new IllegalArgumentException(DigitalOceanHeaders.FLOATING_IP_ADDRESS + " must be specified");
+
+ Actions actions = getEndpoint().getDigitalOceanClient().getAvailableFloatingIPActions(ipAddress, configuration.getPage(), configuration.getPerPage());
+ LOG.trace("Actions for FloatingIP {} : page {} / {} per page [{}] ", ipAddress, configuration.getPage(), configuration.getPerPage(), actions.getActions());
+ exchange.getOut().setBody(actions.getActions());
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/1d57f7b0/components/camel-digitalocean/src/main/java/com/viwilo/camel/producer/DigitalOceanImagesProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-digitalocean/src/main/java/com/viwilo/camel/producer/DigitalOceanImagesProducer.java b/components/camel-digitalocean/src/main/java/com/viwilo/camel/producer/DigitalOceanImagesProducer.java
new file mode 100644
index 0000000..71a2147
--- /dev/null
+++ b/components/camel-digitalocean/src/main/java/com/viwilo/camel/producer/DigitalOceanImagesProducer.java
@@ -0,0 +1,175 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.viwilo.camel.producer;
+
+import com.myjeeva.digitalocean.common.ActionType;
+import com.myjeeva.digitalocean.pojo.*;
+import com.viwilo.camel.DigitalOceanConfiguration;
+import com.viwilo.camel.constants.DigitalOceanHeaders;
+import com.viwilo.camel.DigitalOceanEndpoint;
+import com.viwilo.camel.constants.DigitalOceanImageTypes;
+import org.apache.camel.Exchange;
+import org.apache.camel.util.ObjectHelper;
+
+/**
+ * The DigitalOcean producer for Images API.
+ */
+public class DigitalOceanImagesProducer extends DigitalOceanProducer {
+
+ public DigitalOceanImagesProducer(DigitalOceanEndpoint endpoint, DigitalOceanConfiguration configuration) {
+ super(endpoint, configuration);
+ }
+
+ public void process(Exchange exchange) throws Exception {
+
+ switch(determineOperation(exchange)) {
+
+ case list:
+ getImages(exchange);
+ break;
+ case ownList:
+ getUserImages(exchange);
+ break;
+ case listActions:
+ getImageActions(exchange);
+ break;
+ case get:
+ getImage(exchange);
+ break;
+ case update:
+ updateImage(exchange);
+ break;
+ case delete:
+ deleteImage(exchange);
+ break;
+ case transfer:
+ transferImage(exchange);
+ break;
+ case convert:
+ convertImageToSnapshot(exchange);
+ break;
+ default:
+ throw new IllegalArgumentException("Unsupported operation");
+ }
+ }
+
+
+ private void getUserImages(Exchange exchange) throws Exception {
+ Images images = getEndpoint().getDigitalOceanClient().getUserImages(configuration.getPage(), configuration.getPerPage());
+ LOG.trace("User images : page {} / {} per page [{}] ", configuration.getPage(), configuration.getPerPage(), images.getImages());
+ exchange.getOut().setBody(images.getImages());
+ }
+
+
+ private void getImages(Exchange exchange) throws Exception {
+ DigitalOceanImageTypes type = exchange.getIn().getHeader(DigitalOceanHeaders.TYPE, DigitalOceanImageTypes.class);
+ Images images;
+
+ if (ObjectHelper.isNotEmpty(type))
+ images = getEndpoint().getDigitalOceanClient().getAvailableImages(configuration.getPage(), configuration.getPerPage(), ActionType.valueOf(type.name()));
+ else
+ images = getEndpoint().getDigitalOceanClient().getAvailableImages(configuration.getPage(), configuration.getPerPage());
+ LOG.trace("All Images : page {} / {} per page [{}] ", configuration.getPage(), configuration.getPerPage(), images.getImages());
+ exchange.getOut().setBody(images.getImages());
+ }
+
+ private void getImage(Exchange exchange) throws Exception {
+
+ Integer imageId = exchange.getIn().getHeader(DigitalOceanHeaders.ID, Integer.class);
+ String slug = exchange.getIn().getHeader(DigitalOceanHeaders.DROPLET_IMAGE, String.class);
+ Image image;
+
+ if (ObjectHelper.isNotEmpty(imageId))
+ image = getEndpoint().getDigitalOceanClient().getImageInfo(imageId);
+ else if (ObjectHelper.isNotEmpty(slug))
+ image = getEndpoint().getDigitalOceanClient().getImageInfo(slug);
+ else
+ throw new IllegalArgumentException(DigitalOceanHeaders.ID + " or " + DigitalOceanHeaders.DROPLET_IMAGE + " must be specified");
+
+ LOG.trace("Image [{}] ", image);
+ exchange.getOut().setBody(image);
+ }
+
+
+ private void getImageActions(Exchange exchange) throws Exception {
+ Integer imageId = exchange.getIn().getHeader(DigitalOceanHeaders.ID, Integer.class);
+
+ if (ObjectHelper.isEmpty(imageId))
+ throw new IllegalArgumentException(DigitalOceanHeaders.ID + " must be specified");
+
+ Actions actions = getEndpoint().getDigitalOceanClient().getAvailableImageActions(imageId, configuration.getPage(), configuration.getPerPage());
+ LOG.trace("Actions for Image {} : page {} / {} per page [{}] ", imageId, configuration.getPage(), configuration.getPerPage(), actions.getActions());
+ exchange.getOut().setBody(actions.getActions());
+ }
+
+ private void updateImage(Exchange exchange) throws Exception {
+ Integer imageId = exchange.getIn().getHeader(DigitalOceanHeaders.ID, Integer.class);
+
+ if (ObjectHelper.isEmpty(imageId))
+ throw new IllegalArgumentException(DigitalOceanHeaders.ID + " must be specified");
+
+ String name = exchange.getIn().getHeader(DigitalOceanHeaders.NAME, String.class);
+
+ if (ObjectHelper.isEmpty(name))
+ throw new IllegalArgumentException(DigitalOceanHeaders.NAME + " must be specified");
+
+ Image image = new Image();
+ image.setId(imageId);
+ image.setName(name);
+ image = getEndpoint().getDigitalOceanClient().updateImage(image);
+ LOG.trace("Update Image {} [{}] ", imageId, image);
+ exchange.getOut().setBody(image);
+ }
+
+ private void deleteImage(Exchange exchange) throws Exception {
+ Integer imageId = exchange.getIn().getHeader(DigitalOceanHeaders.ID, Integer.class);
+
+ if (ObjectHelper.isEmpty(imageId))
+ throw new IllegalArgumentException(DigitalOceanHeaders.ID + " must be specified");
+
+ Delete delete = getEndpoint().getDigitalOceanClient().deleteImage(imageId);
+ LOG.trace("Delete Image {} [{}] ", imageId, delete);
+ exchange.getOut().setBody(delete);
+ }
+
+ private void transferImage(Exchange exchange) throws Exception {
+ Integer imageId = exchange.getIn().getHeader(DigitalOceanHeaders.ID, Integer.class);
+
+ if (ObjectHelper.isEmpty(imageId))
+ throw new IllegalArgumentException(DigitalOceanHeaders.ID + " must be specified");
+
+ String region = exchange.getIn().getHeader(DigitalOceanHeaders.REGION, String.class);
+
+ if (ObjectHelper.isEmpty(region))
+ throw new IllegalArgumentException(DigitalOceanHeaders.REGION + " must be specified");
+
+ Action action = getEndpoint().getDigitalOceanClient().transferImage(imageId, region);
+ LOG.trace("Transfer Image {} to Region {} [{}] ", imageId, region, action);
+ exchange.getOut().setBody(action);
+ }
+
+ private void convertImageToSnapshot(Exchange exchange) throws Exception {
+ Integer imageId = exchange.getIn().getHeader(DigitalOceanHeaders.ID, Integer.class);
+
+ if (ObjectHelper.isEmpty(imageId))
+ throw new IllegalArgumentException(DigitalOceanHeaders.ID + " must be specified");
+
+ Action action = getEndpoint().getDigitalOceanClient().convertImage(imageId);
+ LOG.trace("Convert Image {} [{}] ", imageId, action);
+ exchange.getOut().setBody(action);
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/1d57f7b0/components/camel-digitalocean/src/main/java/com/viwilo/camel/producer/DigitalOceanKeysProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-digitalocean/src/main/java/com/viwilo/camel/producer/DigitalOceanKeysProducer.java b/components/camel-digitalocean/src/main/java/com/viwilo/camel/producer/DigitalOceanKeysProducer.java
new file mode 100644
index 0000000..bb66170
--- /dev/null
+++ b/components/camel-digitalocean/src/main/java/com/viwilo/camel/producer/DigitalOceanKeysProducer.java
@@ -0,0 +1,144 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.viwilo.camel.producer;
+
+import com.myjeeva.digitalocean.pojo.*;
+import com.viwilo.camel.DigitalOceanConfiguration;
+import com.viwilo.camel.constants.DigitalOceanHeaders;
+import com.viwilo.camel.DigitalOceanEndpoint;
+import org.apache.camel.Exchange;
+import org.apache.camel.util.ObjectHelper;
+
+/**
+ * The DigitalOcean producer for SSH Keys API.
+ */
+public class DigitalOceanKeysProducer extends DigitalOceanProducer {
+
+ public DigitalOceanKeysProducer(DigitalOceanEndpoint endpoint, DigitalOceanConfiguration configuration) {
+ super(endpoint, configuration);
+ }
+
+ public void process(Exchange exchange) throws Exception {
+
+ switch(determineOperation(exchange)) {
+
+ case list:
+ getKeys(exchange);
+ break;
+ case create:
+ createKey(exchange);
+ break;
+ case get:
+ getKey(exchange);
+ break;
+ case update:
+ updateKey(exchange);
+ break;
+ case delete:
+ deleteKey(exchange);
+ break;
+ default:
+ throw new IllegalArgumentException("Unsupported operation");
+ }
+ }
+
+
+ private void getKey(Exchange exchange) throws Exception {
+ Integer keyId = exchange.getIn().getHeader(DigitalOceanHeaders.ID, Integer.class);
+ String fingerprint = exchange.getIn().getHeader(DigitalOceanHeaders.KEY_FINGERPRINT, String.class);
+ Key key;
+
+ if (ObjectHelper.isNotEmpty(keyId))
+ key = getEndpoint().getDigitalOceanClient().getKeyInfo(keyId);
+ else if (ObjectHelper.isNotEmpty(fingerprint))
+ key = getEndpoint().getDigitalOceanClient().getKeyInfo(fingerprint);
+ else
+ throw new IllegalArgumentException(DigitalOceanHeaders.ID + " or " + DigitalOceanHeaders.KEY_FINGERPRINT + " must be specified");
+
+ LOG.trace("Key [{}] ", key);
+ exchange.getOut().setBody(key);
+ }
+
+ private void getKeys(Exchange exchange) throws Exception {
+ Keys keys = getEndpoint().getDigitalOceanClient().getAvailableKeys(configuration.getPage());
+ LOG.trace("All Keys : page {} [{}] ", configuration.getPage(), keys.getKeys());
+ exchange.getOut().setBody(keys.getKeys());
+ }
+
+ private void deleteKey(Exchange exchange) throws Exception {
+ Integer keyId = exchange.getIn().getHeader(DigitalOceanHeaders.ID, Integer.class);
+ String fingerprint = exchange.getIn().getHeader(DigitalOceanHeaders.KEY_FINGERPRINT, String.class);
+ Delete delete;
+
+ if (ObjectHelper.isNotEmpty(keyId))
+ delete = getEndpoint().getDigitalOceanClient().deleteKey(keyId);
+ else if (ObjectHelper.isNotEmpty(fingerprint))
+ delete = getEndpoint().getDigitalOceanClient().deleteKey(fingerprint);
+ else
+ throw new IllegalArgumentException(DigitalOceanHeaders.ID + " or " + DigitalOceanHeaders.KEY_FINGERPRINT + " must be specified");
+
+ LOG.trace("Delete Key {} ", delete);
+ exchange.getOut().setBody(delete);
+ }
+
+
+ private void createKey(Exchange exchange) throws Exception {
+ Key key = new Key();
+
+ String name = exchange.getIn().getHeader(DigitalOceanHeaders.NAME, String.class);
+
+ if (ObjectHelper.isEmpty(name))
+ throw new IllegalArgumentException(DigitalOceanHeaders.NAME + " must be specified");
+ else
+ key.setName(name);
+
+ String publicKey = exchange.getIn().getHeader(DigitalOceanHeaders.KEY_PUBLIC_KEY, String.class);
+
+ if (ObjectHelper.isEmpty(publicKey))
+ throw new IllegalArgumentException(DigitalOceanHeaders.KEY_PUBLIC_KEY + " must be specified");
+ else
+ key.setPublicKey(publicKey);
+
+ key = getEndpoint().getDigitalOceanClient().createKey(key);
+ LOG.trace("Key created {} ", key);
+ exchange.getOut().setBody(key);
+
+ }
+
+ private void updateKey(Exchange exchange) throws Exception {
+ Integer keyId = exchange.getIn().getHeader(DigitalOceanHeaders.ID, Integer.class);
+ String fingerprint = exchange.getIn().getHeader(DigitalOceanHeaders.KEY_FINGERPRINT, String.class);
+ Key key;
+
+ String name = exchange.getIn().getHeader(DigitalOceanHeaders.NAME, String.class);
+
+ if (ObjectHelper.isEmpty(name))
+ throw new IllegalArgumentException(DigitalOceanHeaders.NAME + " must be specified");
+
+ if (ObjectHelper.isNotEmpty(keyId))
+ key = getEndpoint().getDigitalOceanClient().updateKey(keyId, name);
+ else if (ObjectHelper.isNotEmpty(fingerprint))
+ key = getEndpoint().getDigitalOceanClient().updateKey(fingerprint, name);
+ else
+ throw new IllegalArgumentException(DigitalOceanHeaders.ID + " or " + DigitalOceanHeaders.KEY_FINGERPRINT + " must be specified");
+
+ LOG.trace("Update Key [{}] ", key);
+ exchange.getOut().setBody(key);
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/1d57f7b0/components/camel-digitalocean/src/main/java/com/viwilo/camel/producer/DigitalOceanProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-digitalocean/src/main/java/com/viwilo/camel/producer/DigitalOceanProducer.java b/components/camel-digitalocean/src/main/java/com/viwilo/camel/producer/DigitalOceanProducer.java
new file mode 100644
index 0000000..2ed0165
--- /dev/null
+++ b/components/camel-digitalocean/src/main/java/com/viwilo/camel/producer/DigitalOceanProducer.java
@@ -0,0 +1,53 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.viwilo.camel.producer;
+
+import com.viwilo.camel.DigitalOceanConfiguration;
+import com.viwilo.camel.constants.DigitalOceanHeaders;
+import com.viwilo.camel.DigitalOceanEndpoint;
+import com.viwilo.camel.constants.DigitalOceanOperations;
+import org.apache.camel.Exchange;
+import org.apache.camel.impl.DefaultProducer;
+import org.apache.camel.util.ObjectHelper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * The DigitalOcean producer.
+ */
+public abstract class DigitalOceanProducer extends DefaultProducer {
+ protected static final Logger LOG = LoggerFactory.getLogger(DigitalOceanProducer.class);
+
+ private DigitalOceanEndpoint endpoint;
+ protected DigitalOceanConfiguration configuration;
+
+ public DigitalOceanProducer(DigitalOceanEndpoint endpoint, DigitalOceanConfiguration configuration) {
+ super(endpoint);
+ this.endpoint = endpoint;
+ this.configuration = configuration;
+ }
+
+ protected DigitalOceanOperations determineOperation(Exchange exchange) {
+ DigitalOceanOperations operation = exchange.getIn().getHeader(DigitalOceanHeaders.OPERATION, DigitalOceanOperations.class);
+ return ObjectHelper.isNotEmpty(operation) ? operation : configuration.getOperation();
+ }
+
+ @Override
+ public DigitalOceanEndpoint getEndpoint() {
+ return endpoint;
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/1d57f7b0/components/camel-digitalocean/src/main/java/com/viwilo/camel/producer/DigitalOceanRegionsProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-digitalocean/src/main/java/com/viwilo/camel/producer/DigitalOceanRegionsProducer.java b/components/camel-digitalocean/src/main/java/com/viwilo/camel/producer/DigitalOceanRegionsProducer.java
new file mode 100644
index 0000000..cda1116
--- /dev/null
+++ b/components/camel-digitalocean/src/main/java/com/viwilo/camel/producer/DigitalOceanRegionsProducer.java
@@ -0,0 +1,39 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.viwilo.camel.producer;
+
+import com.myjeeva.digitalocean.pojo.*;
+import com.viwilo.camel.DigitalOceanConfiguration;
+import com.viwilo.camel.DigitalOceanEndpoint;
+import org.apache.camel.Exchange;
+
+/**
+ * The DigitalOcean producer for Regions API.
+ */
+public class DigitalOceanRegionsProducer extends DigitalOceanProducer {
+
+ public DigitalOceanRegionsProducer(DigitalOceanEndpoint endpoint, DigitalOceanConfiguration configuration) {
+ super(endpoint, configuration);
+ }
+
+ public void process(Exchange exchange) throws Exception {
+ Regions regions = getEndpoint().getDigitalOceanClient().getAvailableRegions(configuration.getPage());
+ LOG.trace("All Regions : page {} [{}] ", regions.getRegions(), configuration.getPage());
+ exchange.getOut().setBody(regions.getRegions());
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/1d57f7b0/components/camel-digitalocean/src/main/java/com/viwilo/camel/producer/DigitalOceanSizesProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-digitalocean/src/main/java/com/viwilo/camel/producer/DigitalOceanSizesProducer.java b/components/camel-digitalocean/src/main/java/com/viwilo/camel/producer/DigitalOceanSizesProducer.java
new file mode 100644
index 0000000..0f8d622
--- /dev/null
+++ b/components/camel-digitalocean/src/main/java/com/viwilo/camel/producer/DigitalOceanSizesProducer.java
@@ -0,0 +1,39 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.viwilo.camel.producer;
+
+import com.myjeeva.digitalocean.pojo.*;
+import com.viwilo.camel.DigitalOceanConfiguration;
+import com.viwilo.camel.DigitalOceanEndpoint;
+import org.apache.camel.Exchange;
+
+/**
+ * The DigitalOcean producer for Sizes API.
+ */
+public class DigitalOceanSizesProducer extends DigitalOceanProducer {
+
+ public DigitalOceanSizesProducer(DigitalOceanEndpoint endpoint, DigitalOceanConfiguration configuration) {
+ super(endpoint, configuration);
+ }
+
+ public void process(Exchange exchange) throws Exception {
+ Sizes sizes = getEndpoint().getDigitalOceanClient().getAvailableSizes(configuration.getPage());
+ LOG.trace("All Sizes : page {} [{}] ", sizes.getSizes(), configuration.getPage());
+ exchange.getOut().setBody(sizes.getSizes());
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/1d57f7b0/components/camel-digitalocean/src/main/java/com/viwilo/camel/producer/DigitalOceanSnapshotsProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-digitalocean/src/main/java/com/viwilo/camel/producer/DigitalOceanSnapshotsProducer.java b/components/camel-digitalocean/src/main/java/com/viwilo/camel/producer/DigitalOceanSnapshotsProducer.java
new file mode 100644
index 0000000..2445529
--- /dev/null
+++ b/components/camel-digitalocean/src/main/java/com/viwilo/camel/producer/DigitalOceanSnapshotsProducer.java
@@ -0,0 +1,101 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.viwilo.camel.producer;
+
+import com.myjeeva.digitalocean.pojo.Delete;
+import com.myjeeva.digitalocean.pojo.Snapshot;
+import com.myjeeva.digitalocean.pojo.Snapshots;
+import com.viwilo.camel.DigitalOceanConfiguration;
+import com.viwilo.camel.DigitalOceanEndpoint;
+import com.viwilo.camel.constants.DigitalOceanHeaders;
+import com.viwilo.camel.constants.DigitalOceanSnapshotTypes;
+import org.apache.camel.Exchange;
+import org.apache.camel.util.ObjectHelper;
+
+/**
+ * The DigitalOcean producer for Snapshots API.
+ */
+public class DigitalOceanSnapshotsProducer extends DigitalOceanProducer {
+
+ public DigitalOceanSnapshotsProducer(DigitalOceanEndpoint endpoint, DigitalOceanConfiguration configuration) {
+ super(endpoint, configuration);
+ }
+
+ public void process(Exchange exchange) throws Exception {
+
+ switch (determineOperation(exchange)) {
+
+ case list:
+ getSnapshots(exchange);
+ break;
+ case get:
+ getSnapshot(exchange);
+ break;
+ case delete:
+ deleteSnapshot(exchange);
+ break;
+
+ default:
+ throw new IllegalArgumentException("Unsupported operation");
+ }
+
+
+ }
+
+
+ private void getSnapshots(Exchange exchange) throws Exception {
+ DigitalOceanSnapshotTypes type = exchange.getIn().getHeader(DigitalOceanHeaders.TYPE, DigitalOceanSnapshotTypes.class);
+ Snapshots snapshots;
+
+ if (ObjectHelper.isNotEmpty(type))
+ if(type == DigitalOceanSnapshotTypes.droplet)
+ snapshots = getEndpoint().getDigitalOceanClient().getAllDropletSnapshots(configuration.getPage(), configuration.getPerPage());
+ else
+ snapshots = getEndpoint().getDigitalOceanClient().getAllVolumeSnapshots(configuration.getPage(), configuration.getPerPage());
+ else
+ snapshots = getEndpoint().getDigitalOceanClient().getAvailableSnapshots(configuration.getPage(), configuration.getPerPage());
+
+ LOG.trace("All Snapshots : page {} / {} per page [{}] ", configuration.getPage(), configuration.getPerPage(), snapshots.getSnapshots());
+ exchange.getOut().setBody(snapshots.getSnapshots());
+ }
+
+ private void getSnapshot(Exchange exchange) throws Exception {
+ String snapshotId = exchange.getIn().getHeader(DigitalOceanHeaders.ID, String.class);
+
+ if (ObjectHelper.isEmpty(snapshotId))
+ throw new IllegalArgumentException(DigitalOceanHeaders.ID + " must be specified");
+
+ Snapshot snapshot = getEndpoint().getDigitalOceanClient().getSnaphotInfo(snapshotId);
+ LOG.trace("Snapshot [{}] ", snapshot);
+ exchange.getOut().setBody(snapshot);
+
+ }
+
+ private void deleteSnapshot(Exchange exchange) throws Exception {
+ String snapshotId = exchange.getIn().getHeader(DigitalOceanHeaders.ID, String.class);
+
+ if (ObjectHelper.isEmpty(snapshotId))
+ throw new IllegalArgumentException(DigitalOceanHeaders.ID + " must be specified");
+
+ Delete delete = getEndpoint().getDigitalOceanClient().deleteSnapshot(snapshotId);
+ LOG.trace("Delete Snapshot [{}] ", delete);
+ exchange.getOut().setBody(delete);
+
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/1d57f7b0/components/camel-digitalocean/src/main/java/com/viwilo/camel/producer/DigitalOceanTagsProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-digitalocean/src/main/java/com/viwilo/camel/producer/DigitalOceanTagsProducer.java b/components/camel-digitalocean/src/main/java/com/viwilo/camel/producer/DigitalOceanTagsProducer.java
new file mode 100644
index 0000000..d797616
--- /dev/null
+++ b/components/camel-digitalocean/src/main/java/com/viwilo/camel/producer/DigitalOceanTagsProducer.java
@@ -0,0 +1,114 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.viwilo.camel.producer;
+
+import com.myjeeva.digitalocean.pojo.*;
+import com.viwilo.camel.DigitalOceanConfiguration;
+import com.viwilo.camel.constants.DigitalOceanHeaders;
+import com.viwilo.camel.DigitalOceanEndpoint;
+import org.apache.camel.Exchange;
+import org.apache.camel.util.ObjectHelper;
+
+/**
+ * The DigitalOcean producer for Tags API.
+ */
+public class DigitalOceanTagsProducer extends DigitalOceanProducer {
+
+ public DigitalOceanTagsProducer(DigitalOceanEndpoint endpoint, DigitalOceanConfiguration configuration) {
+ super(endpoint, configuration);
+ }
+
+ public void process(Exchange exchange) throws Exception {
+ switch(determineOperation(exchange)) {
+
+ case list:
+ getTags(exchange);
+ break;
+ case create:
+ createTag(exchange);
+ break;
+ case get:
+ getTag(exchange);
+ break;
+ case delete:
+ deleteTag(exchange);
+ break;
+ case update:
+ updateTag(exchange);
+ break;
+ default:
+ throw new IllegalArgumentException("Unsupported operation");
+ }
+
+ }
+
+ private void createTag(Exchange exchange) throws Exception {
+ String name = exchange.getIn().getHeader(DigitalOceanHeaders.NAME, String.class);
+
+ if (ObjectHelper.isEmpty(name))
+ throw new IllegalArgumentException(DigitalOceanHeaders.NAME + " must be specified");
+ Tag tag = getEndpoint().getDigitalOceanClient().createTag(name);
+ LOG.trace("Create Tag [{}] ", tag);
+ exchange.getOut().setBody(tag);
+ }
+
+
+ private void getTag(Exchange exchange) throws Exception {
+ String name = exchange.getIn().getHeader(DigitalOceanHeaders.NAME, String.class);
+
+ if (ObjectHelper.isEmpty(name))
+ throw new IllegalArgumentException(DigitalOceanHeaders.NAME + " must be specified");
+ Tag tag = getEndpoint().getDigitalOceanClient().getTag(name);
+ LOG.trace("Tag [{}] ", tag);
+ exchange.getOut().setBody(tag);
+ }
+
+ private void getTags(Exchange exchange) throws Exception {
+ Tags tags = getEndpoint().getDigitalOceanClient().getAvailableTags(configuration.getPage(), configuration.getPerPage());
+ LOG.trace("All Tags : page {} / {} per page [{}] ", configuration.getPage(), configuration.getPerPage(), tags.getTags());
+ exchange.getOut().setBody(tags.getTags());
+ }
+
+ private void deleteTag(Exchange exchange) throws Exception {
+ String name = exchange.getIn().getHeader(DigitalOceanHeaders.NAME, String.class);
+
+ if (ObjectHelper.isEmpty(name))
+ throw new IllegalArgumentException(DigitalOceanHeaders.NAME + " must be specified");
+ Delete delete = getEndpoint().getDigitalOceanClient().deleteTag(name);
+ LOG.trace("Delete Tag [{}] ", delete);
+ exchange.getOut().setBody(delete);
+ }
+
+ private void updateTag(Exchange exchange) throws Exception {
+ String name = exchange.getIn().getHeader(DigitalOceanHeaders.NAME, String.class);
+
+ if (ObjectHelper.isEmpty(name))
+ throw new IllegalArgumentException(DigitalOceanHeaders.NAME + " must be specified");
+
+
+ String newName = exchange.getIn().getHeader(DigitalOceanHeaders.NEW_NAME, String.class);
+
+ if (ObjectHelper.isEmpty(newName))
+ throw new IllegalArgumentException(DigitalOceanHeaders.NEW_NAME + " must be specified");
+
+ Tag tag = getEndpoint().getDigitalOceanClient().updateTag(name, newName);
+ LOG.trace("Update Tag [{}] ", tag);
+ exchange.getOut().setBody(tag);
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/1d57f7b0/components/camel-digitalocean/src/main/resources/META-INF/services/org/apache/camel/component/digitalocean
----------------------------------------------------------------------
diff --git a/components/camel-digitalocean/src/main/resources/META-INF/services/org/apache/camel/component/digitalocean b/components/camel-digitalocean/src/main/resources/META-INF/services/org/apache/camel/component/digitalocean
new file mode 100644
index 0000000..37b023f
--- /dev/null
+++ b/components/camel-digitalocean/src/main/resources/META-INF/services/org/apache/camel/component/digitalocean
@@ -0,0 +1,18 @@
+## ---------------------------------------------------------------------------
+## Licensed to the Apache Software Foundation (ASF) under one or more
+## contributor license agreements. See the NOTICE file distributed with
+## this work for additional information regarding copyright ownership.
+## The ASF licenses this file to You under the Apache License, Version 2.0
+## (the "License"); you may not use this file except in compliance with
+## the License. You may obtain a copy of the License at
+##
+## http://www.apache.org/licenses/LICENSE-2.0
+##
+## Unless required by applicable law or agreed to in writing, software
+## distributed under the License is distributed on an "AS IS" BASIS,
+## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+## See the License for the specific language governing permissions and
+## limitations under the License.
+## ---------------------------------------------------------------------------
+
+class=com.viwilo.camel.DigitalOceanComponent
http://git-wip-us.apache.org/repos/asf/camel/blob/1d57f7b0/components/camel-digitalocean/src/main/resources/log4j2.properties
----------------------------------------------------------------------
diff --git a/components/camel-digitalocean/src/main/resources/log4j2.properties b/components/camel-digitalocean/src/main/resources/log4j2.properties
new file mode 100644
index 0000000..60e86f8
--- /dev/null
+++ b/components/camel-digitalocean/src/main/resources/log4j2.properties
@@ -0,0 +1,23 @@
+## ---------------------------------------------------------------------------
+## Licensed to the Apache Software Foundation (ASF) under one or more
+## contributor license agreements. See the NOTICE file distributed with
+## this work for additional information regarding copyright ownership.
+## The ASF licenses this file to You under the Apache License, Version 2.0
+## (the "License"); you may not use this file except in compliance with
+## the License. You may obtain a copy of the License at
+##
+## http://www.apache.org/licenses/LICENSE-2.0
+##
+## Unless required by applicable law or agreed to in writing, software
+## distributed under the License is distributed on an "AS IS" BASIS,
+## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+## See the License for the specific language governing permissions and
+## limitations under the License.
+## ---------------------------------------------------------------------------
+
+appender.out.type = Console
+appender.out.name = out
+appender.out.layout.type = PatternLayout
+appender.out.layout.pattern = [%30.30t] %-30.30c{1} %-5p %m%n
+rootLogger.level = DEBUG
+rootLogger.appenderRef.out.ref = out
http://git-wip-us.apache.org/repos/asf/camel/blob/1d57f7b0/components/camel-digitalocean/src/test/java/com/viwilo/camel/DigitalOceanClientMock.java
----------------------------------------------------------------------
diff --git a/components/camel-digitalocean/src/test/java/com/viwilo/camel/DigitalOceanClientMock.java b/components/camel-digitalocean/src/test/java/com/viwilo/camel/DigitalOceanClientMock.java
new file mode 100644
index 0000000..1011fb4
--- /dev/null
+++ b/components/camel-digitalocean/src/test/java/com/viwilo/camel/DigitalOceanClientMock.java
@@ -0,0 +1,26 @@
+package com.viwilo.camel;
+
+import com.myjeeva.digitalocean.exception.DigitalOceanException;
+import com.myjeeva.digitalocean.exception.RequestUnsuccessfulException;
+import com.myjeeva.digitalocean.impl.DigitalOceanClient;
+import com.myjeeva.digitalocean.pojo.Account;
+
+/**
+ * Created by thomas on 17/03/2017.
+ */
+public class DigitalOceanClientMock extends DigitalOceanClient {
+
+
+
+ public DigitalOceanClientMock() {
+ super("token");
+ }
+
+ @Override
+ public Account getAccountInfo() throws DigitalOceanException, RequestUnsuccessfulException {
+ Account account = new Account();
+ account.setEmail("camel@apache.org");
+
+ return account;
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/1d57f7b0/components/camel-digitalocean/src/test/java/com/viwilo/camel/DigitalOceanComponentTest.java
----------------------------------------------------------------------
diff --git a/components/camel-digitalocean/src/test/java/com/viwilo/camel/DigitalOceanComponentTest.java b/components/camel-digitalocean/src/test/java/com/viwilo/camel/DigitalOceanComponentTest.java
new file mode 100644
index 0000000..b31c430
--- /dev/null
+++ b/components/camel-digitalocean/src/test/java/com/viwilo/camel/DigitalOceanComponentTest.java
@@ -0,0 +1,54 @@
+package com.viwilo.camel;
+
+import com.myjeeva.digitalocean.impl.DigitalOceanClient;
+import com.myjeeva.digitalocean.pojo.Account;
+import com.viwilo.camel.constants.DigitalOceanHeaders;
+import com.viwilo.camel.constants.DigitalOceanOperations;
+import org.apache.camel.EndpointInject;
+import org.apache.camel.Exchange;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.impl.JndiRegistry;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Test;
+
+public class DigitalOceanComponentTest extends CamelTestSupport {
+
+
+
+ @Override
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ public void configure() {
+ from("direct:getAccountInfo")
+ .setHeader(DigitalOceanHeaders.OPERATION, constant(DigitalOceanOperations.get))
+ .to("digitalocean:account?digitalOceanClient=#digitalOceanClient")
+ .to("mock:result");
+ }
+ };
+ }
+
+ @EndpointInject(uri = "mock:result")
+ protected MockEndpoint mockResultEndpoint;
+
+ @Test
+ public void testGetAccountInfo() throws Exception {
+
+ mockResultEndpoint.expectedMinimumMessageCount(1);
+ Exchange exchange = template.request("direct:getAccountInfo", null);
+ assertMockEndpointsSatisfied();
+ assertIsInstanceOf(Account.class, exchange.getOut().getBody());
+ assertEquals(exchange.getIn().getBody(Account.class).getEmail(), "camel@apache.org");
+ }
+
+
+
+
+ @Override
+ protected JndiRegistry createRegistry() throws Exception {
+ JndiRegistry registry = super.createRegistry();
+ DigitalOceanClient digitalOceanClient = new DigitalOceanClientMock();
+ registry.bind("digitalOceanClient", digitalOceanClient);
+ return registry;
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/1d57f7b0/components/camel-digitalocean/src/test/java/com/viwilo/camel/integration/DigitalOceanComponentIntegrationTest.java
----------------------------------------------------------------------
diff --git a/components/camel-digitalocean/src/test/java/com/viwilo/camel/integration/DigitalOceanComponentIntegrationTest.java b/components/camel-digitalocean/src/test/java/com/viwilo/camel/integration/DigitalOceanComponentIntegrationTest.java
new file mode 100644
index 0000000..7a72086
--- /dev/null
+++ b/components/camel-digitalocean/src/test/java/com/viwilo/camel/integration/DigitalOceanComponentIntegrationTest.java
@@ -0,0 +1,323 @@
+package com.viwilo.camel.integration;
+
+import com.myjeeva.digitalocean.pojo.*;
+import com.viwilo.camel.constants.DigitalOceanHeaders;
+import com.viwilo.camel.constants.DigitalOceanOperations;
+import org.apache.camel.EndpointInject;
+import org.apache.camel.Exchange;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.junit.Ignore;
+import org.junit.Test;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+
+//@Ignore("Must be manually tested. Provide your own oAuthToken")
+public class DigitalOceanComponentIntegrationTest extends DigitalOceanTestSupport {
+
+ @Override
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ public void configure() {
+ from("direct:getAccountInfo")
+ .setHeader(DigitalOceanHeaders.OPERATION, constant(DigitalOceanOperations.get))
+ .to("digitalocean:account?oAuthToken={{oAuthToken}}")
+ .to("mock:result");
+
+ from("direct:getAccountInfo2")
+ .to("digitalocean:account?operation="+DigitalOceanOperations.get+"&oAuthToken={{oAuthToken}}")
+ .to("mock:result");
+
+ from("direct:getActions")
+ .to("digitalocean:actions?operation=list&oAuthToken={{oAuthToken}}&perPage=30")
+ .to("mock:result");
+
+ from("direct:getActionInfo")
+ .setHeader(DigitalOceanHeaders.OPERATION, constant(DigitalOceanOperations.get))
+ .setHeader(DigitalOceanHeaders.ID, constant(133459716))
+ .to("digitalocean:actions?oAuthToken={{oAuthToken}}")
+ .to("mock:result");
+
+
+ from("direct:getDroplets")
+ .setHeader(DigitalOceanHeaders.OPERATION, constant(DigitalOceanOperations.list))
+ .to("digitalocean:droplets?oAuthToken={{oAuthToken}}")
+ .to("mock:result");
+
+ from("direct:getDroplet")
+ .setHeader(DigitalOceanHeaders.ID, constant(5428878))
+ .to("digitalocean:droplets?operation=get&oAuthToken={{oAuthToken}}")
+ .to("mock:result");
+
+ from("direct:getDroplet2")
+ .setHeader(DigitalOceanHeaders.OPERATION, constant(DigitalOceanOperations.get))
+ .setHeader(DigitalOceanHeaders.ID, constant(5428878))
+ .to("digitalocean:droplets?oAuthToken={{oAuthToken}}")
+ .to("mock:result");
+
+ from("direct:createDroplet")
+ .setHeader(DigitalOceanHeaders.OPERATION, constant(DigitalOceanOperations.create))
+ .setHeader(DigitalOceanHeaders.NAME, constant("camel-test"))
+ .setHeader(DigitalOceanHeaders.REGION, constant("fra1"))
+ .setHeader(DigitalOceanHeaders.DROPLET_IMAGE, constant("ubuntu-14-04-x64"))
+ .setHeader(DigitalOceanHeaders.DROPLET_SIZE, constant("512mb"))
+ .process(e -> {
+ Collection<String> tags = new ArrayList<String>();
+ tags.add("tag1");
+ tags.add("tag2");
+ e.getIn().setHeader(DigitalOceanHeaders.DROPLET_TAGS, tags);
+
+ })
+ .to("digitalocean:droplets?oAuthToken={{oAuthToken}}")
+ .to("mock:result");
+
+ from("direct:createMultipleDroplets")
+ .setHeader(DigitalOceanHeaders.OPERATION, constant(DigitalOceanOperations.create))
+ .process(e -> {
+ Collection<String> names = new ArrayList<String>();
+ names.add("droplet1");
+ names.add("droplet2");
+ e.getIn().setHeader(DigitalOceanHeaders.NAMES, names);
+
+ })
+ .setHeader(DigitalOceanHeaders.REGION, constant("fra1"))
+ .setHeader(DigitalOceanHeaders.DROPLET_IMAGE, constant("ubuntu-14-04-x64"))
+ .setHeader(DigitalOceanHeaders.DROPLET_SIZE, constant("512mb"))
+ .process(e -> {
+ Collection<String> tags = new ArrayList<String>();
+ tags.add("tag1");
+ tags.add("tag2");
+ e.getIn().setHeader(DigitalOceanHeaders.DROPLET_TAGS, tags);
+
+ })
+ .to("digitalocean://droplets?oAuthToken={{oAuthToken}}")
+ .to("mock:result");
+
+ from("direct:getDropletBackups")
+ .setHeader(DigitalOceanHeaders.OPERATION, constant(DigitalOceanOperations.listBackups))
+ .setHeader(DigitalOceanHeaders.ID, constant(5428878))
+ .to("digitalocean://droplets?oAuthToken={{oAuthToken}}")
+ .to("mock:result");
+
+ from("direct:createTag")
+ .setHeader(DigitalOceanHeaders.OPERATION, constant(DigitalOceanOperations.create))
+ .setHeader(DigitalOceanHeaders.NAME, constant("tag1"))
+ .to("digitalocean://tags?oAuthToken={{oAuthToken}}")
+ .to("mock:result");
+
+ from("direct:getTags")
+ .setHeader(DigitalOceanHeaders.OPERATION, constant(DigitalOceanOperations.list))
+ .to("digitalocean://tags?oAuthToken={{oAuthToken}}")
+ .to("mock:result");
+
+ from("direct:getImages")
+ .setHeader(DigitalOceanHeaders.OPERATION, constant(DigitalOceanOperations.list))
+ .to("digitalocean://images?oAuthToken={{oAuthToken}}")
+ .to("mock:result");
+
+ from("direct:getImage")
+ .setHeader(DigitalOceanHeaders.OPERATION, constant(DigitalOceanOperations.get))
+ .setHeader(DigitalOceanHeaders.DROPLET_IMAGE, constant("ubuntu-14-04-x64"))
+ .to("digitalocean://images?oAuthToken={{oAuthToken}}")
+ .to("mock:result");
+
+ from("direct:getSizes")
+ .setHeader(DigitalOceanHeaders.OPERATION, constant(DigitalOceanOperations.list))
+ .to("digitalocean://sizes?oAuthToken={{oAuthToken}}")
+ .to("mock:result");
+
+ from("direct:getSize")
+ .setHeader(DigitalOceanHeaders.OPERATION, constant(DigitalOceanOperations.get))
+ .setHeader(DigitalOceanHeaders.NAME, constant("512mb"))
+ .to("digitalocean://sizes?oAuthToken={{oAuthToken}}")
+ .to("mock:result");
+
+ from("direct:getRegions")
+ .setHeader(DigitalOceanHeaders.OPERATION, constant(DigitalOceanOperations.list))
+ .to("digitalocean://regions?oAuthToken={{oAuthToken}}")
+ .to("mock:result");
+
+ from("direct:getRegion")
+ .setHeader(DigitalOceanHeaders.OPERATION, constant(DigitalOceanOperations.get))
+ .setHeader(DigitalOceanHeaders.NAME, constant("nyc1"))
+ .to("digitalocean://regions?oAuthToken={{oAuthToken}}")
+ .to("mock:result");
+ }
+ };
+ }
+
+ @EndpointInject(uri = "mock:result")
+ protected MockEndpoint mockResultEndpoint;
+
+ @Test
+ public void testGetAccountInfo() throws Exception {
+ mockResultEndpoint.expectedMinimumMessageCount(2);
+
+ Exchange exchange = template.request("direct:getAccountInfo", null);
+ assertTrue(((Account)exchange.getOut().getBody()).isEmailVerified());
+ exchange = template.request("direct:getAccountInfo2", null);
+ assertTrue(((Account)exchange.getOut().getBody()).isEmailVerified());
+
+ assertMockEndpointsSatisfied();
+
+ }
+
+ @Test
+ public void testGetAllActions() throws Exception {
+ mockResultEndpoint.expectedMinimumMessageCount(1);
+
+ Exchange exchange = template.request("direct:getActions", null);
+
+ assertMockEndpointsSatisfied();
+ assertEquals(((List)exchange.getOut().getBody()).size(), 30);
+ }
+
+ @Test
+ public void testGetActionInfo() throws Exception {
+ mockResultEndpoint.expectedMinimumMessageCount(1);
+
+ Exchange exchange = template.request("direct:getActionInfo", null);
+
+ assertMockEndpointsSatisfied();
+ assertEquals(((Action)exchange.getOut().getBody()).getId(), new Integer(133459716));
+ }
+
+
+
+ @Test
+ public void testGetDropletInfo() throws Exception {
+ mockResultEndpoint.expectedMinimumMessageCount(2);
+
+ Exchange exchange = template.request("direct:getDroplet", null);
+
+ assertEquals(((Droplet)exchange.getOut().getBody()).getId(), new Integer(5428878));
+
+ exchange = template.request("direct:getDroplet2", null);
+
+ assertMockEndpointsSatisfied();
+ assertEquals(((Droplet)exchange.getOut().getBody()).getId(), new Integer(5428878));
+
+ }
+
+
+ @Test
+ public void testCreateDroplet() throws Exception {
+ mockResultEndpoint.expectedMinimumMessageCount(1);
+
+ Exchange exchange = template.request("direct:createDroplet", null);
+
+ assertMockEndpointsSatisfied();
+ Droplet droplet = (Droplet)exchange.getOut().getBody();
+
+ assertNotNull(droplet.getId());
+ assertEquals(droplet.getRegion().getSlug(), "fra1");
+ assertCollectionSize(droplet.getTags(), 2);
+
+ }
+
+ @Test
+ public void testCreateMultipleDroplets() throws Exception {
+ mockResultEndpoint.expectedMinimumMessageCount(1);
+
+ Exchange exchange = template.request("direct:createMultipleDroplets", null);
+
+ assertMockEndpointsSatisfied();
+ List<Droplet> droplets = (List<Droplet>)exchange.getOut().getBody();
+
+ assertCollectionSize(droplets, 2);
+ }
+
+
+ @Test
+ public void testGetAllDroplets() throws Exception {
+ mockResultEndpoint.expectedMinimumMessageCount(1);
+
+ Exchange exchange = template.request("direct:getDroplets", null);
+
+ assertMockEndpointsSatisfied();
+ assertEquals(((List)exchange.getOut().getBody()).size(), 1);
+ }
+
+ @Test
+ public void testGetDropletBackups() throws Exception {
+ mockResultEndpoint.expectedMinimumMessageCount(1);
+
+ Exchange exchange = template.request("direct:getDropletBackups", null);
+
+ assertMockEndpointsSatisfied();
+ assertCollectionSize(((List)exchange.getOut().getBody()), 0);
+ }
+
+ @Test
+ public void testCreateTag() throws Exception {
+ mockResultEndpoint.expectedMinimumMessageCount(1);
+
+ Exchange exchange = template.request("direct:createTag", null);
+
+ assertMockEndpointsSatisfied();
+ assertEquals(((Tag)exchange.getOut().getBody()).getName(), "tag1");
+ }
+
+
+ @Test
+ public void testGetTags() throws Exception {
+ mockResultEndpoint.expectedMinimumMessageCount(1);
+
+ Exchange exchange = template.request("direct:getTags", null);
+
+ assertMockEndpointsSatisfied();
+ assertEquals(((List<Tag>)exchange.getOut().getBody()).get(0).getName(), "tag1");
+ }
+
+ @Test
+ public void getImages() throws Exception {
+ mockResultEndpoint.expectedMinimumMessageCount(1);
+
+ Exchange exchange = template.request("direct:getImages", null);
+
+ assertMockEndpointsSatisfied();
+ List<Image> images = (List<Image>)exchange.getOut().getBody();
+ assertNotEquals(images.size(), 1);
+ }
+
+ @Test
+ public void getImage() throws Exception {
+ mockResultEndpoint.expectedMinimumMessageCount(1);
+
+ Exchange exchange = template.request("direct:getImage", null);
+
+ assertMockEndpointsSatisfied();
+ assertEquals((exchange.getOut().getBody(Image.class)).getSlug(), "ubuntu-14-04-x64");
+
+ }
+
+ @Test
+ public void getSizes() throws Exception {
+ mockResultEndpoint.expectedMinimumMessageCount(1);
+
+ Exchange exchange = template.request("direct:getSizes", null);
+
+ assertMockEndpointsSatisfied();
+ List<Size> sizes = (List<Size>)exchange.getOut().getBody();
+ System.out.println(sizes);
+ assertNotEquals(sizes.size(), 1);
+ }
+
+
+ @Test
+ public void getRegions() throws Exception {
+ mockResultEndpoint.expectedMinimumMessageCount(1);
+
+ Exchange exchange = template.request("direct:getRegions", null);
+
+ assertMockEndpointsSatisfied();
+ List<Region> regions = (List<Region>)exchange.getOut().getBody();
+ System.out.println(regions);
+ assertNotEquals(regions.size(), 1);
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/1d57f7b0/components/camel-digitalocean/src/test/java/com/viwilo/camel/integration/DigitalOceanTestSupport.java
----------------------------------------------------------------------
diff --git a/components/camel-digitalocean/src/test/java/com/viwilo/camel/integration/DigitalOceanTestSupport.java b/components/camel-digitalocean/src/test/java/com/viwilo/camel/integration/DigitalOceanTestSupport.java
new file mode 100644
index 0000000..0e1d4c9
--- /dev/null
+++ b/components/camel-digitalocean/src/test/java/com/viwilo/camel/integration/DigitalOceanTestSupport.java
@@ -0,0 +1,42 @@
+package com.viwilo.camel.integration;
+
+import java.util.Properties;
+import org.apache.camel.test.junit4.CamelTestSupport;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+
+/**
+ * Created by thomas on 17/03/2017.
+ */
+public class DigitalOceanTestSupport extends CamelTestSupport {
+
+ protected final Properties properties;
+
+ protected DigitalOceanTestSupport() {
+ URL url = getClass().getResource("/test-options.properties");
+
+ InputStream inStream;
+ try {
+ inStream = url.openStream();
+ } catch (IOException e) {
+ e.printStackTrace();
+ throw new IllegalAccessError("test-options.properties could not be found");
+ }
+
+ properties = new Properties();
+ try {
+ properties.load(inStream);
+ } catch (IOException e) {
+ e.printStackTrace();
+ throw new IllegalAccessError("test-options.properties could not be found");
+ }
+ }
+
+ @Override
+ protected Properties useOverridePropertiesWithPropertiesComponent() {
+ return properties;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/1d57f7b0/components/camel-digitalocean/src/test/resources/log4j2.properties
----------------------------------------------------------------------
diff --git a/components/camel-digitalocean/src/test/resources/log4j2.properties b/components/camel-digitalocean/src/test/resources/log4j2.properties
new file mode 100644
index 0000000..60e86f8
--- /dev/null
+++ b/components/camel-digitalocean/src/test/resources/log4j2.properties
@@ -0,0 +1,23 @@
+## ---------------------------------------------------------------------------
+## Licensed to the Apache Software Foundation (ASF) under one or more
+## contributor license agreements. See the NOTICE file distributed with
+## this work for additional information regarding copyright ownership.
+## The ASF licenses this file to You under the Apache License, Version 2.0
+## (the "License"); you may not use this file except in compliance with
+## the License. You may obtain a copy of the License at
+##
+## http://www.apache.org/licenses/LICENSE-2.0
+##
+## Unless required by applicable law or agreed to in writing, software
+## distributed under the License is distributed on an "AS IS" BASIS,
+## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+## See the License for the specific language governing permissions and
+## limitations under the License.
+## ---------------------------------------------------------------------------
+
+appender.out.type = Console
+appender.out.name = out
+appender.out.layout.type = PatternLayout
+appender.out.layout.pattern = [%30.30t] %-30.30c{1} %-5p %m%n
+rootLogger.level = DEBUG
+rootLogger.appenderRef.out.ref = out
http://git-wip-us.apache.org/repos/asf/camel/blob/1d57f7b0/components/camel-digitalocean/src/test/resources/test-options.properties
----------------------------------------------------------------------
diff --git a/components/camel-digitalocean/src/test/resources/test-options.properties b/components/camel-digitalocean/src/test/resources/test-options.properties
new file mode 100644
index 0000000..549de90
--- /dev/null
+++ b/components/camel-digitalocean/src/test/resources/test-options.properties
@@ -0,0 +1,18 @@
+## ---------------------------------------------------------------------------
+## Licensed to the Apache Software Foundation (ASF) under one or more
+## contributor license agreements. See the NOTICE file distributed with
+## this work for additional information regarding copyright ownership.
+## The ASF licenses this file to You under the Apache License, Version 2.0
+## (the "License"); you may not use this file except in compliance with
+## the License. You may obtain a copy of the License at
+##
+## http://www.apache.org/licenses/LICENSE-2.0
+##
+## Unless required by applicable law or agreed to in writing, software
+## distributed under the License is distributed on an "AS IS" BASIS,
+## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+## See the License for the specific language governing permissions and
+## limitations under the License.
+## ---------------------------------------------------------------------------
+
+oAuthToken=<yourOAuthToken>
\ No newline at end of file
[10/20] camel git commit: Refactor com.viwilo to org.apache.camel
Posted by ac...@apache.org.
http://git-wip-us.apache.org/repos/asf/camel/blob/17d527d1/components/camel-digitalocean/src/main/java/com/viwilo/camel/producer/DigitalOceanKeysProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-digitalocean/src/main/java/com/viwilo/camel/producer/DigitalOceanKeysProducer.java b/components/camel-digitalocean/src/main/java/com/viwilo/camel/producer/DigitalOceanKeysProducer.java
deleted file mode 100644
index bb66170..0000000
--- a/components/camel-digitalocean/src/main/java/com/viwilo/camel/producer/DigitalOceanKeysProducer.java
+++ /dev/null
@@ -1,144 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.viwilo.camel.producer;
-
-import com.myjeeva.digitalocean.pojo.*;
-import com.viwilo.camel.DigitalOceanConfiguration;
-import com.viwilo.camel.constants.DigitalOceanHeaders;
-import com.viwilo.camel.DigitalOceanEndpoint;
-import org.apache.camel.Exchange;
-import org.apache.camel.util.ObjectHelper;
-
-/**
- * The DigitalOcean producer for SSH Keys API.
- */
-public class DigitalOceanKeysProducer extends DigitalOceanProducer {
-
- public DigitalOceanKeysProducer(DigitalOceanEndpoint endpoint, DigitalOceanConfiguration configuration) {
- super(endpoint, configuration);
- }
-
- public void process(Exchange exchange) throws Exception {
-
- switch(determineOperation(exchange)) {
-
- case list:
- getKeys(exchange);
- break;
- case create:
- createKey(exchange);
- break;
- case get:
- getKey(exchange);
- break;
- case update:
- updateKey(exchange);
- break;
- case delete:
- deleteKey(exchange);
- break;
- default:
- throw new IllegalArgumentException("Unsupported operation");
- }
- }
-
-
- private void getKey(Exchange exchange) throws Exception {
- Integer keyId = exchange.getIn().getHeader(DigitalOceanHeaders.ID, Integer.class);
- String fingerprint = exchange.getIn().getHeader(DigitalOceanHeaders.KEY_FINGERPRINT, String.class);
- Key key;
-
- if (ObjectHelper.isNotEmpty(keyId))
- key = getEndpoint().getDigitalOceanClient().getKeyInfo(keyId);
- else if (ObjectHelper.isNotEmpty(fingerprint))
- key = getEndpoint().getDigitalOceanClient().getKeyInfo(fingerprint);
- else
- throw new IllegalArgumentException(DigitalOceanHeaders.ID + " or " + DigitalOceanHeaders.KEY_FINGERPRINT + " must be specified");
-
- LOG.trace("Key [{}] ", key);
- exchange.getOut().setBody(key);
- }
-
- private void getKeys(Exchange exchange) throws Exception {
- Keys keys = getEndpoint().getDigitalOceanClient().getAvailableKeys(configuration.getPage());
- LOG.trace("All Keys : page {} [{}] ", configuration.getPage(), keys.getKeys());
- exchange.getOut().setBody(keys.getKeys());
- }
-
- private void deleteKey(Exchange exchange) throws Exception {
- Integer keyId = exchange.getIn().getHeader(DigitalOceanHeaders.ID, Integer.class);
- String fingerprint = exchange.getIn().getHeader(DigitalOceanHeaders.KEY_FINGERPRINT, String.class);
- Delete delete;
-
- if (ObjectHelper.isNotEmpty(keyId))
- delete = getEndpoint().getDigitalOceanClient().deleteKey(keyId);
- else if (ObjectHelper.isNotEmpty(fingerprint))
- delete = getEndpoint().getDigitalOceanClient().deleteKey(fingerprint);
- else
- throw new IllegalArgumentException(DigitalOceanHeaders.ID + " or " + DigitalOceanHeaders.KEY_FINGERPRINT + " must be specified");
-
- LOG.trace("Delete Key {} ", delete);
- exchange.getOut().setBody(delete);
- }
-
-
- private void createKey(Exchange exchange) throws Exception {
- Key key = new Key();
-
- String name = exchange.getIn().getHeader(DigitalOceanHeaders.NAME, String.class);
-
- if (ObjectHelper.isEmpty(name))
- throw new IllegalArgumentException(DigitalOceanHeaders.NAME + " must be specified");
- else
- key.setName(name);
-
- String publicKey = exchange.getIn().getHeader(DigitalOceanHeaders.KEY_PUBLIC_KEY, String.class);
-
- if (ObjectHelper.isEmpty(publicKey))
- throw new IllegalArgumentException(DigitalOceanHeaders.KEY_PUBLIC_KEY + " must be specified");
- else
- key.setPublicKey(publicKey);
-
- key = getEndpoint().getDigitalOceanClient().createKey(key);
- LOG.trace("Key created {} ", key);
- exchange.getOut().setBody(key);
-
- }
-
- private void updateKey(Exchange exchange) throws Exception {
- Integer keyId = exchange.getIn().getHeader(DigitalOceanHeaders.ID, Integer.class);
- String fingerprint = exchange.getIn().getHeader(DigitalOceanHeaders.KEY_FINGERPRINT, String.class);
- Key key;
-
- String name = exchange.getIn().getHeader(DigitalOceanHeaders.NAME, String.class);
-
- if (ObjectHelper.isEmpty(name))
- throw new IllegalArgumentException(DigitalOceanHeaders.NAME + " must be specified");
-
- if (ObjectHelper.isNotEmpty(keyId))
- key = getEndpoint().getDigitalOceanClient().updateKey(keyId, name);
- else if (ObjectHelper.isNotEmpty(fingerprint))
- key = getEndpoint().getDigitalOceanClient().updateKey(fingerprint, name);
- else
- throw new IllegalArgumentException(DigitalOceanHeaders.ID + " or " + DigitalOceanHeaders.KEY_FINGERPRINT + " must be specified");
-
- LOG.trace("Update Key [{}] ", key);
- exchange.getOut().setBody(key);
- }
-
-
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/17d527d1/components/camel-digitalocean/src/main/java/com/viwilo/camel/producer/DigitalOceanProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-digitalocean/src/main/java/com/viwilo/camel/producer/DigitalOceanProducer.java b/components/camel-digitalocean/src/main/java/com/viwilo/camel/producer/DigitalOceanProducer.java
deleted file mode 100644
index 2ed0165..0000000
--- a/components/camel-digitalocean/src/main/java/com/viwilo/camel/producer/DigitalOceanProducer.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.viwilo.camel.producer;
-
-import com.viwilo.camel.DigitalOceanConfiguration;
-import com.viwilo.camel.constants.DigitalOceanHeaders;
-import com.viwilo.camel.DigitalOceanEndpoint;
-import com.viwilo.camel.constants.DigitalOceanOperations;
-import org.apache.camel.Exchange;
-import org.apache.camel.impl.DefaultProducer;
-import org.apache.camel.util.ObjectHelper;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * The DigitalOcean producer.
- */
-public abstract class DigitalOceanProducer extends DefaultProducer {
- protected static final Logger LOG = LoggerFactory.getLogger(DigitalOceanProducer.class);
-
- private DigitalOceanEndpoint endpoint;
- protected DigitalOceanConfiguration configuration;
-
- public DigitalOceanProducer(DigitalOceanEndpoint endpoint, DigitalOceanConfiguration configuration) {
- super(endpoint);
- this.endpoint = endpoint;
- this.configuration = configuration;
- }
-
- protected DigitalOceanOperations determineOperation(Exchange exchange) {
- DigitalOceanOperations operation = exchange.getIn().getHeader(DigitalOceanHeaders.OPERATION, DigitalOceanOperations.class);
- return ObjectHelper.isNotEmpty(operation) ? operation : configuration.getOperation();
- }
-
- @Override
- public DigitalOceanEndpoint getEndpoint() {
- return endpoint;
- }
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/17d527d1/components/camel-digitalocean/src/main/java/com/viwilo/camel/producer/DigitalOceanRegionsProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-digitalocean/src/main/java/com/viwilo/camel/producer/DigitalOceanRegionsProducer.java b/components/camel-digitalocean/src/main/java/com/viwilo/camel/producer/DigitalOceanRegionsProducer.java
deleted file mode 100644
index cda1116..0000000
--- a/components/camel-digitalocean/src/main/java/com/viwilo/camel/producer/DigitalOceanRegionsProducer.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.viwilo.camel.producer;
-
-import com.myjeeva.digitalocean.pojo.*;
-import com.viwilo.camel.DigitalOceanConfiguration;
-import com.viwilo.camel.DigitalOceanEndpoint;
-import org.apache.camel.Exchange;
-
-/**
- * The DigitalOcean producer for Regions API.
- */
-public class DigitalOceanRegionsProducer extends DigitalOceanProducer {
-
- public DigitalOceanRegionsProducer(DigitalOceanEndpoint endpoint, DigitalOceanConfiguration configuration) {
- super(endpoint, configuration);
- }
-
- public void process(Exchange exchange) throws Exception {
- Regions regions = getEndpoint().getDigitalOceanClient().getAvailableRegions(configuration.getPage());
- LOG.trace("All Regions : page {} [{}] ", regions.getRegions(), configuration.getPage());
- exchange.getOut().setBody(regions.getRegions());
- }
-
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/17d527d1/components/camel-digitalocean/src/main/java/com/viwilo/camel/producer/DigitalOceanSizesProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-digitalocean/src/main/java/com/viwilo/camel/producer/DigitalOceanSizesProducer.java b/components/camel-digitalocean/src/main/java/com/viwilo/camel/producer/DigitalOceanSizesProducer.java
deleted file mode 100644
index 0f8d622..0000000
--- a/components/camel-digitalocean/src/main/java/com/viwilo/camel/producer/DigitalOceanSizesProducer.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.viwilo.camel.producer;
-
-import com.myjeeva.digitalocean.pojo.*;
-import com.viwilo.camel.DigitalOceanConfiguration;
-import com.viwilo.camel.DigitalOceanEndpoint;
-import org.apache.camel.Exchange;
-
-/**
- * The DigitalOcean producer for Sizes API.
- */
-public class DigitalOceanSizesProducer extends DigitalOceanProducer {
-
- public DigitalOceanSizesProducer(DigitalOceanEndpoint endpoint, DigitalOceanConfiguration configuration) {
- super(endpoint, configuration);
- }
-
- public void process(Exchange exchange) throws Exception {
- Sizes sizes = getEndpoint().getDigitalOceanClient().getAvailableSizes(configuration.getPage());
- LOG.trace("All Sizes : page {} [{}] ", sizes.getSizes(), configuration.getPage());
- exchange.getOut().setBody(sizes.getSizes());
- }
-
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/17d527d1/components/camel-digitalocean/src/main/java/com/viwilo/camel/producer/DigitalOceanSnapshotsProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-digitalocean/src/main/java/com/viwilo/camel/producer/DigitalOceanSnapshotsProducer.java b/components/camel-digitalocean/src/main/java/com/viwilo/camel/producer/DigitalOceanSnapshotsProducer.java
deleted file mode 100644
index 2445529..0000000
--- a/components/camel-digitalocean/src/main/java/com/viwilo/camel/producer/DigitalOceanSnapshotsProducer.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.viwilo.camel.producer;
-
-import com.myjeeva.digitalocean.pojo.Delete;
-import com.myjeeva.digitalocean.pojo.Snapshot;
-import com.myjeeva.digitalocean.pojo.Snapshots;
-import com.viwilo.camel.DigitalOceanConfiguration;
-import com.viwilo.camel.DigitalOceanEndpoint;
-import com.viwilo.camel.constants.DigitalOceanHeaders;
-import com.viwilo.camel.constants.DigitalOceanSnapshotTypes;
-import org.apache.camel.Exchange;
-import org.apache.camel.util.ObjectHelper;
-
-/**
- * The DigitalOcean producer for Snapshots API.
- */
-public class DigitalOceanSnapshotsProducer extends DigitalOceanProducer {
-
- public DigitalOceanSnapshotsProducer(DigitalOceanEndpoint endpoint, DigitalOceanConfiguration configuration) {
- super(endpoint, configuration);
- }
-
- public void process(Exchange exchange) throws Exception {
-
- switch (determineOperation(exchange)) {
-
- case list:
- getSnapshots(exchange);
- break;
- case get:
- getSnapshot(exchange);
- break;
- case delete:
- deleteSnapshot(exchange);
- break;
-
- default:
- throw new IllegalArgumentException("Unsupported operation");
- }
-
-
- }
-
-
- private void getSnapshots(Exchange exchange) throws Exception {
- DigitalOceanSnapshotTypes type = exchange.getIn().getHeader(DigitalOceanHeaders.TYPE, DigitalOceanSnapshotTypes.class);
- Snapshots snapshots;
-
- if (ObjectHelper.isNotEmpty(type))
- if(type == DigitalOceanSnapshotTypes.droplet)
- snapshots = getEndpoint().getDigitalOceanClient().getAllDropletSnapshots(configuration.getPage(), configuration.getPerPage());
- else
- snapshots = getEndpoint().getDigitalOceanClient().getAllVolumeSnapshots(configuration.getPage(), configuration.getPerPage());
- else
- snapshots = getEndpoint().getDigitalOceanClient().getAvailableSnapshots(configuration.getPage(), configuration.getPerPage());
-
- LOG.trace("All Snapshots : page {} / {} per page [{}] ", configuration.getPage(), configuration.getPerPage(), snapshots.getSnapshots());
- exchange.getOut().setBody(snapshots.getSnapshots());
- }
-
- private void getSnapshot(Exchange exchange) throws Exception {
- String snapshotId = exchange.getIn().getHeader(DigitalOceanHeaders.ID, String.class);
-
- if (ObjectHelper.isEmpty(snapshotId))
- throw new IllegalArgumentException(DigitalOceanHeaders.ID + " must be specified");
-
- Snapshot snapshot = getEndpoint().getDigitalOceanClient().getSnaphotInfo(snapshotId);
- LOG.trace("Snapshot [{}] ", snapshot);
- exchange.getOut().setBody(snapshot);
-
- }
-
- private void deleteSnapshot(Exchange exchange) throws Exception {
- String snapshotId = exchange.getIn().getHeader(DigitalOceanHeaders.ID, String.class);
-
- if (ObjectHelper.isEmpty(snapshotId))
- throw new IllegalArgumentException(DigitalOceanHeaders.ID + " must be specified");
-
- Delete delete = getEndpoint().getDigitalOceanClient().deleteSnapshot(snapshotId);
- LOG.trace("Delete Snapshot [{}] ", delete);
- exchange.getOut().setBody(delete);
-
- }
-
-
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/17d527d1/components/camel-digitalocean/src/main/java/com/viwilo/camel/producer/DigitalOceanTagsProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-digitalocean/src/main/java/com/viwilo/camel/producer/DigitalOceanTagsProducer.java b/components/camel-digitalocean/src/main/java/com/viwilo/camel/producer/DigitalOceanTagsProducer.java
deleted file mode 100644
index d797616..0000000
--- a/components/camel-digitalocean/src/main/java/com/viwilo/camel/producer/DigitalOceanTagsProducer.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.viwilo.camel.producer;
-
-import com.myjeeva.digitalocean.pojo.*;
-import com.viwilo.camel.DigitalOceanConfiguration;
-import com.viwilo.camel.constants.DigitalOceanHeaders;
-import com.viwilo.camel.DigitalOceanEndpoint;
-import org.apache.camel.Exchange;
-import org.apache.camel.util.ObjectHelper;
-
-/**
- * The DigitalOcean producer for Tags API.
- */
-public class DigitalOceanTagsProducer extends DigitalOceanProducer {
-
- public DigitalOceanTagsProducer(DigitalOceanEndpoint endpoint, DigitalOceanConfiguration configuration) {
- super(endpoint, configuration);
- }
-
- public void process(Exchange exchange) throws Exception {
- switch(determineOperation(exchange)) {
-
- case list:
- getTags(exchange);
- break;
- case create:
- createTag(exchange);
- break;
- case get:
- getTag(exchange);
- break;
- case delete:
- deleteTag(exchange);
- break;
- case update:
- updateTag(exchange);
- break;
- default:
- throw new IllegalArgumentException("Unsupported operation");
- }
-
- }
-
- private void createTag(Exchange exchange) throws Exception {
- String name = exchange.getIn().getHeader(DigitalOceanHeaders.NAME, String.class);
-
- if (ObjectHelper.isEmpty(name))
- throw new IllegalArgumentException(DigitalOceanHeaders.NAME + " must be specified");
- Tag tag = getEndpoint().getDigitalOceanClient().createTag(name);
- LOG.trace("Create Tag [{}] ", tag);
- exchange.getOut().setBody(tag);
- }
-
-
- private void getTag(Exchange exchange) throws Exception {
- String name = exchange.getIn().getHeader(DigitalOceanHeaders.NAME, String.class);
-
- if (ObjectHelper.isEmpty(name))
- throw new IllegalArgumentException(DigitalOceanHeaders.NAME + " must be specified");
- Tag tag = getEndpoint().getDigitalOceanClient().getTag(name);
- LOG.trace("Tag [{}] ", tag);
- exchange.getOut().setBody(tag);
- }
-
- private void getTags(Exchange exchange) throws Exception {
- Tags tags = getEndpoint().getDigitalOceanClient().getAvailableTags(configuration.getPage(), configuration.getPerPage());
- LOG.trace("All Tags : page {} / {} per page [{}] ", configuration.getPage(), configuration.getPerPage(), tags.getTags());
- exchange.getOut().setBody(tags.getTags());
- }
-
- private void deleteTag(Exchange exchange) throws Exception {
- String name = exchange.getIn().getHeader(DigitalOceanHeaders.NAME, String.class);
-
- if (ObjectHelper.isEmpty(name))
- throw new IllegalArgumentException(DigitalOceanHeaders.NAME + " must be specified");
- Delete delete = getEndpoint().getDigitalOceanClient().deleteTag(name);
- LOG.trace("Delete Tag [{}] ", delete);
- exchange.getOut().setBody(delete);
- }
-
- private void updateTag(Exchange exchange) throws Exception {
- String name = exchange.getIn().getHeader(DigitalOceanHeaders.NAME, String.class);
-
- if (ObjectHelper.isEmpty(name))
- throw new IllegalArgumentException(DigitalOceanHeaders.NAME + " must be specified");
-
-
- String newName = exchange.getIn().getHeader(DigitalOceanHeaders.NEW_NAME, String.class);
-
- if (ObjectHelper.isEmpty(newName))
- throw new IllegalArgumentException(DigitalOceanHeaders.NEW_NAME + " must be specified");
-
- Tag tag = getEndpoint().getDigitalOceanClient().updateTag(name, newName);
- LOG.trace("Update Tag [{}] ", tag);
- exchange.getOut().setBody(tag);
- }
-
-
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/17d527d1/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/DigitalOceanComponent.java
----------------------------------------------------------------------
diff --git a/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/DigitalOceanComponent.java b/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/DigitalOceanComponent.java
new file mode 100644
index 0000000..74daca2
--- /dev/null
+++ b/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/DigitalOceanComponent.java
@@ -0,0 +1,59 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.digitalocean;
+
+import java.util.Map;
+
+import org.apache.camel.component.digitalocean.constants.DigitalOceanResources;
+import org.apache.camel.CamelContext;
+import org.apache.camel.Endpoint;
+
+import org.apache.camel.impl.UriEndpointComponent;
+import org.apache.camel.util.ObjectHelper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Represents the component that manages {@link DigitalOceanEndpoint}.
+ */
+public class DigitalOceanComponent extends UriEndpointComponent {
+
+ private static final transient Logger LOG = LoggerFactory.getLogger(DigitalOceanComponent.class);
+
+
+ public DigitalOceanComponent() {
+ super(DigitalOceanEndpoint.class);
+ }
+
+ public DigitalOceanComponent(CamelContext context) {
+ super(context, DigitalOceanEndpoint.class);
+ }
+
+ protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception {
+
+ DigitalOceanConfiguration configuration = new DigitalOceanConfiguration();
+ setProperties(configuration, parameters);
+ configuration.setResource(DigitalOceanResources.valueOf(remaining));
+
+ if (ObjectHelper.isEmpty(configuration.getOAuthToken()) && ObjectHelper.isEmpty(configuration.getDigitalOceanClient()))
+ throw new DigitalOceanException("oAuthToken or digitalOceanClient must be specified");
+
+ Endpoint endpoint = new DigitalOceanEndpoint(uri, this, configuration);
+ return endpoint;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/17d527d1/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/DigitalOceanConfiguration.java
----------------------------------------------------------------------
diff --git a/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/DigitalOceanConfiguration.java b/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/DigitalOceanConfiguration.java
new file mode 100644
index 0000000..895fa89
--- /dev/null
+++ b/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/DigitalOceanConfiguration.java
@@ -0,0 +1,173 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.digitalocean;
+
+import com.myjeeva.digitalocean.impl.DigitalOceanClient;
+import org.apache.camel.component.digitalocean.constants.DigitalOceanResources;
+import org.apache.camel.component.digitalocean.constants.DigitalOceanOperations;
+import org.apache.camel.spi.Metadata;
+import org.apache.camel.spi.UriParam;
+import org.apache.camel.spi.UriParams;
+import org.apache.camel.spi.UriPath;
+
+@UriParams
+public class DigitalOceanConfiguration {
+
+
+ @UriParam(enums = "account,actions,blockStorages,droplets,mages,snapshots,keys,regions,sizes,floatingIPs,tags")
+ @Metadata(required = "true")
+ private DigitalOceanResources resource;
+
+ @UriPath(enums = "create,update,delete,list,ownList,get,listBackups,listActions,listNeighbors,listSnapshots,listKernels,listAllNeighbors," +
+ "enableBackups,disableBackups,reboot,powerCycle,shutdown,powerOn,powerOff,restore,resetPassword," +
+ "resize,rebuild,rename,changeKernel,enableIpv6,enablePrivateNetworking,takeSnapshot,transfer,convert," +
+ "attach,detach,assign,unassign,tag,untag")
+ private DigitalOceanOperations operation;
+
+ @UriParam
+ private DigitalOceanClient digitalOceanClient;
+
+ @UriParam(label = "security", secret = true)
+ private String oAuthToken;
+
+ @UriParam(defaultValue = "1")
+ private Integer page = 1;
+
+ @UriParam(defaultValue = "25")
+ private Integer perPage = 25;
+
+
+ @UriParam(label = "proxy")
+ private String httpProxyHost;
+ @UriParam(label = "proxy")
+ private String httpProxyUser;
+ @UriParam(label = "proxy")
+ private String httpProxyPassword;
+ @UriParam(label = "proxy")
+ private Integer httpProxyPort;
+
+ public DigitalOceanResources getResource() {
+ return resource;
+ }
+
+ /**
+ * The DigitalOcean resource type on which perform the operation.
+ */
+ public void setResource(DigitalOceanResources resource) {
+ this.resource = resource;
+ }
+
+ /**
+ * The operation to perform to the given resource.
+ */
+ public DigitalOceanOperations getOperation() {
+ return operation;
+ }
+
+ public void setOperation(DigitalOceanOperations operation) {
+ this.operation = operation;
+ }
+
+ public String getOAuthToken() {
+ return oAuthToken;
+ }
+
+ /**
+ * DigitalOcean OAuth Token
+ */
+ public void setOAuthToken(String oAuthToken) {
+ this.oAuthToken = oAuthToken;
+ }
+
+ /**
+ * Use for pagination. Set the number of item per request. The maximum number of results per page is 200.
+ */
+ public Integer getPerPage() {
+ return perPage;
+ }
+
+ public void setPerPage(Integer perPage) {
+ this.perPage = perPage;
+ }
+
+ /**
+ * Use for paginsation. Force the page number.
+ */
+ public Integer getPage() {
+ return page;
+ }
+
+ public void setPage(Integer page) {
+ this.page = page;
+ }
+
+ /**
+ * Set a proxy host if needed
+ */
+ public String getHttpProxyHost() {
+ return httpProxyHost;
+ }
+
+ public void setHttpProxyHost(String httpProxyHost) {
+ this.httpProxyHost = httpProxyHost;
+ }
+
+ /**
+ * Set a proxy user if needed
+ */
+ public String getHttpProxyUser() {
+ return httpProxyUser;
+ }
+
+ public void setHttpProxyUser(String httpProxyUser) {
+ this.httpProxyUser = httpProxyUser;
+ }
+
+ /**
+ * Set a proxy password if needed
+ */
+ public String getHttpProxyPassword() {
+ return httpProxyPassword;
+ }
+
+ public void setHttpProxyPassword(String httpProxyPassword) {
+ this.httpProxyPassword = httpProxyPassword;
+ }
+
+ /**
+ * Set a proxy port if needed
+ */
+ public Integer getHttpProxyPort() {
+ return httpProxyPort;
+ }
+
+ public void setHttpProxyPort(Integer httpProxyPort) {
+ this.httpProxyPort = httpProxyPort;
+ }
+
+
+ /**
+ * To use a existing configured DigitalOceanClient as client
+ */
+ public DigitalOceanClient getDigitalOceanClient() {
+ return digitalOceanClient;
+ }
+
+ public void setDigitalOceanClient(DigitalOceanClient digitalOceanClient) {
+ this.digitalOceanClient = digitalOceanClient;
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/17d527d1/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/DigitalOceanEndpoint.java
----------------------------------------------------------------------
diff --git a/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/DigitalOceanEndpoint.java b/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/DigitalOceanEndpoint.java
new file mode 100644
index 0000000..576e22c
--- /dev/null
+++ b/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/DigitalOceanEndpoint.java
@@ -0,0 +1,130 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.digitalocean;
+
+import com.myjeeva.digitalocean.impl.DigitalOceanClient;
+import org.apache.camel.Consumer;
+import org.apache.camel.Processor;
+import org.apache.camel.Producer;
+import org.apache.camel.component.digitalocean.producer.*;
+import org.apache.camel.impl.DefaultEndpoint;
+import org.apache.camel.spi.UriEndpoint;
+import org.apache.camel.spi.UriParam;
+import org.apache.http.HttpHost;
+import org.apache.http.auth.AuthScope;
+import org.apache.http.auth.UsernamePasswordCredentials;
+import org.apache.http.impl.client.BasicCredentialsProvider;
+import org.apache.http.impl.client.HttpClientBuilder;
+import org.apache.http.impl.client.HttpClients;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Represents the DigitalOcean endpoint.
+ */
+@UriEndpoint(scheme = "digitalocean", title = "DigitalOcean", syntax="digitalocean:label", producerOnly = true, label = "cloud,management")
+public class DigitalOceanEndpoint extends DefaultEndpoint {
+
+ private static final transient Logger LOG = LoggerFactory.getLogger(DigitalOceanEndpoint.class);
+
+ @UriParam
+ private DigitalOceanConfiguration configuration;
+
+ private DigitalOceanClient digitalOceanClient;
+
+ public DigitalOceanEndpoint(String uri, DigitalOceanComponent component, DigitalOceanConfiguration configuration) {
+ super(uri, component);
+ this.configuration = configuration;
+ }
+
+ public Producer createProducer() throws Exception {
+ LOG.trace("Resolve producer digitalocean endpoint {" + configuration.getResource() + "}");
+
+ switch (configuration.getResource()) {
+ case account:
+ return new DigitalOceanAccountProducer(this, configuration);
+ case actions:
+ return new DigitalOceanActionsProducer(this, configuration);
+ case blockStorages:
+ return new DigitalOceanBlockStoragesProducer(this, configuration);
+ case droplets:
+ return new DigitalOceanDropletsProducer(this, configuration);
+ case images:
+ return new DigitalOceanImagesProducer(this, configuration);
+ case snapshots:
+ return new DigitalOceanSnapshotsProducer(this, configuration);
+ case keys:
+ return new DigitalOceanKeysProducer(this, configuration);
+ case regions:
+ return new DigitalOceanRegionsProducer(this, configuration);
+ case sizes:
+ return new DigitalOceanSizesProducer(this, configuration);
+ case floatingIPs:
+ return new DigitalOceanFloatingIPsProducer(this, configuration);
+ case tags:
+ return new DigitalOceanTagsProducer(this, configuration);
+ default:
+ throw new UnsupportedOperationException("Operation specified is not valid for producer");
+ }
+
+ }
+
+ public Consumer createConsumer(Processor processor) throws Exception {
+ throw new UnsupportedOperationException("You cannot receive messages from this endpoint");
+ }
+
+ public boolean isSingleton() {
+ return true;
+ }
+
+
+ @Override
+ public void doStart() throws Exception {
+ super.doStart();
+
+ if(configuration.getDigitalOceanClient() != null)
+ digitalOceanClient = configuration.getDigitalOceanClient();
+ else
+ if(configuration.getHttpProxyHost() != null && configuration.getHttpProxyPort() != null) {
+
+ HttpClientBuilder builder = HttpClients.custom()
+ .useSystemProperties()
+ .setProxy(new HttpHost(configuration.getHttpProxyHost(), configuration.getHttpProxyPort()));
+
+ if(configuration.getHttpProxyUser() != null && configuration.getHttpProxyPassword() != null) {
+ BasicCredentialsProvider credsProvider = new BasicCredentialsProvider();
+ credsProvider.setCredentials(
+ new AuthScope(configuration.getHttpProxyHost(), configuration.getHttpProxyPort()),
+ new UsernamePasswordCredentials(configuration.getHttpProxyUser() , configuration.getHttpProxyPassword()));
+ builder.setDefaultCredentialsProvider(credsProvider);
+
+ }
+
+ digitalOceanClient = new DigitalOceanClient("v2", configuration.getOAuthToken(), builder.build());
+
+ } else
+ digitalOceanClient = new DigitalOceanClient(configuration.getOAuthToken());
+
+
+ }
+
+ public DigitalOceanConfiguration getConfiguration() { return configuration; }
+ public DigitalOceanClient getDigitalOceanClient() {
+ return digitalOceanClient;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/17d527d1/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/DigitalOceanException.java
----------------------------------------------------------------------
diff --git a/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/DigitalOceanException.java b/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/DigitalOceanException.java
new file mode 100644
index 0000000..a149fd4
--- /dev/null
+++ b/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/DigitalOceanException.java
@@ -0,0 +1,30 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.digitalocean;
+
+public class DigitalOceanException extends Exception {
+
+ private static final long serialVersionUID = 1L;
+
+ public DigitalOceanException(Throwable e) {
+ super(e);
+ }
+
+ public DigitalOceanException(String message) {
+ super(message);
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/camel/blob/17d527d1/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/constants/DigitalOceanHeaders.java
----------------------------------------------------------------------
diff --git a/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/constants/DigitalOceanHeaders.java b/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/constants/DigitalOceanHeaders.java
new file mode 100644
index 0000000..d4462c2
--- /dev/null
+++ b/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/constants/DigitalOceanHeaders.java
@@ -0,0 +1,54 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.digitalocean.constants;
+
+public interface DigitalOceanHeaders {
+
+ String OPERATION = "CamelDigitalOceanOperation";
+ String ID = "CamelDigitalOceanId";
+ String TYPE = "CamelDigitalOceanType";
+ String NAME = "CamelDigitalOceanName";
+ String NEW_NAME = "CamelDigitalOceanNewName";
+ String NAMES = "CamelDigitalOceanNames";
+ String REGION = "CamelDigitalOceanRegion";
+ String DESCRIPTION = "CamelDigitalOceanDescription";
+
+ String DROPLET_SIZE = "CamelDigitalOceanDropletSize";
+ String DROPLET_IMAGE = "CamelDigitalOceanDropletImage";
+ String DROPLET_KEYS = "CamelDigitalOceanDropletSSHKeys";
+ String DROPLET_ENABLE_BACKUPS = "CamelDigitalOceanDropletEnableBackups";
+ String DROPLET_ENABLE_IPV6 = "CamelDigitalOceanDropletEnableIpv6";
+ String DROPLET_ENABLE_PRIVATE_NETWORKING = "CamelDigitalOceanDropletEnablePrivateNetworking";
+ String DROPLET_USER_DATA = "CamelDigitalOceanDropletUserData";
+ String DROPLET_VOLUMES = "CamelDigitalOceanDropletVolumes";
+ String DROPLET_TAGS = "CamelDigitalOceanDropletTags";
+
+ String DROPLET_ID = "CamelDigitalOceanDropletId";
+ String IMAGE_ID = "CamelDigitalOceanImageId";
+ String KERNEL_ID = "CamelDigitalOceanKernelId";
+ String VOLUME_NAME = "CamelDigitalOceanVolumeName";
+ String VOLUME_SIZE_GIGABYTES = "CamelDigitalOceanVolumeSizeGigabytes";
+
+ String FLOATING_IP_ADDRESS = "CamelDigitalOceanFloatingIPAddress";
+
+ String KEY_FINGERPRINT = "CamelDigitalOceanKeyFingerprint";
+ String KEY_PUBLIC_KEY = "CamelDigitalOceanKeyPublicKey";
+
+
+
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/17d527d1/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/constants/DigitalOceanImageTypes.java
----------------------------------------------------------------------
diff --git a/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/constants/DigitalOceanImageTypes.java b/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/constants/DigitalOceanImageTypes.java
new file mode 100644
index 0000000..f5c4a12
--- /dev/null
+++ b/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/constants/DigitalOceanImageTypes.java
@@ -0,0 +1,24 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.digitalocean.constants;
+
+public enum DigitalOceanImageTypes {
+
+ distribution,
+ application
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/17d527d1/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/constants/DigitalOceanOperations.java
----------------------------------------------------------------------
diff --git a/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/constants/DigitalOceanOperations.java b/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/constants/DigitalOceanOperations.java
new file mode 100644
index 0000000..8677c38
--- /dev/null
+++ b/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/constants/DigitalOceanOperations.java
@@ -0,0 +1,57 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.digitalocean.constants;
+
+public enum DigitalOceanOperations {
+
+ create,
+ update,
+ delete,
+ list,
+ ownList,
+ get,
+ listBackups,
+ listActions,
+ listNeighbors,
+ listSnapshots,
+ listKernels,
+ listAllNeighbors,
+ enableBackups,
+ disableBackups,
+ reboot,
+ powerCycle,
+ shutdown,
+ powerOn,
+ powerOff,
+ restore,
+ resetPassword,
+ resize,
+ rebuild,
+ rename,
+ changeKernel,
+ enableIpv6,
+ enablePrivateNetworking,
+ takeSnapshot,
+ transfer,
+ convert,
+ attach,
+ detach,
+ assign,
+ unassign,
+ tag,
+ untag
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/17d527d1/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/constants/DigitalOceanResources.java
----------------------------------------------------------------------
diff --git a/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/constants/DigitalOceanResources.java b/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/constants/DigitalOceanResources.java
new file mode 100644
index 0000000..8188cb8
--- /dev/null
+++ b/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/constants/DigitalOceanResources.java
@@ -0,0 +1,36 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.digitalocean.constants;
+
+
+public enum DigitalOceanResources {
+
+ account,
+ actions,
+ blockStorages,
+ droplets,
+ images,
+ snapshots,
+ keys,
+ regions,
+ sizes,
+ floatingIPs,
+ tags
+
+
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/17d527d1/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/constants/DigitalOceanSnapshotTypes.java
----------------------------------------------------------------------
diff --git a/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/constants/DigitalOceanSnapshotTypes.java b/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/constants/DigitalOceanSnapshotTypes.java
new file mode 100644
index 0000000..f08a461
--- /dev/null
+++ b/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/constants/DigitalOceanSnapshotTypes.java
@@ -0,0 +1,24 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.digitalocean.constants;
+
+public enum DigitalOceanSnapshotTypes {
+
+ droplet,
+ volume
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/17d527d1/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/producer/DigitalOceanAccountProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/producer/DigitalOceanAccountProducer.java b/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/producer/DigitalOceanAccountProducer.java
new file mode 100644
index 0000000..dddc1a5
--- /dev/null
+++ b/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/producer/DigitalOceanAccountProducer.java
@@ -0,0 +1,39 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.digitalocean.producer;
+
+import com.myjeeva.digitalocean.pojo.*;
+import org.apache.camel.component.digitalocean.DigitalOceanConfiguration;
+import org.apache.camel.component.digitalocean.DigitalOceanEndpoint;
+import org.apache.camel.Exchange;
+
+/**
+ * The DigitalOcean producer for Account API.
+ */
+public class DigitalOceanAccountProducer extends DigitalOceanProducer {
+
+ public DigitalOceanAccountProducer(DigitalOceanEndpoint endpoint, DigitalOceanConfiguration configuration) {
+ super(endpoint, configuration);
+ }
+
+ public void process(Exchange exchange) throws Exception {
+ Account accountInfo = getEndpoint().getDigitalOceanClient().getAccountInfo();
+ LOG.trace("Account [{}] ", accountInfo);
+ exchange.getOut().setBody(accountInfo);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/17d527d1/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/producer/DigitalOceanActionsProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/producer/DigitalOceanActionsProducer.java b/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/producer/DigitalOceanActionsProducer.java
new file mode 100644
index 0000000..67fdd67
--- /dev/null
+++ b/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/producer/DigitalOceanActionsProducer.java
@@ -0,0 +1,66 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.digitalocean.producer;
+
+import com.myjeeva.digitalocean.pojo.*;
+import org.apache.camel.component.digitalocean.DigitalOceanConfiguration;
+import org.apache.camel.component.digitalocean.DigitalOceanEndpoint;
+import org.apache.camel.component.digitalocean.constants.DigitalOceanHeaders;
+import org.apache.camel.Exchange;
+import org.apache.camel.util.ObjectHelper;
+
+/**
+ * The DigitalOcean producer for Actions API.
+ */
+public class DigitalOceanActionsProducer extends DigitalOceanProducer {
+
+ public DigitalOceanActionsProducer(DigitalOceanEndpoint endpoint, DigitalOceanConfiguration configuration) {
+ super(endpoint, configuration);
+ }
+
+ public void process(Exchange exchange) throws Exception {
+ switch(determineOperation(exchange)) {
+
+ case list:
+ getActions(exchange);
+ break;
+ case get:
+ getAction(exchange);
+ break;
+ default:
+ throw new IllegalArgumentException("Unsupported operation");
+ }
+
+ }
+
+
+ private void getAction(Exchange exchange) throws Exception {
+ Integer actionId = exchange.getIn().getHeader(DigitalOceanHeaders.ID, Integer.class);
+
+ if (ObjectHelper.isEmpty(actionId))
+ throw new IllegalArgumentException(DigitalOceanHeaders.ID + " must be specified");
+ Action action = getEndpoint().getDigitalOceanClient().getActionInfo(actionId);
+ LOG.trace("Action [{}] ", action);
+ exchange.getOut().setBody(action);
+ }
+
+ private void getActions(Exchange exchange) throws Exception {
+ Actions actions = getEndpoint().getDigitalOceanClient().getAvailableActions(configuration.getPage(), configuration.getPerPage());
+ LOG.trace("All Actions : page {} / {} per page [{}] ", configuration.getPage(), configuration.getPerPage(), actions.getActions());
+ exchange.getOut().setBody(actions.getActions());
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/17d527d1/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/producer/DigitalOceanBlockStoragesProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/producer/DigitalOceanBlockStoragesProducer.java b/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/producer/DigitalOceanBlockStoragesProducer.java
new file mode 100644
index 0000000..0e00507
--- /dev/null
+++ b/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/producer/DigitalOceanBlockStoragesProducer.java
@@ -0,0 +1,252 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.digitalocean.producer;
+
+import com.myjeeva.digitalocean.pojo.*;
+import org.apache.camel.component.digitalocean.DigitalOceanConfiguration;
+import org.apache.camel.component.digitalocean.constants.DigitalOceanHeaders;
+import org.apache.camel.component.digitalocean.DigitalOceanEndpoint;
+import org.apache.camel.Exchange;
+import org.apache.camel.Message;
+import org.apache.camel.util.ObjectHelper;
+
+import java.util.List;
+
+/**
+ * The DigitalOcean producer for BlockStorages API.
+ */
+public class DigitalOceanBlockStoragesProducer extends DigitalOceanProducer {
+
+ public DigitalOceanBlockStoragesProducer(DigitalOceanEndpoint endpoint, DigitalOceanConfiguration configuration) {
+ super(endpoint, configuration);
+ }
+
+ public void process(Exchange exchange) throws Exception {
+
+ switch (determineOperation(exchange)) {
+
+ case list:
+ getVolumes(exchange);
+ break;
+ case get:
+ getVolume(exchange);
+ break;
+ case listSnapshots:
+ getVolumeSnapshots(exchange);
+ break;
+ case create:
+ createVolume(exchange);
+ break;
+ case delete:
+ deleteVolume(exchange);
+ break;
+ case attach:
+ attachVolumeToDroplet(exchange);
+ break;
+ case detach:
+ detachVolumeToDroplet(exchange);
+ break;
+ case resize:
+ resizeVolume(exchange);
+ break;
+ case listActions:
+ getVolumeActions(exchange);
+ break;
+ default:
+ throw new IllegalArgumentException("Unsupported operation");
+ }
+ }
+
+ private void getVolumes(Exchange exchange) throws Exception {
+ String region = exchange.getIn().getHeader(DigitalOceanHeaders.REGION, String.class);
+ if (ObjectHelper.isEmpty(region))
+ throw new IllegalArgumentException(DigitalOceanHeaders.REGION + " must be specified");
+
+ Volumes volumes = getEndpoint().getDigitalOceanClient().getAvailableVolumes(region);
+ LOG.trace("All Volumes for region {} [{}] ", region, volumes.getVolumes());
+ exchange.getOut().setBody(volumes.getVolumes());
+
+ }
+
+ private void createVolume(Exchange exchange) throws Exception {
+ Message in = exchange.getIn();
+
+ Volume volume = new Volume();
+
+ if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(DigitalOceanHeaders.VOLUME_SIZE_GIGABYTES)))
+ volume.setSize(in.getHeader(DigitalOceanHeaders.VOLUME_SIZE_GIGABYTES, Double.class));
+ else
+ throw new IllegalArgumentException(DigitalOceanHeaders.VOLUME_SIZE_GIGABYTES + " must be specified");
+
+ if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(DigitalOceanHeaders.NAME)))
+ volume.setName(in.getHeader(DigitalOceanHeaders.NAME, String.class));
+ else
+ throw new IllegalArgumentException(DigitalOceanHeaders.NAME + " must be specified");
+
+ if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(DigitalOceanHeaders.REGION)))
+ volume.setRegion(new Region(in.getHeader(DigitalOceanHeaders.REGION, String.class)));
+ else
+ throw new IllegalArgumentException(DigitalOceanHeaders.REGION + " must be specified");
+
+ if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(DigitalOceanHeaders.DESCRIPTION)))
+ volume.setDescription(in.getHeader(DigitalOceanHeaders.DESCRIPTION, String.class));
+ else
+ throw new IllegalArgumentException(DigitalOceanHeaders.DESCRIPTION + " must be specified");
+
+ volume = getEndpoint().getDigitalOceanClient().createVolume(volume);
+ LOG.trace("Volume created {} ", volume);
+ exchange.getOut().setBody(volume);
+ }
+
+ private void getVolume(Exchange exchange) throws Exception {
+ String volumeId = exchange.getIn().getHeader(DigitalOceanHeaders.ID, String.class);
+ Volume volume = null;
+ if (ObjectHelper.isEmpty(volumeId)) {
+ String name = exchange.getIn().getHeader(DigitalOceanHeaders.NAME, String.class);
+ String region = exchange.getIn().getHeader(DigitalOceanHeaders.REGION, String.class);
+
+ if (ObjectHelper.isEmpty(name) && ObjectHelper.isEmpty(region))
+ throw new IllegalArgumentException(DigitalOceanHeaders.ID + " or " + DigitalOceanHeaders.NAME + " and " + DigitalOceanHeaders.REGION + " must be specified");
+
+ List<Volume> volumes = getEndpoint().getDigitalOceanClient().getVolumeInfo(name, region).getVolumes();
+ if (volumes.size() > 0)
+ volume = volumes.get(1);
+ } else
+ volume = getEndpoint().getDigitalOceanClient().getVolumeInfo(volumeId);
+
+ LOG.trace("Volume [{}] ", volume);
+ exchange.getOut().setBody(volume);
+
+ }
+
+ private void getVolumeSnapshots(Exchange exchange) throws Exception {
+ String volumeId = exchange.getIn().getHeader(DigitalOceanHeaders.ID, String.class);
+ if (ObjectHelper.isEmpty(volumeId))
+ throw new IllegalArgumentException(DigitalOceanHeaders.ID + " must be specified");
+
+ Snapshots snapshots = getEndpoint().getDigitalOceanClient().getVolumeSnapshots(volumeId, configuration.getPage(), configuration.getPerPage());
+ LOG.trace("All Snapshots for volume {} [{}] ", volumeId, snapshots.getSnapshots());
+ exchange.getOut().setBody(snapshots.getSnapshots());
+ }
+
+ private void deleteVolume(Exchange exchange) throws Exception {
+ String volumeId = exchange.getIn().getHeader(DigitalOceanHeaders.ID, String.class);
+ Delete delete;
+ if (ObjectHelper.isEmpty(volumeId)) {
+ String name = exchange.getIn().getHeader(DigitalOceanHeaders.NAME, String.class);
+ String region = exchange.getIn().getHeader(DigitalOceanHeaders.REGION, String.class);
+
+ if (ObjectHelper.isEmpty(name) && ObjectHelper.isEmpty(region))
+ throw new IllegalArgumentException(DigitalOceanHeaders.ID + " or " + DigitalOceanHeaders.NAME + " and " + DigitalOceanHeaders.REGION + " must be specified");
+
+ delete = getEndpoint().getDigitalOceanClient().deleteVolume(name, region);
+
+ } else
+ delete = getEndpoint().getDigitalOceanClient().deleteVolume(volumeId);
+
+ LOG.trace("Delete Volume [{}] ", delete);
+ exchange.getOut().setBody(delete);
+
+ }
+
+ private void attachVolumeToDroplet(Exchange exchange) throws Exception {
+ String volumeId = exchange.getIn().getHeader(DigitalOceanHeaders.ID, String.class);
+ String volumeName = exchange.getIn().getHeader(DigitalOceanHeaders.VOLUME_NAME, String.class);
+ Integer dropletId = exchange.getIn().getHeader(DigitalOceanHeaders.DROPLET_ID, Integer.class);
+ String region = exchange.getIn().getHeader(DigitalOceanHeaders.REGION, String.class);
+
+ if (ObjectHelper.isEmpty(dropletId))
+ throw new IllegalArgumentException(DigitalOceanHeaders.DROPLET_ID + " must be specified");
+
+ if (ObjectHelper.isEmpty(region))
+ throw new IllegalArgumentException(DigitalOceanHeaders.REGION + " must be specified");
+
+ Action action;
+
+ if (ObjectHelper.isNotEmpty(volumeName)) {
+ action = getEndpoint().getDigitalOceanClient().attachVolumeByName(dropletId, volumeName, region);
+ LOG.trace("Attach Volume {} to Droplet {} [{}] ", volumeName, dropletId, action);
+ } else if (ObjectHelper.isNotEmpty(volumeId)) {
+ action = getEndpoint().getDigitalOceanClient().attachVolume(dropletId, volumeId, region);
+ LOG.trace("Attach Volume {} to Droplet {} [{}] ", volumeId, dropletId, action);
+ } else
+ throw new IllegalArgumentException(DigitalOceanHeaders.ID + " or " + DigitalOceanHeaders.VOLUME_NAME + " must be specified");
+
+ exchange.getOut().setBody(action);
+ }
+
+
+
+ private void detachVolumeToDroplet(Exchange exchange) throws Exception {
+ String volumeId = exchange.getIn().getHeader(DigitalOceanHeaders.ID, String.class);
+ String volumeName = exchange.getIn().getHeader(DigitalOceanHeaders.VOLUME_NAME, String.class);
+ Integer dropletId = exchange.getIn().getHeader(DigitalOceanHeaders.DROPLET_ID, Integer.class);
+ String region = exchange.getIn().getHeader(DigitalOceanHeaders.REGION, String.class);
+
+ if (ObjectHelper.isEmpty(dropletId))
+ throw new IllegalArgumentException(DigitalOceanHeaders.DROPLET_ID + " must be specified");
+
+ if (ObjectHelper.isEmpty(region))
+ throw new IllegalArgumentException(DigitalOceanHeaders.REGION + " must be specified");
+
+ Action action;
+
+ if (ObjectHelper.isNotEmpty(volumeName)) {
+ action = getEndpoint().getDigitalOceanClient().detachVolumeByName(dropletId, volumeName, region);
+ LOG.trace("Detach Volume {} to Droplet {} [{}] ", volumeName, dropletId, action);
+ } else if (ObjectHelper.isNotEmpty(volumeId)) {
+ action = getEndpoint().getDigitalOceanClient().detachVolume(dropletId, volumeId, region);
+ LOG.trace("Detach Volume {} to Droplet {} [{}] ", volumeId, dropletId, action);
+ } else
+ throw new IllegalArgumentException(DigitalOceanHeaders.ID + " or " + DigitalOceanHeaders.VOLUME_NAME + " must be specified");
+
+ exchange.getOut().setBody(action);
+
+ }
+
+ private void resizeVolume(Exchange exchange) throws Exception {
+ String volumeId = exchange.getIn().getHeader(DigitalOceanHeaders.ID, String.class);
+
+ if (ObjectHelper.isEmpty(volumeId))
+ throw new IllegalArgumentException(DigitalOceanHeaders.ID + " must be specified");
+
+ String region = exchange.getIn().getHeader(DigitalOceanHeaders.REGION, String.class);
+
+ if (ObjectHelper.isEmpty(region))
+ throw new IllegalArgumentException(DigitalOceanHeaders.REGION + " must be specified");
+
+ Double size = exchange.getIn().getHeader(DigitalOceanHeaders.VOLUME_SIZE_GIGABYTES, Double.class);
+
+ if (ObjectHelper.isEmpty(size))
+ throw new IllegalArgumentException(DigitalOceanHeaders.VOLUME_SIZE_GIGABYTES + " must be specified");
+
+ Action action = getEndpoint().getDigitalOceanClient().resizeVolume(volumeId, region, size);
+ LOG.trace("Resize Volume {} [{}] ", volumeId, action);
+ }
+
+ private void getVolumeActions(Exchange exchange) throws Exception {
+ String volumeId = exchange.getIn().getHeader(DigitalOceanHeaders.ID, String.class);
+
+ if (ObjectHelper.isEmpty(volumeId))
+ throw new IllegalArgumentException(DigitalOceanHeaders.ID + " must be specified");
+
+ Actions actions = getEndpoint().getDigitalOceanClient().getAvailableVolumeActions(volumeId);
+ LOG.trace("Actions for Volume {} [{}] ", volumeId, actions.getActions());
+ exchange.getOut().setBody(actions.getActions());
+ }
+
+}
[18/20] camel git commit: CAMEL-11062: Added docs to
camel-digitalocean component
Posted by ac...@apache.org.
CAMEL-11062: Added docs to camel-digitalocean component
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/db20dc99
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/db20dc99
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/db20dc99
Branch: refs/heads/master
Commit: db20dc99784dcc5f15d777b299df8c164641bd51
Parents: 1142fd4
Author: Andrea Cosentino <an...@gmail.com>
Authored: Mon Mar 27 09:46:18 2017 +0200
Committer: Andrea Cosentino <an...@gmail.com>
Committed: Mon Mar 27 09:48:35 2017 +0200
----------------------------------------------------------------------
components/camel-digitalocean/README.md | 254 -----------------
.../src/main/docs/digitalocean-component.adoc | 283 +++++++++++++++++++
2 files changed, 283 insertions(+), 254 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/db20dc99/components/camel-digitalocean/README.md
----------------------------------------------------------------------
diff --git a/components/camel-digitalocean/README.md b/components/camel-digitalocean/README.md
deleted file mode 100644
index 87771f7..0000000
--- a/components/camel-digitalocean/README.md
+++ /dev/null
@@ -1,254 +0,0 @@
-# Camel DigitalOcean Component
-
-The **DigitalOcean** component allows you to manage Droplets and resources within the DigitalOcean cloud with **Camel** by encapsulating [digitalocean-api-java](https://www.digitalocean.com/community/projects/api-client-in-java). All of the functionality that you are familiar with in the DigitalOcean control panel is also available through this Camel component.
-
-
-## Prerequisites
-
-You must have a valid DigitalOcean account and a valid OAuth token. You can generate an OAuth token by visiting the [Apps & API](https://cloud.digitalocean.com/settings/applications) section of the DigitalOcean control panel for your account.
-
-## URI format
-
-The **DigitalOcean Component** uses the following URI format:
-
-```
-digitalocean://endpoint?[options]
-```
-where `endpoint` is a DigitalOcean resource type.
-
-Example : to list your droplets:
-
-```
-digitalocean://droplets?operation=list&oAuthToken=XXXXXX&page=1&perPage=10
-```
-
-The DigitalOcean component only supports producer endpoints so you cannot use this component at the beginning of a route to listen to messages in a channel.
-
-## URI Endpoints
-
-There is one endpoint for each DigitalOcean resources (defined in `DigitalOceanResources` enumeration):
-
-| Endpoint | Description |
-| ------ | ----------- |
-| `account` | Your account on DigitalOcean. |
-| `actions` | Actions are records of events that have occurred on the resources in your account. |
-| `blockStorages` | Block Storage volumes provide expanded storage capacity for your Droplets and can be moved between Droplets within a specific region. |
-| `droplets` | A Droplet is a DigitalOcean virtual machine. |
-| `images` | An image may refer to a snapshot that has been taken of a Droplet instance. It may also mean an image representing an automatic backup of a Droplet. |
-| `snapshots` | Snapshots are saved instances of a Droplet or a volume. |
-| `keys` | DigitalOcean allows you to add SSH public keys to the interface so that you can embed your public key into a Droplet at the time of creation. |
-| `regions` | A region in DigitalOcean represents a datacenter where Droplets can be deployed and images can be transferred. |
-| `sizes` | The sizes objects represent different packages of hardware resources that can be used for Droplets. |
-| `floatingIPs` | Floating IP objects represent a publicly-accessible static IP addresses that can be mapped to one of your Droplets. |
-| `tags` | A Tag is a label that can be applied to a resource (currently only Droplets) in order to better organize or facilitate the lookups and actions on it. |
-
-
-## URI Options
-
-You have to provide the `digitalOceanClient` in the Registry or your `oAuthToken` to access the DigitalOcean service.
-
-| Option | Type | Example | Description |
-| ------ | ---- | ------- | ----------- |
-| `operation` | String | `operation=list` | The operation to perform to the resource. It can also be set with the `CamelDigitalOceanOperation` Message header. |
-| `oAuthToken` | String | | Your DigitalOcean oAuth token. |
-| `digitalOceanClient` | `com.myjeeva.digitalocean.DigitalOcean` | Reference to a `com.myjeeva.digitalocean.DigitalOcean` in the Registry. |
-| `page` | Integer | `page=3` | Can be used for `list` operations, for pagination. Force the page number.|
-| `perPage` | Integer | `perPage=50` | Can be used for `list` operations, for pagiantion. Set the number of item per request. |
-
-
-You have to provide an **operation** value for each endpoint, with the `operation` URI option or the `CamelDigitalOceanOperation` message header.
-
-All **operation** values are defined in `DigitalOceanOperations` enumeration.
-
-All **header** names used by the component are defined in `DigitalOceanHeaders` enumeration.
-
-
-## Message body result
-All message bodies returned are using objects provided by the **digitalocean-api-java** library.
-
-
-## API Rate Limits
-
-
-DigitalOcean REST API encapsulated by camel-digitalocean component is subjected to API Rate Limiting. You can find the per method limits in the [API Rate Limits documentation](https://developers.digitalocean.com/documentation/v2/#rate-limit).
-
-
-## Account endpoint
-
-| operation | Description | Headers | Result |
-| ------ | ---- | ------- | ----------- |
-| `get` | get account info | | `com.myjeeva.digitalocean.pojo.Account` |
-
-
-
-## BlockStorages endpoint
-
-| operation | Description | Headers | Result |
-| ------ | ---- | ------- | ----------- |
-| `list` | list all of the Block Storage volumes available on your account | | `List<com.myjeeva.digitalocean.pojo.Volume>` |
-| `get` | show information about a Block Storage volume| `CamelDigitalOceanId` _Integer_| `com.myjeeva.digitalocean.pojo.Volume` |
-| `get` | show information about a Block Storage volume by name| `CamelDigitalOceanName` _String_ <br>`CamelDigitalOceanRegion` _String_| `com.myjeeva.digitalocean.pojo.Volume` |
-| `listSnapshots` | retrieve the snapshots that have been created from a volume | `CamelDigitalOceanId` _Integer_| `List<com.myjeeva.digitalocean.pojo.Snapshot>` |
-| `create` | create a new volume | `CamelDigitalOceanVolumeSizeGigabytes` _Integer_<br>`CamelDigitalOceanName` _String_<br>`CamelDigitalOceanDescription`* _String_<br>`CamelDigitalOceanRegion`* _String_| `com.myjeeva.digitalocean.pojo.Volume` |
-| `delete` | delete a Block Storage volume, destroying all data and removing it from your account| `CamelDigitalOceanId` _Integer_| `com.myjeeva.digitalocean.pojo.Delete`|
-| `delete` | delete a Block Storage volume by name| `CamelDigitalOceanName` _String_<br>`CamelDigitalOceanRegion` _String_| `com.myjeeva.digitalocean.pojo.Delete`
-| `attach` | attach a Block Storage volume to a Droplet| `CamelDigitalOceanId` _Integer_ <br>`CamelDigitalOceanDropletId` _Integer_<br>`CamelDigitalOceanDropletRegion` _String_| `com.myjeeva.digitalocean.pojo.Action`
-| `attach` | attach a Block Storage volume to a Droplet by name| `CamelDigitalOceanName` _String_<br>`CamelDigitalOceanDropletId` _Integer_<br>`CamelDigitalOceanDropletRegion` _String_| `com.myjeeva.digitalocean.pojo.Action`
-| `detach` | detach a Block Storage volume from a Droplet| `CamelDigitalOceanId` _Integer_ <br>`CamelDigitalOceanDropletId` _Integer_<br>`CamelDigitalOceanDropletRegion` _String_| `com.myjeeva.digitalocean.pojo.Action`
-| `attach` | detach a Block Storage volume from a Droplet by name| `CamelDigitalOceanName` _String_<br>`CamelDigitalOceanDropletId` _Integer_<br>`CamelDigitalOceanDropletRegion` _String_| `com.myjeeva.digitalocean.pojo.Action`
-| `resize` | resize a Block Storage volume | `CamelDigitalOceanVolumeSizeGigabytes` _Integer_<br>`CamelDigitalOceanRegion` _String_| `com.myjeeva.digitalocean.pojo.Action` |
-| `listActions` | retrieve all actions that have been executed on a volume | `CamelDigitalOceanId` _Integer_| `List<com.myjeeva.digitalocean.pojo.Action>` |
-
-## Droplets endpoint
-
-| operation | Description | Headers | Result |
-| ------ | ---- | ------- | ----------- |
-| `list` | list all Droplets in your account | | `List<com.myjeeva.digitalocean.pojo.Droplet>` |
-| `get` | show an individual droplet | `CamelDigitalOceanId` _Integer_| `com.myjeeva.digitalocean.pojo.Droplet` |
-| `create` | create a new Droplet | `CamelDigitalOceanName` _String_ <br>`CamelDigitalOceanDropletImage` _String_ <br>`CamelDigitalOceanRegion` _String_ <br>`CamelDigitalOceanDropletSize` _String_ <br>`CamelDigitalOceanDropletSSHKeys`* _List\<String\>_ <br>`CamelDigitalOceanDropletEnableBackups`* _Boolean_ <br>`CamelDigitalOceanDropletEnableIpv6`* _Boolean_ <br>`CamelDigitalOceanDropletEnablePrivateNetworking`* _Boolean_ <br>`CamelDigitalOceanDropletUserData`* _String_ <br>`CamelDigitalOceanDropletVolumes`* _List\<String\>_ <br>`CamelDigitalOceanDropletTags` _List\<String\>_| `com.myjeeva.digitalocean.pojo.Droplet` |
-| `create` | create multiple Droplets | `CamelDigitalOceanNames` _List\<String\>_ <br>`CamelDigitalOceanDropletImage` _String_ <br>`CamelDigitalOceanRegion` _String_ <br>`CamelDigitalOceanDropletSize` _String_ <br>`CamelDigitalOceanDropletSSHKeys`* _List\<String\>_ <br>`CamelDigitalOceanDropletEnableBackups`* _Boolean_ <br>`CamelDigitalOceanDropletEnableIpv6`* _Boolean_ <br>`CamelDigitalOceanDropletEnablePrivateNetworking`* _Boolean_ <br>`CamelDigitalOceanDropletUserData`* _String_ <br>`CamelDigitalOceanDropletVolumes`* _List\<String\>_ <br>`CamelDigitalOceanDropletTags` _List\<String\>_| `com.myjeeva.digitalocean.pojo.Droplet` |
-| `delete` | delete a Droplet, | `CamelDigitalOceanId` _Integer_| `com.myjeeva.digitalocean.pojo.Delete` |
-| `enableBackups` | enable backups on an existing Droplet | `CamelDigitalOceanId` _Integer_| `com.myjeeva.digitalocean.pojo.Action` |
-| `disableBackups` | disable backups on an existing Droplet | `CamelDigitalOceanId` _Integer_| `com.myjeeva.digitalocean.pojo.Action` |
-| `enableIpv6` | enable IPv6 networking on an existing Droplet | `CamelDigitalOceanId` _Integer_| `com.myjeeva.digitalocean.pojo.Action` |
-| `enablePrivateNetworking` | enable private networking on an existing Droplet | `CamelDigitalOceanId` _Integer_| `com.myjeeva.digitalocean.pojo.Action` |
-| `reboot` | reboot a Droplet | `CamelDigitalOceanId` _Integer_| `com.myjeeva.digitalocean.pojo.Action` |
-| `powerCycle` | power cycle a Droplet | `CamelDigitalOceanId` _Integer_| `com.myjeeva.digitalocean.pojo.Action` |
-| `shutdown` | shutdown a Droplet | `CamelDigitalOceanId` _Integer_| `com.myjeeva.digitalocean.pojo.Action` |
-| `powerOff` | power off a Droplet | `CamelDigitalOceanId` _Integer_| `com.myjeeva.digitalocean.pojo.Action` |
-| `powerOn` | power on a Droplet | `CamelDigitalOceanId` _Integer_| `com.myjeeva.digitalocean.pojo.Action` |
-| `restore` | shutdown a Droplet | `CamelDigitalOceanId` _Integer_ <br>`CamelDigitalOceanImageId` _Integer_| `com.myjeeva.digitalocean.pojo.Action` |
-| `passwordReset` | reset the password for a Droplet | `CamelDigitalOceanId` _Integer_| `com.myjeeva.digitalocean.pojo.Action` |
-| `resize` | resize a Droplet | `CamelDigitalOceanId` _Integer_ <br>`CamelDigitalOceanDropletSize` _String_| `com.myjeeva.digitalocean.pojo.Action` |
-| `rebuild` | rebuild a Droplet | `CamelDigitalOceanId` _Integer_ <br>`CamelDigitalOceanImageId` _Integer_| `com.myjeeva.digitalocean.pojo.Action` |
-| `rename` | rename a Droplet | `CamelDigitalOceanId` _Integer_ <br>`CamelDigitalOceanName` _String_| `com.myjeeva.digitalocean.pojo.Action` |
-| `changeKernel` | change the kernel of a Droplet | `CamelDigitalOceanId` _Integer_ <br>`CamelDigitalOceanKernelId` _Integer_| `com.myjeeva.digitalocean.pojo.Action` |
-| `takeSnapshot` | snapshot a Droplet | `CamelDigitalOceanId` _Integer_ <br>`CamelDigitalOceanName`* _String_| `com.myjeeva.digitalocean.pojo.Action` |
-| `tag` | tag a Droplet | `CamelDigitalOceanId` _Integer_ <br>`CamelDigitalOceanName` _String_| `com.myjeeva.digitalocean.pojo.Response` |
-| `untag` | untag a Droplet | `CamelDigitalOceanId` _Integer_ <br>`CamelDigitalOceanName` _String_| `com.myjeeva.digitalocean.pojo.Response` |
-| `listKernels` | retrieve a list of all kernels available to a Droplet | `CamelDigitalOceanId` _Integer_ | `List<com.myjeeva.digitalocean.pojo.Kernel>` |
-| `listSnapshots` | retrieve the snapshots that have been created from a Droplet | `CamelDigitalOceanId` _Integer_ | `List<com.myjeeva.digitalocean.pojo.Snapshot>` |
-| `listBackups` | retrieve any backups associated with a Droplet | `CamelDigitalOceanId` _Integer_ | `List<com.myjeeva.digitalocean.pojo.Backup>` |
-| `listActions` | retrieve all actions that have been executed on a Droplet | `CamelDigitalOceanId` _Integer_ | `List<com.myjeeva.digitalocean.pojo.Action>` |
-| `listNeighbors` | retrieve a list of droplets that are running on the same physical server | `CamelDigitalOceanId` _Integer_ | `List<com.myjeeva.digitalocean.pojo.Droplet>` |
-| `listAllNeighbors` | retrieve a list of any droplets that are running on the same physical hardware | | `List<com.myjeeva.digitalocean.pojo.Droplet>` |
-
-## Images endpoint
-
-| operation | Description | Headers | Result |
-| ------ | ---- | ------- | ----------- |
-| `list` | list images available on your account | `CamelDigitalOceanType`* _DigitalOceanImageTypes_ | `List<com.myjeeva.digitalocean.pojo.Image>` |
-| `ownList` | retrieve only the private images of a user | | `List<com.myjeeva.digitalocean.pojo.Image>` |
-| `listActions` | retrieve all actions that have been executed on a Image | `CamelDigitalOceanId` _Integer_ | `List<com.myjeeva.digitalocean.pojo.Action>` |
-| `get` | retrieve information about an image (public or private) by id| `CamelDigitalOceanId` _Integer_| `com.myjeeva.digitalocean.pojo.Image` |
-| `get` | retrieve information about an public image by slug| `CamelDigitalOceanDropletImage` _String_| `com.myjeeva.digitalocean.pojo.Image` |
-| `update` | update an image| `CamelDigitalOceanId` _Integer_ <br>`CamelDigitalOceanName` _String_| `com.myjeeva.digitalocean.pojo.Image` |
-| `delete` | delete an image| `CamelDigitalOceanId` _Integer_ | `com.myjeeva.digitalocean.pojo.Delete` |
-| `transfer` | transfer an image to another region| `CamelDigitalOceanId` _Integer_ <br>`CamelDigitalOceanRegion` _String_| `com.myjeeva.digitalocean.pojo.Action` |
-| `convert` | convert an image, for example, a backup to a snapshot| `CamelDigitalOceanId` _Integer_ | `com.myjeeva.digitalocean.pojo.Action` |
-
-## Snapshots endpoint
-
-| operation | Description | Headers | Result |
-| ------ | ---- | ------- | ----------- |
-| `list` | list all of the snapshots available on your account | `CamelDigitalOceanType`* _DigitalOceanSnapshotTypes_ | `List<com.myjeeva.digitalocean.pojo.Snapshot>` |
-| `get` | retrieve information about a snapshot| `CamelDigitalOceanId` _Integer_| `com.myjeeva.digitalocean.pojo.Snapshot` |
-| `delete` | delete an snapshot| `CamelDigitalOceanId` _Integer_ | `com.myjeeva.digitalocean.pojo.Delete` |
-
-
-## Keys endpoint
-
-| operation | Description | Headers | Result |
-| ------ | ---- | ------- | ----------- |
-| `list` | list all of the keys in your account | | `List<com.myjeeva.digitalocean.pojo.Key>` |
-| `get` | retrieve information about a key by id| `CamelDigitalOceanId` _Integer_| `com.myjeeva.digitalocean.pojo.Key` |
-| `get` | retrieve information about a key by fingerprint| `CamelDigitalOceanKeyFingerprint` _String_| `com.myjeeva.digitalocean.pojo.Key` |
-| `update` | update a key by id| `CamelDigitalOceanId` _Integer_ <br>`CamelDigitalOceanName` _String_| `com.myjeeva.digitalocean.pojo.Key` |
-| `update` | update a key by fingerprint| `CamelDigitalOceanKeyFingerprint` _String_ <br>`CamelDigitalOceanName` _String_| `com.myjeeva.digitalocean.pojo.Key` |
-| `delete` | delete a key by id| `CamelDigitalOceanId` _Integer_ | `com.myjeeva.digitalocean.pojo.Delete` |
-| `delete` | delete a key by fingerprint| `CamelDigitalOceanKeyFingerprint` _String_ | `com.myjeeva.digitalocean.pojo.Delete` |
-
-## Regions endpoint
-
-| operation | Description | Headers | Result |
-| ------ | ---- | ------- | ----------- |
-| `list` | list all of the regions that are available | | `List<com.myjeeva.digitalocean.pojo.Region>` |
-
-
-## Sizes endpoint
-
-| operation | Description | Headers | Result |
-| ------ | ---- | ------- | ----------- |
-| `list` | list all of the sizes that are available | | `List<com.myjeeva.digitalocean.pojo.Size>` |
-
-## Floating IPs endpoint
-
-| operation | Description | Headers | Result |
-| ------ | ---- | ------- | ----------- |
-| `list` | list all of the Floating IPs available on your account | | `List<com.myjeeva.digitalocean.pojo.FloatingIP>` |
-| `create` | create a new Floating IP assigned to a Droplet | `CamelDigitalOceanId` _Integer_ | `List<com.myjeeva.digitalocean.pojo.FloatingIP>` |
-| `create` | create a new Floating IP assigned to a Region | `CamelDigitalOceanRegion` _String_ | `List<com.myjeeva.digitalocean.pojo.FloatingIP>` |
-| `get` | retrieve information about a Floating IP| `CamelDigitalOceanFloatingIPAddress` _String_| `com.myjeeva.digitalocean.pojo.Key` |
-| `delete` | delete a Floating IP and remove it from your account| `CamelDigitalOceanFloatingIPAddress` _String_| `com.myjeeva.digitalocean.pojo.Delete` |
-| `assign` | assign a Floating IP to a Droplet| `CamelDigitalOceanFloatingIPAddress` _String_ <br>`CamelDigitalOceanDropletId` _Integer_| `com.myjeeva.digitalocean.pojo.Action` |
-| `unassign` | unassign a Floating IP | `CamelDigitalOceanFloatingIPAddress` _String_ | `com.myjeeva.digitalocean.pojo.Action` |
-| `listActions` | retrieve all actions that have been executed on a Floating IP | `CamelDigitalOceanFloatingIPAddress` _String_ | `List<com.myjeeva.digitalocean.pojo.Action>` |
-
-## Tags endpoint
-
-| operation | Description | Headers | Result |
-| ------ | ---- | ------- | ----------- |
-| `list` | list all of your tags | | `List<com.myjeeva.digitalocean.pojo.Tag>` |
-| `create` | create a Tag | `CamelDigitalOceanName` _String_ | `com.myjeeva.digitalocean.pojo.Tag` |
-| `get` | retrieve an individual tag | `CamelDigitalOceanName` _String_ | `com.myjeeva.digitalocean.pojo.Tag` |
-| `delete` | delete a tag | `CamelDigitalOceanName` _String_ | `com.myjeeva.digitalocean.pojo.Delete` |
-| `update` | update a tag | `CamelDigitalOceanName` _String_ <br>`CamelDigitalOceanNewName` _String_| `com.myjeeva.digitalocean.pojo.Tag` |
-
-
-## Examples
-
-Get your account info
-
-```
-from("direct:getAccountInfo")
- .setHeader(DigitalOceanConstants.OPERATION, constant(DigitalOceanOperations.get))
- .to("digitalocean:account?oAuthToken=XXXXXX")
-```
-
-Create a droplet
-
-```
-from("direct:createDroplet")
- .setHeader(DigitalOceanConstants.OPERATION, constant("create"))
- .setHeader(DigitalOceanHeaders.NAME, constant("myDroplet"))
- .setHeader(DigitalOceanHeaders.REGION, constant("fra1"))
- .setHeader(DigitalOceanHeaders.DROPLET_IMAGE, constant("ubuntu-14-04-x64"))
- .setHeader(DigitalOceanHeaders.DROPLET_SIZE, constant("512mb"))
- .to("digitalocean:droplet?oAuthToken=XXXXXX")
-```
-
-List all your droplets
-
-```
-from("direct:getDroplets")
- .setHeader(DigitalOceanConstants.OPERATION, constant("list"))
- .to("digitalocean:droplets?oAuthToken=XXXXXX")
-```
-
-Retrieve information for the Droplet (dropletId = 34772987)
-
-```
-from("direct:getDroplet")
- .setHeader(DigitalOceanConstants.OPERATION, constant("get"))
- .setHeader(DigitalOceanConstants.ID, 34772987)
- .to("digitalocean:droplet?oAuthToken=XXXXXX")
-```
-
-Shutdown information for the Droplet (dropletId = 34772987)
-
-```
-from("direct:shutdown")
- .setHeader(DigitalOceanConstants.ID, 34772987)
- .to("digitalocean:droplet?operation=shutdown&oAuthToken=XXXXXX")
-```
-
http://git-wip-us.apache.org/repos/asf/camel/blob/db20dc99/components/camel-digitalocean/src/main/docs/digitalocean-component.adoc
----------------------------------------------------------------------
diff --git a/components/camel-digitalocean/src/main/docs/digitalocean-component.adoc b/components/camel-digitalocean/src/main/docs/digitalocean-component.adoc
new file mode 100644
index 0000000..da40f19
--- /dev/null
+++ b/components/camel-digitalocean/src/main/docs/digitalocean-component.adoc
@@ -0,0 +1,283 @@
+## DigitalOcean Component
+
+*Available as of Camel version *
+
+The **DigitalOcean** component allows you to manage Droplets and resources within the DigitalOcean cloud with **Camel** by encapsulating [digitalocean-api-java](https://www.digitalocean.com/community/projects/api-client-in-java). All of the functionality that you are familiar with in the DigitalOcean control panel is also available through this Camel component.
+
+
+## Prerequisites
+
+You must have a valid DigitalOcean account and a valid OAuth token. You can generate an OAuth token by visiting the [Apps & API](https://cloud.digitalocean.com/settings/applications) section of the DigitalOcean control panel for your account.
+
+## URI format
+
+The **DigitalOcean Component** uses the following URI format:
+
+```
+digitalocean://endpoint?[options]
+```
+where `endpoint` is a DigitalOcean resource type.
+
+Example : to list your droplets:
+
+```
+digitalocean://droplets?operation=list&oAuthToken=XXXXXX&page=1&perPage=10
+```
+
+The DigitalOcean component only supports producer endpoints so you cannot use this component at the beginning of a route to listen to messages in a channel.
+
+## URI Endpoints
+
+There is one endpoint for each DigitalOcean resources (defined in `DigitalOceanResources` enumeration):
+
+| Endpoint | Description |
+| ------ | ----------- |
+| `account` | Your account on DigitalOcean. |
+| `actions` | Actions are records of events that have occurred on the resources in your account. |
+| `blockStorages` | Block Storage volumes provide expanded storage capacity for your Droplets and can be moved between Droplets within a specific region. |
+| `droplets` | A Droplet is a DigitalOcean virtual machine. |
+| `images` | An image may refer to a snapshot that has been taken of a Droplet instance. It may also mean an image representing an automatic backup of a Droplet. |
+| `snapshots` | Snapshots are saved instances of a Droplet or a volume. |
+| `keys` | DigitalOcean allows you to add SSH public keys to the interface so that you can embed your public key into a Droplet at the time of creation. |
+| `regions` | A region in DigitalOcean represents a datacenter where Droplets can be deployed and images can be transferred. |
+| `sizes` | The sizes objects represent different packages of hardware resources that can be used for Droplets. |
+| `floatingIPs` | Floating IP objects represent a publicly-accessible static IP addresses that can be mapped to one of your Droplets. |
+| `tags` | A Tag is a label that can be applied to a resource (currently only Droplets) in order to better organize or facilitate the lookups and actions on it. |
+
+
+### Options
+
+
+// component options: START
+The DigitalOcean component has no options.
+// component options: END
+
+// endpoint options: START
+The DigitalOcean endpoint is configured using URI syntax:
+
+ digitalocean:label
+
+with the following path and query parameters:
+
+#### Path Parameters (1 parameters):
+
+[width="100%",cols="2,5,^1,2",options="header"]
+|=======================================================================
+| Name | Description | Default | Type
+| **operation** | The operation to perform to the given resource. | | DigitalOceanOperations
+|=======================================================================
+
+#### Query Parameters (10 parameters):
+
+[width="100%",cols="2,5,^1,2",options="header"]
+|=======================================================================
+| Name | Description | Default | Type
+| **digitalOceanClient** (producer) | To use a existing configured DigitalOceanClient as client | | DigitalOceanClient
+| **page** (producer) | Use for pagination. Force the page number. | 1 | Integer
+| **perPage** (producer) | Use for pagination. Set the number of item per request. The maximum number of results per page is 200. | 25 | Integer
+| **resource** (producer) | *Required* The DigitalOcean resource type on which perform the operation. | | DigitalOceanResources
+| **synchronous** (advanced) | Sets whether synchronous processing should be strictly used or Camel is allowed to use asynchronous processing (if supported). | false | boolean
+| **httpProxyHost** (proxy) | Set a proxy host if needed | | String
+| **httpProxyPassword** (proxy) | Set a proxy password if needed | | String
+| **httpProxyPort** (proxy) | Set a proxy port if needed | | Integer
+| **httpProxyUser** (proxy) | Set a proxy host if needed | | String
+| **oAuthToken** (security) | DigitalOcean OAuth Token | | String
+|=======================================================================
+// endpoint options: END
+
+
+You have to provide an **operation** value for each endpoint, with the `operation` URI option or the `CamelDigitalOceanOperation` message header.
+
+All **operation** values are defined in `DigitalOceanOperations` enumeration.
+
+All **header** names used by the component are defined in `DigitalOceanHeaders` enumeration.
+
+
+## Message body result
+All message bodies returned are using objects provided by the **digitalocean-api-java** library.
+
+
+## API Rate Limits
+
+
+DigitalOcean REST API encapsulated by camel-digitalocean component is subjected to API Rate Limiting. You can find the per method limits in the [API Rate Limits documentation](https://developers.digitalocean.com/documentation/v2/#rate-limit).
+
+
+## Account endpoint
+
+| operation | Description | Headers | Result |
+| ------ | ---- | ------- | ----------- |
+| `get` | get account info | | `com.myjeeva.digitalocean.pojo.Account` |
+
+
+
+## BlockStorages endpoint
+
+| operation | Description | Headers | Result |
+| ------ | ---- | ------- | ----------- |
+| `list` | list all of the Block Storage volumes available on your account | | `List<com.myjeeva.digitalocean.pojo.Volume>` |
+| `get` | show information about a Block Storage volume| `CamelDigitalOceanId` _Integer_| `com.myjeeva.digitalocean.pojo.Volume` |
+| `get` | show information about a Block Storage volume by name| `CamelDigitalOceanName` _String_ <br>`CamelDigitalOceanRegion` _String_| `com.myjeeva.digitalocean.pojo.Volume` |
+| `listSnapshots` | retrieve the snapshots that have been created from a volume | `CamelDigitalOceanId` _Integer_| `List<com.myjeeva.digitalocean.pojo.Snapshot>` |
+| `create` | create a new volume | `CamelDigitalOceanVolumeSizeGigabytes` _Integer_<br>`CamelDigitalOceanName` _String_<br>`CamelDigitalOceanDescription`* _String_<br>`CamelDigitalOceanRegion`* _String_| `com.myjeeva.digitalocean.pojo.Volume` |
+| `delete` | delete a Block Storage volume, destroying all data and removing it from your account| `CamelDigitalOceanId` _Integer_| `com.myjeeva.digitalocean.pojo.Delete`|
+| `delete` | delete a Block Storage volume by name| `CamelDigitalOceanName` _String_<br>`CamelDigitalOceanRegion` _String_| `com.myjeeva.digitalocean.pojo.Delete`
+| `attach` | attach a Block Storage volume to a Droplet| `CamelDigitalOceanId` _Integer_ <br>`CamelDigitalOceanDropletId` _Integer_<br>`CamelDigitalOceanDropletRegion` _String_| `com.myjeeva.digitalocean.pojo.Action`
+| `attach` | attach a Block Storage volume to a Droplet by name| `CamelDigitalOceanName` _String_<br>`CamelDigitalOceanDropletId` _Integer_<br>`CamelDigitalOceanDropletRegion` _String_| `com.myjeeva.digitalocean.pojo.Action`
+| `detach` | detach a Block Storage volume from a Droplet| `CamelDigitalOceanId` _Integer_ <br>`CamelDigitalOceanDropletId` _Integer_<br>`CamelDigitalOceanDropletRegion` _String_| `com.myjeeva.digitalocean.pojo.Action`
+| `attach` | detach a Block Storage volume from a Droplet by name| `CamelDigitalOceanName` _String_<br>`CamelDigitalOceanDropletId` _Integer_<br>`CamelDigitalOceanDropletRegion` _String_| `com.myjeeva.digitalocean.pojo.Action`
+| `resize` | resize a Block Storage volume | `CamelDigitalOceanVolumeSizeGigabytes` _Integer_<br>`CamelDigitalOceanRegion` _String_| `com.myjeeva.digitalocean.pojo.Action` |
+| `listActions` | retrieve all actions that have been executed on a volume | `CamelDigitalOceanId` _Integer_| `List<com.myjeeva.digitalocean.pojo.Action>` |
+
+## Droplets endpoint
+
+| operation | Description | Headers | Result |
+| ------ | ---- | ------- | ----------- |
+| `list` | list all Droplets in your account | | `List<com.myjeeva.digitalocean.pojo.Droplet>` |
+| `get` | show an individual droplet | `CamelDigitalOceanId` _Integer_| `com.myjeeva.digitalocean.pojo.Droplet` |
+| `create` | create a new Droplet | `CamelDigitalOceanName` _String_ <br>`CamelDigitalOceanDropletImage` _String_ <br>`CamelDigitalOceanRegion` _String_ <br>`CamelDigitalOceanDropletSize` _String_ <br>`CamelDigitalOceanDropletSSHKeys`* _List\<String\>_ <br>`CamelDigitalOceanDropletEnableBackups`* _Boolean_ <br>`CamelDigitalOceanDropletEnableIpv6`* _Boolean_ <br>`CamelDigitalOceanDropletEnablePrivateNetworking`* _Boolean_ <br>`CamelDigitalOceanDropletUserData`* _String_ <br>`CamelDigitalOceanDropletVolumes`* _List\<String\>_ <br>`CamelDigitalOceanDropletTags` _List\<String\>_| `com.myjeeva.digitalocean.pojo.Droplet` |
+| `create` | create multiple Droplets | `CamelDigitalOceanNames` _List\<String\>_ <br>`CamelDigitalOceanDropletImage` _String_ <br>`CamelDigitalOceanRegion` _String_ <br>`CamelDigitalOceanDropletSize` _String_ <br>`CamelDigitalOceanDropletSSHKeys`* _List\<String\>_ <br>`CamelDigitalOceanDropletEnableBackups`* _Boolean_ <br>`CamelDigitalOceanDropletEnableIpv6`* _Boolean_ <br>`CamelDigitalOceanDropletEnablePrivateNetworking`* _Boolean_ <br>`CamelDigitalOceanDropletUserData`* _String_ <br>`CamelDigitalOceanDropletVolumes`* _List\<String\>_ <br>`CamelDigitalOceanDropletTags` _List\<String\>_| `com.myjeeva.digitalocean.pojo.Droplet` |
+| `delete` | delete a Droplet, | `CamelDigitalOceanId` _Integer_| `com.myjeeva.digitalocean.pojo.Delete` |
+| `enableBackups` | enable backups on an existing Droplet | `CamelDigitalOceanId` _Integer_| `com.myjeeva.digitalocean.pojo.Action` |
+| `disableBackups` | disable backups on an existing Droplet | `CamelDigitalOceanId` _Integer_| `com.myjeeva.digitalocean.pojo.Action` |
+| `enableIpv6` | enable IPv6 networking on an existing Droplet | `CamelDigitalOceanId` _Integer_| `com.myjeeva.digitalocean.pojo.Action` |
+| `enablePrivateNetworking` | enable private networking on an existing Droplet | `CamelDigitalOceanId` _Integer_| `com.myjeeva.digitalocean.pojo.Action` |
+| `reboot` | reboot a Droplet | `CamelDigitalOceanId` _Integer_| `com.myjeeva.digitalocean.pojo.Action` |
+| `powerCycle` | power cycle a Droplet | `CamelDigitalOceanId` _Integer_| `com.myjeeva.digitalocean.pojo.Action` |
+| `shutdown` | shutdown a Droplet | `CamelDigitalOceanId` _Integer_| `com.myjeeva.digitalocean.pojo.Action` |
+| `powerOff` | power off a Droplet | `CamelDigitalOceanId` _Integer_| `com.myjeeva.digitalocean.pojo.Action` |
+| `powerOn` | power on a Droplet | `CamelDigitalOceanId` _Integer_| `com.myjeeva.digitalocean.pojo.Action` |
+| `restore` | shutdown a Droplet | `CamelDigitalOceanId` _Integer_ <br>`CamelDigitalOceanImageId` _Integer_| `com.myjeeva.digitalocean.pojo.Action` |
+| `passwordReset` | reset the password for a Droplet | `CamelDigitalOceanId` _Integer_| `com.myjeeva.digitalocean.pojo.Action` |
+| `resize` | resize a Droplet | `CamelDigitalOceanId` _Integer_ <br>`CamelDigitalOceanDropletSize` _String_| `com.myjeeva.digitalocean.pojo.Action` |
+| `rebuild` | rebuild a Droplet | `CamelDigitalOceanId` _Integer_ <br>`CamelDigitalOceanImageId` _Integer_| `com.myjeeva.digitalocean.pojo.Action` |
+| `rename` | rename a Droplet | `CamelDigitalOceanId` _Integer_ <br>`CamelDigitalOceanName` _String_| `com.myjeeva.digitalocean.pojo.Action` |
+| `changeKernel` | change the kernel of a Droplet | `CamelDigitalOceanId` _Integer_ <br>`CamelDigitalOceanKernelId` _Integer_| `com.myjeeva.digitalocean.pojo.Action` |
+| `takeSnapshot` | snapshot a Droplet | `CamelDigitalOceanId` _Integer_ <br>`CamelDigitalOceanName`* _String_| `com.myjeeva.digitalocean.pojo.Action` |
+| `tag` | tag a Droplet | `CamelDigitalOceanId` _Integer_ <br>`CamelDigitalOceanName` _String_| `com.myjeeva.digitalocean.pojo.Response` |
+| `untag` | untag a Droplet | `CamelDigitalOceanId` _Integer_ <br>`CamelDigitalOceanName` _String_| `com.myjeeva.digitalocean.pojo.Response` |
+| `listKernels` | retrieve a list of all kernels available to a Droplet | `CamelDigitalOceanId` _Integer_ | `List<com.myjeeva.digitalocean.pojo.Kernel>` |
+| `listSnapshots` | retrieve the snapshots that have been created from a Droplet | `CamelDigitalOceanId` _Integer_ | `List<com.myjeeva.digitalocean.pojo.Snapshot>` |
+| `listBackups` | retrieve any backups associated with a Droplet | `CamelDigitalOceanId` _Integer_ | `List<com.myjeeva.digitalocean.pojo.Backup>` |
+| `listActions` | retrieve all actions that have been executed on a Droplet | `CamelDigitalOceanId` _Integer_ | `List<com.myjeeva.digitalocean.pojo.Action>` |
+| `listNeighbors` | retrieve a list of droplets that are running on the same physical server | `CamelDigitalOceanId` _Integer_ | `List<com.myjeeva.digitalocean.pojo.Droplet>` |
+| `listAllNeighbors` | retrieve a list of any droplets that are running on the same physical hardware | | `List<com.myjeeva.digitalocean.pojo.Droplet>` |
+
+## Images endpoint
+
+| operation | Description | Headers | Result |
+| ------ | ---- | ------- | ----------- |
+| `list` | list images available on your account | `CamelDigitalOceanType`* _DigitalOceanImageTypes_ | `List<com.myjeeva.digitalocean.pojo.Image>` |
+| `ownList` | retrieve only the private images of a user | | `List<com.myjeeva.digitalocean.pojo.Image>` |
+| `listActions` | retrieve all actions that have been executed on a Image | `CamelDigitalOceanId` _Integer_ | `List<com.myjeeva.digitalocean.pojo.Action>` |
+| `get` | retrieve information about an image (public or private) by id| `CamelDigitalOceanId` _Integer_| `com.myjeeva.digitalocean.pojo.Image` |
+| `get` | retrieve information about an public image by slug| `CamelDigitalOceanDropletImage` _String_| `com.myjeeva.digitalocean.pojo.Image` |
+| `update` | update an image| `CamelDigitalOceanId` _Integer_ <br>`CamelDigitalOceanName` _String_| `com.myjeeva.digitalocean.pojo.Image` |
+| `delete` | delete an image| `CamelDigitalOceanId` _Integer_ | `com.myjeeva.digitalocean.pojo.Delete` |
+| `transfer` | transfer an image to another region| `CamelDigitalOceanId` _Integer_ <br>`CamelDigitalOceanRegion` _String_| `com.myjeeva.digitalocean.pojo.Action` |
+| `convert` | convert an image, for example, a backup to a snapshot| `CamelDigitalOceanId` _Integer_ | `com.myjeeva.digitalocean.pojo.Action` |
+
+## Snapshots endpoint
+
+| operation | Description | Headers | Result |
+| ------ | ---- | ------- | ----------- |
+| `list` | list all of the snapshots available on your account | `CamelDigitalOceanType`* _DigitalOceanSnapshotTypes_ | `List<com.myjeeva.digitalocean.pojo.Snapshot>` |
+| `get` | retrieve information about a snapshot| `CamelDigitalOceanId` _Integer_| `com.myjeeva.digitalocean.pojo.Snapshot` |
+| `delete` | delete an snapshot| `CamelDigitalOceanId` _Integer_ | `com.myjeeva.digitalocean.pojo.Delete` |
+
+
+## Keys endpoint
+
+| operation | Description | Headers | Result |
+| ------ | ---- | ------- | ----------- |
+| `list` | list all of the keys in your account | | `List<com.myjeeva.digitalocean.pojo.Key>` |
+| `get` | retrieve information about a key by id| `CamelDigitalOceanId` _Integer_| `com.myjeeva.digitalocean.pojo.Key` |
+| `get` | retrieve information about a key by fingerprint| `CamelDigitalOceanKeyFingerprint` _String_| `com.myjeeva.digitalocean.pojo.Key` |
+| `update` | update a key by id| `CamelDigitalOceanId` _Integer_ <br>`CamelDigitalOceanName` _String_| `com.myjeeva.digitalocean.pojo.Key` |
+| `update` | update a key by fingerprint| `CamelDigitalOceanKeyFingerprint` _String_ <br>`CamelDigitalOceanName` _String_| `com.myjeeva.digitalocean.pojo.Key` |
+| `delete` | delete a key by id| `CamelDigitalOceanId` _Integer_ | `com.myjeeva.digitalocean.pojo.Delete` |
+| `delete` | delete a key by fingerprint| `CamelDigitalOceanKeyFingerprint` _String_ | `com.myjeeva.digitalocean.pojo.Delete` |
+
+## Regions endpoint
+
+| operation | Description | Headers | Result |
+| ------ | ---- | ------- | ----------- |
+| `list` | list all of the regions that are available | | `List<com.myjeeva.digitalocean.pojo.Region>` |
+
+
+## Sizes endpoint
+
+| operation | Description | Headers | Result |
+| ------ | ---- | ------- | ----------- |
+| `list` | list all of the sizes that are available | | `List<com.myjeeva.digitalocean.pojo.Size>` |
+
+## Floating IPs endpoint
+
+| operation | Description | Headers | Result |
+| ------ | ---- | ------- | ----------- |
+| `list` | list all of the Floating IPs available on your account | | `List<com.myjeeva.digitalocean.pojo.FloatingIP>` |
+| `create` | create a new Floating IP assigned to a Droplet | `CamelDigitalOceanId` _Integer_ | `List<com.myjeeva.digitalocean.pojo.FloatingIP>` |
+| `create` | create a new Floating IP assigned to a Region | `CamelDigitalOceanRegion` _String_ | `List<com.myjeeva.digitalocean.pojo.FloatingIP>` |
+| `get` | retrieve information about a Floating IP| `CamelDigitalOceanFloatingIPAddress` _String_| `com.myjeeva.digitalocean.pojo.Key` |
+| `delete` | delete a Floating IP and remove it from your account| `CamelDigitalOceanFloatingIPAddress` _String_| `com.myjeeva.digitalocean.pojo.Delete` |
+| `assign` | assign a Floating IP to a Droplet| `CamelDigitalOceanFloatingIPAddress` _String_ <br>`CamelDigitalOceanDropletId` _Integer_| `com.myjeeva.digitalocean.pojo.Action` |
+| `unassign` | unassign a Floating IP | `CamelDigitalOceanFloatingIPAddress` _String_ | `com.myjeeva.digitalocean.pojo.Action` |
+| `listActions` | retrieve all actions that have been executed on a Floating IP | `CamelDigitalOceanFloatingIPAddress` _String_ | `List<com.myjeeva.digitalocean.pojo.Action>` |
+
+## Tags endpoint
+
+| operation | Description | Headers | Result |
+| ------ | ---- | ------- | ----------- |
+| `list` | list all of your tags | | `List<com.myjeeva.digitalocean.pojo.Tag>` |
+| `create` | create a Tag | `CamelDigitalOceanName` _String_ | `com.myjeeva.digitalocean.pojo.Tag` |
+| `get` | retrieve an individual tag | `CamelDigitalOceanName` _String_ | `com.myjeeva.digitalocean.pojo.Tag` |
+| `delete` | delete a tag | `CamelDigitalOceanName` _String_ | `com.myjeeva.digitalocean.pojo.Delete` |
+| `update` | update a tag | `CamelDigitalOceanName` _String_ <br>`CamelDigitalOceanNewName` _String_| `com.myjeeva.digitalocean.pojo.Tag` |
+
+
+## Examples
+
+Get your account info
+
+```
+from("direct:getAccountInfo")
+ .setHeader(DigitalOceanConstants.OPERATION, constant(DigitalOceanOperations.get))
+ .to("digitalocean:account?oAuthToken=XXXXXX")
+```
+
+Create a droplet
+
+```
+from("direct:createDroplet")
+ .setHeader(DigitalOceanConstants.OPERATION, constant("create"))
+ .setHeader(DigitalOceanHeaders.NAME, constant("myDroplet"))
+ .setHeader(DigitalOceanHeaders.REGION, constant("fra1"))
+ .setHeader(DigitalOceanHeaders.DROPLET_IMAGE, constant("ubuntu-14-04-x64"))
+ .setHeader(DigitalOceanHeaders.DROPLET_SIZE, constant("512mb"))
+ .to("digitalocean:droplet?oAuthToken=XXXXXX")
+```
+
+List all your droplets
+
+```
+from("direct:getDroplets")
+ .setHeader(DigitalOceanConstants.OPERATION, constant("list"))
+ .to("digitalocean:droplets?oAuthToken=XXXXXX")
+```
+
+Retrieve information for the Droplet (dropletId = 34772987)
+
+```
+from("direct:getDroplet")
+ .setHeader(DigitalOceanConstants.OPERATION, constant("get"))
+ .setHeader(DigitalOceanConstants.ID, 34772987)
+ .to("digitalocean:droplet?oAuthToken=XXXXXX")
+```
+
+Shutdown information for the Droplet (dropletId = 34772987)
+
+```
+from("direct:shutdown")
+ .setHeader(DigitalOceanConstants.ID, 34772987)
+ .to("digitalocean:droplet?operation=shutdown&oAuthToken=XXXXXX")
+```
[02/20] camel git commit: initial commit
Posted by ac...@apache.org.
initial commit
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/1d57f7b0
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/1d57f7b0
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/1d57f7b0
Branch: refs/heads/master
Commit: 1d57f7b0d355f0e0198277999b90e052d5977a93
Parents: 0029082
Author: Thomas Lehoux <tl...@gmail.com>
Authored: Fri Mar 24 11:15:54 2017 +0100
Committer: Andrea Cosentino <an...@gmail.com>
Committed: Mon Mar 27 09:48:33 2017 +0200
----------------------------------------------------------------------
components/camel-digitalocean/.gitignore | 4 +
components/camel-digitalocean/LICENSE | 201 +++++++++
components/camel-digitalocean/README.md | 254 ++++++++++++
components/camel-digitalocean/pom.xml | 162 ++++++++
.../com/viwilo/camel/DigitalOceanComponent.java | 59 +++
.../viwilo/camel/DigitalOceanConfiguration.java | 176 ++++++++
.../com/viwilo/camel/DigitalOceanEndpoint.java | 130 ++++++
.../com/viwilo/camel/DigitalOceanException.java | 30 ++
.../camel/constants/DigitalOceanHeaders.java | 54 +++
.../camel/constants/DigitalOceanImageTypes.java | 24 ++
.../camel/constants/DigitalOceanOperations.java | 57 +++
.../camel/constants/DigitalOceanResources.java | 36 ++
.../constants/DigitalOceanSnapshotTypes.java | 24 ++
.../producer/DigitalOceanAccountProducer.java | 39 ++
.../producer/DigitalOceanActionsProducer.java | 66 +++
.../DigitalOceanBlockStoragesProducer.java | 252 ++++++++++++
.../producer/DigitalOceanDropletsProducer.java | 405 +++++++++++++++++++
.../DigitalOceanFloatingIPsProducer.java | 151 +++++++
.../producer/DigitalOceanImagesProducer.java | 175 ++++++++
.../producer/DigitalOceanKeysProducer.java | 144 +++++++
.../camel/producer/DigitalOceanProducer.java | 53 +++
.../producer/DigitalOceanRegionsProducer.java | 39 ++
.../producer/DigitalOceanSizesProducer.java | 39 ++
.../producer/DigitalOceanSnapshotsProducer.java | 101 +++++
.../producer/DigitalOceanTagsProducer.java | 114 ++++++
.../org/apache/camel/component/digitalocean | 18 +
.../src/main/resources/log4j2.properties | 23 ++
.../viwilo/camel/DigitalOceanClientMock.java | 26 ++
.../viwilo/camel/DigitalOceanComponentTest.java | 54 +++
.../DigitalOceanComponentIntegrationTest.java | 323 +++++++++++++++
.../integration/DigitalOceanTestSupport.java | 42 ++
.../src/test/resources/log4j2.properties | 23 ++
.../src/test/resources/test-options.properties | 18 +
33 files changed, 3316 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/1d57f7b0/components/camel-digitalocean/.gitignore
----------------------------------------------------------------------
diff --git a/components/camel-digitalocean/.gitignore b/components/camel-digitalocean/.gitignore
new file mode 100644
index 0000000..f1f87fc
--- /dev/null
+++ b/components/camel-digitalocean/.gitignore
@@ -0,0 +1,4 @@
+*.iml
+.idea/
+overlays/
+target/
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/camel/blob/1d57f7b0/components/camel-digitalocean/LICENSE
----------------------------------------------------------------------
diff --git a/components/camel-digitalocean/LICENSE b/components/camel-digitalocean/LICENSE
new file mode 100644
index 0000000..7d4b2e0
--- /dev/null
+++ b/components/camel-digitalocean/LICENSE
@@ -0,0 +1,201 @@
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or resource authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting resource and all
+ other entities that control, are controlled by, or are under common
+ control with that resource. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such resource, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such resource.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any resource (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "{}"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright {yyyy} {name of copyright owner}
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
http://git-wip-us.apache.org/repos/asf/camel/blob/1d57f7b0/components/camel-digitalocean/README.md
----------------------------------------------------------------------
diff --git a/components/camel-digitalocean/README.md b/components/camel-digitalocean/README.md
new file mode 100644
index 0000000..87771f7
--- /dev/null
+++ b/components/camel-digitalocean/README.md
@@ -0,0 +1,254 @@
+# Camel DigitalOcean Component
+
+The **DigitalOcean** component allows you to manage Droplets and resources within the DigitalOcean cloud with **Camel** by encapsulating [digitalocean-api-java](https://www.digitalocean.com/community/projects/api-client-in-java). All of the functionality that you are familiar with in the DigitalOcean control panel is also available through this Camel component.
+
+
+## Prerequisites
+
+You must have a valid DigitalOcean account and a valid OAuth token. You can generate an OAuth token by visiting the [Apps & API](https://cloud.digitalocean.com/settings/applications) section of the DigitalOcean control panel for your account.
+
+## URI format
+
+The **DigitalOcean Component** uses the following URI format:
+
+```
+digitalocean://endpoint?[options]
+```
+where `endpoint` is a DigitalOcean resource type.
+
+Example : to list your droplets:
+
+```
+digitalocean://droplets?operation=list&oAuthToken=XXXXXX&page=1&perPage=10
+```
+
+The DigitalOcean component only supports producer endpoints so you cannot use this component at the beginning of a route to listen to messages in a channel.
+
+## URI Endpoints
+
+There is one endpoint for each DigitalOcean resources (defined in `DigitalOceanResources` enumeration):
+
+| Endpoint | Description |
+| ------ | ----------- |
+| `account` | Your account on DigitalOcean. |
+| `actions` | Actions are records of events that have occurred on the resources in your account. |
+| `blockStorages` | Block Storage volumes provide expanded storage capacity for your Droplets and can be moved between Droplets within a specific region. |
+| `droplets` | A Droplet is a DigitalOcean virtual machine. |
+| `images` | An image may refer to a snapshot that has been taken of a Droplet instance. It may also mean an image representing an automatic backup of a Droplet. |
+| `snapshots` | Snapshots are saved instances of a Droplet or a volume. |
+| `keys` | DigitalOcean allows you to add SSH public keys to the interface so that you can embed your public key into a Droplet at the time of creation. |
+| `regions` | A region in DigitalOcean represents a datacenter where Droplets can be deployed and images can be transferred. |
+| `sizes` | The sizes objects represent different packages of hardware resources that can be used for Droplets. |
+| `floatingIPs` | Floating IP objects represent a publicly-accessible static IP addresses that can be mapped to one of your Droplets. |
+| `tags` | A Tag is a label that can be applied to a resource (currently only Droplets) in order to better organize or facilitate the lookups and actions on it. |
+
+
+## URI Options
+
+You have to provide the `digitalOceanClient` in the Registry or your `oAuthToken` to access the DigitalOcean service.
+
+| Option | Type | Example | Description |
+| ------ | ---- | ------- | ----------- |
+| `operation` | String | `operation=list` | The operation to perform to the resource. It can also be set with the `CamelDigitalOceanOperation` Message header. |
+| `oAuthToken` | String | | Your DigitalOcean oAuth token. |
+| `digitalOceanClient` | `com.myjeeva.digitalocean.DigitalOcean` | Reference to a `com.myjeeva.digitalocean.DigitalOcean` in the Registry. |
+| `page` | Integer | `page=3` | Can be used for `list` operations, for pagination. Force the page number.|
+| `perPage` | Integer | `perPage=50` | Can be used for `list` operations, for pagiantion. Set the number of item per request. |
+
+
+You have to provide an **operation** value for each endpoint, with the `operation` URI option or the `CamelDigitalOceanOperation` message header.
+
+All **operation** values are defined in `DigitalOceanOperations` enumeration.
+
+All **header** names used by the component are defined in `DigitalOceanHeaders` enumeration.
+
+
+## Message body result
+All message bodies returned are using objects provided by the **digitalocean-api-java** library.
+
+
+## API Rate Limits
+
+
+DigitalOcean REST API encapsulated by camel-digitalocean component is subjected to API Rate Limiting. You can find the per method limits in the [API Rate Limits documentation](https://developers.digitalocean.com/documentation/v2/#rate-limit).
+
+
+## Account endpoint
+
+| operation | Description | Headers | Result |
+| ------ | ---- | ------- | ----------- |
+| `get` | get account info | | `com.myjeeva.digitalocean.pojo.Account` |
+
+
+
+## BlockStorages endpoint
+
+| operation | Description | Headers | Result |
+| ------ | ---- | ------- | ----------- |
+| `list` | list all of the Block Storage volumes available on your account | | `List<com.myjeeva.digitalocean.pojo.Volume>` |
+| `get` | show information about a Block Storage volume| `CamelDigitalOceanId` _Integer_| `com.myjeeva.digitalocean.pojo.Volume` |
+| `get` | show information about a Block Storage volume by name| `CamelDigitalOceanName` _String_ <br>`CamelDigitalOceanRegion` _String_| `com.myjeeva.digitalocean.pojo.Volume` |
+| `listSnapshots` | retrieve the snapshots that have been created from a volume | `CamelDigitalOceanId` _Integer_| `List<com.myjeeva.digitalocean.pojo.Snapshot>` |
+| `create` | create a new volume | `CamelDigitalOceanVolumeSizeGigabytes` _Integer_<br>`CamelDigitalOceanName` _String_<br>`CamelDigitalOceanDescription`* _String_<br>`CamelDigitalOceanRegion`* _String_| `com.myjeeva.digitalocean.pojo.Volume` |
+| `delete` | delete a Block Storage volume, destroying all data and removing it from your account| `CamelDigitalOceanId` _Integer_| `com.myjeeva.digitalocean.pojo.Delete`|
+| `delete` | delete a Block Storage volume by name| `CamelDigitalOceanName` _String_<br>`CamelDigitalOceanRegion` _String_| `com.myjeeva.digitalocean.pojo.Delete`
+| `attach` | attach a Block Storage volume to a Droplet| `CamelDigitalOceanId` _Integer_ <br>`CamelDigitalOceanDropletId` _Integer_<br>`CamelDigitalOceanDropletRegion` _String_| `com.myjeeva.digitalocean.pojo.Action`
+| `attach` | attach a Block Storage volume to a Droplet by name| `CamelDigitalOceanName` _String_<br>`CamelDigitalOceanDropletId` _Integer_<br>`CamelDigitalOceanDropletRegion` _String_| `com.myjeeva.digitalocean.pojo.Action`
+| `detach` | detach a Block Storage volume from a Droplet| `CamelDigitalOceanId` _Integer_ <br>`CamelDigitalOceanDropletId` _Integer_<br>`CamelDigitalOceanDropletRegion` _String_| `com.myjeeva.digitalocean.pojo.Action`
+| `attach` | detach a Block Storage volume from a Droplet by name| `CamelDigitalOceanName` _String_<br>`CamelDigitalOceanDropletId` _Integer_<br>`CamelDigitalOceanDropletRegion` _String_| `com.myjeeva.digitalocean.pojo.Action`
+| `resize` | resize a Block Storage volume | `CamelDigitalOceanVolumeSizeGigabytes` _Integer_<br>`CamelDigitalOceanRegion` _String_| `com.myjeeva.digitalocean.pojo.Action` |
+| `listActions` | retrieve all actions that have been executed on a volume | `CamelDigitalOceanId` _Integer_| `List<com.myjeeva.digitalocean.pojo.Action>` |
+
+## Droplets endpoint
+
+| operation | Description | Headers | Result |
+| ------ | ---- | ------- | ----------- |
+| `list` | list all Droplets in your account | | `List<com.myjeeva.digitalocean.pojo.Droplet>` |
+| `get` | show an individual droplet | `CamelDigitalOceanId` _Integer_| `com.myjeeva.digitalocean.pojo.Droplet` |
+| `create` | create a new Droplet | `CamelDigitalOceanName` _String_ <br>`CamelDigitalOceanDropletImage` _String_ <br>`CamelDigitalOceanRegion` _String_ <br>`CamelDigitalOceanDropletSize` _String_ <br>`CamelDigitalOceanDropletSSHKeys`* _List\<String\>_ <br>`CamelDigitalOceanDropletEnableBackups`* _Boolean_ <br>`CamelDigitalOceanDropletEnableIpv6`* _Boolean_ <br>`CamelDigitalOceanDropletEnablePrivateNetworking`* _Boolean_ <br>`CamelDigitalOceanDropletUserData`* _String_ <br>`CamelDigitalOceanDropletVolumes`* _List\<String\>_ <br>`CamelDigitalOceanDropletTags` _List\<String\>_| `com.myjeeva.digitalocean.pojo.Droplet` |
+| `create` | create multiple Droplets | `CamelDigitalOceanNames` _List\<String\>_ <br>`CamelDigitalOceanDropletImage` _String_ <br>`CamelDigitalOceanRegion` _String_ <br>`CamelDigitalOceanDropletSize` _String_ <br>`CamelDigitalOceanDropletSSHKeys`* _List\<String\>_ <br>`CamelDigitalOceanDropletEnableBackups`* _Boolean_ <br>`CamelDigitalOceanDropletEnableIpv6`* _Boolean_ <br>`CamelDigitalOceanDropletEnablePrivateNetworking`* _Boolean_ <br>`CamelDigitalOceanDropletUserData`* _String_ <br>`CamelDigitalOceanDropletVolumes`* _List\<String\>_ <br>`CamelDigitalOceanDropletTags` _List\<String\>_| `com.myjeeva.digitalocean.pojo.Droplet` |
+| `delete` | delete a Droplet, | `CamelDigitalOceanId` _Integer_| `com.myjeeva.digitalocean.pojo.Delete` |
+| `enableBackups` | enable backups on an existing Droplet | `CamelDigitalOceanId` _Integer_| `com.myjeeva.digitalocean.pojo.Action` |
+| `disableBackups` | disable backups on an existing Droplet | `CamelDigitalOceanId` _Integer_| `com.myjeeva.digitalocean.pojo.Action` |
+| `enableIpv6` | enable IPv6 networking on an existing Droplet | `CamelDigitalOceanId` _Integer_| `com.myjeeva.digitalocean.pojo.Action` |
+| `enablePrivateNetworking` | enable private networking on an existing Droplet | `CamelDigitalOceanId` _Integer_| `com.myjeeva.digitalocean.pojo.Action` |
+| `reboot` | reboot a Droplet | `CamelDigitalOceanId` _Integer_| `com.myjeeva.digitalocean.pojo.Action` |
+| `powerCycle` | power cycle a Droplet | `CamelDigitalOceanId` _Integer_| `com.myjeeva.digitalocean.pojo.Action` |
+| `shutdown` | shutdown a Droplet | `CamelDigitalOceanId` _Integer_| `com.myjeeva.digitalocean.pojo.Action` |
+| `powerOff` | power off a Droplet | `CamelDigitalOceanId` _Integer_| `com.myjeeva.digitalocean.pojo.Action` |
+| `powerOn` | power on a Droplet | `CamelDigitalOceanId` _Integer_| `com.myjeeva.digitalocean.pojo.Action` |
+| `restore` | shutdown a Droplet | `CamelDigitalOceanId` _Integer_ <br>`CamelDigitalOceanImageId` _Integer_| `com.myjeeva.digitalocean.pojo.Action` |
+| `passwordReset` | reset the password for a Droplet | `CamelDigitalOceanId` _Integer_| `com.myjeeva.digitalocean.pojo.Action` |
+| `resize` | resize a Droplet | `CamelDigitalOceanId` _Integer_ <br>`CamelDigitalOceanDropletSize` _String_| `com.myjeeva.digitalocean.pojo.Action` |
+| `rebuild` | rebuild a Droplet | `CamelDigitalOceanId` _Integer_ <br>`CamelDigitalOceanImageId` _Integer_| `com.myjeeva.digitalocean.pojo.Action` |
+| `rename` | rename a Droplet | `CamelDigitalOceanId` _Integer_ <br>`CamelDigitalOceanName` _String_| `com.myjeeva.digitalocean.pojo.Action` |
+| `changeKernel` | change the kernel of a Droplet | `CamelDigitalOceanId` _Integer_ <br>`CamelDigitalOceanKernelId` _Integer_| `com.myjeeva.digitalocean.pojo.Action` |
+| `takeSnapshot` | snapshot a Droplet | `CamelDigitalOceanId` _Integer_ <br>`CamelDigitalOceanName`* _String_| `com.myjeeva.digitalocean.pojo.Action` |
+| `tag` | tag a Droplet | `CamelDigitalOceanId` _Integer_ <br>`CamelDigitalOceanName` _String_| `com.myjeeva.digitalocean.pojo.Response` |
+| `untag` | untag a Droplet | `CamelDigitalOceanId` _Integer_ <br>`CamelDigitalOceanName` _String_| `com.myjeeva.digitalocean.pojo.Response` |
+| `listKernels` | retrieve a list of all kernels available to a Droplet | `CamelDigitalOceanId` _Integer_ | `List<com.myjeeva.digitalocean.pojo.Kernel>` |
+| `listSnapshots` | retrieve the snapshots that have been created from a Droplet | `CamelDigitalOceanId` _Integer_ | `List<com.myjeeva.digitalocean.pojo.Snapshot>` |
+| `listBackups` | retrieve any backups associated with a Droplet | `CamelDigitalOceanId` _Integer_ | `List<com.myjeeva.digitalocean.pojo.Backup>` |
+| `listActions` | retrieve all actions that have been executed on a Droplet | `CamelDigitalOceanId` _Integer_ | `List<com.myjeeva.digitalocean.pojo.Action>` |
+| `listNeighbors` | retrieve a list of droplets that are running on the same physical server | `CamelDigitalOceanId` _Integer_ | `List<com.myjeeva.digitalocean.pojo.Droplet>` |
+| `listAllNeighbors` | retrieve a list of any droplets that are running on the same physical hardware | | `List<com.myjeeva.digitalocean.pojo.Droplet>` |
+
+## Images endpoint
+
+| operation | Description | Headers | Result |
+| ------ | ---- | ------- | ----------- |
+| `list` | list images available on your account | `CamelDigitalOceanType`* _DigitalOceanImageTypes_ | `List<com.myjeeva.digitalocean.pojo.Image>` |
+| `ownList` | retrieve only the private images of a user | | `List<com.myjeeva.digitalocean.pojo.Image>` |
+| `listActions` | retrieve all actions that have been executed on a Image | `CamelDigitalOceanId` _Integer_ | `List<com.myjeeva.digitalocean.pojo.Action>` |
+| `get` | retrieve information about an image (public or private) by id| `CamelDigitalOceanId` _Integer_| `com.myjeeva.digitalocean.pojo.Image` |
+| `get` | retrieve information about an public image by slug| `CamelDigitalOceanDropletImage` _String_| `com.myjeeva.digitalocean.pojo.Image` |
+| `update` | update an image| `CamelDigitalOceanId` _Integer_ <br>`CamelDigitalOceanName` _String_| `com.myjeeva.digitalocean.pojo.Image` |
+| `delete` | delete an image| `CamelDigitalOceanId` _Integer_ | `com.myjeeva.digitalocean.pojo.Delete` |
+| `transfer` | transfer an image to another region| `CamelDigitalOceanId` _Integer_ <br>`CamelDigitalOceanRegion` _String_| `com.myjeeva.digitalocean.pojo.Action` |
+| `convert` | convert an image, for example, a backup to a snapshot| `CamelDigitalOceanId` _Integer_ | `com.myjeeva.digitalocean.pojo.Action` |
+
+## Snapshots endpoint
+
+| operation | Description | Headers | Result |
+| ------ | ---- | ------- | ----------- |
+| `list` | list all of the snapshots available on your account | `CamelDigitalOceanType`* _DigitalOceanSnapshotTypes_ | `List<com.myjeeva.digitalocean.pojo.Snapshot>` |
+| `get` | retrieve information about a snapshot| `CamelDigitalOceanId` _Integer_| `com.myjeeva.digitalocean.pojo.Snapshot` |
+| `delete` | delete an snapshot| `CamelDigitalOceanId` _Integer_ | `com.myjeeva.digitalocean.pojo.Delete` |
+
+
+## Keys endpoint
+
+| operation | Description | Headers | Result |
+| ------ | ---- | ------- | ----------- |
+| `list` | list all of the keys in your account | | `List<com.myjeeva.digitalocean.pojo.Key>` |
+| `get` | retrieve information about a key by id| `CamelDigitalOceanId` _Integer_| `com.myjeeva.digitalocean.pojo.Key` |
+| `get` | retrieve information about a key by fingerprint| `CamelDigitalOceanKeyFingerprint` _String_| `com.myjeeva.digitalocean.pojo.Key` |
+| `update` | update a key by id| `CamelDigitalOceanId` _Integer_ <br>`CamelDigitalOceanName` _String_| `com.myjeeva.digitalocean.pojo.Key` |
+| `update` | update a key by fingerprint| `CamelDigitalOceanKeyFingerprint` _String_ <br>`CamelDigitalOceanName` _String_| `com.myjeeva.digitalocean.pojo.Key` |
+| `delete` | delete a key by id| `CamelDigitalOceanId` _Integer_ | `com.myjeeva.digitalocean.pojo.Delete` |
+| `delete` | delete a key by fingerprint| `CamelDigitalOceanKeyFingerprint` _String_ | `com.myjeeva.digitalocean.pojo.Delete` |
+
+## Regions endpoint
+
+| operation | Description | Headers | Result |
+| ------ | ---- | ------- | ----------- |
+| `list` | list all of the regions that are available | | `List<com.myjeeva.digitalocean.pojo.Region>` |
+
+
+## Sizes endpoint
+
+| operation | Description | Headers | Result |
+| ------ | ---- | ------- | ----------- |
+| `list` | list all of the sizes that are available | | `List<com.myjeeva.digitalocean.pojo.Size>` |
+
+## Floating IPs endpoint
+
+| operation | Description | Headers | Result |
+| ------ | ---- | ------- | ----------- |
+| `list` | list all of the Floating IPs available on your account | | `List<com.myjeeva.digitalocean.pojo.FloatingIP>` |
+| `create` | create a new Floating IP assigned to a Droplet | `CamelDigitalOceanId` _Integer_ | `List<com.myjeeva.digitalocean.pojo.FloatingIP>` |
+| `create` | create a new Floating IP assigned to a Region | `CamelDigitalOceanRegion` _String_ | `List<com.myjeeva.digitalocean.pojo.FloatingIP>` |
+| `get` | retrieve information about a Floating IP| `CamelDigitalOceanFloatingIPAddress` _String_| `com.myjeeva.digitalocean.pojo.Key` |
+| `delete` | delete a Floating IP and remove it from your account| `CamelDigitalOceanFloatingIPAddress` _String_| `com.myjeeva.digitalocean.pojo.Delete` |
+| `assign` | assign a Floating IP to a Droplet| `CamelDigitalOceanFloatingIPAddress` _String_ <br>`CamelDigitalOceanDropletId` _Integer_| `com.myjeeva.digitalocean.pojo.Action` |
+| `unassign` | unassign a Floating IP | `CamelDigitalOceanFloatingIPAddress` _String_ | `com.myjeeva.digitalocean.pojo.Action` |
+| `listActions` | retrieve all actions that have been executed on a Floating IP | `CamelDigitalOceanFloatingIPAddress` _String_ | `List<com.myjeeva.digitalocean.pojo.Action>` |
+
+## Tags endpoint
+
+| operation | Description | Headers | Result |
+| ------ | ---- | ------- | ----------- |
+| `list` | list all of your tags | | `List<com.myjeeva.digitalocean.pojo.Tag>` |
+| `create` | create a Tag | `CamelDigitalOceanName` _String_ | `com.myjeeva.digitalocean.pojo.Tag` |
+| `get` | retrieve an individual tag | `CamelDigitalOceanName` _String_ | `com.myjeeva.digitalocean.pojo.Tag` |
+| `delete` | delete a tag | `CamelDigitalOceanName` _String_ | `com.myjeeva.digitalocean.pojo.Delete` |
+| `update` | update a tag | `CamelDigitalOceanName` _String_ <br>`CamelDigitalOceanNewName` _String_| `com.myjeeva.digitalocean.pojo.Tag` |
+
+
+## Examples
+
+Get your account info
+
+```
+from("direct:getAccountInfo")
+ .setHeader(DigitalOceanConstants.OPERATION, constant(DigitalOceanOperations.get))
+ .to("digitalocean:account?oAuthToken=XXXXXX")
+```
+
+Create a droplet
+
+```
+from("direct:createDroplet")
+ .setHeader(DigitalOceanConstants.OPERATION, constant("create"))
+ .setHeader(DigitalOceanHeaders.NAME, constant("myDroplet"))
+ .setHeader(DigitalOceanHeaders.REGION, constant("fra1"))
+ .setHeader(DigitalOceanHeaders.DROPLET_IMAGE, constant("ubuntu-14-04-x64"))
+ .setHeader(DigitalOceanHeaders.DROPLET_SIZE, constant("512mb"))
+ .to("digitalocean:droplet?oAuthToken=XXXXXX")
+```
+
+List all your droplets
+
+```
+from("direct:getDroplets")
+ .setHeader(DigitalOceanConstants.OPERATION, constant("list"))
+ .to("digitalocean:droplets?oAuthToken=XXXXXX")
+```
+
+Retrieve information for the Droplet (dropletId = 34772987)
+
+```
+from("direct:getDroplet")
+ .setHeader(DigitalOceanConstants.OPERATION, constant("get"))
+ .setHeader(DigitalOceanConstants.ID, 34772987)
+ .to("digitalocean:droplet?oAuthToken=XXXXXX")
+```
+
+Shutdown information for the Droplet (dropletId = 34772987)
+
+```
+from("direct:shutdown")
+ .setHeader(DigitalOceanConstants.ID, 34772987)
+ .to("digitalocean:droplet?operation=shutdown&oAuthToken=XXXXXX")
+```
+
http://git-wip-us.apache.org/repos/asf/camel/blob/1d57f7b0/components/camel-digitalocean/pom.xml
----------------------------------------------------------------------
diff --git a/components/camel-digitalocean/pom.xml b/components/camel-digitalocean/pom.xml
new file mode 100644
index 0000000..02e01f3
--- /dev/null
+++ b/components/camel-digitalocean/pom.xml
@@ -0,0 +1,162 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements. See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License. You may obtain a copy of the License at
+http://www.apache.org/licenses/LICENSE-2.0
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>com.viwilo.camel</groupId>
+ <artifactId>camel-digitalocean</artifactId>
+ <packaging>jar</packaging>
+ <version>1.0-SNAPSHOT</version>
+
+ <name>Camel DigitalOcean Component</name>
+ <description>A Camel DigitalOcean Services Components</description>
+
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
+ </properties>
+
+ <dependencyManagement>
+ <dependencies>
+ <!-- Camel BOM -->
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-parent</artifactId>
+ <version>2.18.3</version>
+ <scope>import</scope>
+ <type>pom</type>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-core</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>apt</artifactId>
+ <version>2.18.3</version>
+ <scope>provided</scope>
+ </dependency>
+
+
+ <!-- DigitalOcean API java library -->
+ <dependency>
+ <groupId>com.myjeeva.digitalocean</groupId>
+ <artifactId>digitalocean-api-client</artifactId>
+ <version>2.8</version>
+ </dependency>
+
+ <!-- logging -->
+ <dependency>
+ <groupId>org.apache.logging.log4j</groupId>
+ <artifactId>log4j-api</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.logging.log4j</groupId>
+ <artifactId>log4j-core</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.logging.log4j</groupId>
+ <artifactId>log4j-slf4j-impl</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+
+
+ <!-- testing -->
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-test</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-all</artifactId>
+ <version>1.9.5</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <defaultGoal>install</defaultGoal>
+
+ <plugins>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.5.1</version>
+ <configuration>
+ <source>1.8</source>
+ <target>1.8</target>
+ </configuration>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-resources-plugin</artifactId>
+ <version>3.0.1</version>
+ <configuration>
+ <encoding>UTF-8</encoding>
+ </configuration>
+ </plugin>
+
+ <!-- generate components meta-data and validate component includes documentation etc -->
+ <plugin>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-package-maven-plugin</artifactId>
+ <version>2.18.3</version>
+ <executions>
+ <execution>
+ <id>prepare</id>
+ <goals>
+ <goal>prepare-components</goal>
+ </goals>
+ <phase>generate-resources</phase>
+ </execution>
+ <execution>
+ <id>validate</id>
+ <goals>
+ <goal>validate-components</goal>
+ </goals>
+ <phase>prepare-package</phase>
+ </execution>
+ </executions>
+ </plugin>
+ <!-- to generate the MANIFEST-FILE of the bundle -->
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <version>3.2.0</version>
+ <extensions>true</extensions>
+ <configuration>
+ <instructions>
+ <Bundle-SymbolicName>com.viwilo.camel.camel-digitalocean</Bundle-SymbolicName>
+ <Export-Service>org.apache.camel.spi.ComponentResolver;component=digitalocean</Export-Service>
+ </instructions>
+ </configuration>
+ </plugin>
+
+ </plugins>
+ </build>
+
+</project>
http://git-wip-us.apache.org/repos/asf/camel/blob/1d57f7b0/components/camel-digitalocean/src/main/java/com/viwilo/camel/DigitalOceanComponent.java
----------------------------------------------------------------------
diff --git a/components/camel-digitalocean/src/main/java/com/viwilo/camel/DigitalOceanComponent.java b/components/camel-digitalocean/src/main/java/com/viwilo/camel/DigitalOceanComponent.java
new file mode 100644
index 0000000..b341a9b
--- /dev/null
+++ b/components/camel-digitalocean/src/main/java/com/viwilo/camel/DigitalOceanComponent.java
@@ -0,0 +1,59 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.viwilo.camel;
+
+import java.util.Map;
+
+import com.viwilo.camel.constants.DigitalOceanResources;
+import org.apache.camel.CamelContext;
+import org.apache.camel.Endpoint;
+
+import org.apache.camel.impl.UriEndpointComponent;
+import org.apache.camel.util.ObjectHelper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Represents the component that manages {@link DigitalOceanEndpoint}.
+ */
+public class DigitalOceanComponent extends UriEndpointComponent {
+
+ private static final transient Logger LOG = LoggerFactory.getLogger(DigitalOceanComponent.class);
+
+
+ public DigitalOceanComponent() {
+ super(DigitalOceanEndpoint.class);
+ }
+
+ public DigitalOceanComponent(CamelContext context) {
+ super(context, DigitalOceanEndpoint.class);
+ }
+
+ protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception {
+
+ DigitalOceanConfiguration configuration = new DigitalOceanConfiguration();
+ setProperties(configuration, parameters);
+ configuration.setResource(DigitalOceanResources.valueOf(remaining));
+
+ if (ObjectHelper.isEmpty(configuration.getOAuthToken()) && ObjectHelper.isEmpty(configuration.getDigitalOceanClient()))
+ throw new DigitalOceanException("oAuthToken or digitalOceanClient must be specified");
+
+ Endpoint endpoint = new DigitalOceanEndpoint(uri, this, configuration);
+ return endpoint;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/1d57f7b0/components/camel-digitalocean/src/main/java/com/viwilo/camel/DigitalOceanConfiguration.java
----------------------------------------------------------------------
diff --git a/components/camel-digitalocean/src/main/java/com/viwilo/camel/DigitalOceanConfiguration.java b/components/camel-digitalocean/src/main/java/com/viwilo/camel/DigitalOceanConfiguration.java
new file mode 100644
index 0000000..7218de1
--- /dev/null
+++ b/components/camel-digitalocean/src/main/java/com/viwilo/camel/DigitalOceanConfiguration.java
@@ -0,0 +1,176 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.viwilo.camel;
+
+import com.myjeeva.digitalocean.impl.DigitalOceanClient;
+import com.viwilo.camel.constants.DigitalOceanResources;
+import com.viwilo.camel.constants.DigitalOceanOperations;
+import org.apache.camel.spi.Metadata;
+import org.apache.camel.spi.UriParam;
+import org.apache.camel.spi.UriParams;
+import org.apache.camel.spi.UriPath;
+
+/**
+ * Created by thomas on 16/03/2017.
+ */
+@UriParams
+public class DigitalOceanConfiguration {
+
+
+ @UriParam(enums = "account,actions,blockStorages,droplets,mages,snapshots,keys,regions,sizes,floatingIPs,tags")
+ @Metadata(required = "true")
+ private DigitalOceanResources resource;
+
+ @UriPath(enums = "create,update,delete,list,ownList,get,listBackups,listActions,listNeighbors,listSnapshots,listKernels,listAllNeighbors," +
+ "enableBackups,disableBackups,reboot,powerCycle,shutdown,powerOn,powerOff,restore,resetPassword," +
+ "resize,rebuild,rename,changeKernel,enableIpv6,enablePrivateNetworking,takeSnapshot,transfer,convert," +
+ "attach,detach,assign,unassign,tag,untag")
+ private DigitalOceanOperations operation;
+
+ @UriParam
+ private DigitalOceanClient digitalOceanClient;
+
+ @UriParam(label = "security", secret = true)
+ private String oAuthToken;
+
+ @UriParam(defaultValue = "1")
+ private Integer page = 1;
+
+ @UriParam(defaultValue = "25")
+ private Integer perPage = 25;
+
+
+ @UriParam(label = "proxy")
+ private String httpProxyHost;
+ @UriParam(label = "proxy")
+ private String httpProxyUser;
+ @UriParam(label = "proxy")
+ private String httpProxyPassword;
+ @UriParam(label = "proxy")
+ private Integer httpProxyPort;
+
+ public DigitalOceanResources getResource() {
+ return resource;
+ }
+
+ /**
+ * The DigitalOcean resource type on which perform the operation.
+ */
+ public void setResource(DigitalOceanResources resource) {
+ this.resource = resource;
+ }
+
+ /**
+ * The operation to perform to the given resource.
+ */
+ public DigitalOceanOperations getOperation() {
+ return operation;
+ }
+
+ public void setOperation(DigitalOceanOperations operation) {
+ this.operation = operation;
+ }
+
+ public String getOAuthToken() {
+ return oAuthToken;
+ }
+
+ /**
+ * DigitalOcean OAuth Token
+ */
+ public void setOAuthToken(String oAuthToken) {
+ this.oAuthToken = oAuthToken;
+ }
+
+ /**
+ * Use for pagination. Set the number of item per request. The maximum number of results per page is 200.
+ */
+ public Integer getPerPage() {
+ return perPage;
+ }
+
+ public void setPerPage(Integer perPage) {
+ this.perPage = perPage;
+ }
+
+ /**
+ * Use for paginsation. Force the page number.
+ */
+ public Integer getPage() {
+ return page;
+ }
+
+ public void setPage(Integer page) {
+ this.page = page;
+ }
+
+ /**
+ * Set a proxy host if needed
+ */
+ public String getHttpProxyHost() {
+ return httpProxyHost;
+ }
+
+ public void setHttpProxyHost(String httpProxyHost) {
+ this.httpProxyHost = httpProxyHost;
+ }
+
+ /**
+ * Set a proxy user if needed
+ */
+ public String getHttpProxyUser() {
+ return httpProxyUser;
+ }
+
+ public void setHttpProxyUser(String httpProxyUser) {
+ this.httpProxyUser = httpProxyUser;
+ }
+
+ /**
+ * Set a proxy password if needed
+ */
+ public String getHttpProxyPassword() {
+ return httpProxyPassword;
+ }
+
+ public void setHttpProxyPassword(String httpProxyPassword) {
+ this.httpProxyPassword = httpProxyPassword;
+ }
+
+ /**
+ * Set a proxy port if needed
+ */
+ public Integer getHttpProxyPort() {
+ return httpProxyPort;
+ }
+
+ public void setHttpProxyPort(Integer httpProxyPort) {
+ this.httpProxyPort = httpProxyPort;
+ }
+
+
+ /**
+ * To use a existing configured DigitalOceanClient as client
+ */
+ public DigitalOceanClient getDigitalOceanClient() {
+ return digitalOceanClient;
+ }
+
+ public void setDigitalOceanClient(DigitalOceanClient digitalOceanClient) {
+ this.digitalOceanClient = digitalOceanClient;
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/1d57f7b0/components/camel-digitalocean/src/main/java/com/viwilo/camel/DigitalOceanEndpoint.java
----------------------------------------------------------------------
diff --git a/components/camel-digitalocean/src/main/java/com/viwilo/camel/DigitalOceanEndpoint.java b/components/camel-digitalocean/src/main/java/com/viwilo/camel/DigitalOceanEndpoint.java
new file mode 100644
index 0000000..8b0e998
--- /dev/null
+++ b/components/camel-digitalocean/src/main/java/com/viwilo/camel/DigitalOceanEndpoint.java
@@ -0,0 +1,130 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.viwilo.camel;
+
+import com.myjeeva.digitalocean.impl.DigitalOceanClient;
+import com.viwilo.camel.producer.*;
+import org.apache.camel.Consumer;
+import org.apache.camel.Processor;
+import org.apache.camel.Producer;
+import org.apache.camel.impl.DefaultEndpoint;
+import org.apache.camel.spi.UriEndpoint;
+import org.apache.camel.spi.UriParam;
+import org.apache.http.HttpHost;
+import org.apache.http.auth.AuthScope;
+import org.apache.http.auth.UsernamePasswordCredentials;
+import org.apache.http.impl.client.BasicCredentialsProvider;
+import org.apache.http.impl.client.HttpClientBuilder;
+import org.apache.http.impl.client.HttpClients;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Represents the DigitalOcean endpoint.
+ */
+@UriEndpoint(scheme = "digitalocean", title = "DigitalOcean", syntax="digitalocean:label", producerOnly = true, label = "cloud,management")
+public class DigitalOceanEndpoint extends DefaultEndpoint {
+
+ private static final transient Logger LOG = LoggerFactory.getLogger(DigitalOceanEndpoint.class);
+
+ @UriParam
+ private DigitalOceanConfiguration configuration;
+
+ private DigitalOceanClient digitalOceanClient;
+
+ public DigitalOceanEndpoint(String uri, DigitalOceanComponent component, DigitalOceanConfiguration configuration) {
+ super(uri, component);
+ this.configuration = configuration;
+ }
+
+ public Producer createProducer() throws Exception {
+ LOG.trace("Resolve producer digitalocean endpoint {" + configuration.getResource() + "}");
+
+ switch (configuration.getResource()) {
+ case account:
+ return new DigitalOceanAccountProducer(this, configuration);
+ case actions:
+ return new DigitalOceanActionsProducer(this, configuration);
+ case blockStorages:
+ return new DigitalOceanBlockStoragesProducer(this, configuration);
+ case droplets:
+ return new DigitalOceanDropletsProducer(this, configuration);
+ case images:
+ return new DigitalOceanImagesProducer(this, configuration);
+ case snapshots:
+ return new DigitalOceanSnapshotsProducer(this, configuration);
+ case keys:
+ return new DigitalOceanKeysProducer(this, configuration);
+ case regions:
+ return new DigitalOceanRegionsProducer(this, configuration);
+ case sizes:
+ return new DigitalOceanSizesProducer(this, configuration);
+ case floatingIPs:
+ return new DigitalOceanFloatingIPsProducer(this, configuration);
+ case tags:
+ return new DigitalOceanTagsProducer(this, configuration);
+ default:
+ throw new UnsupportedOperationException("Operation specified is not valid for producer");
+ }
+
+ }
+
+ public Consumer createConsumer(Processor processor) throws Exception {
+ throw new UnsupportedOperationException("You cannot receive messages from this endpoint");
+ }
+
+ public boolean isSingleton() {
+ return true;
+ }
+
+
+ @Override
+ public void doStart() throws Exception {
+ super.doStart();
+
+ if(configuration.getDigitalOceanClient() != null)
+ digitalOceanClient = configuration.getDigitalOceanClient();
+ else
+ if(configuration.getHttpProxyHost() != null && configuration.getHttpProxyPort() != null) {
+
+ HttpClientBuilder builder = HttpClients.custom()
+ .useSystemProperties()
+ .setProxy(new HttpHost(configuration.getHttpProxyHost(), configuration.getHttpProxyPort()));
+
+ if(configuration.getHttpProxyUser() != null && configuration.getHttpProxyPassword() != null) {
+ BasicCredentialsProvider credsProvider = new BasicCredentialsProvider();
+ credsProvider.setCredentials(
+ new AuthScope(configuration.getHttpProxyHost(), configuration.getHttpProxyPort()),
+ new UsernamePasswordCredentials(configuration.getHttpProxyUser() , configuration.getHttpProxyPassword()));
+ builder.setDefaultCredentialsProvider(credsProvider);
+
+ }
+
+ digitalOceanClient = new DigitalOceanClient("v2", configuration.getOAuthToken(), builder.build());
+
+ } else
+ digitalOceanClient = new DigitalOceanClient(configuration.getOAuthToken());
+
+
+ }
+
+ public DigitalOceanConfiguration getConfiguration() { return configuration; }
+ public DigitalOceanClient getDigitalOceanClient() {
+ return digitalOceanClient;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/1d57f7b0/components/camel-digitalocean/src/main/java/com/viwilo/camel/DigitalOceanException.java
----------------------------------------------------------------------
diff --git a/components/camel-digitalocean/src/main/java/com/viwilo/camel/DigitalOceanException.java b/components/camel-digitalocean/src/main/java/com/viwilo/camel/DigitalOceanException.java
new file mode 100644
index 0000000..144b4de
--- /dev/null
+++ b/components/camel-digitalocean/src/main/java/com/viwilo/camel/DigitalOceanException.java
@@ -0,0 +1,30 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.viwilo.camel;
+
+public class DigitalOceanException extends Exception {
+
+ private static final long serialVersionUID = 1L;
+
+ public DigitalOceanException(Throwable e) {
+ super(e);
+ }
+
+ public DigitalOceanException(String message) {
+ super(message);
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/camel/blob/1d57f7b0/components/camel-digitalocean/src/main/java/com/viwilo/camel/constants/DigitalOceanHeaders.java
----------------------------------------------------------------------
diff --git a/components/camel-digitalocean/src/main/java/com/viwilo/camel/constants/DigitalOceanHeaders.java b/components/camel-digitalocean/src/main/java/com/viwilo/camel/constants/DigitalOceanHeaders.java
new file mode 100644
index 0000000..7cf3163
--- /dev/null
+++ b/components/camel-digitalocean/src/main/java/com/viwilo/camel/constants/DigitalOceanHeaders.java
@@ -0,0 +1,54 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.viwilo.camel.constants;
+
+public interface DigitalOceanHeaders {
+
+ String OPERATION = "CamelDigitalOceanOperation";
+ String ID = "CamelDigitalOceanId";
+ String TYPE = "CamelDigitalOceanType";
+ String NAME = "CamelDigitalOceanName";
+ String NEW_NAME = "CamelDigitalOceanNewName";
+ String NAMES = "CamelDigitalOceanNames";
+ String REGION = "CamelDigitalOceanRegion";
+ String DESCRIPTION = "CamelDigitalOceanDescription";
+
+ String DROPLET_SIZE = "CamelDigitalOceanDropletSize";
+ String DROPLET_IMAGE = "CamelDigitalOceanDropletImage";
+ String DROPLET_KEYS = "CamelDigitalOceanDropletSSHKeys";
+ String DROPLET_ENABLE_BACKUPS = "CamelDigitalOceanDropletEnableBackups";
+ String DROPLET_ENABLE_IPV6 = "CamelDigitalOceanDropletEnableIpv6";
+ String DROPLET_ENABLE_PRIVATE_NETWORKING = "CamelDigitalOceanDropletEnablePrivateNetworking";
+ String DROPLET_USER_DATA = "CamelDigitalOceanDropletUserData";
+ String DROPLET_VOLUMES = "CamelDigitalOceanDropletVolumes";
+ String DROPLET_TAGS = "CamelDigitalOceanDropletTags";
+
+ String DROPLET_ID = "CamelDigitalOceanDropletId";
+ String IMAGE_ID = "CamelDigitalOceanImageId";
+ String KERNEL_ID = "CamelDigitalOceanKernelId";
+ String VOLUME_NAME = "CamelDigitalOceanVolumeName";
+ String VOLUME_SIZE_GIGABYTES = "CamelDigitalOceanVolumeSizeGigabytes";
+
+ String FLOATING_IP_ADDRESS = "CamelDigitalOceanFloatingIPAddress";
+
+ String KEY_FINGERPRINT = "CamelDigitalOceanKeyFingerprint";
+ String KEY_PUBLIC_KEY = "CamelDigitalOceanKeyPublicKey";
+
+
+
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/1d57f7b0/components/camel-digitalocean/src/main/java/com/viwilo/camel/constants/DigitalOceanImageTypes.java
----------------------------------------------------------------------
diff --git a/components/camel-digitalocean/src/main/java/com/viwilo/camel/constants/DigitalOceanImageTypes.java b/components/camel-digitalocean/src/main/java/com/viwilo/camel/constants/DigitalOceanImageTypes.java
new file mode 100644
index 0000000..f558010
--- /dev/null
+++ b/components/camel-digitalocean/src/main/java/com/viwilo/camel/constants/DigitalOceanImageTypes.java
@@ -0,0 +1,24 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.viwilo.camel.constants;
+
+public enum DigitalOceanImageTypes {
+
+ distribution,
+ application
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/1d57f7b0/components/camel-digitalocean/src/main/java/com/viwilo/camel/constants/DigitalOceanOperations.java
----------------------------------------------------------------------
diff --git a/components/camel-digitalocean/src/main/java/com/viwilo/camel/constants/DigitalOceanOperations.java b/components/camel-digitalocean/src/main/java/com/viwilo/camel/constants/DigitalOceanOperations.java
new file mode 100644
index 0000000..47cb9df
--- /dev/null
+++ b/components/camel-digitalocean/src/main/java/com/viwilo/camel/constants/DigitalOceanOperations.java
@@ -0,0 +1,57 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.viwilo.camel.constants;
+
+public enum DigitalOceanOperations {
+
+ create,
+ update,
+ delete,
+ list,
+ ownList,
+ get,
+ listBackups,
+ listActions,
+ listNeighbors,
+ listSnapshots,
+ listKernels,
+ listAllNeighbors,
+ enableBackups,
+ disableBackups,
+ reboot,
+ powerCycle,
+ shutdown,
+ powerOn,
+ powerOff,
+ restore,
+ resetPassword,
+ resize,
+ rebuild,
+ rename,
+ changeKernel,
+ enableIpv6,
+ enablePrivateNetworking,
+ takeSnapshot,
+ transfer,
+ convert,
+ attach,
+ detach,
+ assign,
+ unassign,
+ tag,
+ untag
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/1d57f7b0/components/camel-digitalocean/src/main/java/com/viwilo/camel/constants/DigitalOceanResources.java
----------------------------------------------------------------------
diff --git a/components/camel-digitalocean/src/main/java/com/viwilo/camel/constants/DigitalOceanResources.java b/components/camel-digitalocean/src/main/java/com/viwilo/camel/constants/DigitalOceanResources.java
new file mode 100644
index 0000000..2faa0b3
--- /dev/null
+++ b/components/camel-digitalocean/src/main/java/com/viwilo/camel/constants/DigitalOceanResources.java
@@ -0,0 +1,36 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.viwilo.camel.constants;
+
+
+public enum DigitalOceanResources {
+
+ account,
+ actions,
+ blockStorages,
+ droplets,
+ images,
+ snapshots,
+ keys,
+ regions,
+ sizes,
+ floatingIPs,
+ tags
+
+
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/1d57f7b0/components/camel-digitalocean/src/main/java/com/viwilo/camel/constants/DigitalOceanSnapshotTypes.java
----------------------------------------------------------------------
diff --git a/components/camel-digitalocean/src/main/java/com/viwilo/camel/constants/DigitalOceanSnapshotTypes.java b/components/camel-digitalocean/src/main/java/com/viwilo/camel/constants/DigitalOceanSnapshotTypes.java
new file mode 100644
index 0000000..903b7a4
--- /dev/null
+++ b/components/camel-digitalocean/src/main/java/com/viwilo/camel/constants/DigitalOceanSnapshotTypes.java
@@ -0,0 +1,24 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.viwilo.camel.constants;
+
+public enum DigitalOceanSnapshotTypes {
+
+ droplet,
+ volume
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/1d57f7b0/components/camel-digitalocean/src/main/java/com/viwilo/camel/producer/DigitalOceanAccountProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-digitalocean/src/main/java/com/viwilo/camel/producer/DigitalOceanAccountProducer.java b/components/camel-digitalocean/src/main/java/com/viwilo/camel/producer/DigitalOceanAccountProducer.java
new file mode 100644
index 0000000..a7da305
--- /dev/null
+++ b/components/camel-digitalocean/src/main/java/com/viwilo/camel/producer/DigitalOceanAccountProducer.java
@@ -0,0 +1,39 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.viwilo.camel.producer;
+
+import com.myjeeva.digitalocean.pojo.*;
+import com.viwilo.camel.DigitalOceanConfiguration;
+import com.viwilo.camel.DigitalOceanEndpoint;
+import org.apache.camel.Exchange;
+
+/**
+ * The DigitalOcean producer for Account API.
+ */
+public class DigitalOceanAccountProducer extends DigitalOceanProducer {
+
+ public DigitalOceanAccountProducer(DigitalOceanEndpoint endpoint, DigitalOceanConfiguration configuration) {
+ super(endpoint, configuration);
+ }
+
+ public void process(Exchange exchange) throws Exception {
+ Account accountInfo = getEndpoint().getDigitalOceanClient().getAccountInfo();
+ LOG.trace("Account [{}] ", accountInfo);
+ exchange.getOut().setBody(accountInfo);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/1d57f7b0/components/camel-digitalocean/src/main/java/com/viwilo/camel/producer/DigitalOceanActionsProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-digitalocean/src/main/java/com/viwilo/camel/producer/DigitalOceanActionsProducer.java b/components/camel-digitalocean/src/main/java/com/viwilo/camel/producer/DigitalOceanActionsProducer.java
new file mode 100644
index 0000000..2b00819
--- /dev/null
+++ b/components/camel-digitalocean/src/main/java/com/viwilo/camel/producer/DigitalOceanActionsProducer.java
@@ -0,0 +1,66 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.viwilo.camel.producer;
+
+import com.myjeeva.digitalocean.pojo.*;
+import com.viwilo.camel.DigitalOceanConfiguration;
+import com.viwilo.camel.DigitalOceanEndpoint;
+import com.viwilo.camel.constants.DigitalOceanHeaders;
+import org.apache.camel.Exchange;
+import org.apache.camel.util.ObjectHelper;
+
+/**
+ * The DigitalOcean producer for Actions API.
+ */
+public class DigitalOceanActionsProducer extends DigitalOceanProducer {
+
+ public DigitalOceanActionsProducer(DigitalOceanEndpoint endpoint, DigitalOceanConfiguration configuration) {
+ super(endpoint, configuration);
+ }
+
+ public void process(Exchange exchange) throws Exception {
+ switch(determineOperation(exchange)) {
+
+ case list:
+ getActions(exchange);
+ break;
+ case get:
+ getAction(exchange);
+ break;
+ default:
+ throw new IllegalArgumentException("Unsupported operation");
+ }
+
+ }
+
+
+ private void getAction(Exchange exchange) throws Exception {
+ Integer actionId = exchange.getIn().getHeader(DigitalOceanHeaders.ID, Integer.class);
+
+ if (ObjectHelper.isEmpty(actionId))
+ throw new IllegalArgumentException(DigitalOceanHeaders.ID + " must be specified");
+ Action action = getEndpoint().getDigitalOceanClient().getActionInfo(actionId);
+ LOG.trace("Action [{}] ", action);
+ exchange.getOut().setBody(action);
+ }
+
+ private void getActions(Exchange exchange) throws Exception {
+ Actions actions = getEndpoint().getDigitalOceanClient().getAvailableActions(configuration.getPage(), configuration.getPerPage());
+ LOG.trace("All Actions : page {} / {} per page [{}] ", configuration.getPage(), configuration.getPerPage(), actions.getActions());
+ exchange.getOut().setBody(actions.getActions());
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/1d57f7b0/components/camel-digitalocean/src/main/java/com/viwilo/camel/producer/DigitalOceanBlockStoragesProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-digitalocean/src/main/java/com/viwilo/camel/producer/DigitalOceanBlockStoragesProducer.java b/components/camel-digitalocean/src/main/java/com/viwilo/camel/producer/DigitalOceanBlockStoragesProducer.java
new file mode 100644
index 0000000..282332a
--- /dev/null
+++ b/components/camel-digitalocean/src/main/java/com/viwilo/camel/producer/DigitalOceanBlockStoragesProducer.java
@@ -0,0 +1,252 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.viwilo.camel.producer;
+
+import com.myjeeva.digitalocean.pojo.*;
+import com.viwilo.camel.DigitalOceanConfiguration;
+import com.viwilo.camel.constants.DigitalOceanHeaders;
+import com.viwilo.camel.DigitalOceanEndpoint;
+import org.apache.camel.Exchange;
+import org.apache.camel.Message;
+import org.apache.camel.util.ObjectHelper;
+
+import java.util.List;
+
+/**
+ * The DigitalOcean producer for BlockStorages API.
+ */
+public class DigitalOceanBlockStoragesProducer extends DigitalOceanProducer {
+
+ public DigitalOceanBlockStoragesProducer(DigitalOceanEndpoint endpoint, DigitalOceanConfiguration configuration) {
+ super(endpoint, configuration);
+ }
+
+ public void process(Exchange exchange) throws Exception {
+
+ switch (determineOperation(exchange)) {
+
+ case list:
+ getVolumes(exchange);
+ break;
+ case get:
+ getVolume(exchange);
+ break;
+ case listSnapshots:
+ getVolumeSnapshots(exchange);
+ break;
+ case create:
+ createVolume(exchange);
+ break;
+ case delete:
+ deleteVolume(exchange);
+ break;
+ case attach:
+ attachVolumeToDroplet(exchange);
+ break;
+ case detach:
+ detachVolumeToDroplet(exchange);
+ break;
+ case resize:
+ resizeVolume(exchange);
+ break;
+ case listActions:
+ getVolumeActions(exchange);
+ break;
+ default:
+ throw new IllegalArgumentException("Unsupported operation");
+ }
+ }
+
+ private void getVolumes(Exchange exchange) throws Exception {
+ String region = exchange.getIn().getHeader(DigitalOceanHeaders.REGION, String.class);
+ if (ObjectHelper.isEmpty(region))
+ throw new IllegalArgumentException(DigitalOceanHeaders.REGION + " must be specified");
+
+ Volumes volumes = getEndpoint().getDigitalOceanClient().getAvailableVolumes(region);
+ LOG.trace("All Volumes for region {} [{}] ", region, volumes.getVolumes());
+ exchange.getOut().setBody(volumes.getVolumes());
+
+ }
+
+ private void createVolume(Exchange exchange) throws Exception {
+ Message in = exchange.getIn();
+
+ Volume volume = new Volume();
+
+ if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(DigitalOceanHeaders.VOLUME_SIZE_GIGABYTES)))
+ volume.setSize(in.getHeader(DigitalOceanHeaders.VOLUME_SIZE_GIGABYTES, Double.class));
+ else
+ throw new IllegalArgumentException(DigitalOceanHeaders.VOLUME_SIZE_GIGABYTES + " must be specified");
+
+ if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(DigitalOceanHeaders.NAME)))
+ volume.setName(in.getHeader(DigitalOceanHeaders.NAME, String.class));
+ else
+ throw new IllegalArgumentException(DigitalOceanHeaders.NAME + " must be specified");
+
+ if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(DigitalOceanHeaders.REGION)))
+ volume.setRegion(new Region(in.getHeader(DigitalOceanHeaders.REGION, String.class)));
+ else
+ throw new IllegalArgumentException(DigitalOceanHeaders.REGION + " must be specified");
+
+ if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(DigitalOceanHeaders.DESCRIPTION)))
+ volume.setDescription(in.getHeader(DigitalOceanHeaders.DESCRIPTION, String.class));
+ else
+ throw new IllegalArgumentException(DigitalOceanHeaders.DESCRIPTION + " must be specified");
+
+ volume = getEndpoint().getDigitalOceanClient().createVolume(volume);
+ LOG.trace("Volume created {} ", volume);
+ exchange.getOut().setBody(volume);
+ }
+
+ private void getVolume(Exchange exchange) throws Exception {
+ String volumeId = exchange.getIn().getHeader(DigitalOceanHeaders.ID, String.class);
+ Volume volume = null;
+ if (ObjectHelper.isEmpty(volumeId)) {
+ String name = exchange.getIn().getHeader(DigitalOceanHeaders.NAME, String.class);
+ String region = exchange.getIn().getHeader(DigitalOceanHeaders.REGION, String.class);
+
+ if (ObjectHelper.isEmpty(name) && ObjectHelper.isEmpty(region))
+ throw new IllegalArgumentException(DigitalOceanHeaders.ID + " or " + DigitalOceanHeaders.NAME + " and " + DigitalOceanHeaders.REGION + " must be specified");
+
+ List<Volume> volumes = getEndpoint().getDigitalOceanClient().getVolumeInfo(name, region).getVolumes();
+ if (volumes.size() > 0)
+ volume = volumes.get(1);
+ } else
+ volume = getEndpoint().getDigitalOceanClient().getVolumeInfo(volumeId);
+
+ LOG.trace("Volume [{}] ", volume);
+ exchange.getOut().setBody(volume);
+
+ }
+
+ private void getVolumeSnapshots(Exchange exchange) throws Exception {
+ String volumeId = exchange.getIn().getHeader(DigitalOceanHeaders.ID, String.class);
+ if (ObjectHelper.isEmpty(volumeId))
+ throw new IllegalArgumentException(DigitalOceanHeaders.ID + " must be specified");
+
+ Snapshots snapshots = getEndpoint().getDigitalOceanClient().getVolumeSnapshots(volumeId, configuration.getPage(), configuration.getPerPage());
+ LOG.trace("All Snapshots for volume {} [{}] ", volumeId, snapshots.getSnapshots());
+ exchange.getOut().setBody(snapshots.getSnapshots());
+ }
+
+ private void deleteVolume(Exchange exchange) throws Exception {
+ String volumeId = exchange.getIn().getHeader(DigitalOceanHeaders.ID, String.class);
+ Delete delete;
+ if (ObjectHelper.isEmpty(volumeId)) {
+ String name = exchange.getIn().getHeader(DigitalOceanHeaders.NAME, String.class);
+ String region = exchange.getIn().getHeader(DigitalOceanHeaders.REGION, String.class);
+
+ if (ObjectHelper.isEmpty(name) && ObjectHelper.isEmpty(region))
+ throw new IllegalArgumentException(DigitalOceanHeaders.ID + " or " + DigitalOceanHeaders.NAME + " and " + DigitalOceanHeaders.REGION + " must be specified");
+
+ delete = getEndpoint().getDigitalOceanClient().deleteVolume(name, region);
+
+ } else
+ delete = getEndpoint().getDigitalOceanClient().deleteVolume(volumeId);
+
+ LOG.trace("Delete Volume [{}] ", delete);
+ exchange.getOut().setBody(delete);
+
+ }
+
+ private void attachVolumeToDroplet(Exchange exchange) throws Exception {
+ String volumeId = exchange.getIn().getHeader(DigitalOceanHeaders.ID, String.class);
+ String volumeName = exchange.getIn().getHeader(DigitalOceanHeaders.VOLUME_NAME, String.class);
+ Integer dropletId = exchange.getIn().getHeader(DigitalOceanHeaders.DROPLET_ID, Integer.class);
+ String region = exchange.getIn().getHeader(DigitalOceanHeaders.REGION, String.class);
+
+ if (ObjectHelper.isEmpty(dropletId))
+ throw new IllegalArgumentException(DigitalOceanHeaders.DROPLET_ID + " must be specified");
+
+ if (ObjectHelper.isEmpty(region))
+ throw new IllegalArgumentException(DigitalOceanHeaders.REGION + " must be specified");
+
+ Action action;
+
+ if (ObjectHelper.isNotEmpty(volumeName)) {
+ action = getEndpoint().getDigitalOceanClient().attachVolumeByName(dropletId, volumeName, region);
+ LOG.trace("Attach Volume {} to Droplet {} [{}] ", volumeName, dropletId, action);
+ } else if (ObjectHelper.isNotEmpty(volumeId)) {
+ action = getEndpoint().getDigitalOceanClient().attachVolume(dropletId, volumeId, region);
+ LOG.trace("Attach Volume {} to Droplet {} [{}] ", volumeId, dropletId, action);
+ } else
+ throw new IllegalArgumentException(DigitalOceanHeaders.ID + " or " + DigitalOceanHeaders.VOLUME_NAME + " must be specified");
+
+ exchange.getOut().setBody(action);
+ }
+
+
+
+ private void detachVolumeToDroplet(Exchange exchange) throws Exception {
+ String volumeId = exchange.getIn().getHeader(DigitalOceanHeaders.ID, String.class);
+ String volumeName = exchange.getIn().getHeader(DigitalOceanHeaders.VOLUME_NAME, String.class);
+ Integer dropletId = exchange.getIn().getHeader(DigitalOceanHeaders.DROPLET_ID, Integer.class);
+ String region = exchange.getIn().getHeader(DigitalOceanHeaders.REGION, String.class);
+
+ if (ObjectHelper.isEmpty(dropletId))
+ throw new IllegalArgumentException(DigitalOceanHeaders.DROPLET_ID + " must be specified");
+
+ if (ObjectHelper.isEmpty(region))
+ throw new IllegalArgumentException(DigitalOceanHeaders.REGION + " must be specified");
+
+ Action action;
+
+ if (ObjectHelper.isNotEmpty(volumeName)) {
+ action = getEndpoint().getDigitalOceanClient().detachVolumeByName(dropletId, volumeName, region);
+ LOG.trace("Detach Volume {} to Droplet {} [{}] ", volumeName, dropletId, action);
+ } else if (ObjectHelper.isNotEmpty(volumeId)) {
+ action = getEndpoint().getDigitalOceanClient().detachVolume(dropletId, volumeId, region);
+ LOG.trace("Detach Volume {} to Droplet {} [{}] ", volumeId, dropletId, action);
+ } else
+ throw new IllegalArgumentException(DigitalOceanHeaders.ID + " or " + DigitalOceanHeaders.VOLUME_NAME + " must be specified");
+
+ exchange.getOut().setBody(action);
+
+ }
+
+ private void resizeVolume(Exchange exchange) throws Exception {
+ String volumeId = exchange.getIn().getHeader(DigitalOceanHeaders.ID, String.class);
+
+ if (ObjectHelper.isEmpty(volumeId))
+ throw new IllegalArgumentException(DigitalOceanHeaders.ID + " must be specified");
+
+ String region = exchange.getIn().getHeader(DigitalOceanHeaders.REGION, String.class);
+
+ if (ObjectHelper.isEmpty(region))
+ throw new IllegalArgumentException(DigitalOceanHeaders.REGION + " must be specified");
+
+ Double size = exchange.getIn().getHeader(DigitalOceanHeaders.VOLUME_SIZE_GIGABYTES, Double.class);
+
+ if (ObjectHelper.isEmpty(size))
+ throw new IllegalArgumentException(DigitalOceanHeaders.VOLUME_SIZE_GIGABYTES + " must be specified");
+
+ Action action = getEndpoint().getDigitalOceanClient().resizeVolume(volumeId, region, size);
+ LOG.trace("Resize Volume {} [{}] ", volumeId, action);
+ }
+
+ private void getVolumeActions(Exchange exchange) throws Exception {
+ String volumeId = exchange.getIn().getHeader(DigitalOceanHeaders.ID, String.class);
+
+ if (ObjectHelper.isEmpty(volumeId))
+ throw new IllegalArgumentException(DigitalOceanHeaders.ID + " must be specified");
+
+ Actions actions = getEndpoint().getDigitalOceanClient().getAvailableVolumeActions(volumeId);
+ LOG.trace("Actions for Volume {} [{}] ", volumeId, actions.getActions());
+ exchange.getOut().setBody(actions.getActions());
+ }
+
+}
[09/20] camel git commit: Refactor com.viwilo to org.apache.camel
Posted by ac...@apache.org.
http://git-wip-us.apache.org/repos/asf/camel/blob/17d527d1/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/producer/DigitalOceanDropletsProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/producer/DigitalOceanDropletsProducer.java b/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/producer/DigitalOceanDropletsProducer.java
new file mode 100644
index 0000000..444a68d
--- /dev/null
+++ b/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/producer/DigitalOceanDropletsProducer.java
@@ -0,0 +1,405 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.digitalocean.producer;
+
+import com.myjeeva.digitalocean.common.ResourceType;
+import com.myjeeva.digitalocean.pojo.*;
+import com.myjeeva.digitalocean.pojo.Response;
+import org.apache.camel.component.digitalocean.DigitalOceanConfiguration;
+import org.apache.camel.component.digitalocean.constants.DigitalOceanHeaders;
+import org.apache.camel.component.digitalocean.DigitalOceanEndpoint;
+import org.apache.camel.component.digitalocean.constants.DigitalOceanOperations;
+import org.apache.camel.Exchange;
+import org.apache.camel.Message;
+import org.apache.camel.util.ObjectHelper;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.stream.Collectors;
+
+/**
+ * The DigitalOcean producer for Droplets API.
+ */
+public class DigitalOceanDropletsProducer extends DigitalOceanProducer {
+
+ public DigitalOceanDropletsProducer(DigitalOceanEndpoint endpoint, DigitalOceanConfiguration configuration) {
+ super(endpoint, configuration);
+ }
+
+ private Integer dropletId;
+
+ public void process(Exchange exchange) throws Exception {
+
+ DigitalOceanOperations op = determineOperation(exchange);
+ if (op != DigitalOceanOperations.create && op != DigitalOceanOperations.list && op != DigitalOceanOperations.listAllNeighbors) {
+ dropletId = exchange.getIn().getHeader(DigitalOceanHeaders.ID, Integer.class);
+ if (ObjectHelper.isEmpty(dropletId))
+ throw new IllegalArgumentException(DigitalOceanHeaders.ID + " must be specified");
+ }
+
+ switch (op) {
+ case create:
+ createDroplet(exchange);
+ break;
+ case list:
+ getDroplets(exchange);
+ break;
+ case delete:
+ deleteDroplet(exchange);
+ break;
+ case get:
+ getDroplet(exchange);
+ break;
+ case listActions:
+ getDropletActions(exchange);
+ break;
+ case listSnapshots:
+ getDropletSnapshots(exchange);
+ break;
+ case listKernels:
+ getDropletKernels(exchange);
+ break;
+ case listBackups:
+ getDropletBackups(exchange);
+ break;
+ case listNeighbors:
+ getDropletNeighbors(exchange);
+ break;
+ case listAllNeighbors:
+ getAllDropletNeighbors(exchange);
+ break;
+ case enableBackups:
+ enableDropletBackups(exchange);
+ break;
+ case disableBackups:
+ disableDropletBackups(exchange);
+ break;
+ case reboot:
+ rebootDroplet(exchange);
+ break;
+ case powerCycle:
+ powerCycleDroplet(exchange);
+ break;
+ case shutdown:
+ shutdownDroplet(exchange);
+ break;
+ case powerOn:
+ powerOnDroplet(exchange);
+ break;
+ case powerOff:
+ powerOffDroplet(exchange);
+ break;
+ case restore:
+ restoreDroplet(exchange);
+ break;
+ case resetPassword:
+ resetDropletPassword(exchange);
+ break;
+ case resize:
+ resizeDroplet(exchange);
+ break;
+ case rebuild:
+ rebuildDroplet(exchange);
+ break;
+ case rename:
+ renameDroplet(exchange);
+ break;
+ case changeKernel:
+ changeDropletKernel(exchange);
+ break;
+ case enableIpv6:
+ enableDropletIpv6(exchange);
+ break;
+ case enablePrivateNetworking:
+ enableDropletPrivateNetworking(exchange);
+ break;
+ case takeSnapshot:
+ takeDropletSnapshot(exchange);
+ break;
+ case tag:
+ tagDroplet(exchange);
+ break;
+ case untag:
+ untagDroplet(exchange);
+ break;
+ default:
+ throw new IllegalArgumentException("Unsupported operation");
+ }
+ }
+
+
+
+ private void getDroplet(Exchange exchange) throws Exception {
+ Droplet droplet = getEndpoint().getDigitalOceanClient().getDropletInfo(dropletId);
+ LOG.trace("Droplet {} ", droplet);
+ exchange.getOut().setBody(droplet);
+ }
+
+
+ private void getDroplets(Exchange exchange) throws Exception {
+ Droplets droplets = getEndpoint().getDigitalOceanClient().getAvailableDroplets(configuration.getPage(), configuration.getPerPage());
+ LOG.trace("All Droplets : page {} / {} per page [{}] ", configuration.getPage(), configuration.getPerPage(), droplets.getDroplets());
+ exchange.getOut().setBody(droplets.getDroplets());
+ }
+
+
+ private void getDropletActions(Exchange exchange) throws Exception {
+ Actions actions = getEndpoint().getDigitalOceanClient().getAvailableDropletActions(dropletId, configuration.getPage(), configuration.getPerPage());
+ LOG.trace("Actions for Droplet {} : page {} / {} per page [{}] ", dropletId, configuration.getPage(), configuration.getPerPage(), actions.getActions());
+ exchange.getOut().setBody(actions.getActions());
+ }
+
+ private void getDropletKernels(Exchange exchange) throws Exception {
+ Kernels kernels = getEndpoint().getDigitalOceanClient().getDropletKernels(dropletId, configuration.getPage(), configuration.getPerPage());
+ LOG.trace("Kernels for Droplet {} : page {} / {} per page [{}] ", dropletId, configuration.getPage(), configuration.getPerPage(), kernels.getKernels());
+ exchange.getOut().setBody(kernels.getKernels());
+ }
+
+ private void getDropletBackups(Exchange exchange) throws Exception {
+ Backups backups = getEndpoint().getDigitalOceanClient().getDropletBackups(dropletId, configuration.getPage(), configuration.getPerPage());
+ LOG.trace("Backups for Droplet {} : page {} / {} per page [{}] ", dropletId, configuration.getPage(), configuration.getPerPage(), backups.getBackups());
+ exchange.getOut().setBody(backups.getBackups());
+ }
+
+ private void getDropletSnapshots(Exchange exchange) throws Exception {
+ Snapshots snapshots = getEndpoint().getDigitalOceanClient().getDropletSnapshots(dropletId, configuration.getPage(), configuration.getPerPage());
+ LOG.trace("Snapshots for Droplet {} : page {} / {} per page [{}] ", dropletId, configuration.getPage(), configuration.getPerPage(), snapshots.getSnapshots());
+ exchange.getOut().setBody(snapshots.getSnapshots());
+ }
+
+ private void getDropletNeighbors(Exchange exchange) throws Exception {
+ Droplets droplets = getEndpoint().getDigitalOceanClient().getDropletNeighbors(dropletId, configuration.getPage());
+ LOG.trace("Neighbors for Droplet {} : page {} [{}] ", dropletId, configuration.getPage(), droplets.getDroplets());
+ exchange.getOut().setBody(droplets.getDroplets());
+ }
+
+ private void getAllDropletNeighbors(Exchange exchange) throws Exception {
+ Neighbors neighbors = getEndpoint().getDigitalOceanClient().getAllDropletNeighbors(configuration.getPage());
+ LOG.trace("All Neighbors : page {} [{}] ", configuration.getPage(), neighbors.getNeighbors());
+ exchange.getOut().setBody(neighbors.getNeighbors());
+ }
+
+ private void deleteDroplet(Exchange exchange) throws Exception {
+ Delete delete = getEndpoint().getDigitalOceanClient().deleteDroplet(dropletId);
+ LOG.trace("Delete Droplet {} ", delete);
+ exchange.getOut().setBody(delete);
+ }
+
+ @SuppressWarnings("unchecked")
+ private void createDroplet(Exchange exchange) throws Exception {
+ Message in = exchange.getIn();
+
+ Droplet droplet = new Droplet();
+
+ if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(DigitalOceanHeaders.REGION)))
+ droplet.setRegion(new Region(in.getHeader(DigitalOceanHeaders.REGION, String.class)));
+ else
+ throw new IllegalArgumentException(DigitalOceanHeaders.REGION + " must be specified");
+
+ if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(DigitalOceanHeaders.DROPLET_SIZE)))
+ droplet.setSize(in.getHeader(DigitalOceanHeaders.DROPLET_SIZE, String.class));
+ else
+ throw new IllegalArgumentException(DigitalOceanHeaders.DROPLET_SIZE + " must be specified");
+
+ if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(DigitalOceanHeaders.DROPLET_IMAGE)))
+ droplet.setImage(new Image(in.getHeader(DigitalOceanHeaders.DROPLET_IMAGE, String.class)));
+ else
+ throw new IllegalArgumentException(DigitalOceanHeaders.DROPLET_IMAGE + " must be specified");
+
+ if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(DigitalOceanHeaders.DROPLET_KEYS))) {
+ List<String> keys = (List<String>) exchange.getIn().getHeader(DigitalOceanHeaders.DROPLET_KEYS);
+ droplet.setKeys(keys.stream().map(Key::new).collect(Collectors.toList()));
+ }
+
+ if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(DigitalOceanHeaders.DROPLET_ENABLE_BACKUPS)))
+ droplet.setEnableBackup(in.getHeader(DigitalOceanHeaders.DROPLET_ENABLE_BACKUPS, Boolean.class));
+
+ if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(DigitalOceanHeaders.DROPLET_ENABLE_IPV6)))
+ droplet.setEnableIpv6(in.getHeader(DigitalOceanHeaders.DROPLET_ENABLE_IPV6, Boolean.class));
+
+ if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(DigitalOceanHeaders.DROPLET_ENABLE_PRIVATE_NETWORKING)))
+ droplet.setEnablePrivateNetworking(in.getHeader(DigitalOceanHeaders.DROPLET_ENABLE_PRIVATE_NETWORKING, Boolean.class));
+
+ if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(DigitalOceanHeaders.DROPLET_USER_DATA)))
+ droplet.setUserData(in.getHeader(DigitalOceanHeaders.DROPLET_USER_DATA, String.class));
+
+ if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(DigitalOceanHeaders.DROPLET_VOLUMES)))
+ droplet.setVolumeIds((List<String>) exchange.getIn().getHeader(DigitalOceanHeaders.DROPLET_VOLUMES));
+
+ if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(DigitalOceanHeaders.DROPLET_TAGS)))
+ droplet.setTags((List<String>) exchange.getIn().getHeader(DigitalOceanHeaders.DROPLET_TAGS));
+
+ if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(DigitalOceanHeaders.NAMES))) {
+ droplet.setNames((List<String>) in.getHeader(DigitalOceanHeaders.NAMES));
+ Droplets droplets = getEndpoint().getDigitalOceanClient().createDroplets(droplet);
+ LOG.trace("Droplets created {} ", droplets);
+ exchange.getOut().setBody(droplets.getDroplets());
+ } else if(ObjectHelper.isNotEmpty(exchange.getIn().getHeader(DigitalOceanHeaders.NAME))) {
+ droplet.setName(in.getHeader(DigitalOceanHeaders.NAME, String.class));
+ droplet = getEndpoint().getDigitalOceanClient().createDroplet(droplet);
+ LOG.trace("Droplet created {} ", droplet);
+ exchange.getOut().setBody(droplet);
+ } else
+ throw new IllegalArgumentException(DigitalOceanHeaders.NAMES + " or " + DigitalOceanHeaders.NAME + " must be specified");
+
+ }
+
+ private void restoreDroplet(Exchange exchange) throws Exception {
+ if (ObjectHelper.isEmpty(exchange.getIn().getHeader(DigitalOceanHeaders.IMAGE_ID)))
+ throw new IllegalArgumentException(DigitalOceanHeaders.IMAGE_ID + " must be specified");
+
+ Action action = getEndpoint().getDigitalOceanClient().restoreDroplet(dropletId, exchange.getIn().getHeader(DigitalOceanHeaders.IMAGE_ID, Integer.class));
+ LOG.trace("DropletAction Restore [{}] ", action);
+ exchange.getOut().setBody(action);
+
+ }
+
+ private void resizeDroplet(Exchange exchange) throws Exception {
+ if (ObjectHelper.isEmpty(exchange.getIn().getHeader(DigitalOceanHeaders.DROPLET_SIZE)))
+ throw new IllegalArgumentException(DigitalOceanHeaders.DROPLET_SIZE + " must be specified");
+
+ Action action = getEndpoint().getDigitalOceanClient().resizeDroplet(dropletId, exchange.getIn().getHeader(DigitalOceanHeaders.DROPLET_SIZE, String.class));
+ LOG.trace("DropletAction Resize [{}] ", action);
+ exchange.getOut().setBody(action);
+ }
+
+
+ private void rebuildDroplet(Exchange exchange) throws Exception {
+ if (ObjectHelper.isEmpty(exchange.getIn().getHeader(DigitalOceanHeaders.IMAGE_ID)))
+ throw new IllegalArgumentException(DigitalOceanHeaders.IMAGE_ID + " must be specified");
+
+ Action action = getEndpoint().getDigitalOceanClient().rebuildDroplet(dropletId, exchange.getIn().getHeader(DigitalOceanHeaders.IMAGE_ID, Integer.class));
+ LOG.trace("Rebuild Droplet {} : [{}] ", dropletId, action);
+ exchange.getOut().setBody(action);
+ }
+
+ private void renameDroplet(Exchange exchange) throws Exception {
+ if (ObjectHelper.isEmpty(exchange.getIn().getHeader(DigitalOceanHeaders.NAME)))
+ throw new IllegalArgumentException(DigitalOceanHeaders.NAME + " must be specified");
+
+ Action action = getEndpoint().getDigitalOceanClient().renameDroplet(dropletId, exchange.getIn().getHeader(DigitalOceanHeaders.NAME, String.class));
+ LOG.trace("Rename Droplet {} : [{}] ", dropletId, action);
+ exchange.getOut().setBody(action);
+ }
+
+
+ private void changeDropletKernel(Exchange exchange) throws Exception {
+ if (ObjectHelper.isEmpty(exchange.getIn().getHeader(DigitalOceanHeaders.KERNEL_ID)))
+ throw new IllegalArgumentException(DigitalOceanHeaders.KERNEL_ID + " must be specified");
+
+ Action action = getEndpoint().getDigitalOceanClient().changeDropletKernel(dropletId, exchange.getIn().getHeader(DigitalOceanHeaders.KERNEL_ID, Integer.class));
+ LOG.trace("Rename Droplet {} : [{}] ", dropletId, action);
+ exchange.getOut().setBody(action);
+ }
+
+ private void resetDropletPassword(Exchange exchange) throws Exception {
+ Action action = getEndpoint().getDigitalOceanClient().resetDropletPassword(dropletId);
+ LOG.trace("Reset password Droplet {} : [{}] ", dropletId, action);
+ exchange.getOut().setBody(action);
+ }
+
+
+ private void powerOnDroplet(Exchange exchange) throws Exception {
+ Action action = getEndpoint().getDigitalOceanClient().powerOnDroplet(dropletId);
+ LOG.trace("Power on Droplet {} : [{}] ", dropletId, action);
+ exchange.getOut().setBody(action);
+ }
+
+ private void powerOffDroplet(Exchange exchange) throws Exception {
+ Action action = getEndpoint().getDigitalOceanClient().powerOffDroplet(dropletId);
+ LOG.trace("Power off Droplet {} : [{}] ", dropletId, action);
+ exchange.getOut().setBody(action);
+ }
+
+ private void shutdownDroplet(Exchange exchange) throws Exception {
+ Action action = getEndpoint().getDigitalOceanClient().shutdownDroplet(dropletId);
+ LOG.trace("Shutdown Droplet {} : [{}] ", dropletId, action);
+ exchange.getOut().setBody(action);
+ }
+
+ private void powerCycleDroplet(Exchange exchange) throws Exception {
+ Action action = getEndpoint().getDigitalOceanClient().powerCycleDroplet(dropletId);
+ LOG.trace("Power cycle Droplet {} : [{}] ", dropletId, action);
+ exchange.getOut().setBody(action);
+ }
+
+ private void enableDropletBackups(Exchange exchange) throws Exception {
+ Action action = getEndpoint().getDigitalOceanClient().enableDropletBackups(dropletId);
+ LOG.trace("Enable backups Droplet {} : [{}] ", dropletId, action);
+ exchange.getOut().setBody(action);
+ }
+
+ private void disableDropletBackups(Exchange exchange) throws Exception {
+ Action action = getEndpoint().getDigitalOceanClient().disableDropletBackups(dropletId);
+ LOG.trace("Disable backups for Droplet {} : [{}] ", dropletId, action);
+ exchange.getOut().setBody(action);
+ }
+
+ private void enableDropletIpv6(Exchange exchange) throws Exception {
+ Action action = getEndpoint().getDigitalOceanClient().enableDropletIpv6(dropletId);
+ LOG.trace("Enable IP v6 for Droplet {} : [{}] ", dropletId, action);
+ exchange.getOut().setBody(action);
+ }
+
+ private void enableDropletPrivateNetworking(Exchange exchange) throws Exception {
+ Action action = getEndpoint().getDigitalOceanClient().enableDropletPrivateNetworking(dropletId);
+ LOG.trace("Enable private networking for Droplet {} : [{}] ", dropletId, action);
+ exchange.getOut().setBody(action);
+ }
+
+
+ private void rebootDroplet(Exchange exchange) throws Exception {
+ Action action = getEndpoint().getDigitalOceanClient().rebootDroplet(dropletId);
+ LOG.trace("Reboot Droplet {} : [{}] ", dropletId, action);
+ exchange.getOut().setBody(action);
+ }
+
+ private void takeDropletSnapshot(Exchange exchange) throws Exception {
+ Action action;
+
+ if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(DigitalOceanHeaders.NAME)))
+ action = getEndpoint().getDigitalOceanClient().takeDropletSnapshot(dropletId, exchange.getIn().getHeader(DigitalOceanHeaders.NAME, String.class));
+ else
+ action = getEndpoint().getDigitalOceanClient().takeDropletSnapshot(dropletId);
+
+ LOG.trace("Take Snapshot for Droplet {} : [{}] ", dropletId, action);
+ exchange.getOut().setBody(action);
+ }
+
+ private void tagDroplet(Exchange exchange) throws Exception {
+ if (ObjectHelper.isEmpty(exchange.getIn().getHeader(DigitalOceanHeaders.NAME)))
+ throw new IllegalArgumentException(DigitalOceanHeaders.NAME + " must be specified");
+
+ ArrayList<Resource> resources = new ArrayList<>(1);
+ resources.add(new Resource(dropletId.toString(), ResourceType.DROPLET));
+ Response response = getEndpoint().getDigitalOceanClient().tagResources(dropletId.toString(), resources);
+ LOG.trace("Tag Droplet {} : [{}] ", dropletId, response);
+ exchange.getOut().setBody(response);
+ }
+
+ private void untagDroplet(Exchange exchange) throws Exception {
+ if (ObjectHelper.isEmpty(exchange.getIn().getHeader(DigitalOceanHeaders.NAME)))
+ throw new IllegalArgumentException(DigitalOceanHeaders.NAME + " must be specified");
+
+ ArrayList<Resource> resources = new ArrayList<>(1);
+ resources.add(new Resource(dropletId.toString(), ResourceType.DROPLET));
+ Response response = getEndpoint().getDigitalOceanClient().untagResources(dropletId.toString(), resources);
+ LOG.trace("Untag Droplet {} : [{}] ", dropletId, response);
+ exchange.getOut().setBody(response);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/17d527d1/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/producer/DigitalOceanFloatingIPsProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/producer/DigitalOceanFloatingIPsProducer.java b/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/producer/DigitalOceanFloatingIPsProducer.java
new file mode 100644
index 0000000..da94dc0
--- /dev/null
+++ b/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/producer/DigitalOceanFloatingIPsProducer.java
@@ -0,0 +1,152 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.digitalocean.producer;
+
+import com.myjeeva.digitalocean.pojo.*;
+import org.apache.camel.component.digitalocean.DigitalOceanConfiguration;
+import org.apache.camel.component.digitalocean.constants.DigitalOceanHeaders;
+import org.apache.camel.component.digitalocean.DigitalOceanEndpoint;
+import org.apache.camel.Exchange;
+import org.apache.camel.component.digitalocean.constants.DigitalOceanOperations;
+import org.apache.camel.util.ObjectHelper;
+
+/**
+ * The DigitalOcean producer for FloatingIps API.
+ */
+public class DigitalOceanFloatingIPsProducer extends DigitalOceanProducer {
+
+ public DigitalOceanFloatingIPsProducer(DigitalOceanEndpoint endpoint, DigitalOceanConfiguration configuration) {
+ super(endpoint, configuration);
+ }
+
+ public void process(Exchange exchange) throws Exception {
+ switch(determineOperation(exchange)) {
+
+ case DigitalOceanOperations.list:
+ getFloatingIPs(exchange);
+ break;
+ case DigitalOceanOperations.create:
+ createFloatingIp(exchange);
+ break;
+ case DigitalOceanOperations.get:
+ getFloatingIP(exchange);
+ break;
+ case DigitalOceanOperations.delete:
+ deleteFloatingIP(exchange);
+ break;
+ case DigitalOceanOperations.assign:
+ assignFloatingIPToDroplet(exchange);
+ break;
+ case DigitalOceanOperations.unassign:
+ unassignFloatingIP(exchange);
+ break;
+ case DigitalOceanOperations.listActions:
+ getFloatingIPActions(exchange);
+ break;
+ default:
+ throw new IllegalArgumentException("Unsupported operation");
+ }
+ }
+
+ private void createFloatingIp(Exchange exchange) throws Exception {
+ Integer dropletId = exchange.getIn().getHeader(DigitalOceanHeaders.DROPLET_ID, Integer.class);
+ String region = exchange.getIn().getHeader(DigitalOceanHeaders.REGION, String.class);
+ FloatingIP ip;
+
+ if (ObjectHelper.isNotEmpty(dropletId))
+ ip = getEndpoint().getDigitalOceanClient().createFloatingIP(dropletId);
+ else if (ObjectHelper.isNotEmpty(region))
+ ip = getEndpoint().getDigitalOceanClient().createFloatingIP(region);
+ else
+ throw new IllegalArgumentException(DigitalOceanHeaders.DROPLET_ID + " or " + DigitalOceanHeaders.REGION + " must be specified");
+
+ LOG.trace("FloatingIP [{}] ", ip);
+ exchange.getOut().setBody(ip);
+ }
+
+
+ private void getFloatingIPs(Exchange exchange) throws Exception {
+ FloatingIPs ips = getEndpoint().getDigitalOceanClient().getAvailableFloatingIPs(configuration.getPage(), configuration.getPerPage());
+ LOG.trace("All Floating IPs : page {} / {} per page [{}] ", configuration.getPage(), configuration.getPerPage(), ips.getFloatingIPs());
+ exchange.getOut().setBody(ips.getFloatingIPs());
+ }
+
+
+ private void getFloatingIP(Exchange exchange) throws Exception {
+ String ipAddress = exchange.getIn().getHeader(DigitalOceanHeaders.FLOATING_IP_ADDRESS, String.class);
+
+ if (ObjectHelper.isEmpty(ipAddress))
+ throw new IllegalArgumentException(DigitalOceanHeaders.FLOATING_IP_ADDRESS + " must be specified");
+
+
+ FloatingIP ip = getEndpoint().getDigitalOceanClient().getFloatingIPInfo(ipAddress);
+ LOG.trace("Floating IP {} ", ip);
+ exchange.getOut().setBody(ip);
+ }
+
+
+ private void deleteFloatingIP(Exchange exchange) throws Exception {
+ String ipAddress = exchange.getIn().getHeader(DigitalOceanHeaders.FLOATING_IP_ADDRESS, String.class);
+
+ if (ObjectHelper.isEmpty(ipAddress))
+ throw new IllegalArgumentException(DigitalOceanHeaders.FLOATING_IP_ADDRESS + " must be specified");
+
+
+ Delete delete = getEndpoint().getDigitalOceanClient().deleteFloatingIP(ipAddress);
+ LOG.trace("Delete Floating IP {} ", delete);
+ exchange.getOut().setBody(delete);
+ }
+
+ private void assignFloatingIPToDroplet(Exchange exchange) throws Exception {
+ Integer dropletId = exchange.getIn().getHeader(DigitalOceanHeaders.DROPLET_ID, Integer.class);
+
+ if(ObjectHelper.isEmpty(dropletId))
+ throw new IllegalArgumentException(DigitalOceanHeaders.DROPLET_ID + " must be specified");
+
+ String ipAddress = exchange.getIn().getHeader(DigitalOceanHeaders.FLOATING_IP_ADDRESS, String.class);
+
+ if (ObjectHelper.isEmpty(ipAddress))
+ throw new IllegalArgumentException(DigitalOceanHeaders.FLOATING_IP_ADDRESS + " must be specified");
+
+ Action action = getEndpoint().getDigitalOceanClient().assignFloatingIP(dropletId, ipAddress);
+ LOG.trace("Assign Floating IP to Droplet {} ", action);
+ exchange.getOut().setBody(action);
+ }
+
+ private void unassignFloatingIP(Exchange exchange) throws Exception {
+ String ipAddress = exchange.getIn().getHeader(DigitalOceanHeaders.FLOATING_IP_ADDRESS, String.class);
+
+ if (ObjectHelper.isEmpty(ipAddress))
+ throw new IllegalArgumentException(DigitalOceanHeaders.FLOATING_IP_ADDRESS + " must be specified");
+
+ Action action = getEndpoint().getDigitalOceanClient().unassignFloatingIP(ipAddress);
+ LOG.trace("Unassign Floating IP {} ", action);
+ exchange.getOut().setBody(action);
+ }
+
+ private void getFloatingIPActions(Exchange exchange) throws Exception {
+ String ipAddress = exchange.getIn().getHeader(DigitalOceanHeaders.FLOATING_IP_ADDRESS, String.class);
+
+ if (ObjectHelper.isEmpty(ipAddress))
+ throw new IllegalArgumentException(DigitalOceanHeaders.FLOATING_IP_ADDRESS + " must be specified");
+
+ Actions actions = getEndpoint().getDigitalOceanClient().getAvailableFloatingIPActions(ipAddress, configuration.getPage(), configuration.getPerPage());
+ LOG.trace("Actions for FloatingIP {} : page {} / {} per page [{}] ", ipAddress, configuration.getPage(), configuration.getPerPage(), actions.getActions());
+ exchange.getOut().setBody(actions.getActions());
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/17d527d1/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/producer/DigitalOceanImagesProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/producer/DigitalOceanImagesProducer.java b/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/producer/DigitalOceanImagesProducer.java
new file mode 100644
index 0000000..a8c98cc
--- /dev/null
+++ b/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/producer/DigitalOceanImagesProducer.java
@@ -0,0 +1,176 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.digitalocean.producer;
+
+import com.myjeeva.digitalocean.common.ActionType;
+import com.myjeeva.digitalocean.pojo.*;
+import org.apache.camel.component.digitalocean.DigitalOceanConfiguration;
+import org.apache.camel.component.digitalocean.constants.DigitalOceanHeaders;
+import org.apache.camel.component.digitalocean.DigitalOceanEndpoint;
+import org.apache.camel.component.digitalocean.constants.DigitalOceanImageTypes;
+import org.apache.camel.Exchange;
+import org.apache.camel.component.digitalocean.constants.DigitalOceanOperations;
+import org.apache.camel.util.ObjectHelper;
+
+/**
+ * The DigitalOcean producer for Images API.
+ */
+public class DigitalOceanImagesProducer extends DigitalOceanProducer {
+
+ public DigitalOceanImagesProducer(DigitalOceanEndpoint endpoint, DigitalOceanConfiguration configuration) {
+ super(endpoint, configuration);
+ }
+
+ public void process(Exchange exchange) throws Exception {
+
+ switch(determineOperation(exchange)) {
+
+ case DigitalOceanOperations.list:
+ getImages(exchange);
+ break;
+ case DigitalOceanOperations.ownList:
+ getUserImages(exchange);
+ break;
+ case DigitalOceanOperations.listActions:
+ getImageActions(exchange);
+ break;
+ case DigitalOceanOperations.get:
+ getImage(exchange);
+ break;
+ case DigitalOceanOperations.update:
+ updateImage(exchange);
+ break;
+ case DigitalOceanOperations.delete:
+ deleteImage(exchange);
+ break;
+ case DigitalOceanOperations.transfer:
+ transferImage(exchange);
+ break;
+ case DigitalOceanOperations.convert:
+ convertImageToSnapshot(exchange);
+ break;
+ default:
+ throw new IllegalArgumentException("Unsupported operation");
+ }
+ }
+
+
+ private void getUserImages(Exchange exchange) throws Exception {
+ Images images = getEndpoint().getDigitalOceanClient().getUserImages(configuration.getPage(), configuration.getPerPage());
+ LOG.trace("User images : page {} / {} per page [{}] ", configuration.getPage(), configuration.getPerPage(), images.getImages());
+ exchange.getOut().setBody(images.getImages());
+ }
+
+
+ private void getImages(Exchange exchange) throws Exception {
+ DigitalOceanImageTypes type = exchange.getIn().getHeader(DigitalOceanHeaders.TYPE, DigitalOceanImageTypes.class);
+ Images images;
+
+ if (ObjectHelper.isNotEmpty(type))
+ images = getEndpoint().getDigitalOceanClient().getAvailableImages(configuration.getPage(), configuration.getPerPage(), ActionType.valueOf(type.name()));
+ else
+ images = getEndpoint().getDigitalOceanClient().getAvailableImages(configuration.getPage(), configuration.getPerPage());
+ LOG.trace("All Images : page {} / {} per page [{}] ", configuration.getPage(), configuration.getPerPage(), images.getImages());
+ exchange.getOut().setBody(images.getImages());
+ }
+
+ private void getImage(Exchange exchange) throws Exception {
+
+ Integer imageId = exchange.getIn().getHeader(DigitalOceanHeaders.ID, Integer.class);
+ String slug = exchange.getIn().getHeader(DigitalOceanHeaders.DROPLET_IMAGE, String.class);
+ Image image;
+
+ if (ObjectHelper.isNotEmpty(imageId))
+ image = getEndpoint().getDigitalOceanClient().getImageInfo(imageId);
+ else if (ObjectHelper.isNotEmpty(slug))
+ image = getEndpoint().getDigitalOceanClient().getImageInfo(slug);
+ else
+ throw new IllegalArgumentException(DigitalOceanHeaders.ID + " or " + DigitalOceanHeaders.DROPLET_IMAGE + " must be specified");
+
+ LOG.trace("Image [{}] ", image);
+ exchange.getOut().setBody(image);
+ }
+
+
+ private void getImageActions(Exchange exchange) throws Exception {
+ Integer imageId = exchange.getIn().getHeader(DigitalOceanHeaders.ID, Integer.class);
+
+ if (ObjectHelper.isEmpty(imageId))
+ throw new IllegalArgumentException(DigitalOceanHeaders.ID + " must be specified");
+
+ Actions actions = getEndpoint().getDigitalOceanClient().getAvailableImageActions(imageId, configuration.getPage(), configuration.getPerPage());
+ LOG.trace("Actions for Image {} : page {} / {} per page [{}] ", imageId, configuration.getPage(), configuration.getPerPage(), actions.getActions());
+ exchange.getOut().setBody(actions.getActions());
+ }
+
+ private void updateImage(Exchange exchange) throws Exception {
+ Integer imageId = exchange.getIn().getHeader(DigitalOceanHeaders.ID, Integer.class);
+
+ if (ObjectHelper.isEmpty(imageId))
+ throw new IllegalArgumentException(DigitalOceanHeaders.ID + " must be specified");
+
+ String name = exchange.getIn().getHeader(DigitalOceanHeaders.NAME, String.class);
+
+ if (ObjectHelper.isEmpty(name))
+ throw new IllegalArgumentException(DigitalOceanHeaders.NAME + " must be specified");
+
+ Image image = new Image();
+ image.setId(imageId);
+ image.setName(name);
+ image = getEndpoint().getDigitalOceanClient().updateImage(image);
+ LOG.trace("Update Image {} [{}] ", imageId, image);
+ exchange.getOut().setBody(image);
+ }
+
+ private void deleteImage(Exchange exchange) throws Exception {
+ Integer imageId = exchange.getIn().getHeader(DigitalOceanHeaders.ID, Integer.class);
+
+ if (ObjectHelper.isEmpty(imageId))
+ throw new IllegalArgumentException(DigitalOceanHeaders.ID + " must be specified");
+
+ Delete delete = getEndpoint().getDigitalOceanClient().deleteImage(imageId);
+ LOG.trace("Delete Image {} [{}] ", imageId, delete);
+ exchange.getOut().setBody(delete);
+ }
+
+ private void transferImage(Exchange exchange) throws Exception {
+ Integer imageId = exchange.getIn().getHeader(DigitalOceanHeaders.ID, Integer.class);
+
+ if (ObjectHelper.isEmpty(imageId))
+ throw new IllegalArgumentException(DigitalOceanHeaders.ID + " must be specified");
+
+ String region = exchange.getIn().getHeader(DigitalOceanHeaders.REGION, String.class);
+
+ if (ObjectHelper.isEmpty(region))
+ throw new IllegalArgumentException(DigitalOceanHeaders.REGION + " must be specified");
+
+ Action action = getEndpoint().getDigitalOceanClient().transferImage(imageId, region);
+ LOG.trace("Transfer Image {} to Region {} [{}] ", imageId, region, action);
+ exchange.getOut().setBody(action);
+ }
+
+ private void convertImageToSnapshot(Exchange exchange) throws Exception {
+ Integer imageId = exchange.getIn().getHeader(DigitalOceanHeaders.ID, Integer.class);
+
+ if (ObjectHelper.isEmpty(imageId))
+ throw new IllegalArgumentException(DigitalOceanHeaders.ID + " must be specified");
+
+ Action action = getEndpoint().getDigitalOceanClient().convertImage(imageId);
+ LOG.trace("Convert Image {} [{}] ", imageId, action);
+ exchange.getOut().setBody(action);
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/17d527d1/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/producer/DigitalOceanKeysProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/producer/DigitalOceanKeysProducer.java b/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/producer/DigitalOceanKeysProducer.java
new file mode 100644
index 0000000..3dec39b
--- /dev/null
+++ b/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/producer/DigitalOceanKeysProducer.java
@@ -0,0 +1,144 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.digitalocean.producer;
+
+import com.myjeeva.digitalocean.pojo.*;
+import org.apache.camel.component.digitalocean.DigitalOceanConfiguration;
+import org.apache.camel.component.digitalocean.constants.DigitalOceanHeaders;
+import org.apache.camel.component.digitalocean.DigitalOceanEndpoint;
+import org.apache.camel.Exchange;
+import org.apache.camel.util.ObjectHelper;
+
+/**
+ * The DigitalOcean producer for SSH Keys API.
+ */
+public class DigitalOceanKeysProducer extends DigitalOceanProducer {
+
+ public DigitalOceanKeysProducer(DigitalOceanEndpoint endpoint, DigitalOceanConfiguration configuration) {
+ super(endpoint, configuration);
+ }
+
+ public void process(Exchange exchange) throws Exception {
+
+ switch(determineOperation(exchange)) {
+
+ case list:
+ getKeys(exchange);
+ break;
+ case create:
+ createKey(exchange);
+ break;
+ case get:
+ getKey(exchange);
+ break;
+ case update:
+ updateKey(exchange);
+ break;
+ case delete:
+ deleteKey(exchange);
+ break;
+ default:
+ throw new IllegalArgumentException("Unsupported operation");
+ }
+ }
+
+
+ private void getKey(Exchange exchange) throws Exception {
+ Integer keyId = exchange.getIn().getHeader(DigitalOceanHeaders.ID, Integer.class);
+ String fingerprint = exchange.getIn().getHeader(DigitalOceanHeaders.KEY_FINGERPRINT, String.class);
+ Key key;
+
+ if (ObjectHelper.isNotEmpty(keyId))
+ key = getEndpoint().getDigitalOceanClient().getKeyInfo(keyId);
+ else if (ObjectHelper.isNotEmpty(fingerprint))
+ key = getEndpoint().getDigitalOceanClient().getKeyInfo(fingerprint);
+ else
+ throw new IllegalArgumentException(DigitalOceanHeaders.ID + " or " + DigitalOceanHeaders.KEY_FINGERPRINT + " must be specified");
+
+ LOG.trace("Key [{}] ", key);
+ exchange.getOut().setBody(key);
+ }
+
+ private void getKeys(Exchange exchange) throws Exception {
+ Keys keys = getEndpoint().getDigitalOceanClient().getAvailableKeys(configuration.getPage());
+ LOG.trace("All Keys : page {} [{}] ", configuration.getPage(), keys.getKeys());
+ exchange.getOut().setBody(keys.getKeys());
+ }
+
+ private void deleteKey(Exchange exchange) throws Exception {
+ Integer keyId = exchange.getIn().getHeader(DigitalOceanHeaders.ID, Integer.class);
+ String fingerprint = exchange.getIn().getHeader(DigitalOceanHeaders.KEY_FINGERPRINT, String.class);
+ Delete delete;
+
+ if (ObjectHelper.isNotEmpty(keyId))
+ delete = getEndpoint().getDigitalOceanClient().deleteKey(keyId);
+ else if (ObjectHelper.isNotEmpty(fingerprint))
+ delete = getEndpoint().getDigitalOceanClient().deleteKey(fingerprint);
+ else
+ throw new IllegalArgumentException(DigitalOceanHeaders.ID + " or " + DigitalOceanHeaders.KEY_FINGERPRINT + " must be specified");
+
+ LOG.trace("Delete Key {} ", delete);
+ exchange.getOut().setBody(delete);
+ }
+
+
+ private void createKey(Exchange exchange) throws Exception {
+ Key key = new Key();
+
+ String name = exchange.getIn().getHeader(DigitalOceanHeaders.NAME, String.class);
+
+ if (ObjectHelper.isEmpty(name))
+ throw new IllegalArgumentException(DigitalOceanHeaders.NAME + " must be specified");
+ else
+ key.setName(name);
+
+ String publicKey = exchange.getIn().getHeader(DigitalOceanHeaders.KEY_PUBLIC_KEY, String.class);
+
+ if (ObjectHelper.isEmpty(publicKey))
+ throw new IllegalArgumentException(DigitalOceanHeaders.KEY_PUBLIC_KEY + " must be specified");
+ else
+ key.setPublicKey(publicKey);
+
+ key = getEndpoint().getDigitalOceanClient().createKey(key);
+ LOG.trace("Key created {} ", key);
+ exchange.getOut().setBody(key);
+
+ }
+
+ private void updateKey(Exchange exchange) throws Exception {
+ Integer keyId = exchange.getIn().getHeader(DigitalOceanHeaders.ID, Integer.class);
+ String fingerprint = exchange.getIn().getHeader(DigitalOceanHeaders.KEY_FINGERPRINT, String.class);
+ Key key;
+
+ String name = exchange.getIn().getHeader(DigitalOceanHeaders.NAME, String.class);
+
+ if (ObjectHelper.isEmpty(name))
+ throw new IllegalArgumentException(DigitalOceanHeaders.NAME + " must be specified");
+
+ if (ObjectHelper.isNotEmpty(keyId))
+ key = getEndpoint().getDigitalOceanClient().updateKey(keyId, name);
+ else if (ObjectHelper.isNotEmpty(fingerprint))
+ key = getEndpoint().getDigitalOceanClient().updateKey(fingerprint, name);
+ else
+ throw new IllegalArgumentException(DigitalOceanHeaders.ID + " or " + DigitalOceanHeaders.KEY_FINGERPRINT + " must be specified");
+
+ LOG.trace("Update Key [{}] ", key);
+ exchange.getOut().setBody(key);
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/17d527d1/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/producer/DigitalOceanProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/producer/DigitalOceanProducer.java b/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/producer/DigitalOceanProducer.java
new file mode 100644
index 0000000..fa35f4a
--- /dev/null
+++ b/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/producer/DigitalOceanProducer.java
@@ -0,0 +1,53 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.digitalocean.producer;
+
+import org.apache.camel.component.digitalocean.DigitalOceanConfiguration;
+import org.apache.camel.component.digitalocean.constants.DigitalOceanHeaders;
+import org.apache.camel.component.digitalocean.DigitalOceanEndpoint;
+import org.apache.camel.component.digitalocean.constants.DigitalOceanOperations;
+import org.apache.camel.Exchange;
+import org.apache.camel.impl.DefaultProducer;
+import org.apache.camel.util.ObjectHelper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * The DigitalOcean producer.
+ */
+public abstract class DigitalOceanProducer extends DefaultProducer {
+ protected static final Logger LOG = LoggerFactory.getLogger(DigitalOceanProducer.class);
+
+ private DigitalOceanEndpoint endpoint;
+ protected DigitalOceanConfiguration configuration;
+
+ public DigitalOceanProducer(DigitalOceanEndpoint endpoint, DigitalOceanConfiguration configuration) {
+ super(endpoint);
+ this.endpoint = endpoint;
+ this.configuration = configuration;
+ }
+
+ protected DigitalOceanOperations determineOperation(Exchange exchange) {
+ DigitalOceanOperations operation = exchange.getIn().getHeader(DigitalOceanHeaders.OPERATION, DigitalOceanOperations.class);
+ return ObjectHelper.isNotEmpty(operation) ? operation : configuration.getOperation();
+ }
+
+ @Override
+ public DigitalOceanEndpoint getEndpoint() {
+ return endpoint;
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/17d527d1/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/producer/DigitalOceanRegionsProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/producer/DigitalOceanRegionsProducer.java b/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/producer/DigitalOceanRegionsProducer.java
new file mode 100644
index 0000000..b03c22f
--- /dev/null
+++ b/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/producer/DigitalOceanRegionsProducer.java
@@ -0,0 +1,39 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.digitalocean.producer;
+
+import com.myjeeva.digitalocean.pojo.*;
+import org.apache.camel.component.digitalocean.DigitalOceanConfiguration;
+import org.apache.camel.component.digitalocean.DigitalOceanEndpoint;
+import org.apache.camel.Exchange;
+
+/**
+ * The DigitalOcean producer for Regions API.
+ */
+public class DigitalOceanRegionsProducer extends DigitalOceanProducer {
+
+ public DigitalOceanRegionsProducer(DigitalOceanEndpoint endpoint, DigitalOceanConfiguration configuration) {
+ super(endpoint, configuration);
+ }
+
+ public void process(Exchange exchange) throws Exception {
+ Regions regions = getEndpoint().getDigitalOceanClient().getAvailableRegions(configuration.getPage());
+ LOG.trace("All Regions : page {} [{}] ", regions.getRegions(), configuration.getPage());
+ exchange.getOut().setBody(regions.getRegions());
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/17d527d1/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/producer/DigitalOceanSizesProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/producer/DigitalOceanSizesProducer.java b/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/producer/DigitalOceanSizesProducer.java
new file mode 100644
index 0000000..668a80a
--- /dev/null
+++ b/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/producer/DigitalOceanSizesProducer.java
@@ -0,0 +1,39 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.digitalocean.producer;
+
+import com.myjeeva.digitalocean.pojo.*;
+import org.apache.camel.component.digitalocean.DigitalOceanConfiguration;
+import org.apache.camel.component.digitalocean.DigitalOceanEndpoint;
+import org.apache.camel.Exchange;
+
+/**
+ * The DigitalOcean producer for Sizes API.
+ */
+public class DigitalOceanSizesProducer extends DigitalOceanProducer {
+
+ public DigitalOceanSizesProducer(DigitalOceanEndpoint endpoint, DigitalOceanConfiguration configuration) {
+ super(endpoint, configuration);
+ }
+
+ public void process(Exchange exchange) throws Exception {
+ Sizes sizes = getEndpoint().getDigitalOceanClient().getAvailableSizes(configuration.getPage());
+ LOG.trace("All Sizes : page {} [{}] ", sizes.getSizes(), configuration.getPage());
+ exchange.getOut().setBody(sizes.getSizes());
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/17d527d1/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/producer/DigitalOceanSnapshotsProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/producer/DigitalOceanSnapshotsProducer.java b/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/producer/DigitalOceanSnapshotsProducer.java
new file mode 100644
index 0000000..fb70703
--- /dev/null
+++ b/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/producer/DigitalOceanSnapshotsProducer.java
@@ -0,0 +1,101 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.digitalocean.producer;
+
+import com.myjeeva.digitalocean.pojo.Delete;
+import com.myjeeva.digitalocean.pojo.Snapshot;
+import com.myjeeva.digitalocean.pojo.Snapshots;
+import org.apache.camel.component.digitalocean.DigitalOceanConfiguration;
+import org.apache.camel.component.digitalocean.DigitalOceanEndpoint;
+import org.apache.camel.component.digitalocean.constants.DigitalOceanHeaders;
+import org.apache.camel.component.digitalocean.constants.DigitalOceanSnapshotTypes;
+import org.apache.camel.Exchange;
+import org.apache.camel.util.ObjectHelper;
+
+/**
+ * The DigitalOcean producer for Snapshots API.
+ */
+public class DigitalOceanSnapshotsProducer extends DigitalOceanProducer {
+
+ public DigitalOceanSnapshotsProducer(DigitalOceanEndpoint endpoint, DigitalOceanConfiguration configuration) {
+ super(endpoint, configuration);
+ }
+
+ public void process(Exchange exchange) throws Exception {
+
+ switch (determineOperation(exchange)) {
+
+ case list:
+ getSnapshots(exchange);
+ break;
+ case get:
+ getSnapshot(exchange);
+ break;
+ case delete:
+ deleteSnapshot(exchange);
+ break;
+
+ default:
+ throw new IllegalArgumentException("Unsupported operation");
+ }
+
+
+ }
+
+
+ private void getSnapshots(Exchange exchange) throws Exception {
+ DigitalOceanSnapshotTypes type = exchange.getIn().getHeader(DigitalOceanHeaders.TYPE, DigitalOceanSnapshotTypes.class);
+ Snapshots snapshots;
+
+ if (ObjectHelper.isNotEmpty(type))
+ if(type == DigitalOceanSnapshotTypes.droplet)
+ snapshots = getEndpoint().getDigitalOceanClient().getAllDropletSnapshots(configuration.getPage(), configuration.getPerPage());
+ else
+ snapshots = getEndpoint().getDigitalOceanClient().getAllVolumeSnapshots(configuration.getPage(), configuration.getPerPage());
+ else
+ snapshots = getEndpoint().getDigitalOceanClient().getAvailableSnapshots(configuration.getPage(), configuration.getPerPage());
+
+ LOG.trace("All Snapshots : page {} / {} per page [{}] ", configuration.getPage(), configuration.getPerPage(), snapshots.getSnapshots());
+ exchange.getOut().setBody(snapshots.getSnapshots());
+ }
+
+ private void getSnapshot(Exchange exchange) throws Exception {
+ String snapshotId = exchange.getIn().getHeader(DigitalOceanHeaders.ID, String.class);
+
+ if (ObjectHelper.isEmpty(snapshotId))
+ throw new IllegalArgumentException(DigitalOceanHeaders.ID + " must be specified");
+
+ Snapshot snapshot = getEndpoint().getDigitalOceanClient().getSnaphotInfo(snapshotId);
+ LOG.trace("Snapshot [{}] ", snapshot);
+ exchange.getOut().setBody(snapshot);
+
+ }
+
+ private void deleteSnapshot(Exchange exchange) throws Exception {
+ String snapshotId = exchange.getIn().getHeader(DigitalOceanHeaders.ID, String.class);
+
+ if (ObjectHelper.isEmpty(snapshotId))
+ throw new IllegalArgumentException(DigitalOceanHeaders.ID + " must be specified");
+
+ Delete delete = getEndpoint().getDigitalOceanClient().deleteSnapshot(snapshotId);
+ LOG.trace("Delete Snapshot [{}] ", delete);
+ exchange.getOut().setBody(delete);
+
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/17d527d1/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/producer/DigitalOceanTagsProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/producer/DigitalOceanTagsProducer.java b/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/producer/DigitalOceanTagsProducer.java
new file mode 100644
index 0000000..00c0cba
--- /dev/null
+++ b/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/producer/DigitalOceanTagsProducer.java
@@ -0,0 +1,115 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.digitalocean.producer;
+
+import com.myjeeva.digitalocean.pojo.*;
+import org.apache.camel.component.digitalocean.DigitalOceanConfiguration;
+import org.apache.camel.component.digitalocean.constants.DigitalOceanHeaders;
+import org.apache.camel.component.digitalocean.DigitalOceanEndpoint;
+import org.apache.camel.Exchange;
+import org.apache.camel.component.digitalocean.constants.DigitalOceanOperations;
+import org.apache.camel.util.ObjectHelper;
+
+/**
+ * The DigitalOcean producer for Tags API.
+ */
+public class DigitalOceanTagsProducer extends DigitalOceanProducer {
+
+ public DigitalOceanTagsProducer(DigitalOceanEndpoint endpoint, DigitalOceanConfiguration configuration) {
+ super(endpoint, configuration);
+ }
+
+ public void process(Exchange exchange) throws Exception {
+ switch(determineOperation(exchange)) {
+
+ case DigitalOceanOperations.list:
+ getTags(exchange);
+ break;
+ case DigitalOceanOperations.create:
+ createTag(exchange);
+ break;
+ case DigitalOceanOperations.get:
+ getTag(exchange);
+ break;
+ case DigitalOceanOperations.delete:
+ deleteTag(exchange);
+ break;
+ case DigitalOceanOperations.update:
+ updateTag(exchange);
+ break;
+ default:
+ throw new IllegalArgumentException("Unsupported operation");
+ }
+
+ }
+
+ private void createTag(Exchange exchange) throws Exception {
+ String name = exchange.getIn().getHeader(DigitalOceanHeaders.NAME, String.class);
+
+ if (ObjectHelper.isEmpty(name))
+ throw new IllegalArgumentException(DigitalOceanHeaders.NAME + " must be specified");
+ Tag tag = getEndpoint().getDigitalOceanClient().createTag(name);
+ LOG.trace("Create Tag [{}] ", tag);
+ exchange.getOut().setBody(tag);
+ }
+
+
+ private void getTag(Exchange exchange) throws Exception {
+ String name = exchange.getIn().getHeader(DigitalOceanHeaders.NAME, String.class);
+
+ if (ObjectHelper.isEmpty(name))
+ throw new IllegalArgumentException(DigitalOceanHeaders.NAME + " must be specified");
+ Tag tag = getEndpoint().getDigitalOceanClient().getTag(name);
+ LOG.trace("Tag [{}] ", tag);
+ exchange.getOut().setBody(tag);
+ }
+
+ private void getTags(Exchange exchange) throws Exception {
+ Tags tags = getEndpoint().getDigitalOceanClient().getAvailableTags(configuration.getPage(), configuration.getPerPage());
+ LOG.trace("All Tags : page {} / {} per page [{}] ", configuration.getPage(), configuration.getPerPage(), tags.getTags());
+ exchange.getOut().setBody(tags.getTags());
+ }
+
+ private void deleteTag(Exchange exchange) throws Exception {
+ String name = exchange.getIn().getHeader(DigitalOceanHeaders.NAME, String.class);
+
+ if (ObjectHelper.isEmpty(name))
+ throw new IllegalArgumentException(DigitalOceanHeaders.NAME + " must be specified");
+ Delete delete = getEndpoint().getDigitalOceanClient().deleteTag(name);
+ LOG.trace("Delete Tag [{}] ", delete);
+ exchange.getOut().setBody(delete);
+ }
+
+ private void updateTag(Exchange exchange) throws Exception {
+ String name = exchange.getIn().getHeader(DigitalOceanHeaders.NAME, String.class);
+
+ if (ObjectHelper.isEmpty(name))
+ throw new IllegalArgumentException(DigitalOceanHeaders.NAME + " must be specified");
+
+
+ String newName = exchange.getIn().getHeader(DigitalOceanHeaders.NEW_NAME, String.class);
+
+ if (ObjectHelper.isEmpty(newName))
+ throw new IllegalArgumentException(DigitalOceanHeaders.NEW_NAME + " must be specified");
+
+ Tag tag = getEndpoint().getDigitalOceanClient().updateTag(name, newName);
+ LOG.trace("Update Tag [{}] ", tag);
+ exchange.getOut().setBody(tag);
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/17d527d1/components/camel-digitalocean/src/test/java/com/viwilo/camel/DigitalOceanClientMock.java
----------------------------------------------------------------------
diff --git a/components/camel-digitalocean/src/test/java/com/viwilo/camel/DigitalOceanClientMock.java b/components/camel-digitalocean/src/test/java/com/viwilo/camel/DigitalOceanClientMock.java
deleted file mode 100644
index 1011fb4..0000000
--- a/components/camel-digitalocean/src/test/java/com/viwilo/camel/DigitalOceanClientMock.java
+++ /dev/null
@@ -1,26 +0,0 @@
-package com.viwilo.camel;
-
-import com.myjeeva.digitalocean.exception.DigitalOceanException;
-import com.myjeeva.digitalocean.exception.RequestUnsuccessfulException;
-import com.myjeeva.digitalocean.impl.DigitalOceanClient;
-import com.myjeeva.digitalocean.pojo.Account;
-
-/**
- * Created by thomas on 17/03/2017.
- */
-public class DigitalOceanClientMock extends DigitalOceanClient {
-
-
-
- public DigitalOceanClientMock() {
- super("token");
- }
-
- @Override
- public Account getAccountInfo() throws DigitalOceanException, RequestUnsuccessfulException {
- Account account = new Account();
- account.setEmail("camel@apache.org");
-
- return account;
- }
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/17d527d1/components/camel-digitalocean/src/test/java/com/viwilo/camel/DigitalOceanComponentTest.java
----------------------------------------------------------------------
diff --git a/components/camel-digitalocean/src/test/java/com/viwilo/camel/DigitalOceanComponentTest.java b/components/camel-digitalocean/src/test/java/com/viwilo/camel/DigitalOceanComponentTest.java
deleted file mode 100644
index b31c430..0000000
--- a/components/camel-digitalocean/src/test/java/com/viwilo/camel/DigitalOceanComponentTest.java
+++ /dev/null
@@ -1,54 +0,0 @@
-package com.viwilo.camel;
-
-import com.myjeeva.digitalocean.impl.DigitalOceanClient;
-import com.myjeeva.digitalocean.pojo.Account;
-import com.viwilo.camel.constants.DigitalOceanHeaders;
-import com.viwilo.camel.constants.DigitalOceanOperations;
-import org.apache.camel.EndpointInject;
-import org.apache.camel.Exchange;
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.impl.JndiRegistry;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.Test;
-
-public class DigitalOceanComponentTest extends CamelTestSupport {
-
-
-
- @Override
- protected RouteBuilder createRouteBuilder() throws Exception {
- return new RouteBuilder() {
- public void configure() {
- from("direct:getAccountInfo")
- .setHeader(DigitalOceanHeaders.OPERATION, constant(DigitalOceanOperations.get))
- .to("digitalocean:account?digitalOceanClient=#digitalOceanClient")
- .to("mock:result");
- }
- };
- }
-
- @EndpointInject(uri = "mock:result")
- protected MockEndpoint mockResultEndpoint;
-
- @Test
- public void testGetAccountInfo() throws Exception {
-
- mockResultEndpoint.expectedMinimumMessageCount(1);
- Exchange exchange = template.request("direct:getAccountInfo", null);
- assertMockEndpointsSatisfied();
- assertIsInstanceOf(Account.class, exchange.getOut().getBody());
- assertEquals(exchange.getIn().getBody(Account.class).getEmail(), "camel@apache.org");
- }
-
-
-
-
- @Override
- protected JndiRegistry createRegistry() throws Exception {
- JndiRegistry registry = super.createRegistry();
- DigitalOceanClient digitalOceanClient = new DigitalOceanClientMock();
- registry.bind("digitalOceanClient", digitalOceanClient);
- return registry;
- }
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/17d527d1/components/camel-digitalocean/src/test/java/com/viwilo/camel/integration/DigitalOceanComponentIntegrationTest.java
----------------------------------------------------------------------
diff --git a/components/camel-digitalocean/src/test/java/com/viwilo/camel/integration/DigitalOceanComponentIntegrationTest.java b/components/camel-digitalocean/src/test/java/com/viwilo/camel/integration/DigitalOceanComponentIntegrationTest.java
deleted file mode 100644
index 7a72086..0000000
--- a/components/camel-digitalocean/src/test/java/com/viwilo/camel/integration/DigitalOceanComponentIntegrationTest.java
+++ /dev/null
@@ -1,323 +0,0 @@
-package com.viwilo.camel.integration;
-
-import com.myjeeva.digitalocean.pojo.*;
-import com.viwilo.camel.constants.DigitalOceanHeaders;
-import com.viwilo.camel.constants.DigitalOceanOperations;
-import org.apache.camel.EndpointInject;
-import org.apache.camel.Exchange;
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.mock.MockEndpoint;
-import org.junit.Ignore;
-import org.junit.Test;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-
-
-//@Ignore("Must be manually tested. Provide your own oAuthToken")
-public class DigitalOceanComponentIntegrationTest extends DigitalOceanTestSupport {
-
- @Override
- protected RouteBuilder createRouteBuilder() throws Exception {
- return new RouteBuilder() {
- public void configure() {
- from("direct:getAccountInfo")
- .setHeader(DigitalOceanHeaders.OPERATION, constant(DigitalOceanOperations.get))
- .to("digitalocean:account?oAuthToken={{oAuthToken}}")
- .to("mock:result");
-
- from("direct:getAccountInfo2")
- .to("digitalocean:account?operation="+DigitalOceanOperations.get+"&oAuthToken={{oAuthToken}}")
- .to("mock:result");
-
- from("direct:getActions")
- .to("digitalocean:actions?operation=list&oAuthToken={{oAuthToken}}&perPage=30")
- .to("mock:result");
-
- from("direct:getActionInfo")
- .setHeader(DigitalOceanHeaders.OPERATION, constant(DigitalOceanOperations.get))
- .setHeader(DigitalOceanHeaders.ID, constant(133459716))
- .to("digitalocean:actions?oAuthToken={{oAuthToken}}")
- .to("mock:result");
-
-
- from("direct:getDroplets")
- .setHeader(DigitalOceanHeaders.OPERATION, constant(DigitalOceanOperations.list))
- .to("digitalocean:droplets?oAuthToken={{oAuthToken}}")
- .to("mock:result");
-
- from("direct:getDroplet")
- .setHeader(DigitalOceanHeaders.ID, constant(5428878))
- .to("digitalocean:droplets?operation=get&oAuthToken={{oAuthToken}}")
- .to("mock:result");
-
- from("direct:getDroplet2")
- .setHeader(DigitalOceanHeaders.OPERATION, constant(DigitalOceanOperations.get))
- .setHeader(DigitalOceanHeaders.ID, constant(5428878))
- .to("digitalocean:droplets?oAuthToken={{oAuthToken}}")
- .to("mock:result");
-
- from("direct:createDroplet")
- .setHeader(DigitalOceanHeaders.OPERATION, constant(DigitalOceanOperations.create))
- .setHeader(DigitalOceanHeaders.NAME, constant("camel-test"))
- .setHeader(DigitalOceanHeaders.REGION, constant("fra1"))
- .setHeader(DigitalOceanHeaders.DROPLET_IMAGE, constant("ubuntu-14-04-x64"))
- .setHeader(DigitalOceanHeaders.DROPLET_SIZE, constant("512mb"))
- .process(e -> {
- Collection<String> tags = new ArrayList<String>();
- tags.add("tag1");
- tags.add("tag2");
- e.getIn().setHeader(DigitalOceanHeaders.DROPLET_TAGS, tags);
-
- })
- .to("digitalocean:droplets?oAuthToken={{oAuthToken}}")
- .to("mock:result");
-
- from("direct:createMultipleDroplets")
- .setHeader(DigitalOceanHeaders.OPERATION, constant(DigitalOceanOperations.create))
- .process(e -> {
- Collection<String> names = new ArrayList<String>();
- names.add("droplet1");
- names.add("droplet2");
- e.getIn().setHeader(DigitalOceanHeaders.NAMES, names);
-
- })
- .setHeader(DigitalOceanHeaders.REGION, constant("fra1"))
- .setHeader(DigitalOceanHeaders.DROPLET_IMAGE, constant("ubuntu-14-04-x64"))
- .setHeader(DigitalOceanHeaders.DROPLET_SIZE, constant("512mb"))
- .process(e -> {
- Collection<String> tags = new ArrayList<String>();
- tags.add("tag1");
- tags.add("tag2");
- e.getIn().setHeader(DigitalOceanHeaders.DROPLET_TAGS, tags);
-
- })
- .to("digitalocean://droplets?oAuthToken={{oAuthToken}}")
- .to("mock:result");
-
- from("direct:getDropletBackups")
- .setHeader(DigitalOceanHeaders.OPERATION, constant(DigitalOceanOperations.listBackups))
- .setHeader(DigitalOceanHeaders.ID, constant(5428878))
- .to("digitalocean://droplets?oAuthToken={{oAuthToken}}")
- .to("mock:result");
-
- from("direct:createTag")
- .setHeader(DigitalOceanHeaders.OPERATION, constant(DigitalOceanOperations.create))
- .setHeader(DigitalOceanHeaders.NAME, constant("tag1"))
- .to("digitalocean://tags?oAuthToken={{oAuthToken}}")
- .to("mock:result");
-
- from("direct:getTags")
- .setHeader(DigitalOceanHeaders.OPERATION, constant(DigitalOceanOperations.list))
- .to("digitalocean://tags?oAuthToken={{oAuthToken}}")
- .to("mock:result");
-
- from("direct:getImages")
- .setHeader(DigitalOceanHeaders.OPERATION, constant(DigitalOceanOperations.list))
- .to("digitalocean://images?oAuthToken={{oAuthToken}}")
- .to("mock:result");
-
- from("direct:getImage")
- .setHeader(DigitalOceanHeaders.OPERATION, constant(DigitalOceanOperations.get))
- .setHeader(DigitalOceanHeaders.DROPLET_IMAGE, constant("ubuntu-14-04-x64"))
- .to("digitalocean://images?oAuthToken={{oAuthToken}}")
- .to("mock:result");
-
- from("direct:getSizes")
- .setHeader(DigitalOceanHeaders.OPERATION, constant(DigitalOceanOperations.list))
- .to("digitalocean://sizes?oAuthToken={{oAuthToken}}")
- .to("mock:result");
-
- from("direct:getSize")
- .setHeader(DigitalOceanHeaders.OPERATION, constant(DigitalOceanOperations.get))
- .setHeader(DigitalOceanHeaders.NAME, constant("512mb"))
- .to("digitalocean://sizes?oAuthToken={{oAuthToken}}")
- .to("mock:result");
-
- from("direct:getRegions")
- .setHeader(DigitalOceanHeaders.OPERATION, constant(DigitalOceanOperations.list))
- .to("digitalocean://regions?oAuthToken={{oAuthToken}}")
- .to("mock:result");
-
- from("direct:getRegion")
- .setHeader(DigitalOceanHeaders.OPERATION, constant(DigitalOceanOperations.get))
- .setHeader(DigitalOceanHeaders.NAME, constant("nyc1"))
- .to("digitalocean://regions?oAuthToken={{oAuthToken}}")
- .to("mock:result");
- }
- };
- }
-
- @EndpointInject(uri = "mock:result")
- protected MockEndpoint mockResultEndpoint;
-
- @Test
- public void testGetAccountInfo() throws Exception {
- mockResultEndpoint.expectedMinimumMessageCount(2);
-
- Exchange exchange = template.request("direct:getAccountInfo", null);
- assertTrue(((Account)exchange.getOut().getBody()).isEmailVerified());
- exchange = template.request("direct:getAccountInfo2", null);
- assertTrue(((Account)exchange.getOut().getBody()).isEmailVerified());
-
- assertMockEndpointsSatisfied();
-
- }
-
- @Test
- public void testGetAllActions() throws Exception {
- mockResultEndpoint.expectedMinimumMessageCount(1);
-
- Exchange exchange = template.request("direct:getActions", null);
-
- assertMockEndpointsSatisfied();
- assertEquals(((List)exchange.getOut().getBody()).size(), 30);
- }
-
- @Test
- public void testGetActionInfo() throws Exception {
- mockResultEndpoint.expectedMinimumMessageCount(1);
-
- Exchange exchange = template.request("direct:getActionInfo", null);
-
- assertMockEndpointsSatisfied();
- assertEquals(((Action)exchange.getOut().getBody()).getId(), new Integer(133459716));
- }
-
-
-
- @Test
- public void testGetDropletInfo() throws Exception {
- mockResultEndpoint.expectedMinimumMessageCount(2);
-
- Exchange exchange = template.request("direct:getDroplet", null);
-
- assertEquals(((Droplet)exchange.getOut().getBody()).getId(), new Integer(5428878));
-
- exchange = template.request("direct:getDroplet2", null);
-
- assertMockEndpointsSatisfied();
- assertEquals(((Droplet)exchange.getOut().getBody()).getId(), new Integer(5428878));
-
- }
-
-
- @Test
- public void testCreateDroplet() throws Exception {
- mockResultEndpoint.expectedMinimumMessageCount(1);
-
- Exchange exchange = template.request("direct:createDroplet", null);
-
- assertMockEndpointsSatisfied();
- Droplet droplet = (Droplet)exchange.getOut().getBody();
-
- assertNotNull(droplet.getId());
- assertEquals(droplet.getRegion().getSlug(), "fra1");
- assertCollectionSize(droplet.getTags(), 2);
-
- }
-
- @Test
- public void testCreateMultipleDroplets() throws Exception {
- mockResultEndpoint.expectedMinimumMessageCount(1);
-
- Exchange exchange = template.request("direct:createMultipleDroplets", null);
-
- assertMockEndpointsSatisfied();
- List<Droplet> droplets = (List<Droplet>)exchange.getOut().getBody();
-
- assertCollectionSize(droplets, 2);
- }
-
-
- @Test
- public void testGetAllDroplets() throws Exception {
- mockResultEndpoint.expectedMinimumMessageCount(1);
-
- Exchange exchange = template.request("direct:getDroplets", null);
-
- assertMockEndpointsSatisfied();
- assertEquals(((List)exchange.getOut().getBody()).size(), 1);
- }
-
- @Test
- public void testGetDropletBackups() throws Exception {
- mockResultEndpoint.expectedMinimumMessageCount(1);
-
- Exchange exchange = template.request("direct:getDropletBackups", null);
-
- assertMockEndpointsSatisfied();
- assertCollectionSize(((List)exchange.getOut().getBody()), 0);
- }
-
- @Test
- public void testCreateTag() throws Exception {
- mockResultEndpoint.expectedMinimumMessageCount(1);
-
- Exchange exchange = template.request("direct:createTag", null);
-
- assertMockEndpointsSatisfied();
- assertEquals(((Tag)exchange.getOut().getBody()).getName(), "tag1");
- }
-
-
- @Test
- public void testGetTags() throws Exception {
- mockResultEndpoint.expectedMinimumMessageCount(1);
-
- Exchange exchange = template.request("direct:getTags", null);
-
- assertMockEndpointsSatisfied();
- assertEquals(((List<Tag>)exchange.getOut().getBody()).get(0).getName(), "tag1");
- }
-
- @Test
- public void getImages() throws Exception {
- mockResultEndpoint.expectedMinimumMessageCount(1);
-
- Exchange exchange = template.request("direct:getImages", null);
-
- assertMockEndpointsSatisfied();
- List<Image> images = (List<Image>)exchange.getOut().getBody();
- assertNotEquals(images.size(), 1);
- }
-
- @Test
- public void getImage() throws Exception {
- mockResultEndpoint.expectedMinimumMessageCount(1);
-
- Exchange exchange = template.request("direct:getImage", null);
-
- assertMockEndpointsSatisfied();
- assertEquals((exchange.getOut().getBody(Image.class)).getSlug(), "ubuntu-14-04-x64");
-
- }
-
- @Test
- public void getSizes() throws Exception {
- mockResultEndpoint.expectedMinimumMessageCount(1);
-
- Exchange exchange = template.request("direct:getSizes", null);
-
- assertMockEndpointsSatisfied();
- List<Size> sizes = (List<Size>)exchange.getOut().getBody();
- System.out.println(sizes);
- assertNotEquals(sizes.size(), 1);
- }
-
-
- @Test
- public void getRegions() throws Exception {
- mockResultEndpoint.expectedMinimumMessageCount(1);
-
- Exchange exchange = template.request("direct:getRegions", null);
-
- assertMockEndpointsSatisfied();
- List<Region> regions = (List<Region>)exchange.getOut().getBody();
- System.out.println(regions);
- assertNotEquals(regions.size(), 1);
- }
-
-
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/17d527d1/components/camel-digitalocean/src/test/java/com/viwilo/camel/integration/DigitalOceanTestSupport.java
----------------------------------------------------------------------
diff --git a/components/camel-digitalocean/src/test/java/com/viwilo/camel/integration/DigitalOceanTestSupport.java b/components/camel-digitalocean/src/test/java/com/viwilo/camel/integration/DigitalOceanTestSupport.java
deleted file mode 100644
index 0e1d4c9..0000000
--- a/components/camel-digitalocean/src/test/java/com/viwilo/camel/integration/DigitalOceanTestSupport.java
+++ /dev/null
@@ -1,42 +0,0 @@
-package com.viwilo.camel.integration;
-
-import java.util.Properties;
-import org.apache.camel.test.junit4.CamelTestSupport;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URL;
-
-/**
- * Created by thomas on 17/03/2017.
- */
-public class DigitalOceanTestSupport extends CamelTestSupport {
-
- protected final Properties properties;
-
- protected DigitalOceanTestSupport() {
- URL url = getClass().getResource("/test-options.properties");
-
- InputStream inStream;
- try {
- inStream = url.openStream();
- } catch (IOException e) {
- e.printStackTrace();
- throw new IllegalAccessError("test-options.properties could not be found");
- }
-
- properties = new Properties();
- try {
- properties.load(inStream);
- } catch (IOException e) {
- e.printStackTrace();
- throw new IllegalAccessError("test-options.properties could not be found");
- }
- }
-
- @Override
- protected Properties useOverridePropertiesWithPropertiesComponent() {
- return properties;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/17d527d1/components/camel-digitalocean/src/test/java/org/apache/camel/component/digitalocean/DigitalOceanClientMock.java
----------------------------------------------------------------------
diff --git a/components/camel-digitalocean/src/test/java/org/apache/camel/component/digitalocean/DigitalOceanClientMock.java b/components/camel-digitalocean/src/test/java/org/apache/camel/component/digitalocean/DigitalOceanClientMock.java
new file mode 100644
index 0000000..2bb8c8b
--- /dev/null
+++ b/components/camel-digitalocean/src/test/java/org/apache/camel/component/digitalocean/DigitalOceanClientMock.java
@@ -0,0 +1,26 @@
+package org.apache.camel.component.digitalocean;
+
+import com.myjeeva.digitalocean.exception.DigitalOceanException;
+import com.myjeeva.digitalocean.exception.RequestUnsuccessfulException;
+import com.myjeeva.digitalocean.impl.DigitalOceanClient;
+import com.myjeeva.digitalocean.pojo.Account;
+
+/**
+ * Created by thomas on 17/03/2017.
+ */
+public class DigitalOceanClientMock extends DigitalOceanClient {
+
+
+
+ public DigitalOceanClientMock() {
+ super("token");
+ }
+
+ @Override
+ public Account getAccountInfo() throws DigitalOceanException, RequestUnsuccessfulException {
+ Account account = new Account();
+ account.setEmail("camel@apache.org");
+
+ return account;
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/17d527d1/components/camel-digitalocean/src/test/java/org/apache/camel/component/digitalocean/DigitalOceanComponentTest.java
----------------------------------------------------------------------
diff --git a/components/camel-digitalocean/src/test/java/org/apache/camel/component/digitalocean/DigitalOceanComponentTest.java b/components/camel-digitalocean/src/test/java/org/apache/camel/component/digitalocean/DigitalOceanComponentTest.java
new file mode 100644
index 0000000..5f0d85d
--- /dev/null
+++ b/components/camel-digitalocean/src/test/java/org/apache/camel/component/digitalocean/DigitalOceanComponentTest.java
@@ -0,0 +1,54 @@
+package org.apache.camel.component.digitalocean;
+
+import com.myjeeva.digitalocean.impl.DigitalOceanClient;
+import com.myjeeva.digitalocean.pojo.Account;
+import org.apache.camel.component.digitalocean.constants.DigitalOceanHeaders;
+import org.apache.camel.component.digitalocean.constants.DigitalOceanOperations;
+import org.apache.camel.EndpointInject;
+import org.apache.camel.Exchange;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.impl.JndiRegistry;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Test;
+
+public class DigitalOceanComponentTest extends CamelTestSupport {
+
+
+
+ @Override
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ public void configure() {
+ from("direct:getAccountInfo")
+ .setHeader(DigitalOceanHeaders.OPERATION, constant(DigitalOceanOperations.get))
+ .to("digitalocean:account?digitalOceanClient=#digitalOceanClient")
+ .to("mock:result");
+ }
+ };
+ }
+
+ @EndpointInject(uri = "mock:result")
+ protected MockEndpoint mockResultEndpoint;
+
+ @Test
+ public void testGetAccountInfo() throws Exception {
+
+ mockResultEndpoint.expectedMinimumMessageCount(1);
+ Exchange exchange = template.request("direct:getAccountInfo", null);
+ assertMockEndpointsSatisfied();
+ assertIsInstanceOf(Account.class, exchange.getOut().getBody());
+ assertEquals(exchange.getIn().getBody(Account.class).getEmail(), "camel@apache.org");
+ }
+
+
+
+
+ @Override
+ protected JndiRegistry createRegistry() throws Exception {
+ JndiRegistry registry = super.createRegistry();
+ DigitalOceanClient digitalOceanClient = new DigitalOceanClientMock();
+ registry.bind("digitalOceanClient", digitalOceanClient);
+ return registry;
+ }
+}
[08/20] camel git commit: Refactor com.viwilo to org.apache.camel
Posted by ac...@apache.org.
http://git-wip-us.apache.org/repos/asf/camel/blob/17d527d1/components/camel-digitalocean/src/test/java/org/apache/camel/component/digitalocean/integration/DigitalOceanComponentIntegrationTest.java
----------------------------------------------------------------------
diff --git a/components/camel-digitalocean/src/test/java/org/apache/camel/component/digitalocean/integration/DigitalOceanComponentIntegrationTest.java b/components/camel-digitalocean/src/test/java/org/apache/camel/component/digitalocean/integration/DigitalOceanComponentIntegrationTest.java
new file mode 100644
index 0000000..e76d516
--- /dev/null
+++ b/components/camel-digitalocean/src/test/java/org/apache/camel/component/digitalocean/integration/DigitalOceanComponentIntegrationTest.java
@@ -0,0 +1,322 @@
+package org.apache.camel.component.digitalocean.integration;
+
+import com.myjeeva.digitalocean.pojo.*;
+import org.apache.camel.component.digitalocean.constants.DigitalOceanHeaders;
+import org.apache.camel.component.digitalocean.constants.DigitalOceanOperations;
+import org.apache.camel.EndpointInject;
+import org.apache.camel.Exchange;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.junit.Test;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+
+//@Ignore("Must be manually tested. Provide your own oAuthToken")
+public class DigitalOceanComponentIntegrationTest extends DigitalOceanTestSupport {
+
+ @Override
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ public void configure() {
+ from("direct:getAccountInfo")
+ .setHeader(DigitalOceanHeaders.OPERATION, constant(DigitalOceanOperations.get))
+ .to("digitalocean:account?oAuthToken={{oAuthToken}}")
+ .to("mock:result");
+
+ from("direct:getAccountInfo2")
+ .to("digitalocean:account?operation="+DigitalOceanOperations.get+"&oAuthToken={{oAuthToken}}")
+ .to("mock:result");
+
+ from("direct:getActions")
+ .to("digitalocean:actions?operation=list&oAuthToken={{oAuthToken}}&perPage=30")
+ .to("mock:result");
+
+ from("direct:getActionInfo")
+ .setHeader(DigitalOceanHeaders.OPERATION, constant(DigitalOceanOperations.get))
+ .setHeader(DigitalOceanHeaders.ID, constant(133459716))
+ .to("digitalocean:actions?oAuthToken={{oAuthToken}}")
+ .to("mock:result");
+
+
+ from("direct:getDroplets")
+ .setHeader(DigitalOceanHeaders.OPERATION, constant(DigitalOceanOperations.list))
+ .to("digitalocean:droplets?oAuthToken={{oAuthToken}}")
+ .to("mock:result");
+
+ from("direct:getDroplet")
+ .setHeader(DigitalOceanHeaders.ID, constant(5428878))
+ .to("digitalocean:droplets?operation=get&oAuthToken={{oAuthToken}}")
+ .to("mock:result");
+
+ from("direct:getDroplet2")
+ .setHeader(DigitalOceanHeaders.OPERATION, constant(DigitalOceanOperations.get))
+ .setHeader(DigitalOceanHeaders.ID, constant(5428878))
+ .to("digitalocean:droplets?oAuthToken={{oAuthToken}}")
+ .to("mock:result");
+
+ from("direct:createDroplet")
+ .setHeader(DigitalOceanHeaders.OPERATION, constant(DigitalOceanOperations.create))
+ .setHeader(DigitalOceanHeaders.NAME, constant("camel-test"))
+ .setHeader(DigitalOceanHeaders.REGION, constant("fra1"))
+ .setHeader(DigitalOceanHeaders.DROPLET_IMAGE, constant("ubuntu-14-04-x64"))
+ .setHeader(DigitalOceanHeaders.DROPLET_SIZE, constant("512mb"))
+ .process(e -> {
+ Collection<String> tags = new ArrayList<String>();
+ tags.add("tag1");
+ tags.add("tag2");
+ e.getIn().setHeader(DigitalOceanHeaders.DROPLET_TAGS, tags);
+
+ })
+ .to("digitalocean:droplets?oAuthToken={{oAuthToken}}")
+ .to("mock:result");
+
+ from("direct:createMultipleDroplets")
+ .setHeader(DigitalOceanHeaders.OPERATION, constant(DigitalOceanOperations.create))
+ .process(e -> {
+ Collection<String> names = new ArrayList<String>();
+ names.add("droplet1");
+ names.add("droplet2");
+ e.getIn().setHeader(DigitalOceanHeaders.NAMES, names);
+
+ })
+ .setHeader(DigitalOceanHeaders.REGION, constant("fra1"))
+ .setHeader(DigitalOceanHeaders.DROPLET_IMAGE, constant("ubuntu-14-04-x64"))
+ .setHeader(DigitalOceanHeaders.DROPLET_SIZE, constant("512mb"))
+ .process(e -> {
+ Collection<String> tags = new ArrayList<String>();
+ tags.add("tag1");
+ tags.add("tag2");
+ e.getIn().setHeader(DigitalOceanHeaders.DROPLET_TAGS, tags);
+
+ })
+ .to("digitalocean://droplets?oAuthToken={{oAuthToken}}")
+ .to("mock:result");
+
+ from("direct:getDropletBackups")
+ .setHeader(DigitalOceanHeaders.OPERATION, constant(DigitalOceanOperations.listBackups))
+ .setHeader(DigitalOceanHeaders.ID, constant(5428878))
+ .to("digitalocean://droplets?oAuthToken={{oAuthToken}}")
+ .to("mock:result");
+
+ from("direct:createTag")
+ .setHeader(DigitalOceanHeaders.OPERATION, constant(DigitalOceanOperations.create))
+ .setHeader(DigitalOceanHeaders.NAME, constant("tag1"))
+ .to("digitalocean://tags?oAuthToken={{oAuthToken}}")
+ .to("mock:result");
+
+ from("direct:getTags")
+ .setHeader(DigitalOceanHeaders.OPERATION, constant(DigitalOceanOperations.list))
+ .to("digitalocean://tags?oAuthToken={{oAuthToken}}")
+ .to("mock:result");
+
+ from("direct:getImages")
+ .setHeader(DigitalOceanHeaders.OPERATION, constant(DigitalOceanOperations.list))
+ .to("digitalocean://images?oAuthToken={{oAuthToken}}")
+ .to("mock:result");
+
+ from("direct:getImage")
+ .setHeader(DigitalOceanHeaders.OPERATION, constant(DigitalOceanOperations.get))
+ .setHeader(DigitalOceanHeaders.DROPLET_IMAGE, constant("ubuntu-14-04-x64"))
+ .to("digitalocean://images?oAuthToken={{oAuthToken}}")
+ .to("mock:result");
+
+ from("direct:getSizes")
+ .setHeader(DigitalOceanHeaders.OPERATION, constant(DigitalOceanOperations.list))
+ .to("digitalocean://sizes?oAuthToken={{oAuthToken}}")
+ .to("mock:result");
+
+ from("direct:getSize")
+ .setHeader(DigitalOceanHeaders.OPERATION, constant(DigitalOceanOperations.get))
+ .setHeader(DigitalOceanHeaders.NAME, constant("512mb"))
+ .to("digitalocean://sizes?oAuthToken={{oAuthToken}}")
+ .to("mock:result");
+
+ from("direct:getRegions")
+ .setHeader(DigitalOceanHeaders.OPERATION, constant(DigitalOceanOperations.list))
+ .to("digitalocean://regions?oAuthToken={{oAuthToken}}")
+ .to("mock:result");
+
+ from("direct:getRegion")
+ .setHeader(DigitalOceanHeaders.OPERATION, constant(DigitalOceanOperations.get))
+ .setHeader(DigitalOceanHeaders.NAME, constant("nyc1"))
+ .to("digitalocean://regions?oAuthToken={{oAuthToken}}")
+ .to("mock:result");
+ }
+ };
+ }
+
+ @EndpointInject(uri = "mock:result")
+ protected MockEndpoint mockResultEndpoint;
+
+ @Test
+ public void testGetAccountInfo() throws Exception {
+ mockResultEndpoint.expectedMinimumMessageCount(2);
+
+ Exchange exchange = template.request("direct:getAccountInfo", null);
+ assertTrue(((Account)exchange.getOut().getBody()).isEmailVerified());
+ exchange = template.request("direct:getAccountInfo2", null);
+ assertTrue(((Account)exchange.getOut().getBody()).isEmailVerified());
+
+ assertMockEndpointsSatisfied();
+
+ }
+
+ @Test
+ public void testGetAllActions() throws Exception {
+ mockResultEndpoint.expectedMinimumMessageCount(1);
+
+ Exchange exchange = template.request("direct:getActions", null);
+
+ assertMockEndpointsSatisfied();
+ assertEquals(((List)exchange.getOut().getBody()).size(), 30);
+ }
+
+ @Test
+ public void testGetActionInfo() throws Exception {
+ mockResultEndpoint.expectedMinimumMessageCount(1);
+
+ Exchange exchange = template.request("direct:getActionInfo", null);
+
+ assertMockEndpointsSatisfied();
+ assertEquals(((Action)exchange.getOut().getBody()).getId(), new Integer(133459716));
+ }
+
+
+
+ @Test
+ public void testGetDropletInfo() throws Exception {
+ mockResultEndpoint.expectedMinimumMessageCount(2);
+
+ Exchange exchange = template.request("direct:getDroplet", null);
+
+ assertEquals(((Droplet)exchange.getOut().getBody()).getId(), new Integer(5428878));
+
+ exchange = template.request("direct:getDroplet2", null);
+
+ assertMockEndpointsSatisfied();
+ assertEquals(((Droplet)exchange.getOut().getBody()).getId(), new Integer(5428878));
+
+ }
+
+
+ @Test
+ public void testCreateDroplet() throws Exception {
+ mockResultEndpoint.expectedMinimumMessageCount(1);
+
+ Exchange exchange = template.request("direct:createDroplet", null);
+
+ assertMockEndpointsSatisfied();
+ Droplet droplet = (Droplet)exchange.getOut().getBody();
+
+ assertNotNull(droplet.getId());
+ assertEquals(droplet.getRegion().getSlug(), "fra1");
+ assertCollectionSize(droplet.getTags(), 2);
+
+ }
+
+ @Test
+ public void testCreateMultipleDroplets() throws Exception {
+ mockResultEndpoint.expectedMinimumMessageCount(1);
+
+ Exchange exchange = template.request("direct:createMultipleDroplets", null);
+
+ assertMockEndpointsSatisfied();
+ List<Droplet> droplets = (List<Droplet>)exchange.getOut().getBody();
+
+ assertCollectionSize(droplets, 2);
+ }
+
+
+ @Test
+ public void testGetAllDroplets() throws Exception {
+ mockResultEndpoint.expectedMinimumMessageCount(1);
+
+ Exchange exchange = template.request("direct:getDroplets", null);
+
+ assertMockEndpointsSatisfied();
+ assertEquals(((List)exchange.getOut().getBody()).size(), 1);
+ }
+
+ @Test
+ public void testGetDropletBackups() throws Exception {
+ mockResultEndpoint.expectedMinimumMessageCount(1);
+
+ Exchange exchange = template.request("direct:getDropletBackups", null);
+
+ assertMockEndpointsSatisfied();
+ assertCollectionSize(((List)exchange.getOut().getBody()), 0);
+ }
+
+ @Test
+ public void testCreateTag() throws Exception {
+ mockResultEndpoint.expectedMinimumMessageCount(1);
+
+ Exchange exchange = template.request("direct:createTag", null);
+
+ assertMockEndpointsSatisfied();
+ assertEquals(((Tag)exchange.getOut().getBody()).getName(), "tag1");
+ }
+
+
+ @Test
+ public void testGetTags() throws Exception {
+ mockResultEndpoint.expectedMinimumMessageCount(1);
+
+ Exchange exchange = template.request("direct:getTags", null);
+
+ assertMockEndpointsSatisfied();
+ assertEquals(((List<Tag>)exchange.getOut().getBody()).get(0).getName(), "tag1");
+ }
+
+ @Test
+ public void getImages() throws Exception {
+ mockResultEndpoint.expectedMinimumMessageCount(1);
+
+ Exchange exchange = template.request("direct:getImages", null);
+
+ assertMockEndpointsSatisfied();
+ List<Image> images = (List<Image>)exchange.getOut().getBody();
+ assertNotEquals(images.size(), 1);
+ }
+
+ @Test
+ public void getImage() throws Exception {
+ mockResultEndpoint.expectedMinimumMessageCount(1);
+
+ Exchange exchange = template.request("direct:getImage", null);
+
+ assertMockEndpointsSatisfied();
+ assertEquals((exchange.getOut().getBody(Image.class)).getSlug(), "ubuntu-14-04-x64");
+
+ }
+
+ @Test
+ public void getSizes() throws Exception {
+ mockResultEndpoint.expectedMinimumMessageCount(1);
+
+ Exchange exchange = template.request("direct:getSizes", null);
+
+ assertMockEndpointsSatisfied();
+ List<Size> sizes = (List<Size>)exchange.getOut().getBody();
+ System.out.println(sizes);
+ assertNotEquals(sizes.size(), 1);
+ }
+
+
+ @Test
+ public void getRegions() throws Exception {
+ mockResultEndpoint.expectedMinimumMessageCount(1);
+
+ Exchange exchange = template.request("direct:getRegions", null);
+
+ assertMockEndpointsSatisfied();
+ List<Region> regions = (List<Region>)exchange.getOut().getBody();
+ System.out.println(regions);
+ assertNotEquals(regions.size(), 1);
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/17d527d1/components/camel-digitalocean/src/test/java/org/apache/camel/component/digitalocean/integration/DigitalOceanTestSupport.java
----------------------------------------------------------------------
diff --git a/components/camel-digitalocean/src/test/java/org/apache/camel/component/digitalocean/integration/DigitalOceanTestSupport.java b/components/camel-digitalocean/src/test/java/org/apache/camel/component/digitalocean/integration/DigitalOceanTestSupport.java
new file mode 100644
index 0000000..3c3ffd8
--- /dev/null
+++ b/components/camel-digitalocean/src/test/java/org/apache/camel/component/digitalocean/integration/DigitalOceanTestSupport.java
@@ -0,0 +1,42 @@
+package org.apache.camel.component.digitalocean.integration;
+
+import java.util.Properties;
+import org.apache.camel.test.junit4.CamelTestSupport;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+
+/**
+ * Created by thomas on 17/03/2017.
+ */
+public class DigitalOceanTestSupport extends CamelTestSupport {
+
+ protected final Properties properties;
+
+ protected DigitalOceanTestSupport() {
+ URL url = getClass().getResource("/test-options.properties");
+
+ InputStream inStream;
+ try {
+ inStream = url.openStream();
+ } catch (IOException e) {
+ e.printStackTrace();
+ throw new IllegalAccessError("test-options.properties could not be found");
+ }
+
+ properties = new Properties();
+ try {
+ properties.load(inStream);
+ } catch (IOException e) {
+ e.printStackTrace();
+ throw new IllegalAccessError("test-options.properties could not be found");
+ }
+ }
+
+ @Override
+ protected Properties useOverridePropertiesWithPropertiesComponent() {
+ return properties;
+ }
+
+}
[17/20] camel git commit: CAMEL-11062: Added camel-digitalocean
starter to kit
Posted by ac...@apache.org.
CAMEL-11062: Added camel-digitalocean starter to kit
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/1142fd46
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/1142fd46
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/1142fd46
Branch: refs/heads/master
Commit: 1142fd46ca218173201babe63c18a3e5e6b06485
Parents: fa9c831
Author: Andrea Cosentino <an...@gmail.com>
Authored: Mon Mar 27 09:41:58 2017 +0200
Committer: Andrea Cosentino <an...@gmail.com>
Committed: Mon Mar 27 09:48:35 2017 +0200
----------------------------------------------------------------------
components/camel-digitalocean/pom.xml | 64 ------
.../digitalocean/DigitalOceanConfiguration.java | 49 +++--
.../camel-digitalocean-starter/pom.xml | 59 ++++++
.../DigitalOceanComponentAutoConfiguration.java | 80 ++++++++
.../src/main/resources/META-INF/LICENSE.txt | 203 +++++++++++++++++++
.../src/main/resources/META-INF/NOTICE.txt | 11 +
...dditional-spring-configuration-metadata.json | 10 +
.../main/resources/META-INF/spring.factories | 19 ++
.../src/main/resources/META-INF/spring.provides | 18 ++
.../spring-boot/components-starter/pom.xml | 1 +
10 files changed, 425 insertions(+), 89 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/1142fd46/components/camel-digitalocean/pom.xml
----------------------------------------------------------------------
diff --git a/components/camel-digitalocean/pom.xml b/components/camel-digitalocean/pom.xml
index e70d5e7..0485072 100644
--- a/components/camel-digitalocean/pom.xml
+++ b/components/camel-digitalocean/pom.xml
@@ -80,68 +80,4 @@ limitations under the License.
<version>1.9.5</version>
</dependency>
</dependencies>
-
- <build>
- <defaultGoal>install</defaultGoal>
-
- <plugins>
-
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <version>3.5.1</version>
- <configuration>
- <source>1.8</source>
- <target>1.8</target>
- </configuration>
- </plugin>
-
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-resources-plugin</artifactId>
- <version>3.0.1</version>
- <configuration>
- <encoding>UTF-8</encoding>
- </configuration>
- </plugin>
-
- <!-- generate components meta-data and validate component includes documentation etc -->
- <plugin>
- <groupId>org.apache.camel</groupId>
- <artifactId>camel-package-maven-plugin</artifactId>
- <version>2.18.3</version>
- <executions>
- <execution>
- <id>prepare</id>
- <goals>
- <goal>prepare-components</goal>
- </goals>
- <phase>generate-resources</phase>
- </execution>
- <execution>
- <id>validate</id>
- <goals>
- <goal>validate-components</goal>
- </goals>
- <phase>prepare-package</phase>
- </execution>
- </executions>
- </plugin>
- <!-- to generate the MANIFEST-FILE of the bundle -->
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <version>3.2.0</version>
- <extensions>true</extensions>
- <configuration>
- <instructions>
- <Bundle-SymbolicName>com.viwilo.camel.camel-digitalocean</Bundle-SymbolicName>
- <Export-Service>org.apache.camel.spi.ComponentResolver;component=digitalocean</Export-Service>
- </instructions>
- </configuration>
- </plugin>
-
- </plugins>
- </build>
-
</project>
http://git-wip-us.apache.org/repos/asf/camel/blob/1142fd46/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/DigitalOceanConfiguration.java
----------------------------------------------------------------------
diff --git a/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/DigitalOceanConfiguration.java b/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/DigitalOceanConfiguration.java
index 90b9dac..848b886 100644
--- a/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/DigitalOceanConfiguration.java
+++ b/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/DigitalOceanConfiguration.java
@@ -72,13 +72,13 @@ public class DigitalOceanConfiguration {
this.resource = resource;
}
- /**
- * The operation to perform to the given resource.
- */
public DigitalOceanOperations getOperation() {
return operation;
}
+ /**
+ * The operation to perform to the given resource.
+ */
public void setOperation(DigitalOceanOperations operation) {
this.operation = operation;
}
@@ -94,80 +94,79 @@ public class DigitalOceanConfiguration {
this.oAuthToken = oAuthToken;
}
- /**
- * Use for pagination. Set the number of item per request. The maximum number of results per page is 200.
- */
public Integer getPerPage() {
return perPage;
}
+ /**
+ * Use for pagination. Set the number of item per request. The maximum number of results per page is 200.
+ */
public void setPerPage(Integer perPage) {
this.perPage = perPage;
}
- /**
- * Use for paginsation. Force the page number.
- */
public Integer getPage() {
return page;
}
+ /**
+ * Use for pagination. Force the page number.
+ */
public void setPage(Integer page) {
this.page = page;
}
- /**
- * Set a proxy host if needed
- */
public String getHttpProxyHost() {
return httpProxyHost;
}
+ /**
+ * Set a proxy host if needed
+ */
public void setHttpProxyHost(String httpProxyHost) {
this.httpProxyHost = httpProxyHost;
}
- /**
- * Set a proxy user if needed
- */
public String getHttpProxyUser() {
return httpProxyUser;
}
+ /**
+ * Set a proxy host if needed
+ */
public void setHttpProxyUser(String httpProxyUser) {
this.httpProxyUser = httpProxyUser;
}
- /**
- * Set a proxy password if needed
- */
public String getHttpProxyPassword() {
return httpProxyPassword;
}
+ /**
+ * Set a proxy password if needed
+ */
public void setHttpProxyPassword(String httpProxyPassword) {
this.httpProxyPassword = httpProxyPassword;
}
- /**
- * Set a proxy port if needed
- */
public Integer getHttpProxyPort() {
return httpProxyPort;
}
+ /**
+ * Set a proxy port if needed
+ */
public void setHttpProxyPort(Integer httpProxyPort) {
this.httpProxyPort = httpProxyPort;
}
-
- /**
- * To use a existing configured DigitalOceanClient as client
- */
public DigitalOceanClient getDigitalOceanClient() {
return digitalOceanClient;
}
+ /**
+ * To use a existing configured DigitalOceanClient as client
+ */
public void setDigitalOceanClient(DigitalOceanClient digitalOceanClient) {
this.digitalOceanClient = digitalOceanClient;
}
http://git-wip-us.apache.org/repos/asf/camel/blob/1142fd46/platforms/spring-boot/components-starter/camel-digitalocean-starter/pom.xml
----------------------------------------------------------------------
diff --git a/platforms/spring-boot/components-starter/camel-digitalocean-starter/pom.xml b/platforms/spring-boot/components-starter/camel-digitalocean-starter/pom.xml
new file mode 100644
index 0000000..563bc9d
--- /dev/null
+++ b/platforms/spring-boot/components-starter/camel-digitalocean-starter/pom.xml
@@ -0,0 +1,59 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>components-starter</artifactId>
+ <version>2.19.0-SNAPSHOT</version>
+ </parent>
+ <artifactId>camel-digitalocean-starter</artifactId>
+ <packaging>jar</packaging>
+ <name>Spring-Boot Starter :: Camel :: DigitalOcean</name>
+ <description>Spring-Boot Starter for Camel DigitalOcean support</description>
+ <dependencies>
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter</artifactId>
+ <version>${spring-boot-version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-digitalocean</artifactId>
+ <version>${project.version}</version>
+ <!--START OF GENERATED CODE-->
+ <exclusions>
+ <exclusion>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ </exclusion>
+ </exclusions>
+ <!--END OF GENERATED CODE-->
+ </dependency>
+ <!--START OF GENERATED CODE-->
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-core-starter</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-spring-boot-starter</artifactId>
+ </dependency>
+ <!--END OF GENERATED CODE-->
+ </dependencies>
+</project>
http://git-wip-us.apache.org/repos/asf/camel/blob/1142fd46/platforms/spring-boot/components-starter/camel-digitalocean-starter/src/main/java/org/apache/camel/component/digitalocean/springboot/DigitalOceanComponentAutoConfiguration.java
----------------------------------------------------------------------
diff --git a/platforms/spring-boot/components-starter/camel-digitalocean-starter/src/main/java/org/apache/camel/component/digitalocean/springboot/DigitalOceanComponentAutoConfiguration.java b/platforms/spring-boot/components-starter/camel-digitalocean-starter/src/main/java/org/apache/camel/component/digitalocean/springboot/DigitalOceanComponentAutoConfiguration.java
new file mode 100644
index 0000000..c095a33
--- /dev/null
+++ b/platforms/spring-boot/components-starter/camel-digitalocean-starter/src/main/java/org/apache/camel/component/digitalocean/springboot/DigitalOceanComponentAutoConfiguration.java
@@ -0,0 +1,80 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.digitalocean.springboot;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.component.digitalocean.DigitalOceanComponent;
+import org.springframework.boot.autoconfigure.AutoConfigureAfter;
+import org.springframework.boot.autoconfigure.condition.ConditionMessage;
+import org.springframework.boot.autoconfigure.condition.ConditionOutcome;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
+import org.springframework.boot.autoconfigure.condition.SpringBootCondition;
+import org.springframework.boot.bind.RelaxedPropertyResolver;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.ConditionContext;
+import org.springframework.context.annotation.Conditional;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Lazy;
+import org.springframework.core.type.AnnotatedTypeMetadata;
+
+/**
+ * Generated by camel-package-maven-plugin - do not edit this file!
+ */
+@Configuration
+@ConditionalOnBean(type = "org.apache.camel.spring.boot.CamelAutoConfiguration")
+@Conditional(DigitalOceanComponentAutoConfiguration.Condition.class)
+@AutoConfigureAfter(name = "org.apache.camel.spring.boot.CamelAutoConfiguration")
+public class DigitalOceanComponentAutoConfiguration {
+
+ @Lazy
+ @Bean(name = "digitalocean-component")
+ @ConditionalOnClass(CamelContext.class)
+ @ConditionalOnMissingBean(DigitalOceanComponent.class)
+ public DigitalOceanComponent configureDigitalOceanComponent(
+ CamelContext camelContext) throws Exception {
+ DigitalOceanComponent component = new DigitalOceanComponent();
+ component.setCamelContext(camelContext);
+ return component;
+ }
+
+ public static class Condition extends SpringBootCondition {
+ @Override
+ public ConditionOutcome getMatchOutcome(
+ ConditionContext conditionContext,
+ AnnotatedTypeMetadata annotatedTypeMetadata) {
+ boolean groupEnabled = isEnabled(conditionContext,
+ "camel.component.", true);
+ ConditionMessage.Builder message = ConditionMessage
+ .forCondition("camel.component.digitalocean");
+ if (isEnabled(conditionContext, "camel.component.digitalocean.",
+ groupEnabled)) {
+ return ConditionOutcome.match(message.because("enabled"));
+ }
+ return ConditionOutcome.noMatch(message.because("not enabled"));
+ }
+
+ private boolean isEnabled(
+ org.springframework.context.annotation.ConditionContext context,
+ java.lang.String prefix, boolean defaultValue) {
+ RelaxedPropertyResolver resolver = new RelaxedPropertyResolver(
+ context.getEnvironment(), prefix);
+ return resolver.getProperty("enabled", Boolean.class, defaultValue);
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/camel/blob/1142fd46/platforms/spring-boot/components-starter/camel-digitalocean-starter/src/main/resources/META-INF/LICENSE.txt
----------------------------------------------------------------------
diff --git a/platforms/spring-boot/components-starter/camel-digitalocean-starter/src/main/resources/META-INF/LICENSE.txt b/platforms/spring-boot/components-starter/camel-digitalocean-starter/src/main/resources/META-INF/LICENSE.txt
new file mode 100644
index 0000000..6b0b127
--- /dev/null
+++ b/platforms/spring-boot/components-starter/camel-digitalocean-starter/src/main/resources/META-INF/LICENSE.txt
@@ -0,0 +1,203 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
http://git-wip-us.apache.org/repos/asf/camel/blob/1142fd46/platforms/spring-boot/components-starter/camel-digitalocean-starter/src/main/resources/META-INF/NOTICE.txt
----------------------------------------------------------------------
diff --git a/platforms/spring-boot/components-starter/camel-digitalocean-starter/src/main/resources/META-INF/NOTICE.txt b/platforms/spring-boot/components-starter/camel-digitalocean-starter/src/main/resources/META-INF/NOTICE.txt
new file mode 100644
index 0000000..2e215bf
--- /dev/null
+++ b/platforms/spring-boot/components-starter/camel-digitalocean-starter/src/main/resources/META-INF/NOTICE.txt
@@ -0,0 +1,11 @@
+ =========================================================================
+ == NOTICE file corresponding to the section 4 d of ==
+ == the Apache License, Version 2.0, ==
+ == in this case for the Apache Camel distribution. ==
+ =========================================================================
+
+ This product includes software developed by
+ The Apache Software Foundation (http://www.apache.org/).
+
+ Please read the different LICENSE files present in the licenses directory of
+ this distribution.
http://git-wip-us.apache.org/repos/asf/camel/blob/1142fd46/platforms/spring-boot/components-starter/camel-digitalocean-starter/src/main/resources/META-INF/additional-spring-configuration-metadata.json
----------------------------------------------------------------------
diff --git a/platforms/spring-boot/components-starter/camel-digitalocean-starter/src/main/resources/META-INF/additional-spring-configuration-metadata.json b/platforms/spring-boot/components-starter/camel-digitalocean-starter/src/main/resources/META-INF/additional-spring-configuration-metadata.json
new file mode 100644
index 0000000..bce673b
--- /dev/null
+++ b/platforms/spring-boot/components-starter/camel-digitalocean-starter/src/main/resources/META-INF/additional-spring-configuration-metadata.json
@@ -0,0 +1,10 @@
+{
+ "properties": [
+ {
+ "defaultValue": true,
+ "name": "camel.component.digitalocean.enabled",
+ "description": "Enable digitalocean component",
+ "type": "java.lang.Boolean"
+ }
+ ]
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/camel/blob/1142fd46/platforms/spring-boot/components-starter/camel-digitalocean-starter/src/main/resources/META-INF/spring.factories
----------------------------------------------------------------------
diff --git a/platforms/spring-boot/components-starter/camel-digitalocean-starter/src/main/resources/META-INF/spring.factories b/platforms/spring-boot/components-starter/camel-digitalocean-starter/src/main/resources/META-INF/spring.factories
new file mode 100644
index 0000000..e724e0d
--- /dev/null
+++ b/platforms/spring-boot/components-starter/camel-digitalocean-starter/src/main/resources/META-INF/spring.factories
@@ -0,0 +1,19 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
+org.apache.camel.component.digitalocean.springboot.DigitalOceanComponentAutoConfiguration
http://git-wip-us.apache.org/repos/asf/camel/blob/1142fd46/platforms/spring-boot/components-starter/camel-digitalocean-starter/src/main/resources/META-INF/spring.provides
----------------------------------------------------------------------
diff --git a/platforms/spring-boot/components-starter/camel-digitalocean-starter/src/main/resources/META-INF/spring.provides b/platforms/spring-boot/components-starter/camel-digitalocean-starter/src/main/resources/META-INF/spring.provides
new file mode 100644
index 0000000..7ff425e
--- /dev/null
+++ b/platforms/spring-boot/components-starter/camel-digitalocean-starter/src/main/resources/META-INF/spring.provides
@@ -0,0 +1,18 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+provides: camel-digitalocean
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/camel/blob/1142fd46/platforms/spring-boot/components-starter/pom.xml
----------------------------------------------------------------------
diff --git a/platforms/spring-boot/components-starter/pom.xml b/platforms/spring-boot/components-starter/pom.xml
index a7dd309..ec74327 100644
--- a/platforms/spring-boot/components-starter/pom.xml
+++ b/platforms/spring-boot/components-starter/pom.xml
@@ -114,6 +114,7 @@
<module>camel-csv-starter</module>
<module>camel-cxf-starter</module>
<module>camel-cxf-transport-starter</module>
+ <module>camel-digitalocean-starter</module>
<module>camel-disruptor-starter</module>
<module>camel-dns-starter</module>
<module>camel-docker-starter</module>
[03/20] camel git commit: Add README.md
Posted by ac...@apache.org.
Add README.md
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/f86b289d
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/f86b289d
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/f86b289d
Branch: refs/heads/master
Commit: f86b289d63b1c4ed1c7ecd7f6e7e94f73c458c7a
Parents: 0dd2c2f
Author: Thomas Lehoux <tl...@gmail.com>
Authored: Fri Mar 24 15:55:49 2017 +0100
Committer: Andrea Cosentino <an...@gmail.com>
Committed: Mon Mar 27 09:48:34 2017 +0200
----------------------------------------------------------------------
components/camel-digitalocean/README.md | 254 +++++++++++++++++++++++++++
1 file changed, 254 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/f86b289d/components/camel-digitalocean/README.md
----------------------------------------------------------------------
diff --git a/components/camel-digitalocean/README.md b/components/camel-digitalocean/README.md
new file mode 100644
index 0000000..87771f7
--- /dev/null
+++ b/components/camel-digitalocean/README.md
@@ -0,0 +1,254 @@
+# Camel DigitalOcean Component
+
+The **DigitalOcean** component allows you to manage Droplets and resources within the DigitalOcean cloud with **Camel** by encapsulating [digitalocean-api-java](https://www.digitalocean.com/community/projects/api-client-in-java). All of the functionality that you are familiar with in the DigitalOcean control panel is also available through this Camel component.
+
+
+## Prerequisites
+
+You must have a valid DigitalOcean account and a valid OAuth token. You can generate an OAuth token by visiting the [Apps & API](https://cloud.digitalocean.com/settings/applications) section of the DigitalOcean control panel for your account.
+
+## URI format
+
+The **DigitalOcean Component** uses the following URI format:
+
+```
+digitalocean://endpoint?[options]
+```
+where `endpoint` is a DigitalOcean resource type.
+
+Example : to list your droplets:
+
+```
+digitalocean://droplets?operation=list&oAuthToken=XXXXXX&page=1&perPage=10
+```
+
+The DigitalOcean component only supports producer endpoints so you cannot use this component at the beginning of a route to listen to messages in a channel.
+
+## URI Endpoints
+
+There is one endpoint for each DigitalOcean resources (defined in `DigitalOceanResources` enumeration):
+
+| Endpoint | Description |
+| ------ | ----------- |
+| `account` | Your account on DigitalOcean. |
+| `actions` | Actions are records of events that have occurred on the resources in your account. |
+| `blockStorages` | Block Storage volumes provide expanded storage capacity for your Droplets and can be moved between Droplets within a specific region. |
+| `droplets` | A Droplet is a DigitalOcean virtual machine. |
+| `images` | An image may refer to a snapshot that has been taken of a Droplet instance. It may also mean an image representing an automatic backup of a Droplet. |
+| `snapshots` | Snapshots are saved instances of a Droplet or a volume. |
+| `keys` | DigitalOcean allows you to add SSH public keys to the interface so that you can embed your public key into a Droplet at the time of creation. |
+| `regions` | A region in DigitalOcean represents a datacenter where Droplets can be deployed and images can be transferred. |
+| `sizes` | The sizes objects represent different packages of hardware resources that can be used for Droplets. |
+| `floatingIPs` | Floating IP objects represent a publicly-accessible static IP addresses that can be mapped to one of your Droplets. |
+| `tags` | A Tag is a label that can be applied to a resource (currently only Droplets) in order to better organize or facilitate the lookups and actions on it. |
+
+
+## URI Options
+
+You have to provide the `digitalOceanClient` in the Registry or your `oAuthToken` to access the DigitalOcean service.
+
+| Option | Type | Example | Description |
+| ------ | ---- | ------- | ----------- |
+| `operation` | String | `operation=list` | The operation to perform to the resource. It can also be set with the `CamelDigitalOceanOperation` Message header. |
+| `oAuthToken` | String | | Your DigitalOcean oAuth token. |
+| `digitalOceanClient` | `com.myjeeva.digitalocean.DigitalOcean` | Reference to a `com.myjeeva.digitalocean.DigitalOcean` in the Registry. |
+| `page` | Integer | `page=3` | Can be used for `list` operations, for pagination. Force the page number.|
+| `perPage` | Integer | `perPage=50` | Can be used for `list` operations, for pagiantion. Set the number of item per request. |
+
+
+You have to provide an **operation** value for each endpoint, with the `operation` URI option or the `CamelDigitalOceanOperation` message header.
+
+All **operation** values are defined in `DigitalOceanOperations` enumeration.
+
+All **header** names used by the component are defined in `DigitalOceanHeaders` enumeration.
+
+
+## Message body result
+All message bodies returned are using objects provided by the **digitalocean-api-java** library.
+
+
+## API Rate Limits
+
+
+DigitalOcean REST API encapsulated by camel-digitalocean component is subjected to API Rate Limiting. You can find the per method limits in the [API Rate Limits documentation](https://developers.digitalocean.com/documentation/v2/#rate-limit).
+
+
+## Account endpoint
+
+| operation | Description | Headers | Result |
+| ------ | ---- | ------- | ----------- |
+| `get` | get account info | | `com.myjeeva.digitalocean.pojo.Account` |
+
+
+
+## BlockStorages endpoint
+
+| operation | Description | Headers | Result |
+| ------ | ---- | ------- | ----------- |
+| `list` | list all of the Block Storage volumes available on your account | | `List<com.myjeeva.digitalocean.pojo.Volume>` |
+| `get` | show information about a Block Storage volume| `CamelDigitalOceanId` _Integer_| `com.myjeeva.digitalocean.pojo.Volume` |
+| `get` | show information about a Block Storage volume by name| `CamelDigitalOceanName` _String_ <br>`CamelDigitalOceanRegion` _String_| `com.myjeeva.digitalocean.pojo.Volume` |
+| `listSnapshots` | retrieve the snapshots that have been created from a volume | `CamelDigitalOceanId` _Integer_| `List<com.myjeeva.digitalocean.pojo.Snapshot>` |
+| `create` | create a new volume | `CamelDigitalOceanVolumeSizeGigabytes` _Integer_<br>`CamelDigitalOceanName` _String_<br>`CamelDigitalOceanDescription`* _String_<br>`CamelDigitalOceanRegion`* _String_| `com.myjeeva.digitalocean.pojo.Volume` |
+| `delete` | delete a Block Storage volume, destroying all data and removing it from your account| `CamelDigitalOceanId` _Integer_| `com.myjeeva.digitalocean.pojo.Delete`|
+| `delete` | delete a Block Storage volume by name| `CamelDigitalOceanName` _String_<br>`CamelDigitalOceanRegion` _String_| `com.myjeeva.digitalocean.pojo.Delete`
+| `attach` | attach a Block Storage volume to a Droplet| `CamelDigitalOceanId` _Integer_ <br>`CamelDigitalOceanDropletId` _Integer_<br>`CamelDigitalOceanDropletRegion` _String_| `com.myjeeva.digitalocean.pojo.Action`
+| `attach` | attach a Block Storage volume to a Droplet by name| `CamelDigitalOceanName` _String_<br>`CamelDigitalOceanDropletId` _Integer_<br>`CamelDigitalOceanDropletRegion` _String_| `com.myjeeva.digitalocean.pojo.Action`
+| `detach` | detach a Block Storage volume from a Droplet| `CamelDigitalOceanId` _Integer_ <br>`CamelDigitalOceanDropletId` _Integer_<br>`CamelDigitalOceanDropletRegion` _String_| `com.myjeeva.digitalocean.pojo.Action`
+| `attach` | detach a Block Storage volume from a Droplet by name| `CamelDigitalOceanName` _String_<br>`CamelDigitalOceanDropletId` _Integer_<br>`CamelDigitalOceanDropletRegion` _String_| `com.myjeeva.digitalocean.pojo.Action`
+| `resize` | resize a Block Storage volume | `CamelDigitalOceanVolumeSizeGigabytes` _Integer_<br>`CamelDigitalOceanRegion` _String_| `com.myjeeva.digitalocean.pojo.Action` |
+| `listActions` | retrieve all actions that have been executed on a volume | `CamelDigitalOceanId` _Integer_| `List<com.myjeeva.digitalocean.pojo.Action>` |
+
+## Droplets endpoint
+
+| operation | Description | Headers | Result |
+| ------ | ---- | ------- | ----------- |
+| `list` | list all Droplets in your account | | `List<com.myjeeva.digitalocean.pojo.Droplet>` |
+| `get` | show an individual droplet | `CamelDigitalOceanId` _Integer_| `com.myjeeva.digitalocean.pojo.Droplet` |
+| `create` | create a new Droplet | `CamelDigitalOceanName` _String_ <br>`CamelDigitalOceanDropletImage` _String_ <br>`CamelDigitalOceanRegion` _String_ <br>`CamelDigitalOceanDropletSize` _String_ <br>`CamelDigitalOceanDropletSSHKeys`* _List\<String\>_ <br>`CamelDigitalOceanDropletEnableBackups`* _Boolean_ <br>`CamelDigitalOceanDropletEnableIpv6`* _Boolean_ <br>`CamelDigitalOceanDropletEnablePrivateNetworking`* _Boolean_ <br>`CamelDigitalOceanDropletUserData`* _String_ <br>`CamelDigitalOceanDropletVolumes`* _List\<String\>_ <br>`CamelDigitalOceanDropletTags` _List\<String\>_| `com.myjeeva.digitalocean.pojo.Droplet` |
+| `create` | create multiple Droplets | `CamelDigitalOceanNames` _List\<String\>_ <br>`CamelDigitalOceanDropletImage` _String_ <br>`CamelDigitalOceanRegion` _String_ <br>`CamelDigitalOceanDropletSize` _String_ <br>`CamelDigitalOceanDropletSSHKeys`* _List\<String\>_ <br>`CamelDigitalOceanDropletEnableBackups`* _Boolean_ <br>`CamelDigitalOceanDropletEnableIpv6`* _Boolean_ <br>`CamelDigitalOceanDropletEnablePrivateNetworking`* _Boolean_ <br>`CamelDigitalOceanDropletUserData`* _String_ <br>`CamelDigitalOceanDropletVolumes`* _List\<String\>_ <br>`CamelDigitalOceanDropletTags` _List\<String\>_| `com.myjeeva.digitalocean.pojo.Droplet` |
+| `delete` | delete a Droplet, | `CamelDigitalOceanId` _Integer_| `com.myjeeva.digitalocean.pojo.Delete` |
+| `enableBackups` | enable backups on an existing Droplet | `CamelDigitalOceanId` _Integer_| `com.myjeeva.digitalocean.pojo.Action` |
+| `disableBackups` | disable backups on an existing Droplet | `CamelDigitalOceanId` _Integer_| `com.myjeeva.digitalocean.pojo.Action` |
+| `enableIpv6` | enable IPv6 networking on an existing Droplet | `CamelDigitalOceanId` _Integer_| `com.myjeeva.digitalocean.pojo.Action` |
+| `enablePrivateNetworking` | enable private networking on an existing Droplet | `CamelDigitalOceanId` _Integer_| `com.myjeeva.digitalocean.pojo.Action` |
+| `reboot` | reboot a Droplet | `CamelDigitalOceanId` _Integer_| `com.myjeeva.digitalocean.pojo.Action` |
+| `powerCycle` | power cycle a Droplet | `CamelDigitalOceanId` _Integer_| `com.myjeeva.digitalocean.pojo.Action` |
+| `shutdown` | shutdown a Droplet | `CamelDigitalOceanId` _Integer_| `com.myjeeva.digitalocean.pojo.Action` |
+| `powerOff` | power off a Droplet | `CamelDigitalOceanId` _Integer_| `com.myjeeva.digitalocean.pojo.Action` |
+| `powerOn` | power on a Droplet | `CamelDigitalOceanId` _Integer_| `com.myjeeva.digitalocean.pojo.Action` |
+| `restore` | shutdown a Droplet | `CamelDigitalOceanId` _Integer_ <br>`CamelDigitalOceanImageId` _Integer_| `com.myjeeva.digitalocean.pojo.Action` |
+| `passwordReset` | reset the password for a Droplet | `CamelDigitalOceanId` _Integer_| `com.myjeeva.digitalocean.pojo.Action` |
+| `resize` | resize a Droplet | `CamelDigitalOceanId` _Integer_ <br>`CamelDigitalOceanDropletSize` _String_| `com.myjeeva.digitalocean.pojo.Action` |
+| `rebuild` | rebuild a Droplet | `CamelDigitalOceanId` _Integer_ <br>`CamelDigitalOceanImageId` _Integer_| `com.myjeeva.digitalocean.pojo.Action` |
+| `rename` | rename a Droplet | `CamelDigitalOceanId` _Integer_ <br>`CamelDigitalOceanName` _String_| `com.myjeeva.digitalocean.pojo.Action` |
+| `changeKernel` | change the kernel of a Droplet | `CamelDigitalOceanId` _Integer_ <br>`CamelDigitalOceanKernelId` _Integer_| `com.myjeeva.digitalocean.pojo.Action` |
+| `takeSnapshot` | snapshot a Droplet | `CamelDigitalOceanId` _Integer_ <br>`CamelDigitalOceanName`* _String_| `com.myjeeva.digitalocean.pojo.Action` |
+| `tag` | tag a Droplet | `CamelDigitalOceanId` _Integer_ <br>`CamelDigitalOceanName` _String_| `com.myjeeva.digitalocean.pojo.Response` |
+| `untag` | untag a Droplet | `CamelDigitalOceanId` _Integer_ <br>`CamelDigitalOceanName` _String_| `com.myjeeva.digitalocean.pojo.Response` |
+| `listKernels` | retrieve a list of all kernels available to a Droplet | `CamelDigitalOceanId` _Integer_ | `List<com.myjeeva.digitalocean.pojo.Kernel>` |
+| `listSnapshots` | retrieve the snapshots that have been created from a Droplet | `CamelDigitalOceanId` _Integer_ | `List<com.myjeeva.digitalocean.pojo.Snapshot>` |
+| `listBackups` | retrieve any backups associated with a Droplet | `CamelDigitalOceanId` _Integer_ | `List<com.myjeeva.digitalocean.pojo.Backup>` |
+| `listActions` | retrieve all actions that have been executed on a Droplet | `CamelDigitalOceanId` _Integer_ | `List<com.myjeeva.digitalocean.pojo.Action>` |
+| `listNeighbors` | retrieve a list of droplets that are running on the same physical server | `CamelDigitalOceanId` _Integer_ | `List<com.myjeeva.digitalocean.pojo.Droplet>` |
+| `listAllNeighbors` | retrieve a list of any droplets that are running on the same physical hardware | | `List<com.myjeeva.digitalocean.pojo.Droplet>` |
+
+## Images endpoint
+
+| operation | Description | Headers | Result |
+| ------ | ---- | ------- | ----------- |
+| `list` | list images available on your account | `CamelDigitalOceanType`* _DigitalOceanImageTypes_ | `List<com.myjeeva.digitalocean.pojo.Image>` |
+| `ownList` | retrieve only the private images of a user | | `List<com.myjeeva.digitalocean.pojo.Image>` |
+| `listActions` | retrieve all actions that have been executed on a Image | `CamelDigitalOceanId` _Integer_ | `List<com.myjeeva.digitalocean.pojo.Action>` |
+| `get` | retrieve information about an image (public or private) by id| `CamelDigitalOceanId` _Integer_| `com.myjeeva.digitalocean.pojo.Image` |
+| `get` | retrieve information about an public image by slug| `CamelDigitalOceanDropletImage` _String_| `com.myjeeva.digitalocean.pojo.Image` |
+| `update` | update an image| `CamelDigitalOceanId` _Integer_ <br>`CamelDigitalOceanName` _String_| `com.myjeeva.digitalocean.pojo.Image` |
+| `delete` | delete an image| `CamelDigitalOceanId` _Integer_ | `com.myjeeva.digitalocean.pojo.Delete` |
+| `transfer` | transfer an image to another region| `CamelDigitalOceanId` _Integer_ <br>`CamelDigitalOceanRegion` _String_| `com.myjeeva.digitalocean.pojo.Action` |
+| `convert` | convert an image, for example, a backup to a snapshot| `CamelDigitalOceanId` _Integer_ | `com.myjeeva.digitalocean.pojo.Action` |
+
+## Snapshots endpoint
+
+| operation | Description | Headers | Result |
+| ------ | ---- | ------- | ----------- |
+| `list` | list all of the snapshots available on your account | `CamelDigitalOceanType`* _DigitalOceanSnapshotTypes_ | `List<com.myjeeva.digitalocean.pojo.Snapshot>` |
+| `get` | retrieve information about a snapshot| `CamelDigitalOceanId` _Integer_| `com.myjeeva.digitalocean.pojo.Snapshot` |
+| `delete` | delete an snapshot| `CamelDigitalOceanId` _Integer_ | `com.myjeeva.digitalocean.pojo.Delete` |
+
+
+## Keys endpoint
+
+| operation | Description | Headers | Result |
+| ------ | ---- | ------- | ----------- |
+| `list` | list all of the keys in your account | | `List<com.myjeeva.digitalocean.pojo.Key>` |
+| `get` | retrieve information about a key by id| `CamelDigitalOceanId` _Integer_| `com.myjeeva.digitalocean.pojo.Key` |
+| `get` | retrieve information about a key by fingerprint| `CamelDigitalOceanKeyFingerprint` _String_| `com.myjeeva.digitalocean.pojo.Key` |
+| `update` | update a key by id| `CamelDigitalOceanId` _Integer_ <br>`CamelDigitalOceanName` _String_| `com.myjeeva.digitalocean.pojo.Key` |
+| `update` | update a key by fingerprint| `CamelDigitalOceanKeyFingerprint` _String_ <br>`CamelDigitalOceanName` _String_| `com.myjeeva.digitalocean.pojo.Key` |
+| `delete` | delete a key by id| `CamelDigitalOceanId` _Integer_ | `com.myjeeva.digitalocean.pojo.Delete` |
+| `delete` | delete a key by fingerprint| `CamelDigitalOceanKeyFingerprint` _String_ | `com.myjeeva.digitalocean.pojo.Delete` |
+
+## Regions endpoint
+
+| operation | Description | Headers | Result |
+| ------ | ---- | ------- | ----------- |
+| `list` | list all of the regions that are available | | `List<com.myjeeva.digitalocean.pojo.Region>` |
+
+
+## Sizes endpoint
+
+| operation | Description | Headers | Result |
+| ------ | ---- | ------- | ----------- |
+| `list` | list all of the sizes that are available | | `List<com.myjeeva.digitalocean.pojo.Size>` |
+
+## Floating IPs endpoint
+
+| operation | Description | Headers | Result |
+| ------ | ---- | ------- | ----------- |
+| `list` | list all of the Floating IPs available on your account | | `List<com.myjeeva.digitalocean.pojo.FloatingIP>` |
+| `create` | create a new Floating IP assigned to a Droplet | `CamelDigitalOceanId` _Integer_ | `List<com.myjeeva.digitalocean.pojo.FloatingIP>` |
+| `create` | create a new Floating IP assigned to a Region | `CamelDigitalOceanRegion` _String_ | `List<com.myjeeva.digitalocean.pojo.FloatingIP>` |
+| `get` | retrieve information about a Floating IP| `CamelDigitalOceanFloatingIPAddress` _String_| `com.myjeeva.digitalocean.pojo.Key` |
+| `delete` | delete a Floating IP and remove it from your account| `CamelDigitalOceanFloatingIPAddress` _String_| `com.myjeeva.digitalocean.pojo.Delete` |
+| `assign` | assign a Floating IP to a Droplet| `CamelDigitalOceanFloatingIPAddress` _String_ <br>`CamelDigitalOceanDropletId` _Integer_| `com.myjeeva.digitalocean.pojo.Action` |
+| `unassign` | unassign a Floating IP | `CamelDigitalOceanFloatingIPAddress` _String_ | `com.myjeeva.digitalocean.pojo.Action` |
+| `listActions` | retrieve all actions that have been executed on a Floating IP | `CamelDigitalOceanFloatingIPAddress` _String_ | `List<com.myjeeva.digitalocean.pojo.Action>` |
+
+## Tags endpoint
+
+| operation | Description | Headers | Result |
+| ------ | ---- | ------- | ----------- |
+| `list` | list all of your tags | | `List<com.myjeeva.digitalocean.pojo.Tag>` |
+| `create` | create a Tag | `CamelDigitalOceanName` _String_ | `com.myjeeva.digitalocean.pojo.Tag` |
+| `get` | retrieve an individual tag | `CamelDigitalOceanName` _String_ | `com.myjeeva.digitalocean.pojo.Tag` |
+| `delete` | delete a tag | `CamelDigitalOceanName` _String_ | `com.myjeeva.digitalocean.pojo.Delete` |
+| `update` | update a tag | `CamelDigitalOceanName` _String_ <br>`CamelDigitalOceanNewName` _String_| `com.myjeeva.digitalocean.pojo.Tag` |
+
+
+## Examples
+
+Get your account info
+
+```
+from("direct:getAccountInfo")
+ .setHeader(DigitalOceanConstants.OPERATION, constant(DigitalOceanOperations.get))
+ .to("digitalocean:account?oAuthToken=XXXXXX")
+```
+
+Create a droplet
+
+```
+from("direct:createDroplet")
+ .setHeader(DigitalOceanConstants.OPERATION, constant("create"))
+ .setHeader(DigitalOceanHeaders.NAME, constant("myDroplet"))
+ .setHeader(DigitalOceanHeaders.REGION, constant("fra1"))
+ .setHeader(DigitalOceanHeaders.DROPLET_IMAGE, constant("ubuntu-14-04-x64"))
+ .setHeader(DigitalOceanHeaders.DROPLET_SIZE, constant("512mb"))
+ .to("digitalocean:droplet?oAuthToken=XXXXXX")
+```
+
+List all your droplets
+
+```
+from("direct:getDroplets")
+ .setHeader(DigitalOceanConstants.OPERATION, constant("list"))
+ .to("digitalocean:droplets?oAuthToken=XXXXXX")
+```
+
+Retrieve information for the Droplet (dropletId = 34772987)
+
+```
+from("direct:getDroplet")
+ .setHeader(DigitalOceanConstants.OPERATION, constant("get"))
+ .setHeader(DigitalOceanConstants.ID, 34772987)
+ .to("digitalocean:droplet?oAuthToken=XXXXXX")
+```
+
+Shutdown information for the Droplet (dropletId = 34772987)
+
+```
+from("direct:shutdown")
+ .setHeader(DigitalOceanConstants.ID, 34772987)
+ .to("digitalocean:droplet?operation=shutdown&oAuthToken=XXXXXX")
+```
+
[16/20] camel git commit: Refactor com.viwilo to org.apache.camel
Posted by ac...@apache.org.
Refactor com.viwilo to org.apache.camel
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/6e9d9789
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/6e9d9789
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/6e9d9789
Branch: refs/heads/master
Commit: 6e9d978993013e291577426c25b8611390635d71
Parents: 36971f7
Author: Thomas Lehoux <tl...@gmail.com>
Authored: Fri Mar 24 11:38:52 2017 +0100
Committer: Andrea Cosentino <an...@gmail.com>
Committed: Mon Mar 27 09:48:34 2017 +0200
----------------------------------------------------------------------
.../META-INF/services/org/apache/camel/component/digitalocean | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/6e9d9789/components/camel-digitalocean/src/main/resources/META-INF/services/org/apache/camel/component/digitalocean
----------------------------------------------------------------------
diff --git a/components/camel-digitalocean/src/main/resources/META-INF/services/org/apache/camel/component/digitalocean b/components/camel-digitalocean/src/main/resources/META-INF/services/org/apache/camel/component/digitalocean
index 37b023f..05cf444 100644
--- a/components/camel-digitalocean/src/main/resources/META-INF/services/org/apache/camel/component/digitalocean
+++ b/components/camel-digitalocean/src/main/resources/META-INF/services/org/apache/camel/component/digitalocean
@@ -15,4 +15,4 @@
## limitations under the License.
## ---------------------------------------------------------------------------
-class=com.viwilo.camel.DigitalOceanComponent
+class=org.apache.camel.component.digitalocean.DigitalOceanComponent
[05/20] camel git commit: Fixes reported checkstyle errors.
Posted by ac...@apache.org.
Fixes reported checkstyle errors.
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/0dd2c2f2
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/0dd2c2f2
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/0dd2c2f2
Branch: refs/heads/master
Commit: 0dd2c2f29fc281cbd73b161b111595d45a8e9598
Parents: db910e7
Author: Thomas Lehoux <tl...@gmail.com>
Authored: Fri Mar 24 15:54:46 2017 +0100
Committer: Andrea Cosentino <an...@gmail.com>
Committed: Mon Mar 27 09:48:34 2017 +0200
----------------------------------------------------------------------
components/camel-digitalocean/.gitignore | 5 +
.../digitalocean/DigitalOceanComponent.java | 9 +-
.../digitalocean/DigitalOceanConfiguration.java | 11 +-
.../digitalocean/DigitalOceanEndpoint.java | 99 ++++---
.../constants/DigitalOceanHeaders.java | 62 ++---
.../constants/DigitalOceanResources.java | 1 -
.../producer/DigitalOceanAccountProducer.java | 4 +-
.../producer/DigitalOceanActionsProducer.java | 26 +-
.../DigitalOceanBlockStoragesProducer.java | 148 +++++-----
.../producer/DigitalOceanDropletsProducer.java | 273 +++++++++++--------
.../DigitalOceanFloatingIPsProducer.java | 88 +++---
.../producer/DigitalOceanImagesProducer.java | 103 +++----
.../producer/DigitalOceanKeysProducer.java | 88 +++---
.../producer/DigitalOceanProducer.java | 7 +-
.../producer/DigitalOceanRegionsProducer.java | 4 +-
.../producer/DigitalOceanSizesProducer.java | 4 +-
.../producer/DigitalOceanSnapshotsProducer.java | 42 +--
.../producer/DigitalOceanTagsProducer.java | 62 +++--
.../src/main/resources/log4j2.properties | 13 +-
.../digitalocean/DigitalOceanClientMock.java | 20 +-
.../digitalocean/DigitalOceanComponentTest.java | 33 ++-
.../DigitalOceanComponentIntegrationTest.java | 241 ++++++++--------
.../integration/DigitalOceanTestSupport.java | 26 +-
.../src/test/resources/log4j2.properties | 13 +-
.../src/test/resources/test-options.properties | 1 -
25 files changed, 774 insertions(+), 609 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/0dd2c2f2/components/camel-digitalocean/.gitignore
----------------------------------------------------------------------
diff --git a/components/camel-digitalocean/.gitignore b/components/camel-digitalocean/.gitignore
new file mode 100644
index 0000000..f007cf2
--- /dev/null
+++ b/components/camel-digitalocean/.gitignore
@@ -0,0 +1,5 @@
+*.iml
+.idea/
+overlays/
+target/
+.gitignore
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/camel/blob/0dd2c2f2/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/DigitalOceanComponent.java
----------------------------------------------------------------------
diff --git a/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/DigitalOceanComponent.java b/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/DigitalOceanComponent.java
index 74daca2..8bbb9cc 100644
--- a/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/DigitalOceanComponent.java
+++ b/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/DigitalOceanComponent.java
@@ -18,10 +18,9 @@ package org.apache.camel.component.digitalocean;
import java.util.Map;
-import org.apache.camel.component.digitalocean.constants.DigitalOceanResources;
import org.apache.camel.CamelContext;
import org.apache.camel.Endpoint;
-
+import org.apache.camel.component.digitalocean.constants.DigitalOceanResources;
import org.apache.camel.impl.UriEndpointComponent;
import org.apache.camel.util.ObjectHelper;
import org.slf4j.Logger;
@@ -49,11 +48,11 @@ public class DigitalOceanComponent extends UriEndpointComponent {
setProperties(configuration, parameters);
configuration.setResource(DigitalOceanResources.valueOf(remaining));
- if (ObjectHelper.isEmpty(configuration.getOAuthToken()) && ObjectHelper.isEmpty(configuration.getDigitalOceanClient()))
+ if (ObjectHelper.isEmpty(configuration.getOAuthToken()) && ObjectHelper.isEmpty(configuration.getDigitalOceanClient())) {
throw new DigitalOceanException("oAuthToken or digitalOceanClient must be specified");
+ }
- Endpoint endpoint = new DigitalOceanEndpoint(uri, this, configuration);
- return endpoint;
+ return new DigitalOceanEndpoint(uri, this, configuration);
}
}
http://git-wip-us.apache.org/repos/asf/camel/blob/0dd2c2f2/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/DigitalOceanConfiguration.java
----------------------------------------------------------------------
diff --git a/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/DigitalOceanConfiguration.java b/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/DigitalOceanConfiguration.java
index 895fa89..90b9dac 100644
--- a/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/DigitalOceanConfiguration.java
+++ b/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/DigitalOceanConfiguration.java
@@ -16,9 +16,10 @@
*/
package org.apache.camel.component.digitalocean;
+
import com.myjeeva.digitalocean.impl.DigitalOceanClient;
-import org.apache.camel.component.digitalocean.constants.DigitalOceanResources;
import org.apache.camel.component.digitalocean.constants.DigitalOceanOperations;
+import org.apache.camel.component.digitalocean.constants.DigitalOceanResources;
import org.apache.camel.spi.Metadata;
import org.apache.camel.spi.UriParam;
import org.apache.camel.spi.UriParams;
@@ -32,10 +33,10 @@ public class DigitalOceanConfiguration {
@Metadata(required = "true")
private DigitalOceanResources resource;
- @UriPath(enums = "create,update,delete,list,ownList,get,listBackups,listActions,listNeighbors,listSnapshots,listKernels,listAllNeighbors," +
- "enableBackups,disableBackups,reboot,powerCycle,shutdown,powerOn,powerOff,restore,resetPassword," +
- "resize,rebuild,rename,changeKernel,enableIpv6,enablePrivateNetworking,takeSnapshot,transfer,convert," +
- "attach,detach,assign,unassign,tag,untag")
+ @UriPath(enums = "create,update,delete,list,ownList,get,listBackups,listActions,listNeighbors,listSnapshots,listKernels,listAllNeighbors,"
+ + "enableBackups,disableBackups,reboot,powerCycle,shutdown,powerOn,powerOff,restore,resetPassword,"
+ + "resize,rebuild,rename,changeKernel,enableIpv6,enablePrivateNetworking,takeSnapshot,transfer,convert,"
+ + "attach,detach,assign,unassign,tag,untag")
private DigitalOceanOperations operation;
@UriParam
http://git-wip-us.apache.org/repos/asf/camel/blob/0dd2c2f2/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/DigitalOceanEndpoint.java
----------------------------------------------------------------------
diff --git a/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/DigitalOceanEndpoint.java b/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/DigitalOceanEndpoint.java
index 576e22c..4cf5b15 100644
--- a/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/DigitalOceanEndpoint.java
+++ b/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/DigitalOceanEndpoint.java
@@ -20,7 +20,17 @@ import com.myjeeva.digitalocean.impl.DigitalOceanClient;
import org.apache.camel.Consumer;
import org.apache.camel.Processor;
import org.apache.camel.Producer;
-import org.apache.camel.component.digitalocean.producer.*;
+import org.apache.camel.component.digitalocean.producer.DigitalOceanAccountProducer;
+import org.apache.camel.component.digitalocean.producer.DigitalOceanActionsProducer;
+import org.apache.camel.component.digitalocean.producer.DigitalOceanBlockStoragesProducer;
+import org.apache.camel.component.digitalocean.producer.DigitalOceanDropletsProducer;
+import org.apache.camel.component.digitalocean.producer.DigitalOceanFloatingIPsProducer;
+import org.apache.camel.component.digitalocean.producer.DigitalOceanImagesProducer;
+import org.apache.camel.component.digitalocean.producer.DigitalOceanKeysProducer;
+import org.apache.camel.component.digitalocean.producer.DigitalOceanRegionsProducer;
+import org.apache.camel.component.digitalocean.producer.DigitalOceanSizesProducer;
+import org.apache.camel.component.digitalocean.producer.DigitalOceanSnapshotsProducer;
+import org.apache.camel.component.digitalocean.producer.DigitalOceanTagsProducer;
import org.apache.camel.impl.DefaultEndpoint;
import org.apache.camel.spi.UriEndpoint;
import org.apache.camel.spi.UriParam;
@@ -36,7 +46,7 @@ import org.slf4j.LoggerFactory;
/**
* Represents the DigitalOcean endpoint.
*/
-@UriEndpoint(scheme = "digitalocean", title = "DigitalOcean", syntax="digitalocean:label", producerOnly = true, label = "cloud,management")
+@UriEndpoint(scheme = "digitalocean", title = "DigitalOcean", syntax = "digitalocean:label", producerOnly = true, label = "cloud,management")
public class DigitalOceanEndpoint extends DefaultEndpoint {
private static final transient Logger LOG = LoggerFactory.getLogger(DigitalOceanEndpoint.class);
@@ -55,30 +65,30 @@ public class DigitalOceanEndpoint extends DefaultEndpoint {
LOG.trace("Resolve producer digitalocean endpoint {" + configuration.getResource() + "}");
switch (configuration.getResource()) {
- case account:
- return new DigitalOceanAccountProducer(this, configuration);
- case actions:
- return new DigitalOceanActionsProducer(this, configuration);
- case blockStorages:
- return new DigitalOceanBlockStoragesProducer(this, configuration);
- case droplets:
- return new DigitalOceanDropletsProducer(this, configuration);
- case images:
- return new DigitalOceanImagesProducer(this, configuration);
- case snapshots:
- return new DigitalOceanSnapshotsProducer(this, configuration);
- case keys:
- return new DigitalOceanKeysProducer(this, configuration);
- case regions:
- return new DigitalOceanRegionsProducer(this, configuration);
- case sizes:
- return new DigitalOceanSizesProducer(this, configuration);
- case floatingIPs:
- return new DigitalOceanFloatingIPsProducer(this, configuration);
- case tags:
- return new DigitalOceanTagsProducer(this, configuration);
- default:
- throw new UnsupportedOperationException("Operation specified is not valid for producer");
+ case account:
+ return new DigitalOceanAccountProducer(this, configuration);
+ case actions:
+ return new DigitalOceanActionsProducer(this, configuration);
+ case blockStorages:
+ return new DigitalOceanBlockStoragesProducer(this, configuration);
+ case droplets:
+ return new DigitalOceanDropletsProducer(this, configuration);
+ case images:
+ return new DigitalOceanImagesProducer(this, configuration);
+ case snapshots:
+ return new DigitalOceanSnapshotsProducer(this, configuration);
+ case keys:
+ return new DigitalOceanKeysProducer(this, configuration);
+ case regions:
+ return new DigitalOceanRegionsProducer(this, configuration);
+ case sizes:
+ return new DigitalOceanSizesProducer(this, configuration);
+ case floatingIPs:
+ return new DigitalOceanFloatingIPsProducer(this, configuration);
+ case tags:
+ return new DigitalOceanTagsProducer(this, configuration);
+ default:
+ throw new UnsupportedOperationException("Operation specified is not valid for producer");
}
}
@@ -96,33 +106,36 @@ public class DigitalOceanEndpoint extends DefaultEndpoint {
public void doStart() throws Exception {
super.doStart();
- if(configuration.getDigitalOceanClient() != null)
+ if (configuration.getDigitalOceanClient() != null) {
digitalOceanClient = configuration.getDigitalOceanClient();
- else
- if(configuration.getHttpProxyHost() != null && configuration.getHttpProxyPort() != null) {
+ } else if (configuration.getHttpProxyHost() != null && configuration.getHttpProxyPort() != null) {
- HttpClientBuilder builder = HttpClients.custom()
- .useSystemProperties()
- .setProxy(new HttpHost(configuration.getHttpProxyHost(), configuration.getHttpProxyPort()));
+ HttpClientBuilder builder = HttpClients.custom()
+ .useSystemProperties()
+ .setProxy(new HttpHost(configuration.getHttpProxyHost(), configuration.getHttpProxyPort()));
- if(configuration.getHttpProxyUser() != null && configuration.getHttpProxyPassword() != null) {
- BasicCredentialsProvider credsProvider = new BasicCredentialsProvider();
- credsProvider.setCredentials(
- new AuthScope(configuration.getHttpProxyHost(), configuration.getHttpProxyPort()),
- new UsernamePasswordCredentials(configuration.getHttpProxyUser() , configuration.getHttpProxyPassword()));
- builder.setDefaultCredentialsProvider(credsProvider);
+ if (configuration.getHttpProxyUser() != null && configuration.getHttpProxyPassword() != null) {
+ BasicCredentialsProvider credsProvider = new BasicCredentialsProvider();
+ credsProvider.setCredentials(
+ new AuthScope(configuration.getHttpProxyHost(), configuration.getHttpProxyPort()),
+ new UsernamePasswordCredentials(configuration.getHttpProxyUser(), configuration.getHttpProxyPassword()));
+ builder.setDefaultCredentialsProvider(credsProvider);
- }
+ }
- digitalOceanClient = new DigitalOceanClient("v2", configuration.getOAuthToken(), builder.build());
+ digitalOceanClient = new DigitalOceanClient("v2", configuration.getOAuthToken(), builder.build());
+
+ } else {
+ digitalOceanClient = new DigitalOceanClient(configuration.getOAuthToken());
+ }
- } else
- digitalOceanClient = new DigitalOceanClient(configuration.getOAuthToken());
+ }
+ public DigitalOceanConfiguration getConfiguration() {
+ return configuration;
}
- public DigitalOceanConfiguration getConfiguration() { return configuration; }
public DigitalOceanClient getDigitalOceanClient() {
return digitalOceanClient;
}
http://git-wip-us.apache.org/repos/asf/camel/blob/0dd2c2f2/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/constants/DigitalOceanHeaders.java
----------------------------------------------------------------------
diff --git a/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/constants/DigitalOceanHeaders.java b/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/constants/DigitalOceanHeaders.java
index d4462c2..7950845 100644
--- a/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/constants/DigitalOceanHeaders.java
+++ b/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/constants/DigitalOceanHeaders.java
@@ -18,37 +18,33 @@ package org.apache.camel.component.digitalocean.constants;
public interface DigitalOceanHeaders {
- String OPERATION = "CamelDigitalOceanOperation";
- String ID = "CamelDigitalOceanId";
- String TYPE = "CamelDigitalOceanType";
- String NAME = "CamelDigitalOceanName";
- String NEW_NAME = "CamelDigitalOceanNewName";
- String NAMES = "CamelDigitalOceanNames";
- String REGION = "CamelDigitalOceanRegion";
- String DESCRIPTION = "CamelDigitalOceanDescription";
-
- String DROPLET_SIZE = "CamelDigitalOceanDropletSize";
- String DROPLET_IMAGE = "CamelDigitalOceanDropletImage";
- String DROPLET_KEYS = "CamelDigitalOceanDropletSSHKeys";
- String DROPLET_ENABLE_BACKUPS = "CamelDigitalOceanDropletEnableBackups";
- String DROPLET_ENABLE_IPV6 = "CamelDigitalOceanDropletEnableIpv6";
- String DROPLET_ENABLE_PRIVATE_NETWORKING = "CamelDigitalOceanDropletEnablePrivateNetworking";
- String DROPLET_USER_DATA = "CamelDigitalOceanDropletUserData";
- String DROPLET_VOLUMES = "CamelDigitalOceanDropletVolumes";
- String DROPLET_TAGS = "CamelDigitalOceanDropletTags";
-
- String DROPLET_ID = "CamelDigitalOceanDropletId";
- String IMAGE_ID = "CamelDigitalOceanImageId";
- String KERNEL_ID = "CamelDigitalOceanKernelId";
- String VOLUME_NAME = "CamelDigitalOceanVolumeName";
- String VOLUME_SIZE_GIGABYTES = "CamelDigitalOceanVolumeSizeGigabytes";
-
- String FLOATING_IP_ADDRESS = "CamelDigitalOceanFloatingIPAddress";
-
- String KEY_FINGERPRINT = "CamelDigitalOceanKeyFingerprint";
- String KEY_PUBLIC_KEY = "CamelDigitalOceanKeyPublicKey";
-
-
-
-
+ String OPERATION = "CamelDigitalOceanOperation";
+ String ID = "CamelDigitalOceanId";
+ String TYPE = "CamelDigitalOceanType";
+ String NAME = "CamelDigitalOceanName";
+ String NEW_NAME = "CamelDigitalOceanNewName";
+ String NAMES = "CamelDigitalOceanNames";
+ String REGION = "CamelDigitalOceanRegion";
+ String DESCRIPTION = "CamelDigitalOceanDescription";
+
+ String DROPLET_SIZE = "CamelDigitalOceanDropletSize";
+ String DROPLET_IMAGE = "CamelDigitalOceanDropletImage";
+ String DROPLET_KEYS = "CamelDigitalOceanDropletSSHKeys";
+ String DROPLET_ENABLE_BACKUPS = "CamelDigitalOceanDropletEnableBackups";
+ String DROPLET_ENABLE_IPV6 = "CamelDigitalOceanDropletEnableIpv6";
+ String DROPLET_ENABLE_PRIVATE_NETWORKING = "CamelDigitalOceanDropletEnablePrivateNetworking";
+ String DROPLET_USER_DATA = "CamelDigitalOceanDropletUserData";
+ String DROPLET_VOLUMES = "CamelDigitalOceanDropletVolumes";
+ String DROPLET_TAGS = "CamelDigitalOceanDropletTags";
+
+ String DROPLET_ID = "CamelDigitalOceanDropletId";
+ String IMAGE_ID = "CamelDigitalOceanImageId";
+ String KERNEL_ID = "CamelDigitalOceanKernelId";
+ String VOLUME_NAME = "CamelDigitalOceanVolumeName";
+ String VOLUME_SIZE_GIGABYTES = "CamelDigitalOceanVolumeSizeGigabytes";
+
+ String FLOATING_IP_ADDRESS = "CamelDigitalOceanFloatingIPAddress";
+
+ String KEY_FINGERPRINT = "CamelDigitalOceanKeyFingerprint";
+ String KEY_PUBLIC_KEY = "CamelDigitalOceanKeyPublicKey";
}
http://git-wip-us.apache.org/repos/asf/camel/blob/0dd2c2f2/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/constants/DigitalOceanResources.java
----------------------------------------------------------------------
diff --git a/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/constants/DigitalOceanResources.java b/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/constants/DigitalOceanResources.java
index 8188cb8..f3f9b84 100644
--- a/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/constants/DigitalOceanResources.java
+++ b/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/constants/DigitalOceanResources.java
@@ -32,5 +32,4 @@ public enum DigitalOceanResources {
tags
-
}
http://git-wip-us.apache.org/repos/asf/camel/blob/0dd2c2f2/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/producer/DigitalOceanAccountProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/producer/DigitalOceanAccountProducer.java b/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/producer/DigitalOceanAccountProducer.java
index dddc1a5..f5bb639 100644
--- a/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/producer/DigitalOceanAccountProducer.java
+++ b/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/producer/DigitalOceanAccountProducer.java
@@ -16,10 +16,10 @@
*/
package org.apache.camel.component.digitalocean.producer;
-import com.myjeeva.digitalocean.pojo.*;
+import com.myjeeva.digitalocean.pojo.Account;
+import org.apache.camel.Exchange;
import org.apache.camel.component.digitalocean.DigitalOceanConfiguration;
import org.apache.camel.component.digitalocean.DigitalOceanEndpoint;
-import org.apache.camel.Exchange;
/**
* The DigitalOcean producer for Account API.
http://git-wip-us.apache.org/repos/asf/camel/blob/0dd2c2f2/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/producer/DigitalOceanActionsProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/producer/DigitalOceanActionsProducer.java b/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/producer/DigitalOceanActionsProducer.java
index 67fdd67..ac5050d 100644
--- a/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/producer/DigitalOceanActionsProducer.java
+++ b/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/producer/DigitalOceanActionsProducer.java
@@ -16,11 +16,12 @@
*/
package org.apache.camel.component.digitalocean.producer;
-import com.myjeeva.digitalocean.pojo.*;
+import com.myjeeva.digitalocean.pojo.Action;
+import com.myjeeva.digitalocean.pojo.Actions;
+import org.apache.camel.Exchange;
import org.apache.camel.component.digitalocean.DigitalOceanConfiguration;
import org.apache.camel.component.digitalocean.DigitalOceanEndpoint;
import org.apache.camel.component.digitalocean.constants.DigitalOceanHeaders;
-import org.apache.camel.Exchange;
import org.apache.camel.util.ObjectHelper;
/**
@@ -33,16 +34,16 @@ public class DigitalOceanActionsProducer extends DigitalOceanProducer {
}
public void process(Exchange exchange) throws Exception {
- switch(determineOperation(exchange)) {
+ switch (determineOperation(exchange)) {
- case list:
- getActions(exchange);
- break;
- case get:
- getAction(exchange);
- break;
- default:
- throw new IllegalArgumentException("Unsupported operation");
+ case list:
+ getActions(exchange);
+ break;
+ case get:
+ getAction(exchange);
+ break;
+ default:
+ throw new IllegalArgumentException("Unsupported operation");
}
}
@@ -51,8 +52,9 @@ public class DigitalOceanActionsProducer extends DigitalOceanProducer {
private void getAction(Exchange exchange) throws Exception {
Integer actionId = exchange.getIn().getHeader(DigitalOceanHeaders.ID, Integer.class);
- if (ObjectHelper.isEmpty(actionId))
+ if (ObjectHelper.isEmpty(actionId)) {
throw new IllegalArgumentException(DigitalOceanHeaders.ID + " must be specified");
+ }
Action action = getEndpoint().getDigitalOceanClient().getActionInfo(actionId);
LOG.trace("Action [{}] ", action);
exchange.getOut().setBody(action);
http://git-wip-us.apache.org/repos/asf/camel/blob/0dd2c2f2/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/producer/DigitalOceanBlockStoragesProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/producer/DigitalOceanBlockStoragesProducer.java b/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/producer/DigitalOceanBlockStoragesProducer.java
index 0e00507..f6f9530 100644
--- a/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/producer/DigitalOceanBlockStoragesProducer.java
+++ b/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/producer/DigitalOceanBlockStoragesProducer.java
@@ -16,16 +16,22 @@
*/
package org.apache.camel.component.digitalocean.producer;
-import com.myjeeva.digitalocean.pojo.*;
-import org.apache.camel.component.digitalocean.DigitalOceanConfiguration;
-import org.apache.camel.component.digitalocean.constants.DigitalOceanHeaders;
-import org.apache.camel.component.digitalocean.DigitalOceanEndpoint;
+import java.util.List;
+
+import com.myjeeva.digitalocean.pojo.Action;
+import com.myjeeva.digitalocean.pojo.Actions;
+import com.myjeeva.digitalocean.pojo.Delete;
+import com.myjeeva.digitalocean.pojo.Region;
+import com.myjeeva.digitalocean.pojo.Snapshots;
+import com.myjeeva.digitalocean.pojo.Volume;
+import com.myjeeva.digitalocean.pojo.Volumes;
import org.apache.camel.Exchange;
import org.apache.camel.Message;
+import org.apache.camel.component.digitalocean.DigitalOceanConfiguration;
+import org.apache.camel.component.digitalocean.DigitalOceanEndpoint;
+import org.apache.camel.component.digitalocean.constants.DigitalOceanHeaders;
import org.apache.camel.util.ObjectHelper;
-import java.util.List;
-
/**
* The DigitalOcean producer for BlockStorages API.
*/
@@ -39,42 +45,43 @@ public class DigitalOceanBlockStoragesProducer extends DigitalOceanProducer {
switch (determineOperation(exchange)) {
- case list:
- getVolumes(exchange);
- break;
- case get:
- getVolume(exchange);
- break;
- case listSnapshots:
- getVolumeSnapshots(exchange);
- break;
- case create:
- createVolume(exchange);
- break;
- case delete:
- deleteVolume(exchange);
- break;
- case attach:
- attachVolumeToDroplet(exchange);
- break;
- case detach:
- detachVolumeToDroplet(exchange);
- break;
- case resize:
- resizeVolume(exchange);
- break;
- case listActions:
- getVolumeActions(exchange);
- break;
- default:
- throw new IllegalArgumentException("Unsupported operation");
+ case list:
+ getVolumes(exchange);
+ break;
+ case get:
+ getVolume(exchange);
+ break;
+ case listSnapshots:
+ getVolumeSnapshots(exchange);
+ break;
+ case create:
+ createVolume(exchange);
+ break;
+ case delete:
+ deleteVolume(exchange);
+ break;
+ case attach:
+ attachVolumeToDroplet(exchange);
+ break;
+ case detach:
+ detachVolumeToDroplet(exchange);
+ break;
+ case resize:
+ resizeVolume(exchange);
+ break;
+ case listActions:
+ getVolumeActions(exchange);
+ break;
+ default:
+ throw new IllegalArgumentException("Unsupported operation");
}
}
private void getVolumes(Exchange exchange) throws Exception {
String region = exchange.getIn().getHeader(DigitalOceanHeaders.REGION, String.class);
- if (ObjectHelper.isEmpty(region))
+ if (ObjectHelper.isEmpty(region)) {
throw new IllegalArgumentException(DigitalOceanHeaders.REGION + " must be specified");
+ }
Volumes volumes = getEndpoint().getDigitalOceanClient().getAvailableVolumes(region);
LOG.trace("All Volumes for region {} [{}] ", region, volumes.getVolumes());
@@ -87,25 +94,29 @@ public class DigitalOceanBlockStoragesProducer extends DigitalOceanProducer {
Volume volume = new Volume();
- if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(DigitalOceanHeaders.VOLUME_SIZE_GIGABYTES)))
+ if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(DigitalOceanHeaders.VOLUME_SIZE_GIGABYTES))) {
volume.setSize(in.getHeader(DigitalOceanHeaders.VOLUME_SIZE_GIGABYTES, Double.class));
- else
+ } else {
throw new IllegalArgumentException(DigitalOceanHeaders.VOLUME_SIZE_GIGABYTES + " must be specified");
+ }
- if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(DigitalOceanHeaders.NAME)))
+ if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(DigitalOceanHeaders.NAME))) {
volume.setName(in.getHeader(DigitalOceanHeaders.NAME, String.class));
- else
+ } else {
throw new IllegalArgumentException(DigitalOceanHeaders.NAME + " must be specified");
+ }
- if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(DigitalOceanHeaders.REGION)))
+ if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(DigitalOceanHeaders.REGION))) {
volume.setRegion(new Region(in.getHeader(DigitalOceanHeaders.REGION, String.class)));
- else
+ } else {
throw new IllegalArgumentException(DigitalOceanHeaders.REGION + " must be specified");
+ }
- if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(DigitalOceanHeaders.DESCRIPTION)))
+ if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(DigitalOceanHeaders.DESCRIPTION))) {
volume.setDescription(in.getHeader(DigitalOceanHeaders.DESCRIPTION, String.class));
- else
+ } else {
throw new IllegalArgumentException(DigitalOceanHeaders.DESCRIPTION + " must be specified");
+ }
volume = getEndpoint().getDigitalOceanClient().createVolume(volume);
LOG.trace("Volume created {} ", volume);
@@ -119,14 +130,17 @@ public class DigitalOceanBlockStoragesProducer extends DigitalOceanProducer {
String name = exchange.getIn().getHeader(DigitalOceanHeaders.NAME, String.class);
String region = exchange.getIn().getHeader(DigitalOceanHeaders.REGION, String.class);
- if (ObjectHelper.isEmpty(name) && ObjectHelper.isEmpty(region))
+ if (ObjectHelper.isEmpty(name) && ObjectHelper.isEmpty(region)) {
throw new IllegalArgumentException(DigitalOceanHeaders.ID + " or " + DigitalOceanHeaders.NAME + " and " + DigitalOceanHeaders.REGION + " must be specified");
+ }
List<Volume> volumes = getEndpoint().getDigitalOceanClient().getVolumeInfo(name, region).getVolumes();
- if (volumes.size() > 0)
+ if (volumes.size() > 0) {
volume = volumes.get(1);
- } else
+ }
+ } else {
volume = getEndpoint().getDigitalOceanClient().getVolumeInfo(volumeId);
+ }
LOG.trace("Volume [{}] ", volume);
exchange.getOut().setBody(volume);
@@ -135,8 +149,9 @@ public class DigitalOceanBlockStoragesProducer extends DigitalOceanProducer {
private void getVolumeSnapshots(Exchange exchange) throws Exception {
String volumeId = exchange.getIn().getHeader(DigitalOceanHeaders.ID, String.class);
- if (ObjectHelper.isEmpty(volumeId))
+ if (ObjectHelper.isEmpty(volumeId)) {
throw new IllegalArgumentException(DigitalOceanHeaders.ID + " must be specified");
+ }
Snapshots snapshots = getEndpoint().getDigitalOceanClient().getVolumeSnapshots(volumeId, configuration.getPage(), configuration.getPerPage());
LOG.trace("All Snapshots for volume {} [{}] ", volumeId, snapshots.getSnapshots());
@@ -150,13 +165,15 @@ public class DigitalOceanBlockStoragesProducer extends DigitalOceanProducer {
String name = exchange.getIn().getHeader(DigitalOceanHeaders.NAME, String.class);
String region = exchange.getIn().getHeader(DigitalOceanHeaders.REGION, String.class);
- if (ObjectHelper.isEmpty(name) && ObjectHelper.isEmpty(region))
+ if (ObjectHelper.isEmpty(name) && ObjectHelper.isEmpty(region)) {
throw new IllegalArgumentException(DigitalOceanHeaders.ID + " or " + DigitalOceanHeaders.NAME + " and " + DigitalOceanHeaders.REGION + " must be specified");
+ }
delete = getEndpoint().getDigitalOceanClient().deleteVolume(name, region);
- } else
+ } else {
delete = getEndpoint().getDigitalOceanClient().deleteVolume(volumeId);
+ }
LOG.trace("Delete Volume [{}] ", delete);
exchange.getOut().setBody(delete);
@@ -169,11 +186,13 @@ public class DigitalOceanBlockStoragesProducer extends DigitalOceanProducer {
Integer dropletId = exchange.getIn().getHeader(DigitalOceanHeaders.DROPLET_ID, Integer.class);
String region = exchange.getIn().getHeader(DigitalOceanHeaders.REGION, String.class);
- if (ObjectHelper.isEmpty(dropletId))
+ if (ObjectHelper.isEmpty(dropletId)) {
throw new IllegalArgumentException(DigitalOceanHeaders.DROPLET_ID + " must be specified");
+ }
- if (ObjectHelper.isEmpty(region))
+ if (ObjectHelper.isEmpty(region)) {
throw new IllegalArgumentException(DigitalOceanHeaders.REGION + " must be specified");
+ }
Action action;
@@ -183,25 +202,27 @@ public class DigitalOceanBlockStoragesProducer extends DigitalOceanProducer {
} else if (ObjectHelper.isNotEmpty(volumeId)) {
action = getEndpoint().getDigitalOceanClient().attachVolume(dropletId, volumeId, region);
LOG.trace("Attach Volume {} to Droplet {} [{}] ", volumeId, dropletId, action);
- } else
+ } else {
throw new IllegalArgumentException(DigitalOceanHeaders.ID + " or " + DigitalOceanHeaders.VOLUME_NAME + " must be specified");
+ }
exchange.getOut().setBody(action);
}
-
private void detachVolumeToDroplet(Exchange exchange) throws Exception {
String volumeId = exchange.getIn().getHeader(DigitalOceanHeaders.ID, String.class);
String volumeName = exchange.getIn().getHeader(DigitalOceanHeaders.VOLUME_NAME, String.class);
Integer dropletId = exchange.getIn().getHeader(DigitalOceanHeaders.DROPLET_ID, Integer.class);
String region = exchange.getIn().getHeader(DigitalOceanHeaders.REGION, String.class);
- if (ObjectHelper.isEmpty(dropletId))
+ if (ObjectHelper.isEmpty(dropletId)) {
throw new IllegalArgumentException(DigitalOceanHeaders.DROPLET_ID + " must be specified");
+ }
- if (ObjectHelper.isEmpty(region))
+ if (ObjectHelper.isEmpty(region)) {
throw new IllegalArgumentException(DigitalOceanHeaders.REGION + " must be specified");
+ }
Action action;
@@ -211,8 +232,9 @@ public class DigitalOceanBlockStoragesProducer extends DigitalOceanProducer {
} else if (ObjectHelper.isNotEmpty(volumeId)) {
action = getEndpoint().getDigitalOceanClient().detachVolume(dropletId, volumeId, region);
LOG.trace("Detach Volume {} to Droplet {} [{}] ", volumeId, dropletId, action);
- } else
+ } else {
throw new IllegalArgumentException(DigitalOceanHeaders.ID + " or " + DigitalOceanHeaders.VOLUME_NAME + " must be specified");
+ }
exchange.getOut().setBody(action);
@@ -221,18 +243,21 @@ public class DigitalOceanBlockStoragesProducer extends DigitalOceanProducer {
private void resizeVolume(Exchange exchange) throws Exception {
String volumeId = exchange.getIn().getHeader(DigitalOceanHeaders.ID, String.class);
- if (ObjectHelper.isEmpty(volumeId))
+ if (ObjectHelper.isEmpty(volumeId)) {
throw new IllegalArgumentException(DigitalOceanHeaders.ID + " must be specified");
+ }
String region = exchange.getIn().getHeader(DigitalOceanHeaders.REGION, String.class);
- if (ObjectHelper.isEmpty(region))
+ if (ObjectHelper.isEmpty(region)) {
throw new IllegalArgumentException(DigitalOceanHeaders.REGION + " must be specified");
+ }
Double size = exchange.getIn().getHeader(DigitalOceanHeaders.VOLUME_SIZE_GIGABYTES, Double.class);
- if (ObjectHelper.isEmpty(size))
+ if (ObjectHelper.isEmpty(size)) {
throw new IllegalArgumentException(DigitalOceanHeaders.VOLUME_SIZE_GIGABYTES + " must be specified");
+ }
Action action = getEndpoint().getDigitalOceanClient().resizeVolume(volumeId, region, size);
LOG.trace("Resize Volume {} [{}] ", volumeId, action);
@@ -241,8 +266,9 @@ public class DigitalOceanBlockStoragesProducer extends DigitalOceanProducer {
private void getVolumeActions(Exchange exchange) throws Exception {
String volumeId = exchange.getIn().getHeader(DigitalOceanHeaders.ID, String.class);
- if (ObjectHelper.isEmpty(volumeId))
+ if (ObjectHelper.isEmpty(volumeId)) {
throw new IllegalArgumentException(DigitalOceanHeaders.ID + " must be specified");
+ }
Actions actions = getEndpoint().getDigitalOceanClient().getAvailableVolumeActions(volumeId);
LOG.trace("Actions for Volume {} [{}] ", volumeId, actions.getActions());
http://git-wip-us.apache.org/repos/asf/camel/blob/0dd2c2f2/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/producer/DigitalOceanDropletsProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/producer/DigitalOceanDropletsProducer.java b/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/producer/DigitalOceanDropletsProducer.java
index 444a68d..3c51fea 100644
--- a/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/producer/DigitalOceanDropletsProducer.java
+++ b/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/producer/DigitalOceanDropletsProducer.java
@@ -16,133 +16,146 @@
*/
package org.apache.camel.component.digitalocean.producer;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.stream.Collectors;
+
import com.myjeeva.digitalocean.common.ResourceType;
-import com.myjeeva.digitalocean.pojo.*;
+import com.myjeeva.digitalocean.pojo.Action;
+import com.myjeeva.digitalocean.pojo.Actions;
+import com.myjeeva.digitalocean.pojo.Backups;
+import com.myjeeva.digitalocean.pojo.Delete;
+import com.myjeeva.digitalocean.pojo.Droplet;
+import com.myjeeva.digitalocean.pojo.Droplets;
+import com.myjeeva.digitalocean.pojo.Image;
+import com.myjeeva.digitalocean.pojo.Kernels;
+import com.myjeeva.digitalocean.pojo.Key;
+import com.myjeeva.digitalocean.pojo.Neighbors;
+import com.myjeeva.digitalocean.pojo.Region;
+import com.myjeeva.digitalocean.pojo.Resource;
import com.myjeeva.digitalocean.pojo.Response;
+import com.myjeeva.digitalocean.pojo.Snapshots;
+import org.apache.camel.Exchange;
+import org.apache.camel.Message;
import org.apache.camel.component.digitalocean.DigitalOceanConfiguration;
-import org.apache.camel.component.digitalocean.constants.DigitalOceanHeaders;
import org.apache.camel.component.digitalocean.DigitalOceanEndpoint;
+import org.apache.camel.component.digitalocean.constants.DigitalOceanHeaders;
import org.apache.camel.component.digitalocean.constants.DigitalOceanOperations;
-import org.apache.camel.Exchange;
-import org.apache.camel.Message;
import org.apache.camel.util.ObjectHelper;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.stream.Collectors;
-
/**
* The DigitalOcean producer for Droplets API.
*/
public class DigitalOceanDropletsProducer extends DigitalOceanProducer {
+ private Integer dropletId;
+
public DigitalOceanDropletsProducer(DigitalOceanEndpoint endpoint, DigitalOceanConfiguration configuration) {
super(endpoint, configuration);
}
- private Integer dropletId;
-
public void process(Exchange exchange) throws Exception {
DigitalOceanOperations op = determineOperation(exchange);
if (op != DigitalOceanOperations.create && op != DigitalOceanOperations.list && op != DigitalOceanOperations.listAllNeighbors) {
dropletId = exchange.getIn().getHeader(DigitalOceanHeaders.ID, Integer.class);
- if (ObjectHelper.isEmpty(dropletId))
+ if (ObjectHelper.isEmpty(dropletId)) {
throw new IllegalArgumentException(DigitalOceanHeaders.ID + " must be specified");
+ }
+
}
switch (op) {
- case create:
- createDroplet(exchange);
- break;
- case list:
- getDroplets(exchange);
- break;
- case delete:
- deleteDroplet(exchange);
- break;
- case get:
- getDroplet(exchange);
- break;
- case listActions:
- getDropletActions(exchange);
- break;
- case listSnapshots:
- getDropletSnapshots(exchange);
- break;
- case listKernels:
- getDropletKernels(exchange);
- break;
- case listBackups:
- getDropletBackups(exchange);
- break;
- case listNeighbors:
- getDropletNeighbors(exchange);
- break;
- case listAllNeighbors:
- getAllDropletNeighbors(exchange);
- break;
- case enableBackups:
- enableDropletBackups(exchange);
- break;
- case disableBackups:
- disableDropletBackups(exchange);
- break;
- case reboot:
- rebootDroplet(exchange);
- break;
- case powerCycle:
- powerCycleDroplet(exchange);
- break;
- case shutdown:
- shutdownDroplet(exchange);
- break;
- case powerOn:
- powerOnDroplet(exchange);
- break;
- case powerOff:
- powerOffDroplet(exchange);
- break;
- case restore:
- restoreDroplet(exchange);
- break;
- case resetPassword:
- resetDropletPassword(exchange);
- break;
- case resize:
- resizeDroplet(exchange);
- break;
- case rebuild:
- rebuildDroplet(exchange);
- break;
- case rename:
- renameDroplet(exchange);
- break;
- case changeKernel:
- changeDropletKernel(exchange);
- break;
- case enableIpv6:
- enableDropletIpv6(exchange);
- break;
- case enablePrivateNetworking:
- enableDropletPrivateNetworking(exchange);
- break;
- case takeSnapshot:
- takeDropletSnapshot(exchange);
- break;
- case tag:
- tagDroplet(exchange);
- break;
- case untag:
- untagDroplet(exchange);
- break;
- default:
- throw new IllegalArgumentException("Unsupported operation");
+ case create:
+ createDroplet(exchange);
+ break;
+ case list:
+ getDroplets(exchange);
+ break;
+ case delete:
+ deleteDroplet(exchange);
+ break;
+ case get:
+ getDroplet(exchange);
+ break;
+ case listActions:
+ getDropletActions(exchange);
+ break;
+ case listSnapshots:
+ getDropletSnapshots(exchange);
+ break;
+ case listKernels:
+ getDropletKernels(exchange);
+ break;
+ case listBackups:
+ getDropletBackups(exchange);
+ break;
+ case listNeighbors:
+ getDropletNeighbors(exchange);
+ break;
+ case listAllNeighbors:
+ getAllDropletNeighbors(exchange);
+ break;
+ case enableBackups:
+ enableDropletBackups(exchange);
+ break;
+ case disableBackups:
+ disableDropletBackups(exchange);
+ break;
+ case reboot:
+ rebootDroplet(exchange);
+ break;
+ case powerCycle:
+ powerCycleDroplet(exchange);
+ break;
+ case shutdown:
+ shutdownDroplet(exchange);
+ break;
+ case powerOn:
+ powerOnDroplet(exchange);
+ break;
+ case powerOff:
+ powerOffDroplet(exchange);
+ break;
+ case restore:
+ restoreDroplet(exchange);
+ break;
+ case resetPassword:
+ resetDropletPassword(exchange);
+ break;
+ case resize:
+ resizeDroplet(exchange);
+ break;
+ case rebuild:
+ rebuildDroplet(exchange);
+ break;
+ case rename:
+ renameDroplet(exchange);
+ break;
+ case changeKernel:
+ changeDropletKernel(exchange);
+ break;
+ case enableIpv6:
+ enableDropletIpv6(exchange);
+ break;
+ case enablePrivateNetworking:
+ enableDropletPrivateNetworking(exchange);
+ break;
+ case takeSnapshot:
+ takeDropletSnapshot(exchange);
+ break;
+ case tag:
+ tagDroplet(exchange);
+ break;
+ case untag:
+ untagDroplet(exchange);
+ break;
+ default:
+ throw new IllegalArgumentException("Unsupported operation");
}
}
-
private void getDroplet(Exchange exchange) throws Exception {
Droplet droplet = getEndpoint().getDigitalOceanClient().getDropletInfo(dropletId);
LOG.trace("Droplet {} ", droplet);
@@ -205,62 +218,73 @@ public class DigitalOceanDropletsProducer extends DigitalOceanProducer {
Droplet droplet = new Droplet();
- if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(DigitalOceanHeaders.REGION)))
+ if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(DigitalOceanHeaders.REGION))) {
droplet.setRegion(new Region(in.getHeader(DigitalOceanHeaders.REGION, String.class)));
- else
+ } else {
throw new IllegalArgumentException(DigitalOceanHeaders.REGION + " must be specified");
+ }
- if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(DigitalOceanHeaders.DROPLET_SIZE)))
+ if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(DigitalOceanHeaders.DROPLET_SIZE))) {
droplet.setSize(in.getHeader(DigitalOceanHeaders.DROPLET_SIZE, String.class));
- else
+ } else {
throw new IllegalArgumentException(DigitalOceanHeaders.DROPLET_SIZE + " must be specified");
+ }
- if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(DigitalOceanHeaders.DROPLET_IMAGE)))
+ if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(DigitalOceanHeaders.DROPLET_IMAGE))) {
droplet.setImage(new Image(in.getHeader(DigitalOceanHeaders.DROPLET_IMAGE, String.class)));
- else
+ } else {
throw new IllegalArgumentException(DigitalOceanHeaders.DROPLET_IMAGE + " must be specified");
+ }
if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(DigitalOceanHeaders.DROPLET_KEYS))) {
List<String> keys = (List<String>) exchange.getIn().getHeader(DigitalOceanHeaders.DROPLET_KEYS);
droplet.setKeys(keys.stream().map(Key::new).collect(Collectors.toList()));
}
- if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(DigitalOceanHeaders.DROPLET_ENABLE_BACKUPS)))
+ if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(DigitalOceanHeaders.DROPLET_ENABLE_BACKUPS))) {
droplet.setEnableBackup(in.getHeader(DigitalOceanHeaders.DROPLET_ENABLE_BACKUPS, Boolean.class));
+ }
- if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(DigitalOceanHeaders.DROPLET_ENABLE_IPV6)))
+ if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(DigitalOceanHeaders.DROPLET_ENABLE_IPV6))) {
droplet.setEnableIpv6(in.getHeader(DigitalOceanHeaders.DROPLET_ENABLE_IPV6, Boolean.class));
+ }
- if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(DigitalOceanHeaders.DROPLET_ENABLE_PRIVATE_NETWORKING)))
+ if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(DigitalOceanHeaders.DROPLET_ENABLE_PRIVATE_NETWORKING))) {
droplet.setEnablePrivateNetworking(in.getHeader(DigitalOceanHeaders.DROPLET_ENABLE_PRIVATE_NETWORKING, Boolean.class));
+ }
- if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(DigitalOceanHeaders.DROPLET_USER_DATA)))
+ if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(DigitalOceanHeaders.DROPLET_USER_DATA))) {
droplet.setUserData(in.getHeader(DigitalOceanHeaders.DROPLET_USER_DATA, String.class));
+ }
- if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(DigitalOceanHeaders.DROPLET_VOLUMES)))
+ if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(DigitalOceanHeaders.DROPLET_VOLUMES))) {
droplet.setVolumeIds((List<String>) exchange.getIn().getHeader(DigitalOceanHeaders.DROPLET_VOLUMES));
+ }
- if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(DigitalOceanHeaders.DROPLET_TAGS)))
+ if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(DigitalOceanHeaders.DROPLET_TAGS))) {
droplet.setTags((List<String>) exchange.getIn().getHeader(DigitalOceanHeaders.DROPLET_TAGS));
+ }
if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(DigitalOceanHeaders.NAMES))) {
droplet.setNames((List<String>) in.getHeader(DigitalOceanHeaders.NAMES));
Droplets droplets = getEndpoint().getDigitalOceanClient().createDroplets(droplet);
LOG.trace("Droplets created {} ", droplets);
exchange.getOut().setBody(droplets.getDroplets());
- } else if(ObjectHelper.isNotEmpty(exchange.getIn().getHeader(DigitalOceanHeaders.NAME))) {
+ } else if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(DigitalOceanHeaders.NAME))) {
droplet.setName(in.getHeader(DigitalOceanHeaders.NAME, String.class));
droplet = getEndpoint().getDigitalOceanClient().createDroplet(droplet);
LOG.trace("Droplet created {} ", droplet);
exchange.getOut().setBody(droplet);
- } else
+ } else {
throw new IllegalArgumentException(DigitalOceanHeaders.NAMES + " or " + DigitalOceanHeaders.NAME + " must be specified");
+ }
}
private void restoreDroplet(Exchange exchange) throws Exception {
- if (ObjectHelper.isEmpty(exchange.getIn().getHeader(DigitalOceanHeaders.IMAGE_ID)))
+ if (ObjectHelper.isEmpty(exchange.getIn().getHeader(DigitalOceanHeaders.IMAGE_ID))) {
throw new IllegalArgumentException(DigitalOceanHeaders.IMAGE_ID + " must be specified");
+ }
Action action = getEndpoint().getDigitalOceanClient().restoreDroplet(dropletId, exchange.getIn().getHeader(DigitalOceanHeaders.IMAGE_ID, Integer.class));
LOG.trace("DropletAction Restore [{}] ", action);
@@ -269,8 +293,9 @@ public class DigitalOceanDropletsProducer extends DigitalOceanProducer {
}
private void resizeDroplet(Exchange exchange) throws Exception {
- if (ObjectHelper.isEmpty(exchange.getIn().getHeader(DigitalOceanHeaders.DROPLET_SIZE)))
+ if (ObjectHelper.isEmpty(exchange.getIn().getHeader(DigitalOceanHeaders.DROPLET_SIZE))) {
throw new IllegalArgumentException(DigitalOceanHeaders.DROPLET_SIZE + " must be specified");
+ }
Action action = getEndpoint().getDigitalOceanClient().resizeDroplet(dropletId, exchange.getIn().getHeader(DigitalOceanHeaders.DROPLET_SIZE, String.class));
LOG.trace("DropletAction Resize [{}] ", action);
@@ -279,8 +304,9 @@ public class DigitalOceanDropletsProducer extends DigitalOceanProducer {
private void rebuildDroplet(Exchange exchange) throws Exception {
- if (ObjectHelper.isEmpty(exchange.getIn().getHeader(DigitalOceanHeaders.IMAGE_ID)))
+ if (ObjectHelper.isEmpty(exchange.getIn().getHeader(DigitalOceanHeaders.IMAGE_ID))) {
throw new IllegalArgumentException(DigitalOceanHeaders.IMAGE_ID + " must be specified");
+ }
Action action = getEndpoint().getDigitalOceanClient().rebuildDroplet(dropletId, exchange.getIn().getHeader(DigitalOceanHeaders.IMAGE_ID, Integer.class));
LOG.trace("Rebuild Droplet {} : [{}] ", dropletId, action);
@@ -288,8 +314,9 @@ public class DigitalOceanDropletsProducer extends DigitalOceanProducer {
}
private void renameDroplet(Exchange exchange) throws Exception {
- if (ObjectHelper.isEmpty(exchange.getIn().getHeader(DigitalOceanHeaders.NAME)))
+ if (ObjectHelper.isEmpty(exchange.getIn().getHeader(DigitalOceanHeaders.NAME))) {
throw new IllegalArgumentException(DigitalOceanHeaders.NAME + " must be specified");
+ }
Action action = getEndpoint().getDigitalOceanClient().renameDroplet(dropletId, exchange.getIn().getHeader(DigitalOceanHeaders.NAME, String.class));
LOG.trace("Rename Droplet {} : [{}] ", dropletId, action);
@@ -298,8 +325,9 @@ public class DigitalOceanDropletsProducer extends DigitalOceanProducer {
private void changeDropletKernel(Exchange exchange) throws Exception {
- if (ObjectHelper.isEmpty(exchange.getIn().getHeader(DigitalOceanHeaders.KERNEL_ID)))
+ if (ObjectHelper.isEmpty(exchange.getIn().getHeader(DigitalOceanHeaders.KERNEL_ID))) {
throw new IllegalArgumentException(DigitalOceanHeaders.KERNEL_ID + " must be specified");
+ }
Action action = getEndpoint().getDigitalOceanClient().changeDropletKernel(dropletId, exchange.getIn().getHeader(DigitalOceanHeaders.KERNEL_ID, Integer.class));
LOG.trace("Rename Droplet {} : [{}] ", dropletId, action);
@@ -371,18 +399,20 @@ public class DigitalOceanDropletsProducer extends DigitalOceanProducer {
private void takeDropletSnapshot(Exchange exchange) throws Exception {
Action action;
- if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(DigitalOceanHeaders.NAME)))
+ if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(DigitalOceanHeaders.NAME))) {
action = getEndpoint().getDigitalOceanClient().takeDropletSnapshot(dropletId, exchange.getIn().getHeader(DigitalOceanHeaders.NAME, String.class));
- else
+ } else {
action = getEndpoint().getDigitalOceanClient().takeDropletSnapshot(dropletId);
+ }
LOG.trace("Take Snapshot for Droplet {} : [{}] ", dropletId, action);
exchange.getOut().setBody(action);
}
private void tagDroplet(Exchange exchange) throws Exception {
- if (ObjectHelper.isEmpty(exchange.getIn().getHeader(DigitalOceanHeaders.NAME)))
+ if (ObjectHelper.isEmpty(exchange.getIn().getHeader(DigitalOceanHeaders.NAME))) {
throw new IllegalArgumentException(DigitalOceanHeaders.NAME + " must be specified");
+ }
ArrayList<Resource> resources = new ArrayList<>(1);
resources.add(new Resource(dropletId.toString(), ResourceType.DROPLET));
@@ -392,8 +422,9 @@ public class DigitalOceanDropletsProducer extends DigitalOceanProducer {
}
private void untagDroplet(Exchange exchange) throws Exception {
- if (ObjectHelper.isEmpty(exchange.getIn().getHeader(DigitalOceanHeaders.NAME)))
+ if (ObjectHelper.isEmpty(exchange.getIn().getHeader(DigitalOceanHeaders.NAME))) {
throw new IllegalArgumentException(DigitalOceanHeaders.NAME + " must be specified");
+ }
ArrayList<Resource> resources = new ArrayList<>(1);
resources.add(new Resource(dropletId.toString(), ResourceType.DROPLET));
http://git-wip-us.apache.org/repos/asf/camel/blob/0dd2c2f2/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/producer/DigitalOceanFloatingIPsProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/producer/DigitalOceanFloatingIPsProducer.java b/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/producer/DigitalOceanFloatingIPsProducer.java
index 3bb90de..fad44f2 100644
--- a/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/producer/DigitalOceanFloatingIPsProducer.java
+++ b/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/producer/DigitalOceanFloatingIPsProducer.java
@@ -16,12 +16,15 @@
*/
package org.apache.camel.component.digitalocean.producer;
-import com.myjeeva.digitalocean.pojo.*;
+import com.myjeeva.digitalocean.pojo.Action;
+import com.myjeeva.digitalocean.pojo.Actions;
+import com.myjeeva.digitalocean.pojo.Delete;
+import com.myjeeva.digitalocean.pojo.FloatingIP;
+import com.myjeeva.digitalocean.pojo.FloatingIPs;
+import org.apache.camel.Exchange;
import org.apache.camel.component.digitalocean.DigitalOceanConfiguration;
-import org.apache.camel.component.digitalocean.constants.DigitalOceanHeaders;
import org.apache.camel.component.digitalocean.DigitalOceanEndpoint;
-import org.apache.camel.Exchange;
-import org.apache.camel.component.digitalocean.constants.DigitalOceanOperations;
+import org.apache.camel.component.digitalocean.constants.DigitalOceanHeaders;
import org.apache.camel.util.ObjectHelper;
/**
@@ -34,31 +37,31 @@ public class DigitalOceanFloatingIPsProducer extends DigitalOceanProducer {
}
public void process(Exchange exchange) throws Exception {
- switch(determineOperation(exchange)) {
-
- case list:
- getFloatingIPs(exchange);
- break;
- case create:
- createFloatingIp(exchange);
- break;
- case get:
- getFloatingIP(exchange);
- break;
- case delete:
- deleteFloatingIP(exchange);
- break;
- case assign:
- assignFloatingIPToDroplet(exchange);
- break;
- case unassign:
- unassignFloatingIP(exchange);
- break;
- case listActions:
- getFloatingIPActions(exchange);
- break;
- default:
- throw new IllegalArgumentException("Unsupported operation");
+ switch (determineOperation(exchange)) {
+
+ case list:
+ getFloatingIPs(exchange);
+ break;
+ case create:
+ createFloatingIp(exchange);
+ break;
+ case get:
+ getFloatingIP(exchange);
+ break;
+ case delete:
+ deleteFloatingIP(exchange);
+ break;
+ case assign:
+ assignFloatingIPToDroplet(exchange);
+ break;
+ case unassign:
+ unassignFloatingIP(exchange);
+ break;
+ case listActions:
+ getFloatingIPActions(exchange);
+ break;
+ default:
+ throw new IllegalArgumentException("Unsupported operation");
}
}
@@ -67,12 +70,13 @@ public class DigitalOceanFloatingIPsProducer extends DigitalOceanProducer {
String region = exchange.getIn().getHeader(DigitalOceanHeaders.REGION, String.class);
FloatingIP ip;
- if (ObjectHelper.isNotEmpty(dropletId))
+ if (ObjectHelper.isNotEmpty(dropletId)) {
ip = getEndpoint().getDigitalOceanClient().createFloatingIP(dropletId);
- else if (ObjectHelper.isNotEmpty(region))
+ } else if (ObjectHelper.isNotEmpty(region)) {
ip = getEndpoint().getDigitalOceanClient().createFloatingIP(region);
- else
- throw new IllegalArgumentException(DigitalOceanHeaders.DROPLET_ID + " or " + DigitalOceanHeaders.REGION + " must be specified");
+ } else {
+ throw new IllegalArgumentException(DigitalOceanHeaders.DROPLET_ID + " or " + DigitalOceanHeaders.REGION + " must be specified");
+ }
LOG.trace("FloatingIP [{}] ", ip);
exchange.getOut().setBody(ip);
@@ -89,8 +93,9 @@ public class DigitalOceanFloatingIPsProducer extends DigitalOceanProducer {
private void getFloatingIP(Exchange exchange) throws Exception {
String ipAddress = exchange.getIn().getHeader(DigitalOceanHeaders.FLOATING_IP_ADDRESS, String.class);
- if (ObjectHelper.isEmpty(ipAddress))
+ if (ObjectHelper.isEmpty(ipAddress)) {
throw new IllegalArgumentException(DigitalOceanHeaders.FLOATING_IP_ADDRESS + " must be specified");
+ }
FloatingIP ip = getEndpoint().getDigitalOceanClient().getFloatingIPInfo(ipAddress);
@@ -102,8 +107,9 @@ public class DigitalOceanFloatingIPsProducer extends DigitalOceanProducer {
private void deleteFloatingIP(Exchange exchange) throws Exception {
String ipAddress = exchange.getIn().getHeader(DigitalOceanHeaders.FLOATING_IP_ADDRESS, String.class);
- if (ObjectHelper.isEmpty(ipAddress))
+ if (ObjectHelper.isEmpty(ipAddress)) {
throw new IllegalArgumentException(DigitalOceanHeaders.FLOATING_IP_ADDRESS + " must be specified");
+ }
Delete delete = getEndpoint().getDigitalOceanClient().deleteFloatingIP(ipAddress);
@@ -114,13 +120,15 @@ public class DigitalOceanFloatingIPsProducer extends DigitalOceanProducer {
private void assignFloatingIPToDroplet(Exchange exchange) throws Exception {
Integer dropletId = exchange.getIn().getHeader(DigitalOceanHeaders.DROPLET_ID, Integer.class);
- if(ObjectHelper.isEmpty(dropletId))
+ if (ObjectHelper.isEmpty(dropletId)) {
throw new IllegalArgumentException(DigitalOceanHeaders.DROPLET_ID + " must be specified");
+ }
String ipAddress = exchange.getIn().getHeader(DigitalOceanHeaders.FLOATING_IP_ADDRESS, String.class);
- if (ObjectHelper.isEmpty(ipAddress))
+ if (ObjectHelper.isEmpty(ipAddress)) {
throw new IllegalArgumentException(DigitalOceanHeaders.FLOATING_IP_ADDRESS + " must be specified");
+ }
Action action = getEndpoint().getDigitalOceanClient().assignFloatingIP(dropletId, ipAddress);
LOG.trace("Assign Floating IP to Droplet {} ", action);
@@ -130,8 +138,9 @@ public class DigitalOceanFloatingIPsProducer extends DigitalOceanProducer {
private void unassignFloatingIP(Exchange exchange) throws Exception {
String ipAddress = exchange.getIn().getHeader(DigitalOceanHeaders.FLOATING_IP_ADDRESS, String.class);
- if (ObjectHelper.isEmpty(ipAddress))
+ if (ObjectHelper.isEmpty(ipAddress)) {
throw new IllegalArgumentException(DigitalOceanHeaders.FLOATING_IP_ADDRESS + " must be specified");
+ }
Action action = getEndpoint().getDigitalOceanClient().unassignFloatingIP(ipAddress);
LOG.trace("Unassign Floating IP {} ", action);
@@ -141,8 +150,9 @@ public class DigitalOceanFloatingIPsProducer extends DigitalOceanProducer {
private void getFloatingIPActions(Exchange exchange) throws Exception {
String ipAddress = exchange.getIn().getHeader(DigitalOceanHeaders.FLOATING_IP_ADDRESS, String.class);
- if (ObjectHelper.isEmpty(ipAddress))
+ if (ObjectHelper.isEmpty(ipAddress)) {
throw new IllegalArgumentException(DigitalOceanHeaders.FLOATING_IP_ADDRESS + " must be specified");
+ }
Actions actions = getEndpoint().getDigitalOceanClient().getAvailableFloatingIPActions(ipAddress, configuration.getPage(), configuration.getPerPage());
LOG.trace("Actions for FloatingIP {} : page {} / {} per page [{}] ", ipAddress, configuration.getPage(), configuration.getPerPage(), actions.getActions());
http://git-wip-us.apache.org/repos/asf/camel/blob/0dd2c2f2/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/producer/DigitalOceanImagesProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/producer/DigitalOceanImagesProducer.java b/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/producer/DigitalOceanImagesProducer.java
index b433596..4590cfb 100644
--- a/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/producer/DigitalOceanImagesProducer.java
+++ b/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/producer/DigitalOceanImagesProducer.java
@@ -17,13 +17,16 @@
package org.apache.camel.component.digitalocean.producer;
import com.myjeeva.digitalocean.common.ActionType;
-import com.myjeeva.digitalocean.pojo.*;
+import com.myjeeva.digitalocean.pojo.Action;
+import com.myjeeva.digitalocean.pojo.Actions;
+import com.myjeeva.digitalocean.pojo.Delete;
+import com.myjeeva.digitalocean.pojo.Image;
+import com.myjeeva.digitalocean.pojo.Images;
+import org.apache.camel.Exchange;
import org.apache.camel.component.digitalocean.DigitalOceanConfiguration;
-import org.apache.camel.component.digitalocean.constants.DigitalOceanHeaders;
import org.apache.camel.component.digitalocean.DigitalOceanEndpoint;
+import org.apache.camel.component.digitalocean.constants.DigitalOceanHeaders;
import org.apache.camel.component.digitalocean.constants.DigitalOceanImageTypes;
-import org.apache.camel.Exchange;
-import org.apache.camel.component.digitalocean.constants.DigitalOceanOperations;
import org.apache.camel.util.ObjectHelper;
/**
@@ -37,34 +40,34 @@ public class DigitalOceanImagesProducer extends DigitalOceanProducer {
public void process(Exchange exchange) throws Exception {
- switch(determineOperation(exchange)) {
-
- case list:
- getImages(exchange);
- break;
- case ownList:
- getUserImages(exchange);
- break;
- case listActions:
- getImageActions(exchange);
- break;
- case get:
- getImage(exchange);
- break;
- case update:
- updateImage(exchange);
- break;
- case delete:
- deleteImage(exchange);
- break;
- case transfer:
- transferImage(exchange);
- break;
- case convert:
- convertImageToSnapshot(exchange);
- break;
- default:
- throw new IllegalArgumentException("Unsupported operation");
+ switch (determineOperation(exchange)) {
+
+ case list:
+ getImages(exchange);
+ break;
+ case ownList:
+ getUserImages(exchange);
+ break;
+ case listActions:
+ getImageActions(exchange);
+ break;
+ case get:
+ getImage(exchange);
+ break;
+ case update:
+ updateImage(exchange);
+ break;
+ case delete:
+ deleteImage(exchange);
+ break;
+ case transfer:
+ transferImage(exchange);
+ break;
+ case convert:
+ convertImageToSnapshot(exchange);
+ break;
+ default:
+ throw new IllegalArgumentException("Unsupported operation");
}
}
@@ -80,10 +83,11 @@ public class DigitalOceanImagesProducer extends DigitalOceanProducer {
DigitalOceanImageTypes type = exchange.getIn().getHeader(DigitalOceanHeaders.TYPE, DigitalOceanImageTypes.class);
Images images;
- if (ObjectHelper.isNotEmpty(type))
+ if (ObjectHelper.isNotEmpty(type)) {
images = getEndpoint().getDigitalOceanClient().getAvailableImages(configuration.getPage(), configuration.getPerPage(), ActionType.valueOf(type.name()));
- else
+ } else {
images = getEndpoint().getDigitalOceanClient().getAvailableImages(configuration.getPage(), configuration.getPerPage());
+ }
LOG.trace("All Images : page {} / {} per page [{}] ", configuration.getPage(), configuration.getPerPage(), images.getImages());
exchange.getOut().setBody(images.getImages());
}
@@ -94,12 +98,13 @@ public class DigitalOceanImagesProducer extends DigitalOceanProducer {
String slug = exchange.getIn().getHeader(DigitalOceanHeaders.DROPLET_IMAGE, String.class);
Image image;
- if (ObjectHelper.isNotEmpty(imageId))
+ if (ObjectHelper.isNotEmpty(imageId)) {
image = getEndpoint().getDigitalOceanClient().getImageInfo(imageId);
- else if (ObjectHelper.isNotEmpty(slug))
+ } else if (ObjectHelper.isNotEmpty(slug)) {
image = getEndpoint().getDigitalOceanClient().getImageInfo(slug);
- else
- throw new IllegalArgumentException(DigitalOceanHeaders.ID + " or " + DigitalOceanHeaders.DROPLET_IMAGE + " must be specified");
+ } else {
+ throw new IllegalArgumentException(DigitalOceanHeaders.ID + " or " + DigitalOceanHeaders.DROPLET_IMAGE + " must be specified");
+ }
LOG.trace("Image [{}] ", image);
exchange.getOut().setBody(image);
@@ -109,8 +114,9 @@ public class DigitalOceanImagesProducer extends DigitalOceanProducer {
private void getImageActions(Exchange exchange) throws Exception {
Integer imageId = exchange.getIn().getHeader(DigitalOceanHeaders.ID, Integer.class);
- if (ObjectHelper.isEmpty(imageId))
+ if (ObjectHelper.isEmpty(imageId)) {
throw new IllegalArgumentException(DigitalOceanHeaders.ID + " must be specified");
+ }
Actions actions = getEndpoint().getDigitalOceanClient().getAvailableImageActions(imageId, configuration.getPage(), configuration.getPerPage());
LOG.trace("Actions for Image {} : page {} / {} per page [{}] ", imageId, configuration.getPage(), configuration.getPerPage(), actions.getActions());
@@ -120,14 +126,15 @@ public class DigitalOceanImagesProducer extends DigitalOceanProducer {
private void updateImage(Exchange exchange) throws Exception {
Integer imageId = exchange.getIn().getHeader(DigitalOceanHeaders.ID, Integer.class);
- if (ObjectHelper.isEmpty(imageId))
+ if (ObjectHelper.isEmpty(imageId)) {
throw new IllegalArgumentException(DigitalOceanHeaders.ID + " must be specified");
+ }
String name = exchange.getIn().getHeader(DigitalOceanHeaders.NAME, String.class);
- if (ObjectHelper.isEmpty(name))
+ if (ObjectHelper.isEmpty(name)) {
throw new IllegalArgumentException(DigitalOceanHeaders.NAME + " must be specified");
-
+ }
Image image = new Image();
image.setId(imageId);
image.setName(name);
@@ -139,8 +146,9 @@ public class DigitalOceanImagesProducer extends DigitalOceanProducer {
private void deleteImage(Exchange exchange) throws Exception {
Integer imageId = exchange.getIn().getHeader(DigitalOceanHeaders.ID, Integer.class);
- if (ObjectHelper.isEmpty(imageId))
+ if (ObjectHelper.isEmpty(imageId)) {
throw new IllegalArgumentException(DigitalOceanHeaders.ID + " must be specified");
+ }
Delete delete = getEndpoint().getDigitalOceanClient().deleteImage(imageId);
LOG.trace("Delete Image {} [{}] ", imageId, delete);
@@ -150,13 +158,15 @@ public class DigitalOceanImagesProducer extends DigitalOceanProducer {
private void transferImage(Exchange exchange) throws Exception {
Integer imageId = exchange.getIn().getHeader(DigitalOceanHeaders.ID, Integer.class);
- if (ObjectHelper.isEmpty(imageId))
+ if (ObjectHelper.isEmpty(imageId)) {
throw new IllegalArgumentException(DigitalOceanHeaders.ID + " must be specified");
+ }
String region = exchange.getIn().getHeader(DigitalOceanHeaders.REGION, String.class);
- if (ObjectHelper.isEmpty(region))
+ if (ObjectHelper.isEmpty(region)) {
throw new IllegalArgumentException(DigitalOceanHeaders.REGION + " must be specified");
+ }
Action action = getEndpoint().getDigitalOceanClient().transferImage(imageId, region);
LOG.trace("Transfer Image {} to Region {} [{}] ", imageId, region, action);
@@ -166,8 +176,9 @@ public class DigitalOceanImagesProducer extends DigitalOceanProducer {
private void convertImageToSnapshot(Exchange exchange) throws Exception {
Integer imageId = exchange.getIn().getHeader(DigitalOceanHeaders.ID, Integer.class);
- if (ObjectHelper.isEmpty(imageId))
+ if (ObjectHelper.isEmpty(imageId)) {
throw new IllegalArgumentException(DigitalOceanHeaders.ID + " must be specified");
+ }
Action action = getEndpoint().getDigitalOceanClient().convertImage(imageId);
LOG.trace("Convert Image {} [{}] ", imageId, action);
http://git-wip-us.apache.org/repos/asf/camel/blob/0dd2c2f2/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/producer/DigitalOceanKeysProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/producer/DigitalOceanKeysProducer.java b/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/producer/DigitalOceanKeysProducer.java
index 3dec39b..f16866f 100644
--- a/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/producer/DigitalOceanKeysProducer.java
+++ b/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/producer/DigitalOceanKeysProducer.java
@@ -16,11 +16,13 @@
*/
package org.apache.camel.component.digitalocean.producer;
-import com.myjeeva.digitalocean.pojo.*;
+import com.myjeeva.digitalocean.pojo.Delete;
+import com.myjeeva.digitalocean.pojo.Key;
+import com.myjeeva.digitalocean.pojo.Keys;
+import org.apache.camel.Exchange;
import org.apache.camel.component.digitalocean.DigitalOceanConfiguration;
-import org.apache.camel.component.digitalocean.constants.DigitalOceanHeaders;
import org.apache.camel.component.digitalocean.DigitalOceanEndpoint;
-import org.apache.camel.Exchange;
+import org.apache.camel.component.digitalocean.constants.DigitalOceanHeaders;
import org.apache.camel.util.ObjectHelper;
/**
@@ -34,25 +36,25 @@ public class DigitalOceanKeysProducer extends DigitalOceanProducer {
public void process(Exchange exchange) throws Exception {
- switch(determineOperation(exchange)) {
-
- case list:
- getKeys(exchange);
- break;
- case create:
- createKey(exchange);
- break;
- case get:
- getKey(exchange);
- break;
- case update:
- updateKey(exchange);
- break;
- case delete:
- deleteKey(exchange);
- break;
- default:
- throw new IllegalArgumentException("Unsupported operation");
+ switch (determineOperation(exchange)) {
+
+ case list:
+ getKeys(exchange);
+ break;
+ case create:
+ createKey(exchange);
+ break;
+ case get:
+ getKey(exchange);
+ break;
+ case update:
+ updateKey(exchange);
+ break;
+ case delete:
+ deleteKey(exchange);
+ break;
+ default:
+ throw new IllegalArgumentException("Unsupported operation");
}
}
@@ -62,13 +64,13 @@ public class DigitalOceanKeysProducer extends DigitalOceanProducer {
String fingerprint = exchange.getIn().getHeader(DigitalOceanHeaders.KEY_FINGERPRINT, String.class);
Key key;
- if (ObjectHelper.isNotEmpty(keyId))
+ if (ObjectHelper.isNotEmpty(keyId)) {
key = getEndpoint().getDigitalOceanClient().getKeyInfo(keyId);
- else if (ObjectHelper.isNotEmpty(fingerprint))
+ } else if (ObjectHelper.isNotEmpty(fingerprint)) {
key = getEndpoint().getDigitalOceanClient().getKeyInfo(fingerprint);
- else
- throw new IllegalArgumentException(DigitalOceanHeaders.ID + " or " + DigitalOceanHeaders.KEY_FINGERPRINT + " must be specified");
-
+ } else {
+ throw new IllegalArgumentException(DigitalOceanHeaders.ID + " or " + DigitalOceanHeaders.KEY_FINGERPRINT + " must be specified");
+ }
LOG.trace("Key [{}] ", key);
exchange.getOut().setBody(key);
}
@@ -84,12 +86,13 @@ public class DigitalOceanKeysProducer extends DigitalOceanProducer {
String fingerprint = exchange.getIn().getHeader(DigitalOceanHeaders.KEY_FINGERPRINT, String.class);
Delete delete;
- if (ObjectHelper.isNotEmpty(keyId))
+ if (ObjectHelper.isNotEmpty(keyId)) {
delete = getEndpoint().getDigitalOceanClient().deleteKey(keyId);
- else if (ObjectHelper.isNotEmpty(fingerprint))
+ } else if (ObjectHelper.isNotEmpty(fingerprint)) {
delete = getEndpoint().getDigitalOceanClient().deleteKey(fingerprint);
- else
- throw new IllegalArgumentException(DigitalOceanHeaders.ID + " or " + DigitalOceanHeaders.KEY_FINGERPRINT + " must be specified");
+ } else {
+ throw new IllegalArgumentException(DigitalOceanHeaders.ID + " or " + DigitalOceanHeaders.KEY_FINGERPRINT + " must be specified");
+ }
LOG.trace("Delete Key {} ", delete);
exchange.getOut().setBody(delete);
@@ -101,17 +104,20 @@ public class DigitalOceanKeysProducer extends DigitalOceanProducer {
String name = exchange.getIn().getHeader(DigitalOceanHeaders.NAME, String.class);
- if (ObjectHelper.isEmpty(name))
+ if (ObjectHelper.isEmpty(name)) {
throw new IllegalArgumentException(DigitalOceanHeaders.NAME + " must be specified");
- else
+
+ } else {
key.setName(name);
+ }
String publicKey = exchange.getIn().getHeader(DigitalOceanHeaders.KEY_PUBLIC_KEY, String.class);
- if (ObjectHelper.isEmpty(publicKey))
+ if (ObjectHelper.isEmpty(publicKey)) {
throw new IllegalArgumentException(DigitalOceanHeaders.KEY_PUBLIC_KEY + " must be specified");
- else
+ } else {
key.setPublicKey(publicKey);
+ }
key = getEndpoint().getDigitalOceanClient().createKey(key);
LOG.trace("Key created {} ", key);
@@ -126,15 +132,17 @@ public class DigitalOceanKeysProducer extends DigitalOceanProducer {
String name = exchange.getIn().getHeader(DigitalOceanHeaders.NAME, String.class);
- if (ObjectHelper.isEmpty(name))
+ if (ObjectHelper.isEmpty(name)) {
throw new IllegalArgumentException(DigitalOceanHeaders.NAME + " must be specified");
+ }
- if (ObjectHelper.isNotEmpty(keyId))
+ if (ObjectHelper.isNotEmpty(keyId)) {
key = getEndpoint().getDigitalOceanClient().updateKey(keyId, name);
- else if (ObjectHelper.isNotEmpty(fingerprint))
+ } else if (ObjectHelper.isNotEmpty(fingerprint)) {
key = getEndpoint().getDigitalOceanClient().updateKey(fingerprint, name);
- else
- throw new IllegalArgumentException(DigitalOceanHeaders.ID + " or " + DigitalOceanHeaders.KEY_FINGERPRINT + " must be specified");
+ } else {
+ throw new IllegalArgumentException(DigitalOceanHeaders.ID + " or " + DigitalOceanHeaders.KEY_FINGERPRINT + " must be specified");
+ }
LOG.trace("Update Key [{}] ", key);
exchange.getOut().setBody(key);
http://git-wip-us.apache.org/repos/asf/camel/blob/0dd2c2f2/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/producer/DigitalOceanProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/producer/DigitalOceanProducer.java b/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/producer/DigitalOceanProducer.java
index fa35f4a..1b81bac 100644
--- a/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/producer/DigitalOceanProducer.java
+++ b/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/producer/DigitalOceanProducer.java
@@ -16,11 +16,11 @@
*/
package org.apache.camel.component.digitalocean.producer;
+import org.apache.camel.Exchange;
import org.apache.camel.component.digitalocean.DigitalOceanConfiguration;
-import org.apache.camel.component.digitalocean.constants.DigitalOceanHeaders;
import org.apache.camel.component.digitalocean.DigitalOceanEndpoint;
+import org.apache.camel.component.digitalocean.constants.DigitalOceanHeaders;
import org.apache.camel.component.digitalocean.constants.DigitalOceanOperations;
-import org.apache.camel.Exchange;
import org.apache.camel.impl.DefaultProducer;
import org.apache.camel.util.ObjectHelper;
import org.slf4j.Logger;
@@ -31,9 +31,8 @@ import org.slf4j.LoggerFactory;
*/
public abstract class DigitalOceanProducer extends DefaultProducer {
protected static final Logger LOG = LoggerFactory.getLogger(DigitalOceanProducer.class);
-
- private DigitalOceanEndpoint endpoint;
protected DigitalOceanConfiguration configuration;
+ private DigitalOceanEndpoint endpoint;
public DigitalOceanProducer(DigitalOceanEndpoint endpoint, DigitalOceanConfiguration configuration) {
super(endpoint);
http://git-wip-us.apache.org/repos/asf/camel/blob/0dd2c2f2/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/producer/DigitalOceanRegionsProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/producer/DigitalOceanRegionsProducer.java b/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/producer/DigitalOceanRegionsProducer.java
index b03c22f..9f9eefb 100644
--- a/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/producer/DigitalOceanRegionsProducer.java
+++ b/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/producer/DigitalOceanRegionsProducer.java
@@ -16,10 +16,10 @@
*/
package org.apache.camel.component.digitalocean.producer;
-import com.myjeeva.digitalocean.pojo.*;
+import com.myjeeva.digitalocean.pojo.Regions;
+import org.apache.camel.Exchange;
import org.apache.camel.component.digitalocean.DigitalOceanConfiguration;
import org.apache.camel.component.digitalocean.DigitalOceanEndpoint;
-import org.apache.camel.Exchange;
/**
* The DigitalOcean producer for Regions API.
http://git-wip-us.apache.org/repos/asf/camel/blob/0dd2c2f2/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/producer/DigitalOceanSizesProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/producer/DigitalOceanSizesProducer.java b/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/producer/DigitalOceanSizesProducer.java
index 668a80a..53c6d5e 100644
--- a/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/producer/DigitalOceanSizesProducer.java
+++ b/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/producer/DigitalOceanSizesProducer.java
@@ -16,10 +16,10 @@
*/
package org.apache.camel.component.digitalocean.producer;
-import com.myjeeva.digitalocean.pojo.*;
+import com.myjeeva.digitalocean.pojo.Sizes;
+import org.apache.camel.Exchange;
import org.apache.camel.component.digitalocean.DigitalOceanConfiguration;
import org.apache.camel.component.digitalocean.DigitalOceanEndpoint;
-import org.apache.camel.Exchange;
/**
* The DigitalOcean producer for Sizes API.
[04/20] camel git commit: Fixes reported checkstyle errors.
Posted by ac...@apache.org.
http://git-wip-us.apache.org/repos/asf/camel/blob/0dd2c2f2/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/producer/DigitalOceanSnapshotsProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/producer/DigitalOceanSnapshotsProducer.java b/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/producer/DigitalOceanSnapshotsProducer.java
index fb70703..5302fdf 100644
--- a/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/producer/DigitalOceanSnapshotsProducer.java
+++ b/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/producer/DigitalOceanSnapshotsProducer.java
@@ -19,11 +19,11 @@ package org.apache.camel.component.digitalocean.producer;
import com.myjeeva.digitalocean.pojo.Delete;
import com.myjeeva.digitalocean.pojo.Snapshot;
import com.myjeeva.digitalocean.pojo.Snapshots;
+import org.apache.camel.Exchange;
import org.apache.camel.component.digitalocean.DigitalOceanConfiguration;
import org.apache.camel.component.digitalocean.DigitalOceanEndpoint;
import org.apache.camel.component.digitalocean.constants.DigitalOceanHeaders;
import org.apache.camel.component.digitalocean.constants.DigitalOceanSnapshotTypes;
-import org.apache.camel.Exchange;
import org.apache.camel.util.ObjectHelper;
/**
@@ -39,18 +39,18 @@ public class DigitalOceanSnapshotsProducer extends DigitalOceanProducer {
switch (determineOperation(exchange)) {
- case list:
- getSnapshots(exchange);
- break;
- case get:
- getSnapshot(exchange);
- break;
- case delete:
- deleteSnapshot(exchange);
- break;
-
- default:
- throw new IllegalArgumentException("Unsupported operation");
+ case list:
+ getSnapshots(exchange);
+ break;
+ case get:
+ getSnapshot(exchange);
+ break;
+ case delete:
+ deleteSnapshot(exchange);
+ break;
+
+ default:
+ throw new IllegalArgumentException("Unsupported operation");
}
@@ -61,13 +61,15 @@ public class DigitalOceanSnapshotsProducer extends DigitalOceanProducer {
DigitalOceanSnapshotTypes type = exchange.getIn().getHeader(DigitalOceanHeaders.TYPE, DigitalOceanSnapshotTypes.class);
Snapshots snapshots;
- if (ObjectHelper.isNotEmpty(type))
- if(type == DigitalOceanSnapshotTypes.droplet)
+ if (ObjectHelper.isNotEmpty(type)) {
+ if (type == DigitalOceanSnapshotTypes.droplet) {
snapshots = getEndpoint().getDigitalOceanClient().getAllDropletSnapshots(configuration.getPage(), configuration.getPerPage());
- else
+ } else {
snapshots = getEndpoint().getDigitalOceanClient().getAllVolumeSnapshots(configuration.getPage(), configuration.getPerPage());
- else
+ }
+ } else {
snapshots = getEndpoint().getDigitalOceanClient().getAvailableSnapshots(configuration.getPage(), configuration.getPerPage());
+ }
LOG.trace("All Snapshots : page {} / {} per page [{}] ", configuration.getPage(), configuration.getPerPage(), snapshots.getSnapshots());
exchange.getOut().setBody(snapshots.getSnapshots());
@@ -76,8 +78,9 @@ public class DigitalOceanSnapshotsProducer extends DigitalOceanProducer {
private void getSnapshot(Exchange exchange) throws Exception {
String snapshotId = exchange.getIn().getHeader(DigitalOceanHeaders.ID, String.class);
- if (ObjectHelper.isEmpty(snapshotId))
+ if (ObjectHelper.isEmpty(snapshotId)) {
throw new IllegalArgumentException(DigitalOceanHeaders.ID + " must be specified");
+ }
Snapshot snapshot = getEndpoint().getDigitalOceanClient().getSnaphotInfo(snapshotId);
LOG.trace("Snapshot [{}] ", snapshot);
@@ -88,8 +91,9 @@ public class DigitalOceanSnapshotsProducer extends DigitalOceanProducer {
private void deleteSnapshot(Exchange exchange) throws Exception {
String snapshotId = exchange.getIn().getHeader(DigitalOceanHeaders.ID, String.class);
- if (ObjectHelper.isEmpty(snapshotId))
+ if (ObjectHelper.isEmpty(snapshotId)) {
throw new IllegalArgumentException(DigitalOceanHeaders.ID + " must be specified");
+ }
Delete delete = getEndpoint().getDigitalOceanClient().deleteSnapshot(snapshotId);
LOG.trace("Delete Snapshot [{}] ", delete);
http://git-wip-us.apache.org/repos/asf/camel/blob/0dd2c2f2/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/producer/DigitalOceanTagsProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/producer/DigitalOceanTagsProducer.java b/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/producer/DigitalOceanTagsProducer.java
index 7b6777c..d8d9d12 100644
--- a/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/producer/DigitalOceanTagsProducer.java
+++ b/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/producer/DigitalOceanTagsProducer.java
@@ -16,12 +16,13 @@
*/
package org.apache.camel.component.digitalocean.producer;
-import com.myjeeva.digitalocean.pojo.*;
+import com.myjeeva.digitalocean.pojo.Delete;
+import com.myjeeva.digitalocean.pojo.Tag;
+import com.myjeeva.digitalocean.pojo.Tags;
+import org.apache.camel.Exchange;
import org.apache.camel.component.digitalocean.DigitalOceanConfiguration;
-import org.apache.camel.component.digitalocean.constants.DigitalOceanHeaders;
import org.apache.camel.component.digitalocean.DigitalOceanEndpoint;
-import org.apache.camel.Exchange;
-import org.apache.camel.component.digitalocean.constants.DigitalOceanOperations;
+import org.apache.camel.component.digitalocean.constants.DigitalOceanHeaders;
import org.apache.camel.util.ObjectHelper;
/**
@@ -34,25 +35,24 @@ public class DigitalOceanTagsProducer extends DigitalOceanProducer {
}
public void process(Exchange exchange) throws Exception {
- switch(determineOperation(exchange)) {
-
- case list:
- getTags(exchange);
- break;
- case create:
- createTag(exchange);
- break;
- case get:
- getTag(exchange);
- break;
- case delete:
- deleteTag(exchange);
- break;
- case update:
- updateTag(exchange);
- break;
- default:
- throw new IllegalArgumentException("Unsupported operation");
+ switch (determineOperation(exchange)) {
+ case list:
+ getTags(exchange);
+ break;
+ case create:
+ createTag(exchange);
+ break;
+ case get:
+ getTag(exchange);
+ break;
+ case delete:
+ deleteTag(exchange);
+ break;
+ case update:
+ updateTag(exchange);
+ break;
+ default:
+ throw new IllegalArgumentException("Unsupported operation");
}
}
@@ -60,8 +60,9 @@ public class DigitalOceanTagsProducer extends DigitalOceanProducer {
private void createTag(Exchange exchange) throws Exception {
String name = exchange.getIn().getHeader(DigitalOceanHeaders.NAME, String.class);
- if (ObjectHelper.isEmpty(name))
+ if (ObjectHelper.isEmpty(name)) {
throw new IllegalArgumentException(DigitalOceanHeaders.NAME + " must be specified");
+ }
Tag tag = getEndpoint().getDigitalOceanClient().createTag(name);
LOG.trace("Create Tag [{}] ", tag);
exchange.getOut().setBody(tag);
@@ -71,8 +72,9 @@ public class DigitalOceanTagsProducer extends DigitalOceanProducer {
private void getTag(Exchange exchange) throws Exception {
String name = exchange.getIn().getHeader(DigitalOceanHeaders.NAME, String.class);
- if (ObjectHelper.isEmpty(name))
+ if (ObjectHelper.isEmpty(name)) {
throw new IllegalArgumentException(DigitalOceanHeaders.NAME + " must be specified");
+ }
Tag tag = getEndpoint().getDigitalOceanClient().getTag(name);
LOG.trace("Tag [{}] ", tag);
exchange.getOut().setBody(tag);
@@ -87,8 +89,9 @@ public class DigitalOceanTagsProducer extends DigitalOceanProducer {
private void deleteTag(Exchange exchange) throws Exception {
String name = exchange.getIn().getHeader(DigitalOceanHeaders.NAME, String.class);
- if (ObjectHelper.isEmpty(name))
+ if (ObjectHelper.isEmpty(name)) {
throw new IllegalArgumentException(DigitalOceanHeaders.NAME + " must be specified");
+ }
Delete delete = getEndpoint().getDigitalOceanClient().deleteTag(name);
LOG.trace("Delete Tag [{}] ", delete);
exchange.getOut().setBody(delete);
@@ -97,14 +100,15 @@ public class DigitalOceanTagsProducer extends DigitalOceanProducer {
private void updateTag(Exchange exchange) throws Exception {
String name = exchange.getIn().getHeader(DigitalOceanHeaders.NAME, String.class);
- if (ObjectHelper.isEmpty(name))
+ if (ObjectHelper.isEmpty(name)) {
throw new IllegalArgumentException(DigitalOceanHeaders.NAME + " must be specified");
-
+ }
String newName = exchange.getIn().getHeader(DigitalOceanHeaders.NEW_NAME, String.class);
- if (ObjectHelper.isEmpty(newName))
+ if (ObjectHelper.isEmpty(newName)) {
throw new IllegalArgumentException(DigitalOceanHeaders.NEW_NAME + " must be specified");
+ }
Tag tag = getEndpoint().getDigitalOceanClient().updateTag(name, newName);
LOG.trace("Update Tag [{}] ", tag);
http://git-wip-us.apache.org/repos/asf/camel/blob/0dd2c2f2/components/camel-digitalocean/src/main/resources/log4j2.properties
----------------------------------------------------------------------
diff --git a/components/camel-digitalocean/src/main/resources/log4j2.properties b/components/camel-digitalocean/src/main/resources/log4j2.properties
index 60e86f8..8daffa6 100644
--- a/components/camel-digitalocean/src/main/resources/log4j2.properties
+++ b/components/camel-digitalocean/src/main/resources/log4j2.properties
@@ -14,10 +14,9 @@
## See the License for the specific language governing permissions and
## limitations under the License.
## ---------------------------------------------------------------------------
-
-appender.out.type = Console
-appender.out.name = out
-appender.out.layout.type = PatternLayout
-appender.out.layout.pattern = [%30.30t] %-30.30c{1} %-5p %m%n
-rootLogger.level = DEBUG
-rootLogger.appenderRef.out.ref = out
+appender.out.type=Console
+appender.out.name=out
+appender.out.layout.type=PatternLayout
+appender.out.layout.pattern=[%30.30t] %-30.30c{1} %-5p %m%n
+rootLogger.level=DEBUG
+rootLogger.appenderRef.out.ref=out
http://git-wip-us.apache.org/repos/asf/camel/blob/0dd2c2f2/components/camel-digitalocean/src/test/java/org/apache/camel/component/digitalocean/DigitalOceanClientMock.java
----------------------------------------------------------------------
diff --git a/components/camel-digitalocean/src/test/java/org/apache/camel/component/digitalocean/DigitalOceanClientMock.java b/components/camel-digitalocean/src/test/java/org/apache/camel/component/digitalocean/DigitalOceanClientMock.java
index 2bb8c8b..769c628 100644
--- a/components/camel-digitalocean/src/test/java/org/apache/camel/component/digitalocean/DigitalOceanClientMock.java
+++ b/components/camel-digitalocean/src/test/java/org/apache/camel/component/digitalocean/DigitalOceanClientMock.java
@@ -1,3 +1,19 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package org.apache.camel.component.digitalocean;
import com.myjeeva.digitalocean.exception.DigitalOceanException;
@@ -5,13 +21,9 @@ import com.myjeeva.digitalocean.exception.RequestUnsuccessfulException;
import com.myjeeva.digitalocean.impl.DigitalOceanClient;
import com.myjeeva.digitalocean.pojo.Account;
-/**
- * Created by thomas on 17/03/2017.
- */
public class DigitalOceanClientMock extends DigitalOceanClient {
-
public DigitalOceanClientMock() {
super("token");
}
http://git-wip-us.apache.org/repos/asf/camel/blob/0dd2c2f2/components/camel-digitalocean/src/test/java/org/apache/camel/component/digitalocean/DigitalOceanComponentTest.java
----------------------------------------------------------------------
diff --git a/components/camel-digitalocean/src/test/java/org/apache/camel/component/digitalocean/DigitalOceanComponentTest.java b/components/camel-digitalocean/src/test/java/org/apache/camel/component/digitalocean/DigitalOceanComponentTest.java
index 5f0d85d..ce5a37f 100644
--- a/components/camel-digitalocean/src/test/java/org/apache/camel/component/digitalocean/DigitalOceanComponentTest.java
+++ b/components/camel-digitalocean/src/test/java/org/apache/camel/component/digitalocean/DigitalOceanComponentTest.java
@@ -1,12 +1,28 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package org.apache.camel.component.digitalocean;
import com.myjeeva.digitalocean.impl.DigitalOceanClient;
import com.myjeeva.digitalocean.pojo.Account;
-import org.apache.camel.component.digitalocean.constants.DigitalOceanHeaders;
-import org.apache.camel.component.digitalocean.constants.DigitalOceanOperations;
import org.apache.camel.EndpointInject;
import org.apache.camel.Exchange;
import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.digitalocean.constants.DigitalOceanHeaders;
+import org.apache.camel.component.digitalocean.constants.DigitalOceanOperations;
import org.apache.camel.component.mock.MockEndpoint;
import org.apache.camel.impl.JndiRegistry;
import org.apache.camel.test.junit4.CamelTestSupport;
@@ -15,22 +31,21 @@ import org.junit.Test;
public class DigitalOceanComponentTest extends CamelTestSupport {
+ @EndpointInject(uri = "mock:result")
+ protected MockEndpoint mockResultEndpoint;
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
return new RouteBuilder() {
public void configure() {
from("direct:getAccountInfo")
- .setHeader(DigitalOceanHeaders.OPERATION, constant(DigitalOceanOperations.get))
- .to("digitalocean:account?digitalOceanClient=#digitalOceanClient")
- .to("mock:result");
+ .setHeader(DigitalOceanHeaders.OPERATION, constant(DigitalOceanOperations.get))
+ .to("digitalocean:account?digitalOceanClient=#digitalOceanClient")
+ .to("mock:result");
}
};
}
- @EndpointInject(uri = "mock:result")
- protected MockEndpoint mockResultEndpoint;
-
@Test
public void testGetAccountInfo() throws Exception {
@@ -42,8 +57,6 @@ public class DigitalOceanComponentTest extends CamelTestSupport {
}
-
-
@Override
protected JndiRegistry createRegistry() throws Exception {
JndiRegistry registry = super.createRegistry();
http://git-wip-us.apache.org/repos/asf/camel/blob/0dd2c2f2/components/camel-digitalocean/src/test/java/org/apache/camel/component/digitalocean/integration/DigitalOceanComponentIntegrationTest.java
----------------------------------------------------------------------
diff --git a/components/camel-digitalocean/src/test/java/org/apache/camel/component/digitalocean/integration/DigitalOceanComponentIntegrationTest.java b/components/camel-digitalocean/src/test/java/org/apache/camel/component/digitalocean/integration/DigitalOceanComponentIntegrationTest.java
index c258c81..8fed264 100644
--- a/components/camel-digitalocean/src/test/java/org/apache/camel/component/digitalocean/integration/DigitalOceanComponentIntegrationTest.java
+++ b/components/camel-digitalocean/src/test/java/org/apache/camel/component/digitalocean/integration/DigitalOceanComponentIntegrationTest.java
@@ -1,23 +1,48 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package org.apache.camel.component.digitalocean.integration;
-import com.myjeeva.digitalocean.pojo.*;
-import org.apache.camel.component.digitalocean.constants.DigitalOceanHeaders;
-import org.apache.camel.component.digitalocean.constants.DigitalOceanOperations;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import com.myjeeva.digitalocean.pojo.Account;
+import com.myjeeva.digitalocean.pojo.Action;
+import com.myjeeva.digitalocean.pojo.Droplet;
+import com.myjeeva.digitalocean.pojo.Image;
+import com.myjeeva.digitalocean.pojo.Region;
+import com.myjeeva.digitalocean.pojo.Size;
+import com.myjeeva.digitalocean.pojo.Tag;
import org.apache.camel.EndpointInject;
import org.apache.camel.Exchange;
import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.digitalocean.constants.DigitalOceanHeaders;
+import org.apache.camel.component.digitalocean.constants.DigitalOceanOperations;
import org.apache.camel.component.mock.MockEndpoint;
import org.junit.Ignore;
import org.junit.Test;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-
@Ignore("Must be manually tested. Provide your own oAuthToken")
public class DigitalOceanComponentIntegrationTest extends DigitalOceanTestSupport {
+ @EndpointInject(uri = "mock:result")
+ protected MockEndpoint mockResultEndpoint;
+
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
return new RouteBuilder() {
@@ -28,138 +53,135 @@ public class DigitalOceanComponentIntegrationTest extends DigitalOceanTestSuppor
.to("mock:result");
from("direct:getAccountInfo2")
- .to("digitalocean:account?operation="+DigitalOceanOperations.get+"&oAuthToken={{oAuthToken}}")
- .to("mock:result");
+ .to("digitalocean:account?operation=" + DigitalOceanOperations.get + "&oAuthToken={{oAuthToken}}")
+ .to("mock:result");
from("direct:getActions")
- .to("digitalocean:actions?operation=list&oAuthToken={{oAuthToken}}&perPage=30")
- .to("mock:result");
+ .to("digitalocean:actions?operation=list&oAuthToken={{oAuthToken}}&perPage=30")
+ .to("mock:result");
from("direct:getActionInfo")
- .setHeader(DigitalOceanHeaders.OPERATION, constant(DigitalOceanOperations.get))
- .setHeader(DigitalOceanHeaders.ID, constant(133459716))
- .to("digitalocean:actions?oAuthToken={{oAuthToken}}")
- .to("mock:result");
+ .setHeader(DigitalOceanHeaders.OPERATION, constant(DigitalOceanOperations.get))
+ .setHeader(DigitalOceanHeaders.ID, constant(133459716))
+ .to("digitalocean:actions?oAuthToken={{oAuthToken}}")
+ .to("mock:result");
from("direct:getDroplets")
- .setHeader(DigitalOceanHeaders.OPERATION, constant(DigitalOceanOperations.list))
- .to("digitalocean:droplets?oAuthToken={{oAuthToken}}")
- .to("mock:result");
+ .setHeader(DigitalOceanHeaders.OPERATION, constant(DigitalOceanOperations.list))
+ .to("digitalocean:droplets?oAuthToken={{oAuthToken}}")
+ .to("mock:result");
from("direct:getDroplet")
- .setHeader(DigitalOceanHeaders.ID, constant(5428878))
- .to("digitalocean:droplets?operation=get&oAuthToken={{oAuthToken}}")
- .to("mock:result");
+ .setHeader(DigitalOceanHeaders.ID, constant(5428878))
+ .to("digitalocean:droplets?operation=get&oAuthToken={{oAuthToken}}")
+ .to("mock:result");
from("direct:getDroplet2")
- .setHeader(DigitalOceanHeaders.OPERATION, constant(DigitalOceanOperations.get))
- .setHeader(DigitalOceanHeaders.ID, constant(5428878))
- .to("digitalocean:droplets?oAuthToken={{oAuthToken}}")
- .to("mock:result");
+ .setHeader(DigitalOceanHeaders.OPERATION, constant(DigitalOceanOperations.get))
+ .setHeader(DigitalOceanHeaders.ID, constant(5428878))
+ .to("digitalocean:droplets?oAuthToken={{oAuthToken}}")
+ .to("mock:result");
from("direct:createDroplet")
- .setHeader(DigitalOceanHeaders.OPERATION, constant(DigitalOceanOperations.create))
- .setHeader(DigitalOceanHeaders.NAME, constant("camel-test"))
- .setHeader(DigitalOceanHeaders.REGION, constant("fra1"))
- .setHeader(DigitalOceanHeaders.DROPLET_IMAGE, constant("ubuntu-14-04-x64"))
- .setHeader(DigitalOceanHeaders.DROPLET_SIZE, constant("512mb"))
- .process(e -> {
- Collection<String> tags = new ArrayList<String>();
- tags.add("tag1");
- tags.add("tag2");
- e.getIn().setHeader(DigitalOceanHeaders.DROPLET_TAGS, tags);
-
- })
- .to("digitalocean:droplets?oAuthToken={{oAuthToken}}")
- .to("mock:result");
+ .setHeader(DigitalOceanHeaders.OPERATION, constant(DigitalOceanOperations.create))
+ .setHeader(DigitalOceanHeaders.NAME, constant("camel-test"))
+ .setHeader(DigitalOceanHeaders.REGION, constant("fra1"))
+ .setHeader(DigitalOceanHeaders.DROPLET_IMAGE, constant("ubuntu-14-04-x64"))
+ .setHeader(DigitalOceanHeaders.DROPLET_SIZE, constant("512mb"))
+ .process(e -> {
+ Collection<String> tags = new ArrayList<String>();
+ tags.add("tag1");
+ tags.add("tag2");
+ e.getIn().setHeader(DigitalOceanHeaders.DROPLET_TAGS, tags);
+
+ })
+ .to("digitalocean:droplets?oAuthToken={{oAuthToken}}")
+ .to("mock:result");
from("direct:createMultipleDroplets")
- .setHeader(DigitalOceanHeaders.OPERATION, constant(DigitalOceanOperations.create))
- .process(e -> {
- Collection<String> names = new ArrayList<String>();
- names.add("droplet1");
- names.add("droplet2");
- e.getIn().setHeader(DigitalOceanHeaders.NAMES, names);
-
- })
- .setHeader(DigitalOceanHeaders.REGION, constant("fra1"))
- .setHeader(DigitalOceanHeaders.DROPLET_IMAGE, constant("ubuntu-14-04-x64"))
- .setHeader(DigitalOceanHeaders.DROPLET_SIZE, constant("512mb"))
- .process(e -> {
- Collection<String> tags = new ArrayList<String>();
- tags.add("tag1");
- tags.add("tag2");
- e.getIn().setHeader(DigitalOceanHeaders.DROPLET_TAGS, tags);
-
- })
- .to("digitalocean://droplets?oAuthToken={{oAuthToken}}")
- .to("mock:result");
+ .setHeader(DigitalOceanHeaders.OPERATION, constant(DigitalOceanOperations.create))
+ .process(e -> {
+ Collection<String> names = new ArrayList<String>();
+ names.add("droplet1");
+ names.add("droplet2");
+ e.getIn().setHeader(DigitalOceanHeaders.NAMES, names);
+
+ })
+ .setHeader(DigitalOceanHeaders.REGION, constant("fra1"))
+ .setHeader(DigitalOceanHeaders.DROPLET_IMAGE, constant("ubuntu-14-04-x64"))
+ .setHeader(DigitalOceanHeaders.DROPLET_SIZE, constant("512mb"))
+ .process(e -> {
+ Collection<String> tags = new ArrayList<String>();
+ tags.add("tag1");
+ tags.add("tag2");
+ e.getIn().setHeader(DigitalOceanHeaders.DROPLET_TAGS, tags);
+
+ })
+ .to("digitalocean://droplets?oAuthToken={{oAuthToken}}")
+ .to("mock:result");
from("direct:getDropletBackups")
- .setHeader(DigitalOceanHeaders.OPERATION, constant(DigitalOceanOperations.listBackups))
- .setHeader(DigitalOceanHeaders.ID, constant(5428878))
- .to("digitalocean://droplets?oAuthToken={{oAuthToken}}")
- .to("mock:result");
+ .setHeader(DigitalOceanHeaders.OPERATION, constant(DigitalOceanOperations.listBackups))
+ .setHeader(DigitalOceanHeaders.ID, constant(5428878))
+ .to("digitalocean://droplets?oAuthToken={{oAuthToken}}")
+ .to("mock:result");
from("direct:createTag")
- .setHeader(DigitalOceanHeaders.OPERATION, constant(DigitalOceanOperations.create))
- .setHeader(DigitalOceanHeaders.NAME, constant("tag1"))
- .to("digitalocean://tags?oAuthToken={{oAuthToken}}")
- .to("mock:result");
+ .setHeader(DigitalOceanHeaders.OPERATION, constant(DigitalOceanOperations.create))
+ .setHeader(DigitalOceanHeaders.NAME, constant("tag1"))
+ .to("digitalocean://tags?oAuthToken={{oAuthToken}}")
+ .to("mock:result");
from("direct:getTags")
- .setHeader(DigitalOceanHeaders.OPERATION, constant(DigitalOceanOperations.list))
- .to("digitalocean://tags?oAuthToken={{oAuthToken}}")
- .to("mock:result");
+ .setHeader(DigitalOceanHeaders.OPERATION, constant(DigitalOceanOperations.list))
+ .to("digitalocean://tags?oAuthToken={{oAuthToken}}")
+ .to("mock:result");
from("direct:getImages")
- .setHeader(DigitalOceanHeaders.OPERATION, constant(DigitalOceanOperations.list))
- .to("digitalocean://images?oAuthToken={{oAuthToken}}")
- .to("mock:result");
+ .setHeader(DigitalOceanHeaders.OPERATION, constant(DigitalOceanOperations.list))
+ .to("digitalocean://images?oAuthToken={{oAuthToken}}")
+ .to("mock:result");
from("direct:getImage")
- .setHeader(DigitalOceanHeaders.OPERATION, constant(DigitalOceanOperations.get))
- .setHeader(DigitalOceanHeaders.DROPLET_IMAGE, constant("ubuntu-14-04-x64"))
- .to("digitalocean://images?oAuthToken={{oAuthToken}}")
- .to("mock:result");
+ .setHeader(DigitalOceanHeaders.OPERATION, constant(DigitalOceanOperations.get))
+ .setHeader(DigitalOceanHeaders.DROPLET_IMAGE, constant("ubuntu-14-04-x64"))
+ .to("digitalocean://images?oAuthToken={{oAuthToken}}")
+ .to("mock:result");
from("direct:getSizes")
- .setHeader(DigitalOceanHeaders.OPERATION, constant(DigitalOceanOperations.list))
- .to("digitalocean://sizes?oAuthToken={{oAuthToken}}")
- .to("mock:result");
+ .setHeader(DigitalOceanHeaders.OPERATION, constant(DigitalOceanOperations.list))
+ .to("digitalocean://sizes?oAuthToken={{oAuthToken}}")
+ .to("mock:result");
from("direct:getSize")
- .setHeader(DigitalOceanHeaders.OPERATION, constant(DigitalOceanOperations.get))
- .setHeader(DigitalOceanHeaders.NAME, constant("512mb"))
- .to("digitalocean://sizes?oAuthToken={{oAuthToken}}")
- .to("mock:result");
+ .setHeader(DigitalOceanHeaders.OPERATION, constant(DigitalOceanOperations.get))
+ .setHeader(DigitalOceanHeaders.NAME, constant("512mb"))
+ .to("digitalocean://sizes?oAuthToken={{oAuthToken}}")
+ .to("mock:result");
from("direct:getRegions")
- .setHeader(DigitalOceanHeaders.OPERATION, constant(DigitalOceanOperations.list))
- .to("digitalocean://regions?oAuthToken={{oAuthToken}}")
- .to("mock:result");
+ .setHeader(DigitalOceanHeaders.OPERATION, constant(DigitalOceanOperations.list))
+ .to("digitalocean://regions?oAuthToken={{oAuthToken}}")
+ .to("mock:result");
from("direct:getRegion")
- .setHeader(DigitalOceanHeaders.OPERATION, constant(DigitalOceanOperations.get))
- .setHeader(DigitalOceanHeaders.NAME, constant("nyc1"))
- .to("digitalocean://regions?oAuthToken={{oAuthToken}}")
- .to("mock:result");
+ .setHeader(DigitalOceanHeaders.OPERATION, constant(DigitalOceanOperations.get))
+ .setHeader(DigitalOceanHeaders.NAME, constant("nyc1"))
+ .to("digitalocean://regions?oAuthToken={{oAuthToken}}")
+ .to("mock:result");
}
};
}
- @EndpointInject(uri = "mock:result")
- protected MockEndpoint mockResultEndpoint;
-
@Test
public void testGetAccountInfo() throws Exception {
mockResultEndpoint.expectedMinimumMessageCount(2);
Exchange exchange = template.request("direct:getAccountInfo", null);
- assertTrue(((Account)exchange.getOut().getBody()).isEmailVerified());
+ assertTrue(((Account) exchange.getOut().getBody()).isEmailVerified());
exchange = template.request("direct:getAccountInfo2", null);
- assertTrue(((Account)exchange.getOut().getBody()).isEmailVerified());
+ assertTrue(((Account) exchange.getOut().getBody()).isEmailVerified());
assertMockEndpointsSatisfied();
@@ -172,7 +194,7 @@ public class DigitalOceanComponentIntegrationTest extends DigitalOceanTestSuppor
Exchange exchange = template.request("direct:getActions", null);
assertMockEndpointsSatisfied();
- assertEquals(((List)exchange.getOut().getBody()).size(), 30);
+ assertEquals(((List) exchange.getOut().getBody()).size(), 30);
}
@Test
@@ -182,23 +204,22 @@ public class DigitalOceanComponentIntegrationTest extends DigitalOceanTestSuppor
Exchange exchange = template.request("direct:getActionInfo", null);
assertMockEndpointsSatisfied();
- assertEquals(((Action)exchange.getOut().getBody()).getId(), new Integer(133459716));
+ assertEquals(((Action) exchange.getOut().getBody()).getId(), new Integer(133459716));
}
-
@Test
public void testGetDropletInfo() throws Exception {
mockResultEndpoint.expectedMinimumMessageCount(2);
Exchange exchange = template.request("direct:getDroplet", null);
- assertEquals(((Droplet)exchange.getOut().getBody()).getId(), new Integer(5428878));
+ assertEquals(((Droplet) exchange.getOut().getBody()).getId(), new Integer(5428878));
exchange = template.request("direct:getDroplet2", null);
assertMockEndpointsSatisfied();
- assertEquals(((Droplet)exchange.getOut().getBody()).getId(), new Integer(5428878));
+ assertEquals(((Droplet) exchange.getOut().getBody()).getId(), new Integer(5428878));
}
@@ -210,7 +231,7 @@ public class DigitalOceanComponentIntegrationTest extends DigitalOceanTestSuppor
Exchange exchange = template.request("direct:createDroplet", null);
assertMockEndpointsSatisfied();
- Droplet droplet = (Droplet)exchange.getOut().getBody();
+ Droplet droplet = (Droplet) exchange.getOut().getBody();
assertNotNull(droplet.getId());
assertEquals(droplet.getRegion().getSlug(), "fra1");
@@ -225,7 +246,7 @@ public class DigitalOceanComponentIntegrationTest extends DigitalOceanTestSuppor
Exchange exchange = template.request("direct:createMultipleDroplets", null);
assertMockEndpointsSatisfied();
- List<Droplet> droplets = (List<Droplet>)exchange.getOut().getBody();
+ List<Droplet> droplets = (List<Droplet>) exchange.getOut().getBody();
assertCollectionSize(droplets, 2);
}
@@ -238,7 +259,7 @@ public class DigitalOceanComponentIntegrationTest extends DigitalOceanTestSuppor
Exchange exchange = template.request("direct:getDroplets", null);
assertMockEndpointsSatisfied();
- assertEquals(((List)exchange.getOut().getBody()).size(), 1);
+ assertEquals(((List) exchange.getOut().getBody()).size(), 1);
}
@Test
@@ -248,7 +269,7 @@ public class DigitalOceanComponentIntegrationTest extends DigitalOceanTestSuppor
Exchange exchange = template.request("direct:getDropletBackups", null);
assertMockEndpointsSatisfied();
- assertCollectionSize(((List)exchange.getOut().getBody()), 0);
+ assertCollectionSize((List) exchange.getOut().getBody(), 0);
}
@Test
@@ -258,7 +279,7 @@ public class DigitalOceanComponentIntegrationTest extends DigitalOceanTestSuppor
Exchange exchange = template.request("direct:createTag", null);
assertMockEndpointsSatisfied();
- assertEquals(((Tag)exchange.getOut().getBody()).getName(), "tag1");
+ assertEquals(((Tag) exchange.getOut().getBody()).getName(), "tag1");
}
@@ -269,7 +290,7 @@ public class DigitalOceanComponentIntegrationTest extends DigitalOceanTestSuppor
Exchange exchange = template.request("direct:getTags", null);
assertMockEndpointsSatisfied();
- assertEquals(((List<Tag>)exchange.getOut().getBody()).get(0).getName(), "tag1");
+ assertEquals(((List<Tag>) exchange.getOut().getBody()).get(0).getName(), "tag1");
}
@Test
@@ -279,7 +300,7 @@ public class DigitalOceanComponentIntegrationTest extends DigitalOceanTestSuppor
Exchange exchange = template.request("direct:getImages", null);
assertMockEndpointsSatisfied();
- List<Image> images = (List<Image>)exchange.getOut().getBody();
+ List<Image> images = (List<Image>) exchange.getOut().getBody();
assertNotEquals(images.size(), 1);
}
@@ -301,7 +322,7 @@ public class DigitalOceanComponentIntegrationTest extends DigitalOceanTestSuppor
Exchange exchange = template.request("direct:getSizes", null);
assertMockEndpointsSatisfied();
- List<Size> sizes = (List<Size>)exchange.getOut().getBody();
+ List<Size> sizes = (List<Size>) exchange.getOut().getBody();
System.out.println(sizes);
assertNotEquals(sizes.size(), 1);
}
@@ -314,7 +335,7 @@ public class DigitalOceanComponentIntegrationTest extends DigitalOceanTestSuppor
Exchange exchange = template.request("direct:getRegions", null);
assertMockEndpointsSatisfied();
- List<Region> regions = (List<Region>)exchange.getOut().getBody();
+ List<Region> regions = (List<Region>) exchange.getOut().getBody();
System.out.println(regions);
assertNotEquals(regions.size(), 1);
}
http://git-wip-us.apache.org/repos/asf/camel/blob/0dd2c2f2/components/camel-digitalocean/src/test/java/org/apache/camel/component/digitalocean/integration/DigitalOceanTestSupport.java
----------------------------------------------------------------------
diff --git a/components/camel-digitalocean/src/test/java/org/apache/camel/component/digitalocean/integration/DigitalOceanTestSupport.java b/components/camel-digitalocean/src/test/java/org/apache/camel/component/digitalocean/integration/DigitalOceanTestSupport.java
index 3c3ffd8..914437b 100644
--- a/components/camel-digitalocean/src/test/java/org/apache/camel/component/digitalocean/integration/DigitalOceanTestSupport.java
+++ b/components/camel-digitalocean/src/test/java/org/apache/camel/component/digitalocean/integration/DigitalOceanTestSupport.java
@@ -1,15 +1,29 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package org.apache.camel.component.digitalocean.integration;
-import java.util.Properties;
-import org.apache.camel.test.junit4.CamelTestSupport;
-
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
+import java.util.Properties;
+
+import org.apache.camel.test.junit4.CamelTestSupport;
+
-/**
- * Created by thomas on 17/03/2017.
- */
public class DigitalOceanTestSupport extends CamelTestSupport {
protected final Properties properties;
http://git-wip-us.apache.org/repos/asf/camel/blob/0dd2c2f2/components/camel-digitalocean/src/test/resources/log4j2.properties
----------------------------------------------------------------------
diff --git a/components/camel-digitalocean/src/test/resources/log4j2.properties b/components/camel-digitalocean/src/test/resources/log4j2.properties
index 60e86f8..8daffa6 100644
--- a/components/camel-digitalocean/src/test/resources/log4j2.properties
+++ b/components/camel-digitalocean/src/test/resources/log4j2.properties
@@ -14,10 +14,9 @@
## See the License for the specific language governing permissions and
## limitations under the License.
## ---------------------------------------------------------------------------
-
-appender.out.type = Console
-appender.out.name = out
-appender.out.layout.type = PatternLayout
-appender.out.layout.pattern = [%30.30t] %-30.30c{1} %-5p %m%n
-rootLogger.level = DEBUG
-rootLogger.appenderRef.out.ref = out
+appender.out.type=Console
+appender.out.name=out
+appender.out.layout.type=PatternLayout
+appender.out.layout.pattern=[%30.30t] %-30.30c{1} %-5p %m%n
+rootLogger.level=DEBUG
+rootLogger.appenderRef.out.ref=out
http://git-wip-us.apache.org/repos/asf/camel/blob/0dd2c2f2/components/camel-digitalocean/src/test/resources/test-options.properties
----------------------------------------------------------------------
diff --git a/components/camel-digitalocean/src/test/resources/test-options.properties b/components/camel-digitalocean/src/test/resources/test-options.properties
index 549de90..acae91a 100644
--- a/components/camel-digitalocean/src/test/resources/test-options.properties
+++ b/components/camel-digitalocean/src/test/resources/test-options.properties
@@ -14,5 +14,4 @@
## See the License for the specific language governing permissions and
## limitations under the License.
## ---------------------------------------------------------------------------
-
oAuthToken=<yourOAuthToken>
\ No newline at end of file
[19/20] camel git commit: CAMEL-11062: Added camel-digitalocean to kit
Posted by ac...@apache.org.
CAMEL-11062: Added camel-digitalocean to kit
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/fa9c831e
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/fa9c831e
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/fa9c831e
Branch: refs/heads/master
Commit: fa9c831eed917850a0125e428ab2531a62f8dd7d
Parents: f86b289
Author: Andrea Cosentino <an...@gmail.com>
Authored: Mon Mar 27 09:11:05 2017 +0200
Committer: Andrea Cosentino <an...@gmail.com>
Committed: Mon Mar 27 09:48:35 2017 +0200
----------------------------------------------------------------------
apache-camel/src/main/descriptors/common-bin.xml | 2 ++
components/pom.xml | 1 +
parent/pom.xml | 10 ++++++++++
3 files changed, 13 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/fa9c831e/apache-camel/src/main/descriptors/common-bin.xml
----------------------------------------------------------------------
diff --git a/apache-camel/src/main/descriptors/common-bin.xml b/apache-camel/src/main/descriptors/common-bin.xml
index 211971d..9f297e2 100644
--- a/apache-camel/src/main/descriptors/common-bin.xml
+++ b/apache-camel/src/main/descriptors/common-bin.xml
@@ -67,6 +67,7 @@
<include>org.apache.camel:camel-csv</include>
<include>org.apache.camel:camel-cxf</include>
<include>org.apache.camel:camel-cxf-transport</include>
+ <include>org.apache.camel:camel-digitalocean</include>
<include>org.apache.camel:camel-disruptor</include>
<include>org.apache.camel:camel-dns</include>
<include>org.apache.camel:camel-docker</include>
@@ -349,6 +350,7 @@
<include>org.apache.camel:camel-csv-starter</include>
<include>org.apache.camel:camel-cxf-starter</include>
<include>org.apache.camel:camel-cxf-transport-starter</include>
+ <include>org.apache.camel:camel-digitalocean-starter</include>
<include>org.apache.camel:camel-disruptor-starter</include>
<include>org.apache.camel:camel-dns-starter</include>
<include>org.apache.camel:camel-docker-starter</include>
http://git-wip-us.apache.org/repos/asf/camel/blob/fa9c831e/components/pom.xml
----------------------------------------------------------------------
diff --git a/components/pom.xml b/components/pom.xml
index f160c8e..8b61231 100644
--- a/components/pom.xml
+++ b/components/pom.xml
@@ -100,6 +100,7 @@
<module>camel-couchdb</module>
<module>camel-crypto</module>
<module>camel-csv</module>
+ <module>camel-digitalocean</module>
<module>camel-disruptor</module>
<module>camel-dns</module>
<module>camel-docker</module>
http://git-wip-us.apache.org/repos/asf/camel/blob/fa9c831e/parent/pom.xml
----------------------------------------------------------------------
diff --git a/parent/pom.xml b/parent/pom.xml
index 8b78d21..2a57c14 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -998,6 +998,11 @@
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
+ <artifactId>camel-digitalocean</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
<artifactId>camel-disruptor</artifactId>
<version>${project.version}</version>
</dependency>
@@ -2352,6 +2357,11 @@
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
+ <artifactId>camel-digitalocean-starter</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
<artifactId>camel-disruptor-starter</artifactId>
<version>${project.version}</version>
</dependency>
[13/20] camel git commit: Add Ignore annotation for integration tests
class.
Posted by ac...@apache.org.
Add Ignore annotation for integration tests class.
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/8a1ad4c0
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/8a1ad4c0
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/8a1ad4c0
Branch: refs/heads/master
Commit: 8a1ad4c0634d49a0fd4356cd08efd3fcab130c04
Parents: b8202a2
Author: Thomas Lehoux <tl...@gmail.com>
Authored: Fri Mar 24 11:36:35 2017 +0100
Committer: Andrea Cosentino <an...@gmail.com>
Committed: Mon Mar 27 09:48:34 2017 +0200
----------------------------------------------------------------------
.../integration/DigitalOceanComponentIntegrationTest.java | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/8a1ad4c0/components/camel-digitalocean/src/test/java/org/apache/camel/component/digitalocean/integration/DigitalOceanComponentIntegrationTest.java
----------------------------------------------------------------------
diff --git a/components/camel-digitalocean/src/test/java/org/apache/camel/component/digitalocean/integration/DigitalOceanComponentIntegrationTest.java b/components/camel-digitalocean/src/test/java/org/apache/camel/component/digitalocean/integration/DigitalOceanComponentIntegrationTest.java
index e76d516..c258c81 100644
--- a/components/camel-digitalocean/src/test/java/org/apache/camel/component/digitalocean/integration/DigitalOceanComponentIntegrationTest.java
+++ b/components/camel-digitalocean/src/test/java/org/apache/camel/component/digitalocean/integration/DigitalOceanComponentIntegrationTest.java
@@ -7,6 +7,7 @@ import org.apache.camel.EndpointInject;
import org.apache.camel.Exchange;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
+import org.junit.Ignore;
import org.junit.Test;
import java.util.ArrayList;
@@ -14,7 +15,7 @@ import java.util.Collection;
import java.util.List;
-//@Ignore("Must be manually tested. Provide your own oAuthToken")
+@Ignore("Must be manually tested. Provide your own oAuthToken")
public class DigitalOceanComponentIntegrationTest extends DigitalOceanTestSupport {
@Override
[06/20] camel git commit: remove .gitignore file
Posted by ac...@apache.org.
remove .gitignore file
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/b2156d24
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/b2156d24
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/b2156d24
Branch: refs/heads/master
Commit: b2156d24b667e8befbbf50c6971cf25097da2786
Parents: 1d57f7b
Author: Thomas Lehoux <tl...@gmail.com>
Authored: Fri Mar 24 11:18:48 2017 +0100
Committer: Andrea Cosentino <an...@gmail.com>
Committed: Mon Mar 27 09:48:34 2017 +0200
----------------------------------------------------------------------
components/camel-digitalocean/.gitignore | 4 ----
1 file changed, 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/b2156d24/components/camel-digitalocean/.gitignore
----------------------------------------------------------------------
diff --git a/components/camel-digitalocean/.gitignore b/components/camel-digitalocean/.gitignore
deleted file mode 100644
index f1f87fc..0000000
--- a/components/camel-digitalocean/.gitignore
+++ /dev/null
@@ -1,4 +0,0 @@
-*.iml
-.idea/
-overlays/
-target/
\ No newline at end of file
[15/20] camel git commit: Fixes enumeration issue.
Posted by ac...@apache.org.
Fixes enumeration issue.
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/36971f7d
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/36971f7d
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/36971f7d
Branch: refs/heads/master
Commit: 36971f7d452e1899405554407bdfea758001366c
Parents: 8a1ad4c
Author: Thomas Lehoux <tl...@gmail.com>
Authored: Fri Mar 24 11:37:31 2017 +0100
Committer: Andrea Cosentino <an...@gmail.com>
Committed: Mon Mar 27 09:48:34 2017 +0200
----------------------------------------------------------------------
.../producer/DigitalOceanFloatingIPsProducer.java | 14 +++++++-------
.../producer/DigitalOceanImagesProducer.java | 16 ++++++++--------
.../producer/DigitalOceanTagsProducer.java | 10 +++++-----
3 files changed, 20 insertions(+), 20 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/36971f7d/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/producer/DigitalOceanFloatingIPsProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/producer/DigitalOceanFloatingIPsProducer.java b/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/producer/DigitalOceanFloatingIPsProducer.java
index da94dc0..3bb90de 100644
--- a/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/producer/DigitalOceanFloatingIPsProducer.java
+++ b/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/producer/DigitalOceanFloatingIPsProducer.java
@@ -36,25 +36,25 @@ public class DigitalOceanFloatingIPsProducer extends DigitalOceanProducer {
public void process(Exchange exchange) throws Exception {
switch(determineOperation(exchange)) {
- case DigitalOceanOperations.list:
+ case list:
getFloatingIPs(exchange);
break;
- case DigitalOceanOperations.create:
+ case create:
createFloatingIp(exchange);
break;
- case DigitalOceanOperations.get:
+ case get:
getFloatingIP(exchange);
break;
- case DigitalOceanOperations.delete:
+ case delete:
deleteFloatingIP(exchange);
break;
- case DigitalOceanOperations.assign:
+ case assign:
assignFloatingIPToDroplet(exchange);
break;
- case DigitalOceanOperations.unassign:
+ case unassign:
unassignFloatingIP(exchange);
break;
- case DigitalOceanOperations.listActions:
+ case listActions:
getFloatingIPActions(exchange);
break;
default:
http://git-wip-us.apache.org/repos/asf/camel/blob/36971f7d/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/producer/DigitalOceanImagesProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/producer/DigitalOceanImagesProducer.java b/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/producer/DigitalOceanImagesProducer.java
index a8c98cc..b433596 100644
--- a/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/producer/DigitalOceanImagesProducer.java
+++ b/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/producer/DigitalOceanImagesProducer.java
@@ -39,28 +39,28 @@ public class DigitalOceanImagesProducer extends DigitalOceanProducer {
switch(determineOperation(exchange)) {
- case DigitalOceanOperations.list:
+ case list:
getImages(exchange);
break;
- case DigitalOceanOperations.ownList:
+ case ownList:
getUserImages(exchange);
break;
- case DigitalOceanOperations.listActions:
+ case listActions:
getImageActions(exchange);
break;
- case DigitalOceanOperations.get:
+ case get:
getImage(exchange);
break;
- case DigitalOceanOperations.update:
+ case update:
updateImage(exchange);
break;
- case DigitalOceanOperations.delete:
+ case delete:
deleteImage(exchange);
break;
- case DigitalOceanOperations.transfer:
+ case transfer:
transferImage(exchange);
break;
- case DigitalOceanOperations.convert:
+ case convert:
convertImageToSnapshot(exchange);
break;
default:
http://git-wip-us.apache.org/repos/asf/camel/blob/36971f7d/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/producer/DigitalOceanTagsProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/producer/DigitalOceanTagsProducer.java b/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/producer/DigitalOceanTagsProducer.java
index 00c0cba..7b6777c 100644
--- a/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/producer/DigitalOceanTagsProducer.java
+++ b/components/camel-digitalocean/src/main/java/org/apache/camel/component/digitalocean/producer/DigitalOceanTagsProducer.java
@@ -36,19 +36,19 @@ public class DigitalOceanTagsProducer extends DigitalOceanProducer {
public void process(Exchange exchange) throws Exception {
switch(determineOperation(exchange)) {
- case DigitalOceanOperations.list:
+ case list:
getTags(exchange);
break;
- case DigitalOceanOperations.create:
+ case create:
createTag(exchange);
break;
- case DigitalOceanOperations.get:
+ case get:
getTag(exchange);
break;
- case DigitalOceanOperations.delete:
+ case delete:
deleteTag(exchange);
break;
- case DigitalOceanOperations.update:
+ case update:
updateTag(exchange);
break;
default:
[12/20] camel git commit: Change version to 2.19.0-SNAPSHOT
Posted by ac...@apache.org.
Change version to 2.19.0-SNAPSHOT
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/b8202a21
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/b8202a21
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/b8202a21
Branch: refs/heads/master
Commit: b8202a21ec4003e6ee93a78ca2520be07f15dfc0
Parents: 17d527d
Author: Thomas Lehoux <tl...@gmail.com>
Authored: Fri Mar 24 11:29:48 2017 +0100
Committer: Andrea Cosentino <an...@gmail.com>
Committed: Mon Mar 27 09:48:34 2017 +0200
----------------------------------------------------------------------
components/camel-digitalocean/pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/b8202a21/components/camel-digitalocean/pom.xml
----------------------------------------------------------------------
diff --git a/components/camel-digitalocean/pom.xml b/components/camel-digitalocean/pom.xml
index 02e01f3..8b1ef2f 100644
--- a/components/camel-digitalocean/pom.xml
+++ b/components/camel-digitalocean/pom.xml
@@ -20,7 +20,7 @@ limitations under the License.
<groupId>com.viwilo.camel</groupId>
<artifactId>camel-digitalocean</artifactId>
<packaging>jar</packaging>
- <version>1.0-SNAPSHOT</version>
+ <version>2.19.0-SNAPSHOT</version>
<name>Camel DigitalOcean Component</name>
<description>A Camel DigitalOcean Services Components</description>
[07/20] camel git commit: Clean pom.xml
Posted by ac...@apache.org.
Clean pom.xml
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/db910e7e
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/db910e7e
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/db910e7e
Branch: refs/heads/master
Commit: db910e7e1b55fb6d8d1b50435cef4386d58e2408
Parents: 34dc8c4
Author: Thomas Lehoux <tl...@gmail.com>
Authored: Fri Mar 24 14:54:32 2017 +0100
Committer: Andrea Cosentino <an...@gmail.com>
Committed: Mon Mar 27 09:48:34 2017 +0200
----------------------------------------------------------------------
components/camel-digitalocean/pom.xml | 39 +++++++++---------------------
1 file changed, 12 insertions(+), 27 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/db910e7e/components/camel-digitalocean/pom.xml
----------------------------------------------------------------------
diff --git a/components/camel-digitalocean/pom.xml b/components/camel-digitalocean/pom.xml
index 8b1ef2f..e70d5e7 100644
--- a/components/camel-digitalocean/pom.xml
+++ b/components/camel-digitalocean/pom.xml
@@ -13,49 +13,34 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
- <groupId>com.viwilo.camel</groupId>
+ <parent>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>components</artifactId>
+ <version>2.19.0-SNAPSHOT</version>
+ </parent>
+
<artifactId>camel-digitalocean</artifactId>
<packaging>jar</packaging>
- <version>2.19.0-SNAPSHOT</version>
+ <name>Camel :: DigitalOcean</name>
+ <description>Camel DigitalOcean support</description>
- <name>Camel DigitalOcean Component</name>
- <description>A Camel DigitalOcean Services Components</description>
<properties>
- <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
- <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
+ <camel.osgi.export.pkg>org.apache.camel.component.digitalocean.*</camel.osgi.export.pkg>
+ <camel.osgi.export.service>org.apache.camel.spi.ComponentResolver;component=digitalocean</camel.osgi.export.service>
</properties>
- <dependencyManagement>
- <dependencies>
- <!-- Camel BOM -->
- <dependency>
- <groupId>org.apache.camel</groupId>
- <artifactId>camel-parent</artifactId>
- <version>2.18.3</version>
- <scope>import</scope>
- <type>pom</type>
- </dependency>
- </dependencies>
- </dependencyManagement>
<dependencies>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-core</artifactId>
</dependency>
-
- <dependency>
- <groupId>org.apache.camel</groupId>
- <artifactId>apt</artifactId>
- <version>2.18.3</version>
- <scope>provided</scope>
- </dependency>
-
<!-- DigitalOcean API java library -->
<dependency>
[11/20] camel git commit: Refactor com.viwilo to org.apache.camel
Posted by ac...@apache.org.
Refactor com.viwilo to org.apache.camel
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/17d527d1
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/17d527d1
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/17d527d1
Branch: refs/heads/master
Commit: 17d527d1f4a6b5109ed2f01d1f9f10bc8f0e0749
Parents: b2156d2
Author: Thomas Lehoux <tl...@gmail.com>
Authored: Fri Mar 24 11:27:58 2017 +0100
Committer: Andrea Cosentino <an...@gmail.com>
Committed: Mon Mar 27 09:48:34 2017 +0200
----------------------------------------------------------------------
.../com/viwilo/camel/DigitalOceanComponent.java | 59 ---
.../viwilo/camel/DigitalOceanConfiguration.java | 176 --------
.../com/viwilo/camel/DigitalOceanEndpoint.java | 130 ------
.../com/viwilo/camel/DigitalOceanException.java | 30 --
.../camel/constants/DigitalOceanHeaders.java | 54 ---
.../camel/constants/DigitalOceanImageTypes.java | 24 --
.../camel/constants/DigitalOceanOperations.java | 57 ---
.../camel/constants/DigitalOceanResources.java | 36 --
.../constants/DigitalOceanSnapshotTypes.java | 24 --
.../producer/DigitalOceanAccountProducer.java | 39 --
.../producer/DigitalOceanActionsProducer.java | 66 ---
.../DigitalOceanBlockStoragesProducer.java | 252 ------------
.../producer/DigitalOceanDropletsProducer.java | 405 -------------------
.../DigitalOceanFloatingIPsProducer.java | 151 -------
.../producer/DigitalOceanImagesProducer.java | 175 --------
.../producer/DigitalOceanKeysProducer.java | 144 -------
.../camel/producer/DigitalOceanProducer.java | 53 ---
.../producer/DigitalOceanRegionsProducer.java | 39 --
.../producer/DigitalOceanSizesProducer.java | 39 --
.../producer/DigitalOceanSnapshotsProducer.java | 101 -----
.../producer/DigitalOceanTagsProducer.java | 114 ------
.../digitalocean/DigitalOceanComponent.java | 59 +++
.../digitalocean/DigitalOceanConfiguration.java | 173 ++++++++
.../digitalocean/DigitalOceanEndpoint.java | 130 ++++++
.../digitalocean/DigitalOceanException.java | 30 ++
.../constants/DigitalOceanHeaders.java | 54 +++
.../constants/DigitalOceanImageTypes.java | 24 ++
.../constants/DigitalOceanOperations.java | 57 +++
.../constants/DigitalOceanResources.java | 36 ++
.../constants/DigitalOceanSnapshotTypes.java | 24 ++
.../producer/DigitalOceanAccountProducer.java | 39 ++
.../producer/DigitalOceanActionsProducer.java | 66 +++
.../DigitalOceanBlockStoragesProducer.java | 252 ++++++++++++
.../producer/DigitalOceanDropletsProducer.java | 405 +++++++++++++++++++
.../DigitalOceanFloatingIPsProducer.java | 152 +++++++
.../producer/DigitalOceanImagesProducer.java | 176 ++++++++
.../producer/DigitalOceanKeysProducer.java | 144 +++++++
.../producer/DigitalOceanProducer.java | 53 +++
.../producer/DigitalOceanRegionsProducer.java | 39 ++
.../producer/DigitalOceanSizesProducer.java | 39 ++
.../producer/DigitalOceanSnapshotsProducer.java | 101 +++++
.../producer/DigitalOceanTagsProducer.java | 115 ++++++
.../viwilo/camel/DigitalOceanClientMock.java | 26 --
.../viwilo/camel/DigitalOceanComponentTest.java | 54 ---
.../DigitalOceanComponentIntegrationTest.java | 323 ---------------
.../integration/DigitalOceanTestSupport.java | 42 --
.../digitalocean/DigitalOceanClientMock.java | 26 ++
.../digitalocean/DigitalOceanComponentTest.java | 54 +++
.../DigitalOceanComponentIntegrationTest.java | 322 +++++++++++++++
.../integration/DigitalOceanTestSupport.java | 42 ++
50 files changed, 2612 insertions(+), 2613 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/17d527d1/components/camel-digitalocean/src/main/java/com/viwilo/camel/DigitalOceanComponent.java
----------------------------------------------------------------------
diff --git a/components/camel-digitalocean/src/main/java/com/viwilo/camel/DigitalOceanComponent.java b/components/camel-digitalocean/src/main/java/com/viwilo/camel/DigitalOceanComponent.java
deleted file mode 100644
index b341a9b..0000000
--- a/components/camel-digitalocean/src/main/java/com/viwilo/camel/DigitalOceanComponent.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.viwilo.camel;
-
-import java.util.Map;
-
-import com.viwilo.camel.constants.DigitalOceanResources;
-import org.apache.camel.CamelContext;
-import org.apache.camel.Endpoint;
-
-import org.apache.camel.impl.UriEndpointComponent;
-import org.apache.camel.util.ObjectHelper;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Represents the component that manages {@link DigitalOceanEndpoint}.
- */
-public class DigitalOceanComponent extends UriEndpointComponent {
-
- private static final transient Logger LOG = LoggerFactory.getLogger(DigitalOceanComponent.class);
-
-
- public DigitalOceanComponent() {
- super(DigitalOceanEndpoint.class);
- }
-
- public DigitalOceanComponent(CamelContext context) {
- super(context, DigitalOceanEndpoint.class);
- }
-
- protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception {
-
- DigitalOceanConfiguration configuration = new DigitalOceanConfiguration();
- setProperties(configuration, parameters);
- configuration.setResource(DigitalOceanResources.valueOf(remaining));
-
- if (ObjectHelper.isEmpty(configuration.getOAuthToken()) && ObjectHelper.isEmpty(configuration.getDigitalOceanClient()))
- throw new DigitalOceanException("oAuthToken or digitalOceanClient must be specified");
-
- Endpoint endpoint = new DigitalOceanEndpoint(uri, this, configuration);
- return endpoint;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/17d527d1/components/camel-digitalocean/src/main/java/com/viwilo/camel/DigitalOceanConfiguration.java
----------------------------------------------------------------------
diff --git a/components/camel-digitalocean/src/main/java/com/viwilo/camel/DigitalOceanConfiguration.java b/components/camel-digitalocean/src/main/java/com/viwilo/camel/DigitalOceanConfiguration.java
deleted file mode 100644
index 7218de1..0000000
--- a/components/camel-digitalocean/src/main/java/com/viwilo/camel/DigitalOceanConfiguration.java
+++ /dev/null
@@ -1,176 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.viwilo.camel;
-
-import com.myjeeva.digitalocean.impl.DigitalOceanClient;
-import com.viwilo.camel.constants.DigitalOceanResources;
-import com.viwilo.camel.constants.DigitalOceanOperations;
-import org.apache.camel.spi.Metadata;
-import org.apache.camel.spi.UriParam;
-import org.apache.camel.spi.UriParams;
-import org.apache.camel.spi.UriPath;
-
-/**
- * Created by thomas on 16/03/2017.
- */
-@UriParams
-public class DigitalOceanConfiguration {
-
-
- @UriParam(enums = "account,actions,blockStorages,droplets,mages,snapshots,keys,regions,sizes,floatingIPs,tags")
- @Metadata(required = "true")
- private DigitalOceanResources resource;
-
- @UriPath(enums = "create,update,delete,list,ownList,get,listBackups,listActions,listNeighbors,listSnapshots,listKernels,listAllNeighbors," +
- "enableBackups,disableBackups,reboot,powerCycle,shutdown,powerOn,powerOff,restore,resetPassword," +
- "resize,rebuild,rename,changeKernel,enableIpv6,enablePrivateNetworking,takeSnapshot,transfer,convert," +
- "attach,detach,assign,unassign,tag,untag")
- private DigitalOceanOperations operation;
-
- @UriParam
- private DigitalOceanClient digitalOceanClient;
-
- @UriParam(label = "security", secret = true)
- private String oAuthToken;
-
- @UriParam(defaultValue = "1")
- private Integer page = 1;
-
- @UriParam(defaultValue = "25")
- private Integer perPage = 25;
-
-
- @UriParam(label = "proxy")
- private String httpProxyHost;
- @UriParam(label = "proxy")
- private String httpProxyUser;
- @UriParam(label = "proxy")
- private String httpProxyPassword;
- @UriParam(label = "proxy")
- private Integer httpProxyPort;
-
- public DigitalOceanResources getResource() {
- return resource;
- }
-
- /**
- * The DigitalOcean resource type on which perform the operation.
- */
- public void setResource(DigitalOceanResources resource) {
- this.resource = resource;
- }
-
- /**
- * The operation to perform to the given resource.
- */
- public DigitalOceanOperations getOperation() {
- return operation;
- }
-
- public void setOperation(DigitalOceanOperations operation) {
- this.operation = operation;
- }
-
- public String getOAuthToken() {
- return oAuthToken;
- }
-
- /**
- * DigitalOcean OAuth Token
- */
- public void setOAuthToken(String oAuthToken) {
- this.oAuthToken = oAuthToken;
- }
-
- /**
- * Use for pagination. Set the number of item per request. The maximum number of results per page is 200.
- */
- public Integer getPerPage() {
- return perPage;
- }
-
- public void setPerPage(Integer perPage) {
- this.perPage = perPage;
- }
-
- /**
- * Use for paginsation. Force the page number.
- */
- public Integer getPage() {
- return page;
- }
-
- public void setPage(Integer page) {
- this.page = page;
- }
-
- /**
- * Set a proxy host if needed
- */
- public String getHttpProxyHost() {
- return httpProxyHost;
- }
-
- public void setHttpProxyHost(String httpProxyHost) {
- this.httpProxyHost = httpProxyHost;
- }
-
- /**
- * Set a proxy user if needed
- */
- public String getHttpProxyUser() {
- return httpProxyUser;
- }
-
- public void setHttpProxyUser(String httpProxyUser) {
- this.httpProxyUser = httpProxyUser;
- }
-
- /**
- * Set a proxy password if needed
- */
- public String getHttpProxyPassword() {
- return httpProxyPassword;
- }
-
- public void setHttpProxyPassword(String httpProxyPassword) {
- this.httpProxyPassword = httpProxyPassword;
- }
-
- /**
- * Set a proxy port if needed
- */
- public Integer getHttpProxyPort() {
- return httpProxyPort;
- }
-
- public void setHttpProxyPort(Integer httpProxyPort) {
- this.httpProxyPort = httpProxyPort;
- }
-
-
- /**
- * To use a existing configured DigitalOceanClient as client
- */
- public DigitalOceanClient getDigitalOceanClient() {
- return digitalOceanClient;
- }
-
- public void setDigitalOceanClient(DigitalOceanClient digitalOceanClient) {
- this.digitalOceanClient = digitalOceanClient;
- }
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/17d527d1/components/camel-digitalocean/src/main/java/com/viwilo/camel/DigitalOceanEndpoint.java
----------------------------------------------------------------------
diff --git a/components/camel-digitalocean/src/main/java/com/viwilo/camel/DigitalOceanEndpoint.java b/components/camel-digitalocean/src/main/java/com/viwilo/camel/DigitalOceanEndpoint.java
deleted file mode 100644
index 8b0e998..0000000
--- a/components/camel-digitalocean/src/main/java/com/viwilo/camel/DigitalOceanEndpoint.java
+++ /dev/null
@@ -1,130 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.viwilo.camel;
-
-import com.myjeeva.digitalocean.impl.DigitalOceanClient;
-import com.viwilo.camel.producer.*;
-import org.apache.camel.Consumer;
-import org.apache.camel.Processor;
-import org.apache.camel.Producer;
-import org.apache.camel.impl.DefaultEndpoint;
-import org.apache.camel.spi.UriEndpoint;
-import org.apache.camel.spi.UriParam;
-import org.apache.http.HttpHost;
-import org.apache.http.auth.AuthScope;
-import org.apache.http.auth.UsernamePasswordCredentials;
-import org.apache.http.impl.client.BasicCredentialsProvider;
-import org.apache.http.impl.client.HttpClientBuilder;
-import org.apache.http.impl.client.HttpClients;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Represents the DigitalOcean endpoint.
- */
-@UriEndpoint(scheme = "digitalocean", title = "DigitalOcean", syntax="digitalocean:label", producerOnly = true, label = "cloud,management")
-public class DigitalOceanEndpoint extends DefaultEndpoint {
-
- private static final transient Logger LOG = LoggerFactory.getLogger(DigitalOceanEndpoint.class);
-
- @UriParam
- private DigitalOceanConfiguration configuration;
-
- private DigitalOceanClient digitalOceanClient;
-
- public DigitalOceanEndpoint(String uri, DigitalOceanComponent component, DigitalOceanConfiguration configuration) {
- super(uri, component);
- this.configuration = configuration;
- }
-
- public Producer createProducer() throws Exception {
- LOG.trace("Resolve producer digitalocean endpoint {" + configuration.getResource() + "}");
-
- switch (configuration.getResource()) {
- case account:
- return new DigitalOceanAccountProducer(this, configuration);
- case actions:
- return new DigitalOceanActionsProducer(this, configuration);
- case blockStorages:
- return new DigitalOceanBlockStoragesProducer(this, configuration);
- case droplets:
- return new DigitalOceanDropletsProducer(this, configuration);
- case images:
- return new DigitalOceanImagesProducer(this, configuration);
- case snapshots:
- return new DigitalOceanSnapshotsProducer(this, configuration);
- case keys:
- return new DigitalOceanKeysProducer(this, configuration);
- case regions:
- return new DigitalOceanRegionsProducer(this, configuration);
- case sizes:
- return new DigitalOceanSizesProducer(this, configuration);
- case floatingIPs:
- return new DigitalOceanFloatingIPsProducer(this, configuration);
- case tags:
- return new DigitalOceanTagsProducer(this, configuration);
- default:
- throw new UnsupportedOperationException("Operation specified is not valid for producer");
- }
-
- }
-
- public Consumer createConsumer(Processor processor) throws Exception {
- throw new UnsupportedOperationException("You cannot receive messages from this endpoint");
- }
-
- public boolean isSingleton() {
- return true;
- }
-
-
- @Override
- public void doStart() throws Exception {
- super.doStart();
-
- if(configuration.getDigitalOceanClient() != null)
- digitalOceanClient = configuration.getDigitalOceanClient();
- else
- if(configuration.getHttpProxyHost() != null && configuration.getHttpProxyPort() != null) {
-
- HttpClientBuilder builder = HttpClients.custom()
- .useSystemProperties()
- .setProxy(new HttpHost(configuration.getHttpProxyHost(), configuration.getHttpProxyPort()));
-
- if(configuration.getHttpProxyUser() != null && configuration.getHttpProxyPassword() != null) {
- BasicCredentialsProvider credsProvider = new BasicCredentialsProvider();
- credsProvider.setCredentials(
- new AuthScope(configuration.getHttpProxyHost(), configuration.getHttpProxyPort()),
- new UsernamePasswordCredentials(configuration.getHttpProxyUser() , configuration.getHttpProxyPassword()));
- builder.setDefaultCredentialsProvider(credsProvider);
-
- }
-
- digitalOceanClient = new DigitalOceanClient("v2", configuration.getOAuthToken(), builder.build());
-
- } else
- digitalOceanClient = new DigitalOceanClient(configuration.getOAuthToken());
-
-
- }
-
- public DigitalOceanConfiguration getConfiguration() { return configuration; }
- public DigitalOceanClient getDigitalOceanClient() {
- return digitalOceanClient;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/17d527d1/components/camel-digitalocean/src/main/java/com/viwilo/camel/DigitalOceanException.java
----------------------------------------------------------------------
diff --git a/components/camel-digitalocean/src/main/java/com/viwilo/camel/DigitalOceanException.java b/components/camel-digitalocean/src/main/java/com/viwilo/camel/DigitalOceanException.java
deleted file mode 100644
index 144b4de..0000000
--- a/components/camel-digitalocean/src/main/java/com/viwilo/camel/DigitalOceanException.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.viwilo.camel;
-
-public class DigitalOceanException extends Exception {
-
- private static final long serialVersionUID = 1L;
-
- public DigitalOceanException(Throwable e) {
- super(e);
- }
-
- public DigitalOceanException(String message) {
- super(message);
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/camel/blob/17d527d1/components/camel-digitalocean/src/main/java/com/viwilo/camel/constants/DigitalOceanHeaders.java
----------------------------------------------------------------------
diff --git a/components/camel-digitalocean/src/main/java/com/viwilo/camel/constants/DigitalOceanHeaders.java b/components/camel-digitalocean/src/main/java/com/viwilo/camel/constants/DigitalOceanHeaders.java
deleted file mode 100644
index 7cf3163..0000000
--- a/components/camel-digitalocean/src/main/java/com/viwilo/camel/constants/DigitalOceanHeaders.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.viwilo.camel.constants;
-
-public interface DigitalOceanHeaders {
-
- String OPERATION = "CamelDigitalOceanOperation";
- String ID = "CamelDigitalOceanId";
- String TYPE = "CamelDigitalOceanType";
- String NAME = "CamelDigitalOceanName";
- String NEW_NAME = "CamelDigitalOceanNewName";
- String NAMES = "CamelDigitalOceanNames";
- String REGION = "CamelDigitalOceanRegion";
- String DESCRIPTION = "CamelDigitalOceanDescription";
-
- String DROPLET_SIZE = "CamelDigitalOceanDropletSize";
- String DROPLET_IMAGE = "CamelDigitalOceanDropletImage";
- String DROPLET_KEYS = "CamelDigitalOceanDropletSSHKeys";
- String DROPLET_ENABLE_BACKUPS = "CamelDigitalOceanDropletEnableBackups";
- String DROPLET_ENABLE_IPV6 = "CamelDigitalOceanDropletEnableIpv6";
- String DROPLET_ENABLE_PRIVATE_NETWORKING = "CamelDigitalOceanDropletEnablePrivateNetworking";
- String DROPLET_USER_DATA = "CamelDigitalOceanDropletUserData";
- String DROPLET_VOLUMES = "CamelDigitalOceanDropletVolumes";
- String DROPLET_TAGS = "CamelDigitalOceanDropletTags";
-
- String DROPLET_ID = "CamelDigitalOceanDropletId";
- String IMAGE_ID = "CamelDigitalOceanImageId";
- String KERNEL_ID = "CamelDigitalOceanKernelId";
- String VOLUME_NAME = "CamelDigitalOceanVolumeName";
- String VOLUME_SIZE_GIGABYTES = "CamelDigitalOceanVolumeSizeGigabytes";
-
- String FLOATING_IP_ADDRESS = "CamelDigitalOceanFloatingIPAddress";
-
- String KEY_FINGERPRINT = "CamelDigitalOceanKeyFingerprint";
- String KEY_PUBLIC_KEY = "CamelDigitalOceanKeyPublicKey";
-
-
-
-
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/17d527d1/components/camel-digitalocean/src/main/java/com/viwilo/camel/constants/DigitalOceanImageTypes.java
----------------------------------------------------------------------
diff --git a/components/camel-digitalocean/src/main/java/com/viwilo/camel/constants/DigitalOceanImageTypes.java b/components/camel-digitalocean/src/main/java/com/viwilo/camel/constants/DigitalOceanImageTypes.java
deleted file mode 100644
index f558010..0000000
--- a/components/camel-digitalocean/src/main/java/com/viwilo/camel/constants/DigitalOceanImageTypes.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.viwilo.camel.constants;
-
-public enum DigitalOceanImageTypes {
-
- distribution,
- application
-
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/17d527d1/components/camel-digitalocean/src/main/java/com/viwilo/camel/constants/DigitalOceanOperations.java
----------------------------------------------------------------------
diff --git a/components/camel-digitalocean/src/main/java/com/viwilo/camel/constants/DigitalOceanOperations.java b/components/camel-digitalocean/src/main/java/com/viwilo/camel/constants/DigitalOceanOperations.java
deleted file mode 100644
index 47cb9df..0000000
--- a/components/camel-digitalocean/src/main/java/com/viwilo/camel/constants/DigitalOceanOperations.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.viwilo.camel.constants;
-
-public enum DigitalOceanOperations {
-
- create,
- update,
- delete,
- list,
- ownList,
- get,
- listBackups,
- listActions,
- listNeighbors,
- listSnapshots,
- listKernels,
- listAllNeighbors,
- enableBackups,
- disableBackups,
- reboot,
- powerCycle,
- shutdown,
- powerOn,
- powerOff,
- restore,
- resetPassword,
- resize,
- rebuild,
- rename,
- changeKernel,
- enableIpv6,
- enablePrivateNetworking,
- takeSnapshot,
- transfer,
- convert,
- attach,
- detach,
- assign,
- unassign,
- tag,
- untag
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/17d527d1/components/camel-digitalocean/src/main/java/com/viwilo/camel/constants/DigitalOceanResources.java
----------------------------------------------------------------------
diff --git a/components/camel-digitalocean/src/main/java/com/viwilo/camel/constants/DigitalOceanResources.java b/components/camel-digitalocean/src/main/java/com/viwilo/camel/constants/DigitalOceanResources.java
deleted file mode 100644
index 2faa0b3..0000000
--- a/components/camel-digitalocean/src/main/java/com/viwilo/camel/constants/DigitalOceanResources.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.viwilo.camel.constants;
-
-
-public enum DigitalOceanResources {
-
- account,
- actions,
- blockStorages,
- droplets,
- images,
- snapshots,
- keys,
- regions,
- sizes,
- floatingIPs,
- tags
-
-
-
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/17d527d1/components/camel-digitalocean/src/main/java/com/viwilo/camel/constants/DigitalOceanSnapshotTypes.java
----------------------------------------------------------------------
diff --git a/components/camel-digitalocean/src/main/java/com/viwilo/camel/constants/DigitalOceanSnapshotTypes.java b/components/camel-digitalocean/src/main/java/com/viwilo/camel/constants/DigitalOceanSnapshotTypes.java
deleted file mode 100644
index 903b7a4..0000000
--- a/components/camel-digitalocean/src/main/java/com/viwilo/camel/constants/DigitalOceanSnapshotTypes.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.viwilo.camel.constants;
-
-public enum DigitalOceanSnapshotTypes {
-
- droplet,
- volume
-
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/17d527d1/components/camel-digitalocean/src/main/java/com/viwilo/camel/producer/DigitalOceanAccountProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-digitalocean/src/main/java/com/viwilo/camel/producer/DigitalOceanAccountProducer.java b/components/camel-digitalocean/src/main/java/com/viwilo/camel/producer/DigitalOceanAccountProducer.java
deleted file mode 100644
index a7da305..0000000
--- a/components/camel-digitalocean/src/main/java/com/viwilo/camel/producer/DigitalOceanAccountProducer.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.viwilo.camel.producer;
-
-import com.myjeeva.digitalocean.pojo.*;
-import com.viwilo.camel.DigitalOceanConfiguration;
-import com.viwilo.camel.DigitalOceanEndpoint;
-import org.apache.camel.Exchange;
-
-/**
- * The DigitalOcean producer for Account API.
- */
-public class DigitalOceanAccountProducer extends DigitalOceanProducer {
-
- public DigitalOceanAccountProducer(DigitalOceanEndpoint endpoint, DigitalOceanConfiguration configuration) {
- super(endpoint, configuration);
- }
-
- public void process(Exchange exchange) throws Exception {
- Account accountInfo = getEndpoint().getDigitalOceanClient().getAccountInfo();
- LOG.trace("Account [{}] ", accountInfo);
- exchange.getOut().setBody(accountInfo);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/17d527d1/components/camel-digitalocean/src/main/java/com/viwilo/camel/producer/DigitalOceanActionsProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-digitalocean/src/main/java/com/viwilo/camel/producer/DigitalOceanActionsProducer.java b/components/camel-digitalocean/src/main/java/com/viwilo/camel/producer/DigitalOceanActionsProducer.java
deleted file mode 100644
index 2b00819..0000000
--- a/components/camel-digitalocean/src/main/java/com/viwilo/camel/producer/DigitalOceanActionsProducer.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.viwilo.camel.producer;
-
-import com.myjeeva.digitalocean.pojo.*;
-import com.viwilo.camel.DigitalOceanConfiguration;
-import com.viwilo.camel.DigitalOceanEndpoint;
-import com.viwilo.camel.constants.DigitalOceanHeaders;
-import org.apache.camel.Exchange;
-import org.apache.camel.util.ObjectHelper;
-
-/**
- * The DigitalOcean producer for Actions API.
- */
-public class DigitalOceanActionsProducer extends DigitalOceanProducer {
-
- public DigitalOceanActionsProducer(DigitalOceanEndpoint endpoint, DigitalOceanConfiguration configuration) {
- super(endpoint, configuration);
- }
-
- public void process(Exchange exchange) throws Exception {
- switch(determineOperation(exchange)) {
-
- case list:
- getActions(exchange);
- break;
- case get:
- getAction(exchange);
- break;
- default:
- throw new IllegalArgumentException("Unsupported operation");
- }
-
- }
-
-
- private void getAction(Exchange exchange) throws Exception {
- Integer actionId = exchange.getIn().getHeader(DigitalOceanHeaders.ID, Integer.class);
-
- if (ObjectHelper.isEmpty(actionId))
- throw new IllegalArgumentException(DigitalOceanHeaders.ID + " must be specified");
- Action action = getEndpoint().getDigitalOceanClient().getActionInfo(actionId);
- LOG.trace("Action [{}] ", action);
- exchange.getOut().setBody(action);
- }
-
- private void getActions(Exchange exchange) throws Exception {
- Actions actions = getEndpoint().getDigitalOceanClient().getAvailableActions(configuration.getPage(), configuration.getPerPage());
- LOG.trace("All Actions : page {} / {} per page [{}] ", configuration.getPage(), configuration.getPerPage(), actions.getActions());
- exchange.getOut().setBody(actions.getActions());
- }
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/17d527d1/components/camel-digitalocean/src/main/java/com/viwilo/camel/producer/DigitalOceanBlockStoragesProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-digitalocean/src/main/java/com/viwilo/camel/producer/DigitalOceanBlockStoragesProducer.java b/components/camel-digitalocean/src/main/java/com/viwilo/camel/producer/DigitalOceanBlockStoragesProducer.java
deleted file mode 100644
index 282332a..0000000
--- a/components/camel-digitalocean/src/main/java/com/viwilo/camel/producer/DigitalOceanBlockStoragesProducer.java
+++ /dev/null
@@ -1,252 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.viwilo.camel.producer;
-
-import com.myjeeva.digitalocean.pojo.*;
-import com.viwilo.camel.DigitalOceanConfiguration;
-import com.viwilo.camel.constants.DigitalOceanHeaders;
-import com.viwilo.camel.DigitalOceanEndpoint;
-import org.apache.camel.Exchange;
-import org.apache.camel.Message;
-import org.apache.camel.util.ObjectHelper;
-
-import java.util.List;
-
-/**
- * The DigitalOcean producer for BlockStorages API.
- */
-public class DigitalOceanBlockStoragesProducer extends DigitalOceanProducer {
-
- public DigitalOceanBlockStoragesProducer(DigitalOceanEndpoint endpoint, DigitalOceanConfiguration configuration) {
- super(endpoint, configuration);
- }
-
- public void process(Exchange exchange) throws Exception {
-
- switch (determineOperation(exchange)) {
-
- case list:
- getVolumes(exchange);
- break;
- case get:
- getVolume(exchange);
- break;
- case listSnapshots:
- getVolumeSnapshots(exchange);
- break;
- case create:
- createVolume(exchange);
- break;
- case delete:
- deleteVolume(exchange);
- break;
- case attach:
- attachVolumeToDroplet(exchange);
- break;
- case detach:
- detachVolumeToDroplet(exchange);
- break;
- case resize:
- resizeVolume(exchange);
- break;
- case listActions:
- getVolumeActions(exchange);
- break;
- default:
- throw new IllegalArgumentException("Unsupported operation");
- }
- }
-
- private void getVolumes(Exchange exchange) throws Exception {
- String region = exchange.getIn().getHeader(DigitalOceanHeaders.REGION, String.class);
- if (ObjectHelper.isEmpty(region))
- throw new IllegalArgumentException(DigitalOceanHeaders.REGION + " must be specified");
-
- Volumes volumes = getEndpoint().getDigitalOceanClient().getAvailableVolumes(region);
- LOG.trace("All Volumes for region {} [{}] ", region, volumes.getVolumes());
- exchange.getOut().setBody(volumes.getVolumes());
-
- }
-
- private void createVolume(Exchange exchange) throws Exception {
- Message in = exchange.getIn();
-
- Volume volume = new Volume();
-
- if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(DigitalOceanHeaders.VOLUME_SIZE_GIGABYTES)))
- volume.setSize(in.getHeader(DigitalOceanHeaders.VOLUME_SIZE_GIGABYTES, Double.class));
- else
- throw new IllegalArgumentException(DigitalOceanHeaders.VOLUME_SIZE_GIGABYTES + " must be specified");
-
- if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(DigitalOceanHeaders.NAME)))
- volume.setName(in.getHeader(DigitalOceanHeaders.NAME, String.class));
- else
- throw new IllegalArgumentException(DigitalOceanHeaders.NAME + " must be specified");
-
- if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(DigitalOceanHeaders.REGION)))
- volume.setRegion(new Region(in.getHeader(DigitalOceanHeaders.REGION, String.class)));
- else
- throw new IllegalArgumentException(DigitalOceanHeaders.REGION + " must be specified");
-
- if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(DigitalOceanHeaders.DESCRIPTION)))
- volume.setDescription(in.getHeader(DigitalOceanHeaders.DESCRIPTION, String.class));
- else
- throw new IllegalArgumentException(DigitalOceanHeaders.DESCRIPTION + " must be specified");
-
- volume = getEndpoint().getDigitalOceanClient().createVolume(volume);
- LOG.trace("Volume created {} ", volume);
- exchange.getOut().setBody(volume);
- }
-
- private void getVolume(Exchange exchange) throws Exception {
- String volumeId = exchange.getIn().getHeader(DigitalOceanHeaders.ID, String.class);
- Volume volume = null;
- if (ObjectHelper.isEmpty(volumeId)) {
- String name = exchange.getIn().getHeader(DigitalOceanHeaders.NAME, String.class);
- String region = exchange.getIn().getHeader(DigitalOceanHeaders.REGION, String.class);
-
- if (ObjectHelper.isEmpty(name) && ObjectHelper.isEmpty(region))
- throw new IllegalArgumentException(DigitalOceanHeaders.ID + " or " + DigitalOceanHeaders.NAME + " and " + DigitalOceanHeaders.REGION + " must be specified");
-
- List<Volume> volumes = getEndpoint().getDigitalOceanClient().getVolumeInfo(name, region).getVolumes();
- if (volumes.size() > 0)
- volume = volumes.get(1);
- } else
- volume = getEndpoint().getDigitalOceanClient().getVolumeInfo(volumeId);
-
- LOG.trace("Volume [{}] ", volume);
- exchange.getOut().setBody(volume);
-
- }
-
- private void getVolumeSnapshots(Exchange exchange) throws Exception {
- String volumeId = exchange.getIn().getHeader(DigitalOceanHeaders.ID, String.class);
- if (ObjectHelper.isEmpty(volumeId))
- throw new IllegalArgumentException(DigitalOceanHeaders.ID + " must be specified");
-
- Snapshots snapshots = getEndpoint().getDigitalOceanClient().getVolumeSnapshots(volumeId, configuration.getPage(), configuration.getPerPage());
- LOG.trace("All Snapshots for volume {} [{}] ", volumeId, snapshots.getSnapshots());
- exchange.getOut().setBody(snapshots.getSnapshots());
- }
-
- private void deleteVolume(Exchange exchange) throws Exception {
- String volumeId = exchange.getIn().getHeader(DigitalOceanHeaders.ID, String.class);
- Delete delete;
- if (ObjectHelper.isEmpty(volumeId)) {
- String name = exchange.getIn().getHeader(DigitalOceanHeaders.NAME, String.class);
- String region = exchange.getIn().getHeader(DigitalOceanHeaders.REGION, String.class);
-
- if (ObjectHelper.isEmpty(name) && ObjectHelper.isEmpty(region))
- throw new IllegalArgumentException(DigitalOceanHeaders.ID + " or " + DigitalOceanHeaders.NAME + " and " + DigitalOceanHeaders.REGION + " must be specified");
-
- delete = getEndpoint().getDigitalOceanClient().deleteVolume(name, region);
-
- } else
- delete = getEndpoint().getDigitalOceanClient().deleteVolume(volumeId);
-
- LOG.trace("Delete Volume [{}] ", delete);
- exchange.getOut().setBody(delete);
-
- }
-
- private void attachVolumeToDroplet(Exchange exchange) throws Exception {
- String volumeId = exchange.getIn().getHeader(DigitalOceanHeaders.ID, String.class);
- String volumeName = exchange.getIn().getHeader(DigitalOceanHeaders.VOLUME_NAME, String.class);
- Integer dropletId = exchange.getIn().getHeader(DigitalOceanHeaders.DROPLET_ID, Integer.class);
- String region = exchange.getIn().getHeader(DigitalOceanHeaders.REGION, String.class);
-
- if (ObjectHelper.isEmpty(dropletId))
- throw new IllegalArgumentException(DigitalOceanHeaders.DROPLET_ID + " must be specified");
-
- if (ObjectHelper.isEmpty(region))
- throw new IllegalArgumentException(DigitalOceanHeaders.REGION + " must be specified");
-
- Action action;
-
- if (ObjectHelper.isNotEmpty(volumeName)) {
- action = getEndpoint().getDigitalOceanClient().attachVolumeByName(dropletId, volumeName, region);
- LOG.trace("Attach Volume {} to Droplet {} [{}] ", volumeName, dropletId, action);
- } else if (ObjectHelper.isNotEmpty(volumeId)) {
- action = getEndpoint().getDigitalOceanClient().attachVolume(dropletId, volumeId, region);
- LOG.trace("Attach Volume {} to Droplet {} [{}] ", volumeId, dropletId, action);
- } else
- throw new IllegalArgumentException(DigitalOceanHeaders.ID + " or " + DigitalOceanHeaders.VOLUME_NAME + " must be specified");
-
- exchange.getOut().setBody(action);
- }
-
-
-
- private void detachVolumeToDroplet(Exchange exchange) throws Exception {
- String volumeId = exchange.getIn().getHeader(DigitalOceanHeaders.ID, String.class);
- String volumeName = exchange.getIn().getHeader(DigitalOceanHeaders.VOLUME_NAME, String.class);
- Integer dropletId = exchange.getIn().getHeader(DigitalOceanHeaders.DROPLET_ID, Integer.class);
- String region = exchange.getIn().getHeader(DigitalOceanHeaders.REGION, String.class);
-
- if (ObjectHelper.isEmpty(dropletId))
- throw new IllegalArgumentException(DigitalOceanHeaders.DROPLET_ID + " must be specified");
-
- if (ObjectHelper.isEmpty(region))
- throw new IllegalArgumentException(DigitalOceanHeaders.REGION + " must be specified");
-
- Action action;
-
- if (ObjectHelper.isNotEmpty(volumeName)) {
- action = getEndpoint().getDigitalOceanClient().detachVolumeByName(dropletId, volumeName, region);
- LOG.trace("Detach Volume {} to Droplet {} [{}] ", volumeName, dropletId, action);
- } else if (ObjectHelper.isNotEmpty(volumeId)) {
- action = getEndpoint().getDigitalOceanClient().detachVolume(dropletId, volumeId, region);
- LOG.trace("Detach Volume {} to Droplet {} [{}] ", volumeId, dropletId, action);
- } else
- throw new IllegalArgumentException(DigitalOceanHeaders.ID + " or " + DigitalOceanHeaders.VOLUME_NAME + " must be specified");
-
- exchange.getOut().setBody(action);
-
- }
-
- private void resizeVolume(Exchange exchange) throws Exception {
- String volumeId = exchange.getIn().getHeader(DigitalOceanHeaders.ID, String.class);
-
- if (ObjectHelper.isEmpty(volumeId))
- throw new IllegalArgumentException(DigitalOceanHeaders.ID + " must be specified");
-
- String region = exchange.getIn().getHeader(DigitalOceanHeaders.REGION, String.class);
-
- if (ObjectHelper.isEmpty(region))
- throw new IllegalArgumentException(DigitalOceanHeaders.REGION + " must be specified");
-
- Double size = exchange.getIn().getHeader(DigitalOceanHeaders.VOLUME_SIZE_GIGABYTES, Double.class);
-
- if (ObjectHelper.isEmpty(size))
- throw new IllegalArgumentException(DigitalOceanHeaders.VOLUME_SIZE_GIGABYTES + " must be specified");
-
- Action action = getEndpoint().getDigitalOceanClient().resizeVolume(volumeId, region, size);
- LOG.trace("Resize Volume {} [{}] ", volumeId, action);
- }
-
- private void getVolumeActions(Exchange exchange) throws Exception {
- String volumeId = exchange.getIn().getHeader(DigitalOceanHeaders.ID, String.class);
-
- if (ObjectHelper.isEmpty(volumeId))
- throw new IllegalArgumentException(DigitalOceanHeaders.ID + " must be specified");
-
- Actions actions = getEndpoint().getDigitalOceanClient().getAvailableVolumeActions(volumeId);
- LOG.trace("Actions for Volume {} [{}] ", volumeId, actions.getActions());
- exchange.getOut().setBody(actions.getActions());
- }
-
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/17d527d1/components/camel-digitalocean/src/main/java/com/viwilo/camel/producer/DigitalOceanDropletsProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-digitalocean/src/main/java/com/viwilo/camel/producer/DigitalOceanDropletsProducer.java b/components/camel-digitalocean/src/main/java/com/viwilo/camel/producer/DigitalOceanDropletsProducer.java
deleted file mode 100644
index 5529851..0000000
--- a/components/camel-digitalocean/src/main/java/com/viwilo/camel/producer/DigitalOceanDropletsProducer.java
+++ /dev/null
@@ -1,405 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.viwilo.camel.producer;
-
-import com.myjeeva.digitalocean.common.ResourceType;
-import com.myjeeva.digitalocean.pojo.*;
-import com.myjeeva.digitalocean.pojo.Response;
-import com.viwilo.camel.DigitalOceanConfiguration;
-import com.viwilo.camel.constants.DigitalOceanHeaders;
-import com.viwilo.camel.DigitalOceanEndpoint;
-import com.viwilo.camel.constants.DigitalOceanOperations;
-import org.apache.camel.Exchange;
-import org.apache.camel.Message;
-import org.apache.camel.util.ObjectHelper;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.stream.Collectors;
-
-/**
- * The DigitalOcean producer for Droplets API.
- */
-public class DigitalOceanDropletsProducer extends DigitalOceanProducer {
-
- public DigitalOceanDropletsProducer(DigitalOceanEndpoint endpoint, DigitalOceanConfiguration configuration) {
- super(endpoint, configuration);
- }
-
- private Integer dropletId;
-
- public void process(Exchange exchange) throws Exception {
-
- DigitalOceanOperations op = determineOperation(exchange);
- if (op != DigitalOceanOperations.create && op != DigitalOceanOperations.list && op != DigitalOceanOperations.listAllNeighbors) {
- dropletId = exchange.getIn().getHeader(DigitalOceanHeaders.ID, Integer.class);
- if (ObjectHelper.isEmpty(dropletId))
- throw new IllegalArgumentException(DigitalOceanHeaders.ID + " must be specified");
- }
-
- switch (op) {
- case create:
- createDroplet(exchange);
- break;
- case list:
- getDroplets(exchange);
- break;
- case delete:
- deleteDroplet(exchange);
- break;
- case get:
- getDroplet(exchange);
- break;
- case listActions:
- getDropletActions(exchange);
- break;
- case listSnapshots:
- getDropletSnapshots(exchange);
- break;
- case listKernels:
- getDropletKernels(exchange);
- break;
- case listBackups:
- getDropletBackups(exchange);
- break;
- case listNeighbors:
- getDropletNeighbors(exchange);
- break;
- case listAllNeighbors:
- getAllDropletNeighbors(exchange);
- break;
- case enableBackups:
- enableDropletBackups(exchange);
- break;
- case disableBackups:
- disableDropletBackups(exchange);
- break;
- case reboot:
- rebootDroplet(exchange);
- break;
- case powerCycle:
- powerCycleDroplet(exchange);
- break;
- case shutdown:
- shutdownDroplet(exchange);
- break;
- case powerOn:
- powerOnDroplet(exchange);
- break;
- case powerOff:
- powerOffDroplet(exchange);
- break;
- case restore:
- restoreDroplet(exchange);
- break;
- case resetPassword:
- resetDropletPassword(exchange);
- break;
- case resize:
- resizeDroplet(exchange);
- break;
- case rebuild:
- rebuildDroplet(exchange);
- break;
- case rename:
- renameDroplet(exchange);
- break;
- case changeKernel:
- changeDropletKernel(exchange);
- break;
- case enableIpv6:
- enableDropletIpv6(exchange);
- break;
- case enablePrivateNetworking:
- enableDropletPrivateNetworking(exchange);
- break;
- case takeSnapshot:
- takeDropletSnapshot(exchange);
- break;
- case tag:
- tagDroplet(exchange);
- break;
- case untag:
- untagDroplet(exchange);
- break;
- default:
- throw new IllegalArgumentException("Unsupported operation");
- }
- }
-
-
-
- private void getDroplet(Exchange exchange) throws Exception {
- Droplet droplet = getEndpoint().getDigitalOceanClient().getDropletInfo(dropletId);
- LOG.trace("Droplet {} ", droplet);
- exchange.getOut().setBody(droplet);
- }
-
-
- private void getDroplets(Exchange exchange) throws Exception {
- Droplets droplets = getEndpoint().getDigitalOceanClient().getAvailableDroplets(configuration.getPage(), configuration.getPerPage());
- LOG.trace("All Droplets : page {} / {} per page [{}] ", configuration.getPage(), configuration.getPerPage(), droplets.getDroplets());
- exchange.getOut().setBody(droplets.getDroplets());
- }
-
-
- private void getDropletActions(Exchange exchange) throws Exception {
- Actions actions = getEndpoint().getDigitalOceanClient().getAvailableDropletActions(dropletId, configuration.getPage(), configuration.getPerPage());
- LOG.trace("Actions for Droplet {} : page {} / {} per page [{}] ", dropletId, configuration.getPage(), configuration.getPerPage(), actions.getActions());
- exchange.getOut().setBody(actions.getActions());
- }
-
- private void getDropletKernels(Exchange exchange) throws Exception {
- Kernels kernels = getEndpoint().getDigitalOceanClient().getDropletKernels(dropletId, configuration.getPage(), configuration.getPerPage());
- LOG.trace("Kernels for Droplet {} : page {} / {} per page [{}] ", dropletId, configuration.getPage(), configuration.getPerPage(), kernels.getKernels());
- exchange.getOut().setBody(kernels.getKernels());
- }
-
- private void getDropletBackups(Exchange exchange) throws Exception {
- Backups backups = getEndpoint().getDigitalOceanClient().getDropletBackups(dropletId, configuration.getPage(), configuration.getPerPage());
- LOG.trace("Backups for Droplet {} : page {} / {} per page [{}] ", dropletId, configuration.getPage(), configuration.getPerPage(), backups.getBackups());
- exchange.getOut().setBody(backups.getBackups());
- }
-
- private void getDropletSnapshots(Exchange exchange) throws Exception {
- Snapshots snapshots = getEndpoint().getDigitalOceanClient().getDropletSnapshots(dropletId, configuration.getPage(), configuration.getPerPage());
- LOG.trace("Snapshots for Droplet {} : page {} / {} per page [{}] ", dropletId, configuration.getPage(), configuration.getPerPage(), snapshots.getSnapshots());
- exchange.getOut().setBody(snapshots.getSnapshots());
- }
-
- private void getDropletNeighbors(Exchange exchange) throws Exception {
- Droplets droplets = getEndpoint().getDigitalOceanClient().getDropletNeighbors(dropletId, configuration.getPage());
- LOG.trace("Neighbors for Droplet {} : page {} [{}] ", dropletId, configuration.getPage(), droplets.getDroplets());
- exchange.getOut().setBody(droplets.getDroplets());
- }
-
- private void getAllDropletNeighbors(Exchange exchange) throws Exception {
- Neighbors neighbors = getEndpoint().getDigitalOceanClient().getAllDropletNeighbors(configuration.getPage());
- LOG.trace("All Neighbors : page {} [{}] ", configuration.getPage(), neighbors.getNeighbors());
- exchange.getOut().setBody(neighbors.getNeighbors());
- }
-
- private void deleteDroplet(Exchange exchange) throws Exception {
- Delete delete = getEndpoint().getDigitalOceanClient().deleteDroplet(dropletId);
- LOG.trace("Delete Droplet {} ", delete);
- exchange.getOut().setBody(delete);
- }
-
- @SuppressWarnings("unchecked")
- private void createDroplet(Exchange exchange) throws Exception {
- Message in = exchange.getIn();
-
- Droplet droplet = new Droplet();
-
- if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(DigitalOceanHeaders.REGION)))
- droplet.setRegion(new Region(in.getHeader(DigitalOceanHeaders.REGION, String.class)));
- else
- throw new IllegalArgumentException(DigitalOceanHeaders.REGION + " must be specified");
-
- if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(DigitalOceanHeaders.DROPLET_SIZE)))
- droplet.setSize(in.getHeader(DigitalOceanHeaders.DROPLET_SIZE, String.class));
- else
- throw new IllegalArgumentException(DigitalOceanHeaders.DROPLET_SIZE + " must be specified");
-
- if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(DigitalOceanHeaders.DROPLET_IMAGE)))
- droplet.setImage(new Image(in.getHeader(DigitalOceanHeaders.DROPLET_IMAGE, String.class)));
- else
- throw new IllegalArgumentException(DigitalOceanHeaders.DROPLET_IMAGE + " must be specified");
-
- if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(DigitalOceanHeaders.DROPLET_KEYS))) {
- List<String> keys = (List<String>) exchange.getIn().getHeader(DigitalOceanHeaders.DROPLET_KEYS);
- droplet.setKeys(keys.stream().map(Key::new).collect(Collectors.toList()));
- }
-
- if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(DigitalOceanHeaders.DROPLET_ENABLE_BACKUPS)))
- droplet.setEnableBackup(in.getHeader(DigitalOceanHeaders.DROPLET_ENABLE_BACKUPS, Boolean.class));
-
- if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(DigitalOceanHeaders.DROPLET_ENABLE_IPV6)))
- droplet.setEnableIpv6(in.getHeader(DigitalOceanHeaders.DROPLET_ENABLE_IPV6, Boolean.class));
-
- if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(DigitalOceanHeaders.DROPLET_ENABLE_PRIVATE_NETWORKING)))
- droplet.setEnablePrivateNetworking(in.getHeader(DigitalOceanHeaders.DROPLET_ENABLE_PRIVATE_NETWORKING, Boolean.class));
-
- if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(DigitalOceanHeaders.DROPLET_USER_DATA)))
- droplet.setUserData(in.getHeader(DigitalOceanHeaders.DROPLET_USER_DATA, String.class));
-
- if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(DigitalOceanHeaders.DROPLET_VOLUMES)))
- droplet.setVolumeIds((List<String>) exchange.getIn().getHeader(DigitalOceanHeaders.DROPLET_VOLUMES));
-
- if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(DigitalOceanHeaders.DROPLET_TAGS)))
- droplet.setTags((List<String>) exchange.getIn().getHeader(DigitalOceanHeaders.DROPLET_TAGS));
-
- if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(DigitalOceanHeaders.NAMES))) {
- droplet.setNames((List<String>) in.getHeader(DigitalOceanHeaders.NAMES));
- Droplets droplets = getEndpoint().getDigitalOceanClient().createDroplets(droplet);
- LOG.trace("Droplets created {} ", droplets);
- exchange.getOut().setBody(droplets.getDroplets());
- } else if(ObjectHelper.isNotEmpty(exchange.getIn().getHeader(DigitalOceanHeaders.NAME))) {
- droplet.setName(in.getHeader(DigitalOceanHeaders.NAME, String.class));
- droplet = getEndpoint().getDigitalOceanClient().createDroplet(droplet);
- LOG.trace("Droplet created {} ", droplet);
- exchange.getOut().setBody(droplet);
- } else
- throw new IllegalArgumentException(DigitalOceanHeaders.NAMES + " or " + DigitalOceanHeaders.NAME + " must be specified");
-
- }
-
- private void restoreDroplet(Exchange exchange) throws Exception {
- if (ObjectHelper.isEmpty(exchange.getIn().getHeader(DigitalOceanHeaders.IMAGE_ID)))
- throw new IllegalArgumentException(DigitalOceanHeaders.IMAGE_ID + " must be specified");
-
- Action action = getEndpoint().getDigitalOceanClient().restoreDroplet(dropletId, exchange.getIn().getHeader(DigitalOceanHeaders.IMAGE_ID, Integer.class));
- LOG.trace("DropletAction Restore [{}] ", action);
- exchange.getOut().setBody(action);
-
- }
-
- private void resizeDroplet(Exchange exchange) throws Exception {
- if (ObjectHelper.isEmpty(exchange.getIn().getHeader(DigitalOceanHeaders.DROPLET_SIZE)))
- throw new IllegalArgumentException(DigitalOceanHeaders.DROPLET_SIZE + " must be specified");
-
- Action action = getEndpoint().getDigitalOceanClient().resizeDroplet(dropletId, exchange.getIn().getHeader(DigitalOceanHeaders.DROPLET_SIZE, String.class));
- LOG.trace("DropletAction Resize [{}] ", action);
- exchange.getOut().setBody(action);
- }
-
-
- private void rebuildDroplet(Exchange exchange) throws Exception {
- if (ObjectHelper.isEmpty(exchange.getIn().getHeader(DigitalOceanHeaders.IMAGE_ID)))
- throw new IllegalArgumentException(DigitalOceanHeaders.IMAGE_ID + " must be specified");
-
- Action action = getEndpoint().getDigitalOceanClient().rebuildDroplet(dropletId, exchange.getIn().getHeader(DigitalOceanHeaders.IMAGE_ID, Integer.class));
- LOG.trace("Rebuild Droplet {} : [{}] ", dropletId, action);
- exchange.getOut().setBody(action);
- }
-
- private void renameDroplet(Exchange exchange) throws Exception {
- if (ObjectHelper.isEmpty(exchange.getIn().getHeader(DigitalOceanHeaders.NAME)))
- throw new IllegalArgumentException(DigitalOceanHeaders.NAME + " must be specified");
-
- Action action = getEndpoint().getDigitalOceanClient().renameDroplet(dropletId, exchange.getIn().getHeader(DigitalOceanHeaders.NAME, String.class));
- LOG.trace("Rename Droplet {} : [{}] ", dropletId, action);
- exchange.getOut().setBody(action);
- }
-
-
- private void changeDropletKernel(Exchange exchange) throws Exception {
- if (ObjectHelper.isEmpty(exchange.getIn().getHeader(DigitalOceanHeaders.KERNEL_ID)))
- throw new IllegalArgumentException(DigitalOceanHeaders.KERNEL_ID + " must be specified");
-
- Action action = getEndpoint().getDigitalOceanClient().changeDropletKernel(dropletId, exchange.getIn().getHeader(DigitalOceanHeaders.KERNEL_ID, Integer.class));
- LOG.trace("Rename Droplet {} : [{}] ", dropletId, action);
- exchange.getOut().setBody(action);
- }
-
- private void resetDropletPassword(Exchange exchange) throws Exception {
- Action action = getEndpoint().getDigitalOceanClient().resetDropletPassword(dropletId);
- LOG.trace("Reset password Droplet {} : [{}] ", dropletId, action);
- exchange.getOut().setBody(action);
- }
-
-
- private void powerOnDroplet(Exchange exchange) throws Exception {
- Action action = getEndpoint().getDigitalOceanClient().powerOnDroplet(dropletId);
- LOG.trace("Power on Droplet {} : [{}] ", dropletId, action);
- exchange.getOut().setBody(action);
- }
-
- private void powerOffDroplet(Exchange exchange) throws Exception {
- Action action = getEndpoint().getDigitalOceanClient().powerOffDroplet(dropletId);
- LOG.trace("Power off Droplet {} : [{}] ", dropletId, action);
- exchange.getOut().setBody(action);
- }
-
- private void shutdownDroplet(Exchange exchange) throws Exception {
- Action action = getEndpoint().getDigitalOceanClient().shutdownDroplet(dropletId);
- LOG.trace("Shutdown Droplet {} : [{}] ", dropletId, action);
- exchange.getOut().setBody(action);
- }
-
- private void powerCycleDroplet(Exchange exchange) throws Exception {
- Action action = getEndpoint().getDigitalOceanClient().powerCycleDroplet(dropletId);
- LOG.trace("Power cycle Droplet {} : [{}] ", dropletId, action);
- exchange.getOut().setBody(action);
- }
-
- private void enableDropletBackups(Exchange exchange) throws Exception {
- Action action = getEndpoint().getDigitalOceanClient().enableDropletBackups(dropletId);
- LOG.trace("Enable backups Droplet {} : [{}] ", dropletId, action);
- exchange.getOut().setBody(action);
- }
-
- private void disableDropletBackups(Exchange exchange) throws Exception {
- Action action = getEndpoint().getDigitalOceanClient().disableDropletBackups(dropletId);
- LOG.trace("Disable backups for Droplet {} : [{}] ", dropletId, action);
- exchange.getOut().setBody(action);
- }
-
- private void enableDropletIpv6(Exchange exchange) throws Exception {
- Action action = getEndpoint().getDigitalOceanClient().enableDropletIpv6(dropletId);
- LOG.trace("Enable IP v6 for Droplet {} : [{}] ", dropletId, action);
- exchange.getOut().setBody(action);
- }
-
- private void enableDropletPrivateNetworking(Exchange exchange) throws Exception {
- Action action = getEndpoint().getDigitalOceanClient().enableDropletPrivateNetworking(dropletId);
- LOG.trace("Enable private networking for Droplet {} : [{}] ", dropletId, action);
- exchange.getOut().setBody(action);
- }
-
-
- private void rebootDroplet(Exchange exchange) throws Exception {
- Action action = getEndpoint().getDigitalOceanClient().rebootDroplet(dropletId);
- LOG.trace("Reboot Droplet {} : [{}] ", dropletId, action);
- exchange.getOut().setBody(action);
- }
-
- private void takeDropletSnapshot(Exchange exchange) throws Exception {
- Action action;
-
- if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(DigitalOceanHeaders.NAME)))
- action = getEndpoint().getDigitalOceanClient().takeDropletSnapshot(dropletId, exchange.getIn().getHeader(DigitalOceanHeaders.NAME, String.class));
- else
- action = getEndpoint().getDigitalOceanClient().takeDropletSnapshot(dropletId);
-
- LOG.trace("Take Snapshot for Droplet {} : [{}] ", dropletId, action);
- exchange.getOut().setBody(action);
- }
-
- private void tagDroplet(Exchange exchange) throws Exception {
- if (ObjectHelper.isEmpty(exchange.getIn().getHeader(DigitalOceanHeaders.NAME)))
- throw new IllegalArgumentException(DigitalOceanHeaders.NAME + " must be specified");
-
- ArrayList<Resource> resources = new ArrayList<>(1);
- resources.add(new Resource(dropletId.toString(), ResourceType.DROPLET));
- Response response = getEndpoint().getDigitalOceanClient().tagResources(dropletId.toString(), resources);
- LOG.trace("Tag Droplet {} : [{}] ", dropletId, response);
- exchange.getOut().setBody(response);
- }
-
- private void untagDroplet(Exchange exchange) throws Exception {
- if (ObjectHelper.isEmpty(exchange.getIn().getHeader(DigitalOceanHeaders.NAME)))
- throw new IllegalArgumentException(DigitalOceanHeaders.NAME + " must be specified");
-
- ArrayList<Resource> resources = new ArrayList<>(1);
- resources.add(new Resource(dropletId.toString(), ResourceType.DROPLET));
- Response response = getEndpoint().getDigitalOceanClient().untagResources(dropletId.toString(), resources);
- LOG.trace("Untag Droplet {} : [{}] ", dropletId, response);
- exchange.getOut().setBody(response);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/17d527d1/components/camel-digitalocean/src/main/java/com/viwilo/camel/producer/DigitalOceanFloatingIPsProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-digitalocean/src/main/java/com/viwilo/camel/producer/DigitalOceanFloatingIPsProducer.java b/components/camel-digitalocean/src/main/java/com/viwilo/camel/producer/DigitalOceanFloatingIPsProducer.java
deleted file mode 100644
index ed08b25..0000000
--- a/components/camel-digitalocean/src/main/java/com/viwilo/camel/producer/DigitalOceanFloatingIPsProducer.java
+++ /dev/null
@@ -1,151 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.viwilo.camel.producer;
-
-import com.myjeeva.digitalocean.pojo.*;
-import com.viwilo.camel.DigitalOceanConfiguration;
-import com.viwilo.camel.constants.DigitalOceanHeaders;
-import com.viwilo.camel.DigitalOceanEndpoint;
-import org.apache.camel.Exchange;
-import org.apache.camel.util.ObjectHelper;
-
-/**
- * The DigitalOcean producer for FloatingIps API.
- */
-public class DigitalOceanFloatingIPsProducer extends DigitalOceanProducer {
-
- public DigitalOceanFloatingIPsProducer(DigitalOceanEndpoint endpoint, DigitalOceanConfiguration configuration) {
- super(endpoint, configuration);
- }
-
- public void process(Exchange exchange) throws Exception {
- switch(determineOperation(exchange)) {
-
- case list:
- getFloatingIPs(exchange);
- break;
- case create:
- createFloatingIp(exchange);
- break;
- case get:
- getFloatingIP(exchange);
- break;
- case delete:
- deleteFloatingIP(exchange);
- break;
- case assign:
- assignFloatingIPToDroplet(exchange);
- break;
- case unassign:
- unassignFloatingIP(exchange);
- break;
- case listActions:
- getFloatingIPActions(exchange);
- break;
- default:
- throw new IllegalArgumentException("Unsupported operation");
- }
- }
-
- private void createFloatingIp(Exchange exchange) throws Exception {
- Integer dropletId = exchange.getIn().getHeader(DigitalOceanHeaders.DROPLET_ID, Integer.class);
- String region = exchange.getIn().getHeader(DigitalOceanHeaders.REGION, String.class);
- FloatingIP ip;
-
- if (ObjectHelper.isNotEmpty(dropletId))
- ip = getEndpoint().getDigitalOceanClient().createFloatingIP(dropletId);
- else if (ObjectHelper.isNotEmpty(region))
- ip = getEndpoint().getDigitalOceanClient().createFloatingIP(region);
- else
- throw new IllegalArgumentException(DigitalOceanHeaders.DROPLET_ID + " or " + DigitalOceanHeaders.REGION + " must be specified");
-
- LOG.trace("FloatingIP [{}] ", ip);
- exchange.getOut().setBody(ip);
- }
-
-
- private void getFloatingIPs(Exchange exchange) throws Exception {
- FloatingIPs ips = getEndpoint().getDigitalOceanClient().getAvailableFloatingIPs(configuration.getPage(), configuration.getPerPage());
- LOG.trace("All Floating IPs : page {} / {} per page [{}] ", configuration.getPage(), configuration.getPerPage(), ips.getFloatingIPs());
- exchange.getOut().setBody(ips.getFloatingIPs());
- }
-
-
- private void getFloatingIP(Exchange exchange) throws Exception {
- String ipAddress = exchange.getIn().getHeader(DigitalOceanHeaders.FLOATING_IP_ADDRESS, String.class);
-
- if (ObjectHelper.isEmpty(ipAddress))
- throw new IllegalArgumentException(DigitalOceanHeaders.FLOATING_IP_ADDRESS + " must be specified");
-
-
- FloatingIP ip = getEndpoint().getDigitalOceanClient().getFloatingIPInfo(ipAddress);
- LOG.trace("Floating IP {} ", ip);
- exchange.getOut().setBody(ip);
- }
-
-
- private void deleteFloatingIP(Exchange exchange) throws Exception {
- String ipAddress = exchange.getIn().getHeader(DigitalOceanHeaders.FLOATING_IP_ADDRESS, String.class);
-
- if (ObjectHelper.isEmpty(ipAddress))
- throw new IllegalArgumentException(DigitalOceanHeaders.FLOATING_IP_ADDRESS + " must be specified");
-
-
- Delete delete = getEndpoint().getDigitalOceanClient().deleteFloatingIP(ipAddress);
- LOG.trace("Delete Floating IP {} ", delete);
- exchange.getOut().setBody(delete);
- }
-
- private void assignFloatingIPToDroplet(Exchange exchange) throws Exception {
- Integer dropletId = exchange.getIn().getHeader(DigitalOceanHeaders.DROPLET_ID, Integer.class);
-
- if(ObjectHelper.isEmpty(dropletId))
- throw new IllegalArgumentException(DigitalOceanHeaders.DROPLET_ID + " must be specified");
-
- String ipAddress = exchange.getIn().getHeader(DigitalOceanHeaders.FLOATING_IP_ADDRESS, String.class);
-
- if (ObjectHelper.isEmpty(ipAddress))
- throw new IllegalArgumentException(DigitalOceanHeaders.FLOATING_IP_ADDRESS + " must be specified");
-
- Action action = getEndpoint().getDigitalOceanClient().assignFloatingIP(dropletId, ipAddress);
- LOG.trace("Assign Floating IP to Droplet {} ", action);
- exchange.getOut().setBody(action);
- }
-
- private void unassignFloatingIP(Exchange exchange) throws Exception {
- String ipAddress = exchange.getIn().getHeader(DigitalOceanHeaders.FLOATING_IP_ADDRESS, String.class);
-
- if (ObjectHelper.isEmpty(ipAddress))
- throw new IllegalArgumentException(DigitalOceanHeaders.FLOATING_IP_ADDRESS + " must be specified");
-
- Action action = getEndpoint().getDigitalOceanClient().unassignFloatingIP(ipAddress);
- LOG.trace("Unassign Floating IP {} ", action);
- exchange.getOut().setBody(action);
- }
-
- private void getFloatingIPActions(Exchange exchange) throws Exception {
- String ipAddress = exchange.getIn().getHeader(DigitalOceanHeaders.FLOATING_IP_ADDRESS, String.class);
-
- if (ObjectHelper.isEmpty(ipAddress))
- throw new IllegalArgumentException(DigitalOceanHeaders.FLOATING_IP_ADDRESS + " must be specified");
-
- Actions actions = getEndpoint().getDigitalOceanClient().getAvailableFloatingIPActions(ipAddress, configuration.getPage(), configuration.getPerPage());
- LOG.trace("Actions for FloatingIP {} : page {} / {} per page [{}] ", ipAddress, configuration.getPage(), configuration.getPerPage(), actions.getActions());
- exchange.getOut().setBody(actions.getActions());
- }
-
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/17d527d1/components/camel-digitalocean/src/main/java/com/viwilo/camel/producer/DigitalOceanImagesProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-digitalocean/src/main/java/com/viwilo/camel/producer/DigitalOceanImagesProducer.java b/components/camel-digitalocean/src/main/java/com/viwilo/camel/producer/DigitalOceanImagesProducer.java
deleted file mode 100644
index 71a2147..0000000
--- a/components/camel-digitalocean/src/main/java/com/viwilo/camel/producer/DigitalOceanImagesProducer.java
+++ /dev/null
@@ -1,175 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.viwilo.camel.producer;
-
-import com.myjeeva.digitalocean.common.ActionType;
-import com.myjeeva.digitalocean.pojo.*;
-import com.viwilo.camel.DigitalOceanConfiguration;
-import com.viwilo.camel.constants.DigitalOceanHeaders;
-import com.viwilo.camel.DigitalOceanEndpoint;
-import com.viwilo.camel.constants.DigitalOceanImageTypes;
-import org.apache.camel.Exchange;
-import org.apache.camel.util.ObjectHelper;
-
-/**
- * The DigitalOcean producer for Images API.
- */
-public class DigitalOceanImagesProducer extends DigitalOceanProducer {
-
- public DigitalOceanImagesProducer(DigitalOceanEndpoint endpoint, DigitalOceanConfiguration configuration) {
- super(endpoint, configuration);
- }
-
- public void process(Exchange exchange) throws Exception {
-
- switch(determineOperation(exchange)) {
-
- case list:
- getImages(exchange);
- break;
- case ownList:
- getUserImages(exchange);
- break;
- case listActions:
- getImageActions(exchange);
- break;
- case get:
- getImage(exchange);
- break;
- case update:
- updateImage(exchange);
- break;
- case delete:
- deleteImage(exchange);
- break;
- case transfer:
- transferImage(exchange);
- break;
- case convert:
- convertImageToSnapshot(exchange);
- break;
- default:
- throw new IllegalArgumentException("Unsupported operation");
- }
- }
-
-
- private void getUserImages(Exchange exchange) throws Exception {
- Images images = getEndpoint().getDigitalOceanClient().getUserImages(configuration.getPage(), configuration.getPerPage());
- LOG.trace("User images : page {} / {} per page [{}] ", configuration.getPage(), configuration.getPerPage(), images.getImages());
- exchange.getOut().setBody(images.getImages());
- }
-
-
- private void getImages(Exchange exchange) throws Exception {
- DigitalOceanImageTypes type = exchange.getIn().getHeader(DigitalOceanHeaders.TYPE, DigitalOceanImageTypes.class);
- Images images;
-
- if (ObjectHelper.isNotEmpty(type))
- images = getEndpoint().getDigitalOceanClient().getAvailableImages(configuration.getPage(), configuration.getPerPage(), ActionType.valueOf(type.name()));
- else
- images = getEndpoint().getDigitalOceanClient().getAvailableImages(configuration.getPage(), configuration.getPerPage());
- LOG.trace("All Images : page {} / {} per page [{}] ", configuration.getPage(), configuration.getPerPage(), images.getImages());
- exchange.getOut().setBody(images.getImages());
- }
-
- private void getImage(Exchange exchange) throws Exception {
-
- Integer imageId = exchange.getIn().getHeader(DigitalOceanHeaders.ID, Integer.class);
- String slug = exchange.getIn().getHeader(DigitalOceanHeaders.DROPLET_IMAGE, String.class);
- Image image;
-
- if (ObjectHelper.isNotEmpty(imageId))
- image = getEndpoint().getDigitalOceanClient().getImageInfo(imageId);
- else if (ObjectHelper.isNotEmpty(slug))
- image = getEndpoint().getDigitalOceanClient().getImageInfo(slug);
- else
- throw new IllegalArgumentException(DigitalOceanHeaders.ID + " or " + DigitalOceanHeaders.DROPLET_IMAGE + " must be specified");
-
- LOG.trace("Image [{}] ", image);
- exchange.getOut().setBody(image);
- }
-
-
- private void getImageActions(Exchange exchange) throws Exception {
- Integer imageId = exchange.getIn().getHeader(DigitalOceanHeaders.ID, Integer.class);
-
- if (ObjectHelper.isEmpty(imageId))
- throw new IllegalArgumentException(DigitalOceanHeaders.ID + " must be specified");
-
- Actions actions = getEndpoint().getDigitalOceanClient().getAvailableImageActions(imageId, configuration.getPage(), configuration.getPerPage());
- LOG.trace("Actions for Image {} : page {} / {} per page [{}] ", imageId, configuration.getPage(), configuration.getPerPage(), actions.getActions());
- exchange.getOut().setBody(actions.getActions());
- }
-
- private void updateImage(Exchange exchange) throws Exception {
- Integer imageId = exchange.getIn().getHeader(DigitalOceanHeaders.ID, Integer.class);
-
- if (ObjectHelper.isEmpty(imageId))
- throw new IllegalArgumentException(DigitalOceanHeaders.ID + " must be specified");
-
- String name = exchange.getIn().getHeader(DigitalOceanHeaders.NAME, String.class);
-
- if (ObjectHelper.isEmpty(name))
- throw new IllegalArgumentException(DigitalOceanHeaders.NAME + " must be specified");
-
- Image image = new Image();
- image.setId(imageId);
- image.setName(name);
- image = getEndpoint().getDigitalOceanClient().updateImage(image);
- LOG.trace("Update Image {} [{}] ", imageId, image);
- exchange.getOut().setBody(image);
- }
-
- private void deleteImage(Exchange exchange) throws Exception {
- Integer imageId = exchange.getIn().getHeader(DigitalOceanHeaders.ID, Integer.class);
-
- if (ObjectHelper.isEmpty(imageId))
- throw new IllegalArgumentException(DigitalOceanHeaders.ID + " must be specified");
-
- Delete delete = getEndpoint().getDigitalOceanClient().deleteImage(imageId);
- LOG.trace("Delete Image {} [{}] ", imageId, delete);
- exchange.getOut().setBody(delete);
- }
-
- private void transferImage(Exchange exchange) throws Exception {
- Integer imageId = exchange.getIn().getHeader(DigitalOceanHeaders.ID, Integer.class);
-
- if (ObjectHelper.isEmpty(imageId))
- throw new IllegalArgumentException(DigitalOceanHeaders.ID + " must be specified");
-
- String region = exchange.getIn().getHeader(DigitalOceanHeaders.REGION, String.class);
-
- if (ObjectHelper.isEmpty(region))
- throw new IllegalArgumentException(DigitalOceanHeaders.REGION + " must be specified");
-
- Action action = getEndpoint().getDigitalOceanClient().transferImage(imageId, region);
- LOG.trace("Transfer Image {} to Region {} [{}] ", imageId, region, action);
- exchange.getOut().setBody(action);
- }
-
- private void convertImageToSnapshot(Exchange exchange) throws Exception {
- Integer imageId = exchange.getIn().getHeader(DigitalOceanHeaders.ID, Integer.class);
-
- if (ObjectHelper.isEmpty(imageId))
- throw new IllegalArgumentException(DigitalOceanHeaders.ID + " must be specified");
-
- Action action = getEndpoint().getDigitalOceanClient().convertImage(imageId);
- LOG.trace("Convert Image {} [{}] ", imageId, action);
- exchange.getOut().setBody(action);
- }
-}
[14/20] camel git commit: remove README.md and LICENSE
Posted by ac...@apache.org.
remove README.md and LICENSE
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/34dc8c47
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/34dc8c47
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/34dc8c47
Branch: refs/heads/master
Commit: 34dc8c477cdd7729c614ef27fe07a11423122f0f
Parents: 6e9d978
Author: Thomas Lehoux <tl...@gmail.com>
Authored: Fri Mar 24 11:40:18 2017 +0100
Committer: Andrea Cosentino <an...@gmail.com>
Committed: Mon Mar 27 09:48:34 2017 +0200
----------------------------------------------------------------------
components/camel-digitalocean/LICENSE | 201 ---------------------
components/camel-digitalocean/README.md | 254 ---------------------------
2 files changed, 455 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/34dc8c47/components/camel-digitalocean/LICENSE
----------------------------------------------------------------------
diff --git a/components/camel-digitalocean/LICENSE b/components/camel-digitalocean/LICENSE
deleted file mode 100644
index 7d4b2e0..0000000
--- a/components/camel-digitalocean/LICENSE
+++ /dev/null
@@ -1,201 +0,0 @@
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
- 1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or resource authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting resource and all
- other entities that control, are controlled by, or are under common
- control with that resource. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such resource, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such resource.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
- 2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
- 3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any resource (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
- 4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
- 5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
- 6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
- 7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
- 8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
- 9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
- END OF TERMS AND CONDITIONS
-
- APPENDIX: How to apply the Apache License to your work.
-
- To apply the Apache License to your work, attach the following
- boilerplate notice, with the fields enclosed by brackets "{}"
- replaced with your own identifying information. (Don't include
- the brackets!) The text should be enclosed in the appropriate
- comment syntax for the file format. We also recommend that a
- file or class name and description of purpose be included on the
- same "printed page" as the copyright notice for easier
- identification within third-party archives.
-
- Copyright {yyyy} {name of copyright owner}
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
http://git-wip-us.apache.org/repos/asf/camel/blob/34dc8c47/components/camel-digitalocean/README.md
----------------------------------------------------------------------
diff --git a/components/camel-digitalocean/README.md b/components/camel-digitalocean/README.md
deleted file mode 100644
index 87771f7..0000000
--- a/components/camel-digitalocean/README.md
+++ /dev/null
@@ -1,254 +0,0 @@
-# Camel DigitalOcean Component
-
-The **DigitalOcean** component allows you to manage Droplets and resources within the DigitalOcean cloud with **Camel** by encapsulating [digitalocean-api-java](https://www.digitalocean.com/community/projects/api-client-in-java). All of the functionality that you are familiar with in the DigitalOcean control panel is also available through this Camel component.
-
-
-## Prerequisites
-
-You must have a valid DigitalOcean account and a valid OAuth token. You can generate an OAuth token by visiting the [Apps & API](https://cloud.digitalocean.com/settings/applications) section of the DigitalOcean control panel for your account.
-
-## URI format
-
-The **DigitalOcean Component** uses the following URI format:
-
-```
-digitalocean://endpoint?[options]
-```
-where `endpoint` is a DigitalOcean resource type.
-
-Example : to list your droplets:
-
-```
-digitalocean://droplets?operation=list&oAuthToken=XXXXXX&page=1&perPage=10
-```
-
-The DigitalOcean component only supports producer endpoints so you cannot use this component at the beginning of a route to listen to messages in a channel.
-
-## URI Endpoints
-
-There is one endpoint for each DigitalOcean resources (defined in `DigitalOceanResources` enumeration):
-
-| Endpoint | Description |
-| ------ | ----------- |
-| `account` | Your account on DigitalOcean. |
-| `actions` | Actions are records of events that have occurred on the resources in your account. |
-| `blockStorages` | Block Storage volumes provide expanded storage capacity for your Droplets and can be moved between Droplets within a specific region. |
-| `droplets` | A Droplet is a DigitalOcean virtual machine. |
-| `images` | An image may refer to a snapshot that has been taken of a Droplet instance. It may also mean an image representing an automatic backup of a Droplet. |
-| `snapshots` | Snapshots are saved instances of a Droplet or a volume. |
-| `keys` | DigitalOcean allows you to add SSH public keys to the interface so that you can embed your public key into a Droplet at the time of creation. |
-| `regions` | A region in DigitalOcean represents a datacenter where Droplets can be deployed and images can be transferred. |
-| `sizes` | The sizes objects represent different packages of hardware resources that can be used for Droplets. |
-| `floatingIPs` | Floating IP objects represent a publicly-accessible static IP addresses that can be mapped to one of your Droplets. |
-| `tags` | A Tag is a label that can be applied to a resource (currently only Droplets) in order to better organize or facilitate the lookups and actions on it. |
-
-
-## URI Options
-
-You have to provide the `digitalOceanClient` in the Registry or your `oAuthToken` to access the DigitalOcean service.
-
-| Option | Type | Example | Description |
-| ------ | ---- | ------- | ----------- |
-| `operation` | String | `operation=list` | The operation to perform to the resource. It can also be set with the `CamelDigitalOceanOperation` Message header. |
-| `oAuthToken` | String | | Your DigitalOcean oAuth token. |
-| `digitalOceanClient` | `com.myjeeva.digitalocean.DigitalOcean` | Reference to a `com.myjeeva.digitalocean.DigitalOcean` in the Registry. |
-| `page` | Integer | `page=3` | Can be used for `list` operations, for pagination. Force the page number.|
-| `perPage` | Integer | `perPage=50` | Can be used for `list` operations, for pagiantion. Set the number of item per request. |
-
-
-You have to provide an **operation** value for each endpoint, with the `operation` URI option or the `CamelDigitalOceanOperation` message header.
-
-All **operation** values are defined in `DigitalOceanOperations` enumeration.
-
-All **header** names used by the component are defined in `DigitalOceanHeaders` enumeration.
-
-
-## Message body result
-All message bodies returned are using objects provided by the **digitalocean-api-java** library.
-
-
-## API Rate Limits
-
-
-DigitalOcean REST API encapsulated by camel-digitalocean component is subjected to API Rate Limiting. You can find the per method limits in the [API Rate Limits documentation](https://developers.digitalocean.com/documentation/v2/#rate-limit).
-
-
-## Account endpoint
-
-| operation | Description | Headers | Result |
-| ------ | ---- | ------- | ----------- |
-| `get` | get account info | | `com.myjeeva.digitalocean.pojo.Account` |
-
-
-
-## BlockStorages endpoint
-
-| operation | Description | Headers | Result |
-| ------ | ---- | ------- | ----------- |
-| `list` | list all of the Block Storage volumes available on your account | | `List<com.myjeeva.digitalocean.pojo.Volume>` |
-| `get` | show information about a Block Storage volume| `CamelDigitalOceanId` _Integer_| `com.myjeeva.digitalocean.pojo.Volume` |
-| `get` | show information about a Block Storage volume by name| `CamelDigitalOceanName` _String_ <br>`CamelDigitalOceanRegion` _String_| `com.myjeeva.digitalocean.pojo.Volume` |
-| `listSnapshots` | retrieve the snapshots that have been created from a volume | `CamelDigitalOceanId` _Integer_| `List<com.myjeeva.digitalocean.pojo.Snapshot>` |
-| `create` | create a new volume | `CamelDigitalOceanVolumeSizeGigabytes` _Integer_<br>`CamelDigitalOceanName` _String_<br>`CamelDigitalOceanDescription`* _String_<br>`CamelDigitalOceanRegion`* _String_| `com.myjeeva.digitalocean.pojo.Volume` |
-| `delete` | delete a Block Storage volume, destroying all data and removing it from your account| `CamelDigitalOceanId` _Integer_| `com.myjeeva.digitalocean.pojo.Delete`|
-| `delete` | delete a Block Storage volume by name| `CamelDigitalOceanName` _String_<br>`CamelDigitalOceanRegion` _String_| `com.myjeeva.digitalocean.pojo.Delete`
-| `attach` | attach a Block Storage volume to a Droplet| `CamelDigitalOceanId` _Integer_ <br>`CamelDigitalOceanDropletId` _Integer_<br>`CamelDigitalOceanDropletRegion` _String_| `com.myjeeva.digitalocean.pojo.Action`
-| `attach` | attach a Block Storage volume to a Droplet by name| `CamelDigitalOceanName` _String_<br>`CamelDigitalOceanDropletId` _Integer_<br>`CamelDigitalOceanDropletRegion` _String_| `com.myjeeva.digitalocean.pojo.Action`
-| `detach` | detach a Block Storage volume from a Droplet| `CamelDigitalOceanId` _Integer_ <br>`CamelDigitalOceanDropletId` _Integer_<br>`CamelDigitalOceanDropletRegion` _String_| `com.myjeeva.digitalocean.pojo.Action`
-| `attach` | detach a Block Storage volume from a Droplet by name| `CamelDigitalOceanName` _String_<br>`CamelDigitalOceanDropletId` _Integer_<br>`CamelDigitalOceanDropletRegion` _String_| `com.myjeeva.digitalocean.pojo.Action`
-| `resize` | resize a Block Storage volume | `CamelDigitalOceanVolumeSizeGigabytes` _Integer_<br>`CamelDigitalOceanRegion` _String_| `com.myjeeva.digitalocean.pojo.Action` |
-| `listActions` | retrieve all actions that have been executed on a volume | `CamelDigitalOceanId` _Integer_| `List<com.myjeeva.digitalocean.pojo.Action>` |
-
-## Droplets endpoint
-
-| operation | Description | Headers | Result |
-| ------ | ---- | ------- | ----------- |
-| `list` | list all Droplets in your account | | `List<com.myjeeva.digitalocean.pojo.Droplet>` |
-| `get` | show an individual droplet | `CamelDigitalOceanId` _Integer_| `com.myjeeva.digitalocean.pojo.Droplet` |
-| `create` | create a new Droplet | `CamelDigitalOceanName` _String_ <br>`CamelDigitalOceanDropletImage` _String_ <br>`CamelDigitalOceanRegion` _String_ <br>`CamelDigitalOceanDropletSize` _String_ <br>`CamelDigitalOceanDropletSSHKeys`* _List\<String\>_ <br>`CamelDigitalOceanDropletEnableBackups`* _Boolean_ <br>`CamelDigitalOceanDropletEnableIpv6`* _Boolean_ <br>`CamelDigitalOceanDropletEnablePrivateNetworking`* _Boolean_ <br>`CamelDigitalOceanDropletUserData`* _String_ <br>`CamelDigitalOceanDropletVolumes`* _List\<String\>_ <br>`CamelDigitalOceanDropletTags` _List\<String\>_| `com.myjeeva.digitalocean.pojo.Droplet` |
-| `create` | create multiple Droplets | `CamelDigitalOceanNames` _List\<String\>_ <br>`CamelDigitalOceanDropletImage` _String_ <br>`CamelDigitalOceanRegion` _String_ <br>`CamelDigitalOceanDropletSize` _String_ <br>`CamelDigitalOceanDropletSSHKeys`* _List\<String\>_ <br>`CamelDigitalOceanDropletEnableBackups`* _Boolean_ <br>`CamelDigitalOceanDropletEnableIpv6`* _Boolean_ <br>`CamelDigitalOceanDropletEnablePrivateNetworking`* _Boolean_ <br>`CamelDigitalOceanDropletUserData`* _String_ <br>`CamelDigitalOceanDropletVolumes`* _List\<String\>_ <br>`CamelDigitalOceanDropletTags` _List\<String\>_| `com.myjeeva.digitalocean.pojo.Droplet` |
-| `delete` | delete a Droplet, | `CamelDigitalOceanId` _Integer_| `com.myjeeva.digitalocean.pojo.Delete` |
-| `enableBackups` | enable backups on an existing Droplet | `CamelDigitalOceanId` _Integer_| `com.myjeeva.digitalocean.pojo.Action` |
-| `disableBackups` | disable backups on an existing Droplet | `CamelDigitalOceanId` _Integer_| `com.myjeeva.digitalocean.pojo.Action` |
-| `enableIpv6` | enable IPv6 networking on an existing Droplet | `CamelDigitalOceanId` _Integer_| `com.myjeeva.digitalocean.pojo.Action` |
-| `enablePrivateNetworking` | enable private networking on an existing Droplet | `CamelDigitalOceanId` _Integer_| `com.myjeeva.digitalocean.pojo.Action` |
-| `reboot` | reboot a Droplet | `CamelDigitalOceanId` _Integer_| `com.myjeeva.digitalocean.pojo.Action` |
-| `powerCycle` | power cycle a Droplet | `CamelDigitalOceanId` _Integer_| `com.myjeeva.digitalocean.pojo.Action` |
-| `shutdown` | shutdown a Droplet | `CamelDigitalOceanId` _Integer_| `com.myjeeva.digitalocean.pojo.Action` |
-| `powerOff` | power off a Droplet | `CamelDigitalOceanId` _Integer_| `com.myjeeva.digitalocean.pojo.Action` |
-| `powerOn` | power on a Droplet | `CamelDigitalOceanId` _Integer_| `com.myjeeva.digitalocean.pojo.Action` |
-| `restore` | shutdown a Droplet | `CamelDigitalOceanId` _Integer_ <br>`CamelDigitalOceanImageId` _Integer_| `com.myjeeva.digitalocean.pojo.Action` |
-| `passwordReset` | reset the password for a Droplet | `CamelDigitalOceanId` _Integer_| `com.myjeeva.digitalocean.pojo.Action` |
-| `resize` | resize a Droplet | `CamelDigitalOceanId` _Integer_ <br>`CamelDigitalOceanDropletSize` _String_| `com.myjeeva.digitalocean.pojo.Action` |
-| `rebuild` | rebuild a Droplet | `CamelDigitalOceanId` _Integer_ <br>`CamelDigitalOceanImageId` _Integer_| `com.myjeeva.digitalocean.pojo.Action` |
-| `rename` | rename a Droplet | `CamelDigitalOceanId` _Integer_ <br>`CamelDigitalOceanName` _String_| `com.myjeeva.digitalocean.pojo.Action` |
-| `changeKernel` | change the kernel of a Droplet | `CamelDigitalOceanId` _Integer_ <br>`CamelDigitalOceanKernelId` _Integer_| `com.myjeeva.digitalocean.pojo.Action` |
-| `takeSnapshot` | snapshot a Droplet | `CamelDigitalOceanId` _Integer_ <br>`CamelDigitalOceanName`* _String_| `com.myjeeva.digitalocean.pojo.Action` |
-| `tag` | tag a Droplet | `CamelDigitalOceanId` _Integer_ <br>`CamelDigitalOceanName` _String_| `com.myjeeva.digitalocean.pojo.Response` |
-| `untag` | untag a Droplet | `CamelDigitalOceanId` _Integer_ <br>`CamelDigitalOceanName` _String_| `com.myjeeva.digitalocean.pojo.Response` |
-| `listKernels` | retrieve a list of all kernels available to a Droplet | `CamelDigitalOceanId` _Integer_ | `List<com.myjeeva.digitalocean.pojo.Kernel>` |
-| `listSnapshots` | retrieve the snapshots that have been created from a Droplet | `CamelDigitalOceanId` _Integer_ | `List<com.myjeeva.digitalocean.pojo.Snapshot>` |
-| `listBackups` | retrieve any backups associated with a Droplet | `CamelDigitalOceanId` _Integer_ | `List<com.myjeeva.digitalocean.pojo.Backup>` |
-| `listActions` | retrieve all actions that have been executed on a Droplet | `CamelDigitalOceanId` _Integer_ | `List<com.myjeeva.digitalocean.pojo.Action>` |
-| `listNeighbors` | retrieve a list of droplets that are running on the same physical server | `CamelDigitalOceanId` _Integer_ | `List<com.myjeeva.digitalocean.pojo.Droplet>` |
-| `listAllNeighbors` | retrieve a list of any droplets that are running on the same physical hardware | | `List<com.myjeeva.digitalocean.pojo.Droplet>` |
-
-## Images endpoint
-
-| operation | Description | Headers | Result |
-| ------ | ---- | ------- | ----------- |
-| `list` | list images available on your account | `CamelDigitalOceanType`* _DigitalOceanImageTypes_ | `List<com.myjeeva.digitalocean.pojo.Image>` |
-| `ownList` | retrieve only the private images of a user | | `List<com.myjeeva.digitalocean.pojo.Image>` |
-| `listActions` | retrieve all actions that have been executed on a Image | `CamelDigitalOceanId` _Integer_ | `List<com.myjeeva.digitalocean.pojo.Action>` |
-| `get` | retrieve information about an image (public or private) by id| `CamelDigitalOceanId` _Integer_| `com.myjeeva.digitalocean.pojo.Image` |
-| `get` | retrieve information about an public image by slug| `CamelDigitalOceanDropletImage` _String_| `com.myjeeva.digitalocean.pojo.Image` |
-| `update` | update an image| `CamelDigitalOceanId` _Integer_ <br>`CamelDigitalOceanName` _String_| `com.myjeeva.digitalocean.pojo.Image` |
-| `delete` | delete an image| `CamelDigitalOceanId` _Integer_ | `com.myjeeva.digitalocean.pojo.Delete` |
-| `transfer` | transfer an image to another region| `CamelDigitalOceanId` _Integer_ <br>`CamelDigitalOceanRegion` _String_| `com.myjeeva.digitalocean.pojo.Action` |
-| `convert` | convert an image, for example, a backup to a snapshot| `CamelDigitalOceanId` _Integer_ | `com.myjeeva.digitalocean.pojo.Action` |
-
-## Snapshots endpoint
-
-| operation | Description | Headers | Result |
-| ------ | ---- | ------- | ----------- |
-| `list` | list all of the snapshots available on your account | `CamelDigitalOceanType`* _DigitalOceanSnapshotTypes_ | `List<com.myjeeva.digitalocean.pojo.Snapshot>` |
-| `get` | retrieve information about a snapshot| `CamelDigitalOceanId` _Integer_| `com.myjeeva.digitalocean.pojo.Snapshot` |
-| `delete` | delete an snapshot| `CamelDigitalOceanId` _Integer_ | `com.myjeeva.digitalocean.pojo.Delete` |
-
-
-## Keys endpoint
-
-| operation | Description | Headers | Result |
-| ------ | ---- | ------- | ----------- |
-| `list` | list all of the keys in your account | | `List<com.myjeeva.digitalocean.pojo.Key>` |
-| `get` | retrieve information about a key by id| `CamelDigitalOceanId` _Integer_| `com.myjeeva.digitalocean.pojo.Key` |
-| `get` | retrieve information about a key by fingerprint| `CamelDigitalOceanKeyFingerprint` _String_| `com.myjeeva.digitalocean.pojo.Key` |
-| `update` | update a key by id| `CamelDigitalOceanId` _Integer_ <br>`CamelDigitalOceanName` _String_| `com.myjeeva.digitalocean.pojo.Key` |
-| `update` | update a key by fingerprint| `CamelDigitalOceanKeyFingerprint` _String_ <br>`CamelDigitalOceanName` _String_| `com.myjeeva.digitalocean.pojo.Key` |
-| `delete` | delete a key by id| `CamelDigitalOceanId` _Integer_ | `com.myjeeva.digitalocean.pojo.Delete` |
-| `delete` | delete a key by fingerprint| `CamelDigitalOceanKeyFingerprint` _String_ | `com.myjeeva.digitalocean.pojo.Delete` |
-
-## Regions endpoint
-
-| operation | Description | Headers | Result |
-| ------ | ---- | ------- | ----------- |
-| `list` | list all of the regions that are available | | `List<com.myjeeva.digitalocean.pojo.Region>` |
-
-
-## Sizes endpoint
-
-| operation | Description | Headers | Result |
-| ------ | ---- | ------- | ----------- |
-| `list` | list all of the sizes that are available | | `List<com.myjeeva.digitalocean.pojo.Size>` |
-
-## Floating IPs endpoint
-
-| operation | Description | Headers | Result |
-| ------ | ---- | ------- | ----------- |
-| `list` | list all of the Floating IPs available on your account | | `List<com.myjeeva.digitalocean.pojo.FloatingIP>` |
-| `create` | create a new Floating IP assigned to a Droplet | `CamelDigitalOceanId` _Integer_ | `List<com.myjeeva.digitalocean.pojo.FloatingIP>` |
-| `create` | create a new Floating IP assigned to a Region | `CamelDigitalOceanRegion` _String_ | `List<com.myjeeva.digitalocean.pojo.FloatingIP>` |
-| `get` | retrieve information about a Floating IP| `CamelDigitalOceanFloatingIPAddress` _String_| `com.myjeeva.digitalocean.pojo.Key` |
-| `delete` | delete a Floating IP and remove it from your account| `CamelDigitalOceanFloatingIPAddress` _String_| `com.myjeeva.digitalocean.pojo.Delete` |
-| `assign` | assign a Floating IP to a Droplet| `CamelDigitalOceanFloatingIPAddress` _String_ <br>`CamelDigitalOceanDropletId` _Integer_| `com.myjeeva.digitalocean.pojo.Action` |
-| `unassign` | unassign a Floating IP | `CamelDigitalOceanFloatingIPAddress` _String_ | `com.myjeeva.digitalocean.pojo.Action` |
-| `listActions` | retrieve all actions that have been executed on a Floating IP | `CamelDigitalOceanFloatingIPAddress` _String_ | `List<com.myjeeva.digitalocean.pojo.Action>` |
-
-## Tags endpoint
-
-| operation | Description | Headers | Result |
-| ------ | ---- | ------- | ----------- |
-| `list` | list all of your tags | | `List<com.myjeeva.digitalocean.pojo.Tag>` |
-| `create` | create a Tag | `CamelDigitalOceanName` _String_ | `com.myjeeva.digitalocean.pojo.Tag` |
-| `get` | retrieve an individual tag | `CamelDigitalOceanName` _String_ | `com.myjeeva.digitalocean.pojo.Tag` |
-| `delete` | delete a tag | `CamelDigitalOceanName` _String_ | `com.myjeeva.digitalocean.pojo.Delete` |
-| `update` | update a tag | `CamelDigitalOceanName` _String_ <br>`CamelDigitalOceanNewName` _String_| `com.myjeeva.digitalocean.pojo.Tag` |
-
-
-## Examples
-
-Get your account info
-
-```
-from("direct:getAccountInfo")
- .setHeader(DigitalOceanConstants.OPERATION, constant(DigitalOceanOperations.get))
- .to("digitalocean:account?oAuthToken=XXXXXX")
-```
-
-Create a droplet
-
-```
-from("direct:createDroplet")
- .setHeader(DigitalOceanConstants.OPERATION, constant("create"))
- .setHeader(DigitalOceanHeaders.NAME, constant("myDroplet"))
- .setHeader(DigitalOceanHeaders.REGION, constant("fra1"))
- .setHeader(DigitalOceanHeaders.DROPLET_IMAGE, constant("ubuntu-14-04-x64"))
- .setHeader(DigitalOceanHeaders.DROPLET_SIZE, constant("512mb"))
- .to("digitalocean:droplet?oAuthToken=XXXXXX")
-```
-
-List all your droplets
-
-```
-from("direct:getDroplets")
- .setHeader(DigitalOceanConstants.OPERATION, constant("list"))
- .to("digitalocean:droplets?oAuthToken=XXXXXX")
-```
-
-Retrieve information for the Droplet (dropletId = 34772987)
-
-```
-from("direct:getDroplet")
- .setHeader(DigitalOceanConstants.OPERATION, constant("get"))
- .setHeader(DigitalOceanConstants.ID, 34772987)
- .to("digitalocean:droplet?oAuthToken=XXXXXX")
-```
-
-Shutdown information for the Droplet (dropletId = 34772987)
-
-```
-from("direct:shutdown")
- .setHeader(DigitalOceanConstants.ID, 34772987)
- .to("digitalocean:droplet?operation=shutdown&oAuthToken=XXXXXX")
-```
-
[20/20] camel git commit: CAMEL-11062: Define the digitalocean API
client version in parent POM
Posted by ac...@apache.org.
CAMEL-11062: Define the digitalocean API client version in parent POM
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/4ed4ea9a
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/4ed4ea9a
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/4ed4ea9a
Branch: refs/heads/master
Commit: 4ed4ea9ae68820094cb25027ddff2f3827aa4e22
Parents: db20dc9
Author: Andrea Cosentino <an...@gmail.com>
Authored: Mon Mar 27 09:48:05 2017 +0200
Committer: Andrea Cosentino <an...@gmail.com>
Committed: Mon Mar 27 09:48:35 2017 +0200
----------------------------------------------------------------------
components/camel-digitalocean/pom.xml | 2 +-
parent/pom.xml | 1 +
2 files changed, 2 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/4ed4ea9a/components/camel-digitalocean/pom.xml
----------------------------------------------------------------------
diff --git a/components/camel-digitalocean/pom.xml b/components/camel-digitalocean/pom.xml
index 0485072..efd23e6 100644
--- a/components/camel-digitalocean/pom.xml
+++ b/components/camel-digitalocean/pom.xml
@@ -46,7 +46,7 @@ limitations under the License.
<dependency>
<groupId>com.myjeeva.digitalocean</groupId>
<artifactId>digitalocean-api-client</artifactId>
- <version>2.8</version>
+ <version>${digitalocean-api-client-version}</version>
</dependency>
<!-- logging -->
http://git-wip-us.apache.org/repos/asf/camel/blob/4ed4ea9a/parent/pom.xml
----------------------------------------------------------------------
diff --git a/parent/pom.xml b/parent/pom.xml
index 2a57c14..a697cd8 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -162,6 +162,7 @@
<deltaspike-version>1.7.2</deltaspike-version>
<depends-maven-plugin-version>1.3.1</depends-maven-plugin-version>
<derby-version>10.11.1.1</derby-version>
+ <digitalocean-api-client-version>2.8</digitalocean-api-client-version>
<disruptor-version>3.3.6</disruptor-version>
<dnsjava-version>2.1.8</dnsjava-version>
<dnsjava-bundle-version>2.1.8_1</dnsjava-bundle-version>