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:20 UTC
[02/20] camel git commit: initial commit
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());
+ }
+
+}