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:29 UTC
[11/20] camel git commit: Refactor com.viwilo to org.apache.camel
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);
- }
-}