Skip to content
Permalink
Browse files
Promote DigitalOcean v2
  • Loading branch information
nacx committed Jan 20, 2016
2 parents 52dc1a3 + c188570 commit 886aa156b44d34520ac2b4d2723f7de39086f850
Show file tree
Hide file tree
Showing 119 changed files with 10,612 additions and 0 deletions.
@@ -0,0 +1,152 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.jclouds.labs</groupId>
<artifactId>jclouds-labs</artifactId>
<version>2.0.0-SNAPSHOT</version>
</parent>

<groupId>org.apache.jclouds.labs</groupId>
<artifactId>digitalocean2</artifactId>
<name>jclouds DigitalOcean v2 API Provider</name>
<description>jclouds provider for Digital Ocean v2 Compute API</description>

<properties>
<test.digitalocean2.endpoint>https://api.digitalocean.com/v2/</test.digitalocean2.endpoint>
<test.digitalocean2.api-version>2</test.digitalocean2.api-version>
<test.digitalocean2.identity>FIXME</test.digitalocean2.identity>
<test.digitalocean2.credential>FIXME</test.digitalocean2.credential>
<test.digitalocean2.template>osFamily=UBUNTU,os64Bit=true</test.digitalocean2.template>
</properties>

<dependencies>
<dependency>
<groupId>org.apache.jclouds</groupId>
<artifactId>jclouds-core</artifactId>
<version>${jclouds.version}</version>
</dependency>
<dependency>
<groupId>org.apache.jclouds.api</groupId>
<artifactId>oauth</artifactId>
<version>${jclouds.version}</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.apache.jclouds.api</groupId>
<artifactId>oauth</artifactId>
<version>${jclouds.version}</version>
<type>test-jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.jclouds</groupId>
<artifactId>jclouds-compute</artifactId>
<version>${jclouds.version}</version>
</dependency>
<dependency>
<groupId>org.apache.jclouds</groupId>
<artifactId>jclouds-compute</artifactId>
<version>${jclouds.version}</version>
<type>test-jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.jclouds</groupId>
<artifactId>jclouds-core</artifactId>
<version>${jclouds.version}</version>
<type>test-jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.jclouds.driver</groupId>
<artifactId>jclouds-slf4j</artifactId>
<version>${jclouds.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.jclouds.driver</groupId>
<artifactId>jclouds-sshj</artifactId>
<version>${jclouds.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.squareup.okhttp</groupId>
<artifactId>mockwebserver</artifactId>
<scope>test</scope>
<exclusions>
<!-- Already provided by jclouds-sshj -->
<exclusion>
<groupId>org.bouncycastle</groupId>
<artifactId>bcprov-jdk15on</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.google.auto.value</groupId>
<artifactId>auto-value</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.google.auto.service</groupId>
<artifactId>auto-service</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>
<profiles>
<profile>
<id>live</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<executions>
<execution>
<id>integration</id>
<phase>integration-test</phase>
<goals>
<goal>test</goal>
</goals>
<configuration>
<systemPropertyVariables>
<test.digitalocean2.endpoint>${test.digitalocean2.endpoint}</test.digitalocean2.endpoint>
<test.digitalocean2.api-version>${test.digitalocean2.api-version}</test.digitalocean2.api-version>
<test.digitalocean2.build-version>${test.digitalocean2.build-version}</test.digitalocean2.build-version>
<test.digitalocean2.identity>${test.digitalocean2.identity}</test.digitalocean2.identity>
<test.digitalocean2.credential>${test.digitalocean2.credential}</test.digitalocean2.credential>
<test.digitalocean2.template>${test.digitalocean2.template}</test.digitalocean2.template>
</systemPropertyVariables>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
@@ -0,0 +1,73 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jclouds.digitalocean2;

import java.io.Closeable;

import org.jclouds.digitalocean2.features.ActionApi;
import org.jclouds.digitalocean2.features.DropletApi;
import org.jclouds.digitalocean2.features.ImageApi;
import org.jclouds.digitalocean2.features.KeyApi;
import org.jclouds.digitalocean2.features.RegionApi;
import org.jclouds.digitalocean2.features.SizeApi;
import org.jclouds.rest.annotations.Delegate;

import com.google.common.annotations.Beta;

/**
* Provides access to DigitalOcean.
*/
@Beta
public interface DigitalOcean2Api extends Closeable {

/**
* Provides access to Droplet features
*/
@Delegate
DropletApi dropletApi();

/**
* Provides access to SSH Key features
*/
@Delegate
KeyApi keyApi();

/**
* Provides access to Images
*/
@Delegate
ImageApi imageApi();

/**
* Provides access to Actions
*/
@Delegate
ActionApi actionApi();

/**
* Provides access to Sizes
*/
@Delegate
SizeApi sizeApi();

/**
* Provides access to Regions
*/
@Delegate
RegionApi regionApi();

}
@@ -0,0 +1,111 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jclouds.digitalocean2;

import static org.jclouds.Constants.PROPERTY_SESSION_INTERVAL;
import static org.jclouds.compute.config.ComputeServiceProperties.POLL_INITIAL_PERIOD;
import static org.jclouds.compute.config.ComputeServiceProperties.POLL_MAX_PERIOD;
import static org.jclouds.compute.config.ComputeServiceProperties.TEMPLATE;
import static org.jclouds.compute.config.ComputeServiceProperties.TIMEOUT_NODE_RUNNING;
import static org.jclouds.compute.config.ComputeServiceProperties.TIMEOUT_NODE_SUSPENDED;
import static org.jclouds.compute.config.ComputeServiceProperties.TIMEOUT_NODE_TERMINATED;
import static org.jclouds.oauth.v2.config.CredentialType.BEARER_TOKEN_CREDENTIALS;
import static org.jclouds.oauth.v2.config.OAuthProperties.AUDIENCE;
import static org.jclouds.oauth.v2.config.OAuthProperties.CREDENTIAL_TYPE;
import static org.jclouds.oauth.v2.config.OAuthProperties.JWS_ALG;
import static org.jclouds.reflect.Reflection2.typeToken;

import java.net.URI;
import java.util.Properties;

import org.jclouds.apis.ApiMetadata;
import org.jclouds.compute.ComputeServiceContext;
import org.jclouds.digitalocean2.compute.config.DigitalOcean2ComputeServiceContextModule;
import org.jclouds.digitalocean2.config.DigitalOcean2HttpApiModule;
import org.jclouds.digitalocean2.config.DigitalOceanParserModule;
import org.jclouds.oauth.v2.config.OAuthModule;
import org.jclouds.rest.internal.BaseHttpApiMetadata;

import com.google.common.collect.ImmutableSet;
import com.google.inject.Module;

/**
* Implementation of {@link ApiMetadata} for DigitalOcean v2 API
*/
public class DigitalOcean2ApiMetadata extends BaseHttpApiMetadata<DigitalOcean2Api> {

@Override
public Builder toBuilder() {
return new Builder().fromApiMetadata(this);
}

public DigitalOcean2ApiMetadata() {
this(new Builder());
}

protected DigitalOcean2ApiMetadata(Builder builder) {
super(builder);
}

public static Properties defaultProperties() {
Properties properties = BaseHttpApiMetadata.defaultProperties();
properties.put("oauth.endpoint", "https://cloud.digitalocean.com/v1/oauth/token");
properties.put(JWS_ALG, "RS256");
properties.put(AUDIENCE, "https://cloud.digitalocean.com/v1/oauth/token");
properties.put(CREDENTIAL_TYPE, BEARER_TOKEN_CREDENTIALS.toString());
properties.put(PROPERTY_SESSION_INTERVAL, 3600);
properties.put(TEMPLATE, "osFamily=UBUNTU,os64Bit=true");
properties.put(POLL_INITIAL_PERIOD, 5000);
properties.put(POLL_MAX_PERIOD, 20000);
// Node operations in DigitalOcean can be quite slow. Use a 5 minutes
// timeout by default
properties.put(TIMEOUT_NODE_RUNNING, 300000);
properties.put(TIMEOUT_NODE_SUSPENDED, 300000);
properties.put(TIMEOUT_NODE_TERMINATED, 300000);
return properties;
}

public static class Builder extends BaseHttpApiMetadata.Builder<DigitalOcean2Api, Builder> {

protected Builder() {
id("digitalocean2")
.name("Digital Ocean v2 API")
.identityName("Not used for OAuth")
.credentialName("Must be oauth2 Bearer Token")
.documentation(URI.create("https://developers.digitalocean.com/v2/"))
.defaultEndpoint("https://api.digitalocean.com/v2")
.defaultProperties(DigitalOcean2ApiMetadata.defaultProperties())
.view(typeToken(ComputeServiceContext.class))
.defaultModules(ImmutableSet.<Class<? extends Module>>builder()
.add(DigitalOcean2HttpApiModule.class)
.add(OAuthModule.class)
.add(DigitalOceanParserModule.class)
.add(DigitalOcean2ComputeServiceContextModule.class)
.build());
}

@Override
public DigitalOcean2ApiMetadata build() {
return new DigitalOcean2ApiMetadata(this);
}

@Override
protected Builder self() {
return this;
}
}
}

0 comments on commit 886aa15

Please sign in to comment.