Skip to content
Permalink
Browse files
JCLOUDS-1124 oneandone-server-api
  • Loading branch information
alibazlamit authored and nacx committed Jul 12, 2016
1 parent 2b36a75 commit 7df28d259999b2267484cfc82c7ae486697f0ec6
Show file tree
Hide file tree
Showing 64 changed files with 5,397 additions and 4 deletions.
@@ -0,0 +1,142 @@
<?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/xsd/maven-4.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>

<!-- TODO: when out of labs, switch to org.jclouds.api -->
<artifactId>oneandone</artifactId>
<name>jclouds OneAndOne REST api</name>
<description>jclouds components to access an implementation of OneAndOne</description>
<packaging>bundle</packaging>

<properties>
<test.oneandone.endpoint>https://cloudpanel-api.1and1.com/v1/</test.oneandone.endpoint>
<test.oneandone.identity>FIXME</test.oneandone.identity>
<test.oneandone.api-version>1.0</test.oneandone.api-version>
<jclouds.osgi.export>org.jclouds.oneandone*;version="${project.version}"</jclouds.osgi.export>
<jclouds.osgi.import>
org.jclouds.labs*;version="${project.version}",
org.jclouds*;version="${jclouds.version}",
*
</jclouds.osgi.import>
</properties>

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

import java.io.Closeable;
import org.apache.jclouds.oneandone.rest.features.ServerApi;
import org.jclouds.rest.annotations.Delegate;

public interface OneAndOneApi extends Closeable {

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

import com.google.common.collect.ImmutableSet;
import com.google.inject.Module;
import java.net.URI;
import java.util.Properties;
import org.apache.jclouds.oneandone.rest.config.OneAndOneHttpApiModule;
import org.jclouds.http.okhttp.config.OkHttpCommandExecutorServiceModule;
import org.jclouds.rest.internal.BaseHttpApiMetadata;

public class OneAndOneApiMetadata extends BaseHttpApiMetadata<OneAndOneApi> {

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

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

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

public static Properties defaultProperties() {
Properties properties = BaseHttpApiMetadata.defaultProperties();
return properties;
}

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

protected Builder() {
id("oneandone")
.name("OneAndOne REST API")
.identityName("API Username")
.documentation(URI.create("https://cloudpanel-api.1and1.com/documentation/1and1/v1/en/documentation.html"))
.defaultEndpoint("https://cloudpanel-api.1and1.com/v1")
.defaultProperties(OneAndOneApiMetadata.defaultProperties())
.defaultModules(ImmutableSet.<Class<? extends Module>>builder()
.add(OkHttpCommandExecutorServiceModule.class)
.add(OneAndOneHttpApiModule.class)
.build());
}

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

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

import com.google.auto.service.AutoService;
import java.net.URI;
import java.util.Properties;
import static org.apache.jclouds.oneandone.rest.config.OneAndOneProperties.POLL_MAX_PERIOD;
import static org.apache.jclouds.oneandone.rest.config.OneAndOneProperties.POLL_PERIOD;
import static org.apache.jclouds.oneandone.rest.config.OneAndOneProperties.POLL_TIMEOUT;
import static org.jclouds.Constants.PROPERTY_CONNECTION_TIMEOUT;
import static org.jclouds.Constants.PROPERTY_SO_TIMEOUT;
import org.jclouds.providers.ProviderMetadata;
import org.jclouds.providers.internal.BaseProviderMetadata;

@AutoService(ProviderMetadata.class)
public class OneAndOneProviderMetadata extends BaseProviderMetadata {

public static Builder builder() {
return new Builder();
}

@Override
public Builder toBuilder() {
return builder().fromProviderMetadata(this);
}

public OneAndOneProviderMetadata() {
super(builder());
}

public OneAndOneProviderMetadata(Builder builder) {
super(builder);
}

public static Properties defaultProperties() {
Properties properties = OneAndOneApiMetadata.defaultProperties();
long defaultTimeout = 60l * 60l; // 1 hour
properties.put(POLL_TIMEOUT, defaultTimeout);
properties.put(POLL_PERIOD, 1l);
properties.put(POLL_MAX_PERIOD, 1l * 9l);
properties.put(PROPERTY_SO_TIMEOUT, 60000 * 5);
properties.put(PROPERTY_CONNECTION_TIMEOUT, 60000 * 5);

return properties;
}

public static class Builder extends BaseProviderMetadata.Builder {

protected Builder() {
id("oneandone")
.name("OneAndOne REST Compute")
.apiMetadata(new OneAndOneApiMetadata())
.homepage(URI.create("https://cloudpanel-api.1and1.com"))
.console(URI.create("https://account.1and1.com"))
.endpoint("https://cloudpanel-api.1and1.com/v1")
.defaultProperties(OneAndOneProviderMetadata.defaultProperties());
}

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

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

import com.google.inject.Inject;
import javax.inject.Named;
import javax.inject.Singleton;
import static org.apache.jclouds.oneandone.rest.config.OneAndOneProperties.POLL_MAX_PERIOD;
import static org.apache.jclouds.oneandone.rest.config.OneAndOneProperties.POLL_PERIOD;
import static org.apache.jclouds.oneandone.rest.config.OneAndOneProperties.POLL_TIMEOUT;

@Singleton
public class OneAndOneConstants {

@Inject
@Named(POLL_TIMEOUT)
private String pollTimeout;

@Inject
@Named(POLL_PERIOD)
private String pollPeriod;

@Inject
@Named(POLL_MAX_PERIOD)
private String pollMaxPeriod;

public long pollTimeout() {
return Long.parseLong(pollTimeout);
}

public long pollPeriod() {
return Long.parseLong(pollPeriod);
}

public long pollMaxPeriod() {
return Long.parseLong(pollMaxPeriod);
}
}

0 comments on commit 7df28d2

Please sign in to comment.