Skip to content
Permalink
Browse files
Merge remote-tracking branch 'jclouds-labs-b2-local/promote-b2-moved'…
… into promoted-b2
  • Loading branch information
gaul committed May 8, 2017
2 parents 9ea76eb + c94dfa2 commit 664387207294401863aad4ad46c5c0995edcd026
Show file tree
Hide file tree
Showing 89 changed files with 5,003 additions and 0 deletions.
@@ -0,0 +1,132 @@
<?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:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
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.1.0-SNAPSHOT</version>
</parent>

<!-- TODO: when out of labs, switch to org.jclouds.api -->
<groupId>org.apache.jclouds.labs</groupId>
<artifactId>b2</artifactId>
<name>Apache jclouds B2 API</name>
<description>BlobStore binding to the Backblaze B2 API</description>
<packaging>bundle</packaging>

<properties>
<test.b2.identity>FIXME_IDENTITY</test.b2.identity>
<test.b2.credential>FIXME_CREDENTIAL</test.b2.credential>
<test.b2.build-version />
<jclouds.osgi.export>org.jclouds.b2*;version="${project.version}"</jclouds.osgi.export>
<jclouds.osgi.import>org.jclouds*;version="${project.version}",*</jclouds.osgi.import>
</properties>

<dependencies>
<dependency>
<groupId>org.apache.jclouds</groupId>
<artifactId>jclouds-blobstore</artifactId>
<version>${project.parent.version}</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.apache.jclouds</groupId>
<artifactId>jclouds-core</artifactId>
<version>${project.parent.version}</version>
<type>test-jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.jclouds</groupId>
<artifactId>jclouds-blobstore</artifactId>
<version>${project.parent.version}</version>
<type>test-jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.jclouds.driver</groupId>
<artifactId>jclouds-log4j</artifactId>
<version>${project.parent.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.auto.value</groupId>
<artifactId>auto-value</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.squareup.okhttp</groupId>
<artifactId>mockwebserver</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.auto.service</groupId>
<artifactId>auto-service</artifactId>
<optional>true</optional>
</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>
<groups>live</groups>
<systemPropertyVariables>
<jclouds.blobstore.httpstream.url>${jclouds.blobstore.httpstream.url}</jclouds.blobstore.httpstream.url>
<jclouds.blobstore.httpstream.md5>${jclouds.blobstore.httpstream.md5}</jclouds.blobstore.httpstream.md5>
<test.b2.endpoint>${test.b2.endpoint}</test.b2.endpoint>
<test.b2.api-version>${test.b2.api-version}</test.b2.api-version>
<test.b2.build-version>${test.b2.build-version}</test.b2.build-version>
<test.b2.identity>${test.b2.identity}</test.b2.identity>
<test.b2.credential>${test.b2.credential}</test.b2.credential>
</systemPropertyVariables>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
@@ -0,0 +1,40 @@
/*
* 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.b2;

import java.io.Closeable;

import org.jclouds.b2.features.AuthorizationApi;
import org.jclouds.b2.features.BucketApi;
import org.jclouds.b2.features.MultipartApi;
import org.jclouds.b2.features.ObjectApi;
import org.jclouds.rest.annotations.Delegate;

/** Provides access to Backblaze B2 resources via their REST API. */
public interface B2Api extends Closeable {
@Delegate
AuthorizationApi getAuthorizationApi();

@Delegate
BucketApi getBucketApi();

@Delegate
ObjectApi getObjectApi();

@Delegate
MultipartApi getMultipartApi();
}
@@ -0,0 +1,91 @@
/*
* 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.b2;

import static org.jclouds.reflect.Reflection2.typeToken;

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

import org.jclouds.Constants;
import org.jclouds.apis.ApiMetadata;
import org.jclouds.blobstore.BlobStoreContext;
import org.jclouds.blobstore.reference.BlobStoreConstants;
import org.jclouds.b2.blobstore.config.B2BlobStoreContextModule;
import org.jclouds.b2.config.B2HttpApiModule;
import org.jclouds.rest.internal.BaseHttpApiMetadata;

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

public final class B2ApiMetadata extends BaseHttpApiMetadata {
@Override
public Builder toBuilder() {
return new Builder().fromApiMetadata(this);
}

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

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

public static Properties defaultProperties() {
Properties properties = BaseHttpApiMetadata.defaultProperties();
properties.setProperty(BlobStoreConstants.PROPERTY_USER_METADATA_PREFIX, "X-Bz-Info-");
properties.setProperty(Constants.PROPERTY_SESSION_INTERVAL, String.valueOf(TimeUnit.HOURS.toSeconds(1)));
properties.setProperty(Constants.PROPERTY_IDEMPOTENT_METHODS, "DELETE,GET,HEAD,OPTIONS,POST,PUT");
properties.setProperty(Constants.PROPERTY_RETRY_DELAY_START, String.valueOf(TimeUnit.SECONDS.toMillis(1)));
return properties;
}

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

protected Builder() {
super(B2Api.class);
id("b2")
.name("Backblaze B2 API")
.identityName("Account Id")
.credentialName("Application Key")
.documentation(URI.create("https://www.backblaze.com/b2/docs/"))
.defaultEndpoint("https://api.backblazeb2.com/")
.defaultProperties(B2ApiMetadata.defaultProperties())
.view(typeToken(BlobStoreContext.class))
.defaultModules(ImmutableSet.<Class<? extends Module>>of(
B2HttpApiModule.class,
B2BlobStoreContextModule.class));
}

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

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

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

import java.util.Properties;

import org.jclouds.providers.ProviderMetadata;
import org.jclouds.providers.internal.BaseProviderMetadata;

import com.google.auto.service.AutoService;

@AutoService(ProviderMetadata.class)
public final class B2ProviderMetadata extends BaseProviderMetadata {
@Override
public Builder toBuilder() {
return new Builder().fromProviderMetadata(this);
}

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

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

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

public static class Builder extends BaseProviderMetadata.Builder {

protected Builder() {
id("b2")
.name("Backblaze B2")
.apiMetadata(new B2ApiMetadata())
.endpoint("https://api.backblazeb2.com/")
.defaultProperties(B2ProviderMetadata.defaultProperties());
}

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

@Override
public Builder fromProviderMetadata(ProviderMetadata in) {
return this;
}
}
}
@@ -0,0 +1,38 @@
/*
* 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.b2;

import org.jclouds.b2.domain.B2Error;
import org.jclouds.http.HttpCommand;
import org.jclouds.http.HttpResponse;
import org.jclouds.http.HttpResponseException;

import com.google.common.base.Preconditions;

public final class B2ResponseException extends HttpResponseException {
private final B2Error error;

public B2ResponseException(HttpCommand command, HttpResponse response, B2Error error) {
super("request " + command.getCurrentRequest().getRequestLine() + " failed with code " + response.getStatusCode()
+ ", error: " + Preconditions.checkNotNull(error, "error").toString(), command, response);
this.error = error;
}

public B2Error getError() {
return error;
}
}

0 comments on commit 6643872

Please sign in to comment.