* Change OAuthScopes into an interface as opposed to boilerplating annotations.

* Fixed errors because of boilerplating annotations.
This commit is contained in:
Adrian Cole 2014-11-11 20:15:56 -08:00
parent aebc0c473a
commit 4213fcb4e1
17 changed files with 143 additions and 246 deletions

View File

@ -177,7 +177,7 @@ public final class GCSBlobStore extends BaseBlobStore {
public boolean blobExists(String container, String name) {
try {
String urlName = name.contains("/") ? URLEncoder.encode(name, Charsets.UTF_8.toString()) : name;
return api.getObjectApi().objectExist(container, urlName);
return api.getObjectApi().objectExists(container, urlName);
} catch (UnsupportedEncodingException e) {
throw Throwables.propagate(e);
}

View File

@ -33,6 +33,7 @@ import org.jclouds.http.annotation.ClientError;
import org.jclouds.http.annotation.Redirection;
import org.jclouds.http.annotation.ServerError;
import org.jclouds.location.Provider;
import org.jclouds.oauth.v2.config.OAuthScopes;
import org.jclouds.rest.AuthorizationException;
import org.jclouds.rest.ConfiguresHttpApi;
import org.jclouds.rest.config.HttpApiModule;
@ -44,12 +45,12 @@ import com.google.common.base.Supplier;
import com.google.common.collect.Iterables;
import com.google.inject.Provides;
/**
* Configures the GoogleCloud connection.
*/
@ConfiguresHttpApi
public class GoogleCloudStorageHttpApiModule extends HttpApiModule<GoogleCloudStorageApi> {
public GoogleCloudStorageHttpApiModule() {
@Override public void configure(){
super.configure();
bind(OAuthScopes.class).toInstance(GoogleCloudStorageOAuthScopes.create());
}
@Override

View File

@ -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 org.jclouds.googlecloudstorage.config;
import java.util.List;
import org.jclouds.http.HttpRequest;
import org.jclouds.oauth.v2.config.OAuthScopes;
import com.google.auto.value.AutoValue;
import com.google.common.collect.ImmutableList;
@AutoValue public abstract class GoogleCloudStorageOAuthScopes implements OAuthScopes {
abstract OAuthScopes readOrWriteScopes();
/** Full control is read/write + acls */
abstract List<String> fullControlScopes();
public static GoogleCloudStorageOAuthScopes create() {
return new AutoValue_GoogleCloudStorageOAuthScopes( //
OAuthScopes.ReadOrWriteScopes.create( //
"https://www.googleapis.com/auth/devstorage.read_only", //
"https://www.googleapis.com/auth/devstorage.read_write"), //
ImmutableList.of("https://www.googleapis.com/auth/devstorage.full_control") //
);
}
/** If the path contains or ends with {@code /acl} or {@code /defaultObjectAcl}, it needs full-control. */
@Override public List<String> forRequest(HttpRequest input) {
String path = input.getEndpoint().getPath();
if (path.endsWith("/acl") || path.endsWith("/defaultObjectAcl") //
|| path.contains("/acl/") || path.contains("/defaultObjectAcl/")) {
return fullControlScopes();
}
return readOrWriteScopes().forRequest(input);
}
GoogleCloudStorageOAuthScopes() {
}
}

View File

@ -16,7 +16,7 @@
*/
package org.jclouds.googlecloudstorage.features;
import static org.jclouds.googlecloudstorage.reference.GoogleCloudStorageConstants.STORAGE_FULLCONTROL_SCOPE;
import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
import java.util.List;
@ -29,14 +29,12 @@ import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import org.jclouds.Fallbacks.NullOnNotFoundOr404;
import org.jclouds.googlecloudstorage.domain.BucketAccessControls;
import org.jclouds.googlecloudstorage.domain.templates.BucketAccessControlsTemplate;
import org.jclouds.http.HttpResponse;
import org.jclouds.javax.annotation.Nullable;
import org.jclouds.oauth.v2.config.OAuthScopes;
import org.jclouds.oauth.v2.filters.OAuthAuthenticationFilter;
import org.jclouds.rest.annotations.BinderParam;
import org.jclouds.rest.annotations.Fallback;
@ -54,6 +52,7 @@ import org.jclouds.rest.binders.BindToJsonPayload;
@SkipEncoding({ '/', '=' })
@RequestFilters(OAuthAuthenticationFilter.class)
@Consumes(APPLICATION_JSON)
public interface BucketAccessControlsApi {
/**
@ -70,9 +69,7 @@ public interface BucketAccessControlsApi {
@Named("BucketAccessControls:get")
@GET
@Consumes(MediaType.APPLICATION_JSON)
@Path("/b/{bucket}/acl/{entity}")
@OAuthScopes(STORAGE_FULLCONTROL_SCOPE)
@Fallback(NullOnNotFoundOr404.class)
@Nullable
BucketAccessControls getBucketAccessControls(@PathParam("bucket") String bucketName,
@ -92,9 +89,7 @@ public interface BucketAccessControlsApi {
@Named("BucketAccessControls:insert")
@POST
@Consumes(MediaType.APPLICATION_JSON)
@Path("/b/{bucket}/acl")
@OAuthScopes(STORAGE_FULLCONTROL_SCOPE)
BucketAccessControls createBucketAccessControls(@PathParam("bucket") String bucketName,
@BinderParam(BindToJsonPayload.class) BucketAccessControlsTemplate template);
@ -108,9 +103,7 @@ public interface BucketAccessControlsApi {
@Named("BucketAccessControls:delete")
@DELETE
@Consumes(MediaType.APPLICATION_JSON)
@Path("/b/{bucket}/acl/{entity}")
@OAuthScopes(STORAGE_FULLCONTROL_SCOPE)
@Fallback(NullOnNotFoundOr404.class)
@Nullable
HttpResponse deleteBucketAccessControls(@PathParam("bucket") String bucketName, @PathParam("entity") String entity);
@ -126,10 +119,8 @@ public interface BucketAccessControlsApi {
@Named("BucketAccessControls:list")
@GET
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@Produces(APPLICATION_JSON)
@Path("/b/{bucket}/acl")
@OAuthScopes(STORAGE_FULLCONTROL_SCOPE)
@Fallback(NullOnNotFoundOr404.class)
@Nullable
@SelectJson("items")
@ -147,13 +138,10 @@ public interface BucketAccessControlsApi {
*
* @return If successful, this method returns a {@link BucketAccessControlsTemplate} resource in the response body
*/
@Named("BucketAccessControls:update")
@PUT
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@Produces(APPLICATION_JSON)
@Path("/b/{bucket}/acl/{entity}")
@OAuthScopes(STORAGE_FULLCONTROL_SCOPE)
@Fallback(NullOnNotFoundOr404.class)
BucketAccessControls updateBucketAccessControls(@PathParam("bucket") String bucketName,
@PathParam("entity") String entity,
@ -173,13 +161,10 @@ public interface BucketAccessControlsApi {
*
* @return If successful, this method returns a BucketAccessControls resource in the response body
*/
@Named("BucketAccessControls:patch")
@PATCH
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@Produces(APPLICATION_JSON)
@Path("/b/{bucket}/acl/{entity}")
@OAuthScopes(STORAGE_FULLCONTROL_SCOPE)
@Fallback(NullOnNotFoundOr404.class)
BucketAccessControls patchBucketAccessControls(@PathParam("bucket") String bucketName,
@PathParam("entity") String entity,

View File

@ -16,8 +16,7 @@
*/
package org.jclouds.googlecloudstorage.features;
import static org.jclouds.googlecloudstorage.reference.GoogleCloudStorageConstants.STORAGE_FULLCONTROL_SCOPE;
import static org.jclouds.googlecloudstorage.reference.GoogleCloudStorageConstants.STORAGE_READONLY_SCOPE;
import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
import javax.inject.Named;
import javax.ws.rs.Consumes;
@ -29,7 +28,6 @@ import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
import org.jclouds.Fallbacks.FalseOnNotFoundOr404;
import org.jclouds.Fallbacks.NullOnNotFoundOr404;
@ -46,7 +44,6 @@ import org.jclouds.googlecloudstorage.options.InsertBucketOptions;
import org.jclouds.googlecloudstorage.options.ListOptions;
import org.jclouds.googlecloudstorage.options.UpdateBucketOptions;
import org.jclouds.javax.annotation.Nullable;
import org.jclouds.oauth.v2.config.OAuthScopes;
import org.jclouds.oauth.v2.filters.OAuthAuthenticationFilter;
import org.jclouds.rest.annotations.BinderParam;
import org.jclouds.rest.annotations.Fallback;
@ -63,6 +60,7 @@ import org.jclouds.rest.binders.BindToJsonPayload;
@SkipEncoding({ '/', '=' })
@RequestFilters(OAuthAuthenticationFilter.class)
@Consumes(APPLICATION_JSON)
public interface BucketApi {
/**
@ -75,9 +73,7 @@ public interface BucketApi {
*/
@Named("Bucket:get")
@GET
@Consumes(MediaType.APPLICATION_JSON)
@Path("/b/{bucket}")
@OAuthScopes(STORAGE_FULLCONTROL_SCOPE)
@Fallback(FalseOnNotFoundOr404.class)
boolean bucketExist(@PathParam("bucket") String bucketName);
@ -91,10 +87,8 @@ public interface BucketApi {
*/
@Named("Bucket:get")
@GET
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@Produces(APPLICATION_JSON)
@Path("/b/{bucket}")
@OAuthScopes(STORAGE_READONLY_SCOPE)
@Fallback(NullOnNotFoundOr404.class)
@Nullable
Bucket getBucket(@PathParam("bucket") String bucketName);
@ -111,10 +105,8 @@ public interface BucketApi {
*/
@Named("Bucket:get")
@GET
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@Produces(APPLICATION_JSON)
@Path("/b/{bucket}")
@OAuthScopes(STORAGE_READONLY_SCOPE)
@Fallback(NullOnNotFoundOr404.class)
@Nullable
Bucket getBucket(@PathParam("bucket") String bucketName, GetBucketOptions options);
@ -131,9 +123,7 @@ public interface BucketApi {
*/
@Named("Bucket:insert")
@POST
@Consumes(MediaType.APPLICATION_JSON)
@Path("/b")
@OAuthScopes(STORAGE_FULLCONTROL_SCOPE)
@Fallback(NullOnBucketAlreadyExists.class)
Bucket createBucket(@QueryParam("project") String projectId, @BinderParam(BindToJsonPayload.class) BucketTemplate bucketTemplate);
@ -152,9 +142,7 @@ public interface BucketApi {
*/
@Named("Bucket:insert")
@POST
@Consumes(MediaType.APPLICATION_JSON)
@Path("/b")
@OAuthScopes(STORAGE_FULLCONTROL_SCOPE)
@Fallback(NullOnKeyAlreadyExists.class)
Bucket createBucket(@QueryParam("project") String projectId,
@BinderParam(BindToJsonPayload.class) BucketTemplate bucketTemplate, InsertBucketOptions options);
@ -167,10 +155,8 @@ public interface BucketApi {
*/
@Named("Bucket:delete")
@DELETE
@Consumes(MediaType.APPLICATION_JSON)
@Path("/b/{bucket}")
@Fallback(TrueOnNotFoundOr404.class)
@OAuthScopes(STORAGE_FULLCONTROL_SCOPE)
boolean deleteBucket(@PathParam("bucket") String bucketName);
/**
@ -183,10 +169,8 @@ public interface BucketApi {
*/
@Named("Bucket:delete")
@DELETE
@Consumes(MediaType.APPLICATION_JSON)
@Path("/b/{bucket}")
@Fallback(TrueOnNotFoundOr404.class)
@OAuthScopes(STORAGE_FULLCONTROL_SCOPE)
boolean deleteBucket(@PathParam("bucket") String bucketName, DeleteBucketOptions options);
/**
@ -199,10 +183,8 @@ public interface BucketApi {
*/
@Named("Bucket:list")
@GET
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@Produces(APPLICATION_JSON)
@Path("/b")
@OAuthScopes(STORAGE_FULLCONTROL_SCOPE)
@Fallback(EmptyListPageOnNotFoundOr404.class)
ListPage<Bucket> listBucket(@QueryParam("project") String projectId);
@ -216,10 +198,8 @@ public interface BucketApi {
*/
@Named("Bucket:list")
@GET
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@Produces(APPLICATION_JSON)
@Path("/b")
@OAuthScopes(STORAGE_FULLCONTROL_SCOPE)
@Fallback(EmptyListPageOnNotFoundOr404.class)
ListPage<Bucket> listBucket(@QueryParam("project") String projectId, ListOptions options);
@ -235,10 +215,8 @@ public interface BucketApi {
*/
@Named("Bucket:update")
@PUT
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@Produces(APPLICATION_JSON)
@Path("/b/{bucket}")
@OAuthScopes(STORAGE_FULLCONTROL_SCOPE)
@Fallback(NullOnNotFoundOr404.class)
Bucket updateBucket(@PathParam("bucket") String bucketName,
@BinderParam(BindToJsonPayload.class) BucketTemplate bucketTemplate);
@ -257,10 +235,8 @@ public interface BucketApi {
*/
@Named("Bucket:update")
@PUT
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@Produces(APPLICATION_JSON)
@Path("/b/{bucket}")
@OAuthScopes(STORAGE_FULLCONTROL_SCOPE)
@Fallback(NullOnNotFoundOr404.class)
Bucket updateBucket(@PathParam("bucket") String bucketName,
@BinderParam(BindToJsonPayload.class) BucketTemplate bucketTemplate, UpdateBucketOptions options);
@ -279,10 +255,8 @@ public interface BucketApi {
*/
@Named("Bucket:patch")
@PATCH
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@Produces(APPLICATION_JSON)
@Path("/b/{bucket}")
@OAuthScopes(STORAGE_FULLCONTROL_SCOPE)
@Fallback(NullOnNotFoundOr404.class)
Bucket patchBucket(@PathParam("bucket") String bucketName,
@BinderParam(BindToJsonPayload.class) BucketTemplate bucketTemplate);
@ -303,10 +277,8 @@ public interface BucketApi {
*/
@Named("Bucket:patch")
@PATCH
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@Produces(APPLICATION_JSON)
@Path("/b/{bucket}")
@OAuthScopes(STORAGE_FULLCONTROL_SCOPE)
@Fallback(NullOnNotFoundOr404.class)
Bucket patchBucket(@PathParam("bucket") String bucketName,
@BinderParam(BindToJsonPayload.class) BucketTemplate bucketTemplate, UpdateBucketOptions options);

View File

@ -16,7 +16,7 @@
*/
package org.jclouds.googlecloudstorage.features;
import static org.jclouds.googlecloudstorage.reference.GoogleCloudStorageConstants.STORAGE_FULLCONTROL_SCOPE;
import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
import java.util.List;
@ -30,7 +30,6 @@ import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
import org.jclouds.Fallbacks.NullOnNotFoundOr404;
import org.jclouds.googlecloudstorage.domain.DomainResourceReferences.ObjectRole;
@ -38,7 +37,6 @@ import org.jclouds.googlecloudstorage.domain.ObjectAccessControls;
import org.jclouds.googlecloudstorage.domain.templates.ObjectAccessControlsTemplate;
import org.jclouds.http.HttpResponse;
import org.jclouds.javax.annotation.Nullable;
import org.jclouds.oauth.v2.config.OAuthScopes;
import org.jclouds.oauth.v2.filters.OAuthAuthenticationFilter;
import org.jclouds.rest.annotations.BinderParam;
import org.jclouds.rest.annotations.Fallback;
@ -56,6 +54,7 @@ import org.jclouds.rest.binders.BindToJsonPayload;
@SkipEncoding({ '/', '=' })
@RequestFilters(OAuthAuthenticationFilter.class)
@Consumes(APPLICATION_JSON)
public interface DefaultObjectAccessControlsApi {
/**
@ -69,12 +68,9 @@ public interface DefaultObjectAccessControlsApi {
*
* @return an DefaultObjectAccessControls resource
*/
@Named("DefaultObjectAccessControls:get")
@GET
@Consumes(MediaType.APPLICATION_JSON)
@Path("/b/{bucket}/defaultObjectAcl/{entity}")
@OAuthScopes(STORAGE_FULLCONTROL_SCOPE)
@Fallback(NullOnNotFoundOr404.class)
@Nullable
ObjectAccessControls getDefaultObjectAccessControls(@PathParam("bucket") String bucketName,
@ -89,13 +85,10 @@ public interface DefaultObjectAccessControlsApi {
*
* @return If successful, this method returns a DefaultObjectAccessControls resource
*/
@Named("DefaultObjectAccessControls:insert")
@POST
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@Produces(APPLICATION_JSON)
@Path("/b/{bucket}/defaultObjectAcl")
@OAuthScopes(STORAGE_FULLCONTROL_SCOPE)
ObjectAccessControls createDefaultObjectAccessControls(@PathParam("bucket") String bucketName,
@BinderParam(BindToJsonPayload.class) ObjectAccessControlsTemplate template);
@ -112,9 +105,7 @@ public interface DefaultObjectAccessControlsApi {
*/
@Named("DefaultObjectAccessControls:delete")
@DELETE
@Consumes(MediaType.APPLICATION_JSON)
@Path("/b/{bucket}/defaultObjectAcl/{entity}")
@OAuthScopes(STORAGE_FULLCONTROL_SCOPE)
@Fallback(NullOnNotFoundOr404.class)
@Nullable
HttpResponse deleteDefaultObjectAccessControls(@PathParam("bucket") String bucketName,
@ -129,13 +120,10 @@ public interface DefaultObjectAccessControlsApi {
* @return ListObjectAccessControls resource
*
*/
@Named("DefaultObjectAccessControls:list")
@GET
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@Produces(APPLICATION_JSON)
@Path("/b/{bucket}/defaultObjectAcl")
@OAuthScopes(STORAGE_FULLCONTROL_SCOPE)
@Fallback(NullOnNotFoundOr404.class)
@Nullable
@SelectJson("items")
@ -152,10 +140,8 @@ public interface DefaultObjectAccessControlsApi {
*/
@Named("DefaultObjectAccessControls:update")
@PUT
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@Produces(APPLICATION_JSON)
@Path("/b/{bucket}/defaultObjectAcl/{entity}")
@OAuthScopes(STORAGE_FULLCONTROL_SCOPE)
@Fallback(NullOnNotFoundOr404.class)
ObjectAccessControls updateDefaultObjectAccessControls(@PathParam("bucket") String bucketName,
@PathParam("entity") String entity,
@ -169,10 +155,8 @@ public interface DefaultObjectAccessControlsApi {
*/
@Named("DefaultObjectAccessControls:update")
@PUT
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@Produces(APPLICATION_JSON)
@Path("/b/{bucket}/defaultObjectAcl/{entity}")
@OAuthScopes(STORAGE_FULLCONTROL_SCOPE)
@Fallback(NullOnNotFoundOr404.class)
ObjectAccessControls updateDefaultObjectAccessControls(@PathParam("bucket") String bucketName,
@PathParam("entity") String entity,
@ -187,10 +171,8 @@ public interface DefaultObjectAccessControlsApi {
*/
@Named("DefaultObjectAccessControls:patch")
@PATCH
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@Produces(APPLICATION_JSON)
@Path("/b/{bucket}/defaultObjectAcl/{entity}")
@OAuthScopes(STORAGE_FULLCONTROL_SCOPE)
@Fallback(NullOnNotFoundOr404.class)
ObjectAccessControls patchDefaultObjectAccessControls(@PathParam("bucket") String bucketName,
@PathParam("entity") String entity,

View File

@ -16,7 +16,7 @@
*/
package org.jclouds.googlecloudstorage.features;
import static org.jclouds.googlecloudstorage.reference.GoogleCloudStorageConstants.STORAGE_FULLCONTROL_SCOPE;
import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
import java.util.List;
@ -30,13 +30,11 @@ import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
import org.jclouds.Fallbacks.NullOnNotFoundOr404;
import org.jclouds.googlecloudstorage.domain.ObjectAccessControls;
import org.jclouds.googlecloudstorage.domain.templates.ObjectAccessControlsTemplate;
import org.jclouds.javax.annotation.Nullable;
import org.jclouds.oauth.v2.config.OAuthScopes;
import org.jclouds.oauth.v2.filters.OAuthAuthenticator;
import org.jclouds.rest.annotations.BinderParam;
import org.jclouds.rest.annotations.Fallback;
@ -51,9 +49,9 @@ import org.jclouds.rest.binders.BindToJsonPayload;
*
* @see <a href = " https://developers.google.com/storage/docs/json_api/v1/objectAccessControls "/>
*/
@SkipEncoding({ '/', '=' })
@RequestFilters(OAuthAuthenticator.class)
@Consumes(APPLICATION_JSON)
public interface ObjectAccessControlsApi {
/**
@ -72,9 +70,7 @@ public interface ObjectAccessControlsApi {
@Named("ObjectAccessControls:get")
@GET
@Consumes(MediaType.APPLICATION_JSON)
@Path("/b/{bucket}/o/{object}/acl/{entity}")
@OAuthScopes(STORAGE_FULLCONTROL_SCOPE)
@Fallback(NullOnNotFoundOr404.class)
@Nullable
ObjectAccessControls getObjectAccessControls(@PathParam("bucket") String bucketName,
@ -97,9 +93,7 @@ public interface ObjectAccessControlsApi {
*/
@Named("ObjectAccessControls:get")
@GET
@Consumes(MediaType.APPLICATION_JSON)
@Path("/b/{bucket}/o/{object}/acl/{entity}")
@OAuthScopes(STORAGE_FULLCONTROL_SCOPE)
@Fallback(NullOnNotFoundOr404.class)
@Nullable
ObjectAccessControls getObjectAccessControls(@PathParam("bucket") String bucketName,
@ -119,10 +113,8 @@ public interface ObjectAccessControlsApi {
*/
@Named("ObjectAccessControls:insert")
@POST
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@Produces(APPLICATION_JSON)
@Path("/b/{bucket}/o/{object}/acl")
@OAuthScopes(STORAGE_FULLCONTROL_SCOPE)
ObjectAccessControls createObjectAccessControls(@PathParam("bucket") String bucketName,
@PathParam("object") String objectName,
@BinderParam(BindToJsonPayload.class) ObjectAccessControlsTemplate template);
@ -142,10 +134,8 @@ public interface ObjectAccessControlsApi {
*/
@Named("ObjectAccessControls:insert")
@POST
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@Produces(APPLICATION_JSON)
@Path("/b/{bucket}/o/{object}/acl")
@OAuthScopes(STORAGE_FULLCONTROL_SCOPE)
ObjectAccessControls createObjectAccessControls(@PathParam("bucket") String bucketName,
@PathParam("object") String objectName,
@BinderParam(BindToJsonPayload.class) ObjectAccessControlsTemplate template,
@ -162,12 +152,9 @@ public interface ObjectAccessControlsApi {
* The entity holding the permission. Can be user-userId, user-emailAddress, group-groupId,
* group-emailAddress, allUsers, or allAuthenticatedUsers
*/
@Named("ObjectAccessControls:delete")
@DELETE
@Consumes(MediaType.APPLICATION_JSON)
@Path("/b/{bucket}/o/{object}/acl/{entity}")
@OAuthScopes(STORAGE_FULLCONTROL_SCOPE)
void deleteObjectAccessControls(@PathParam("bucket") String bucketName, @PathParam("object") String objectName,
@PathParam("entity") String entity);
@ -186,9 +173,7 @@ public interface ObjectAccessControlsApi {
*/
@Named("ObjectAccessControls:delete")
@DELETE
@Consumes(MediaType.APPLICATION_JSON)
@Path("/b/{bucket}/o/{object}/acl/{entity}")
@OAuthScopes(STORAGE_FULLCONTROL_SCOPE)
void deleteObjectAccessControls(@PathParam("bucket") String bucketName, @PathParam("object") String objectName,
@PathParam("entity") String entity, @QueryParam("generation") Long generation);
@ -202,12 +187,10 @@ public interface ObjectAccessControlsApi {
*/
@Named("ObjectAccessControls:list")
@GET
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@Produces(APPLICATION_JSON)
@Path("/b/{bucket}/o/{object}/acl")
@OAuthScopes(STORAGE_FULLCONTROL_SCOPE)
@Fallback(NullOnNotFoundOr404.class)
@SelectJson("items")
@Fallback(NullOnNotFoundOr404.class)
@Nullable
List<ObjectAccessControls> listObjectAccessControls(@PathParam("bucket") String bucketName,
@PathParam("object") String objectName);
@ -225,12 +208,10 @@ public interface ObjectAccessControlsApi {
*/
@Named("ObjectAccessControls:list")
@GET
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@Produces(APPLICATION_JSON)
@Path("/b/{bucket}/o/{object}/acl")
@OAuthScopes(STORAGE_FULLCONTROL_SCOPE)
@Fallback(NullOnNotFoundOr404.class)
@SelectJson("items")
@Fallback(NullOnNotFoundOr404.class)
@Nullable
List<ObjectAccessControls> listObjectAccessControls(@PathParam("bucket") String bucketName,
@PathParam("object") String objectName, @QueryParam("generation") Long generation);
@ -253,12 +234,8 @@ public interface ObjectAccessControlsApi {
@Named("ObjectAccessControls:update")
@PUT
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@Produces(APPLICATION_JSON)
@Path("/b/{bucket}/o/{object}/acl/{entity}")
@OAuthScopes(STORAGE_FULLCONTROL_SCOPE)
@Fallback(NullOnNotFoundOr404.class)
@Nullable
ObjectAccessControls updateObjectAccessControls(@PathParam("bucket") String bucketName,
@PathParam("object") String objectName, @PathParam("entity") String entity,
@BinderParam(BindToJsonPayload.class) ObjectAccessControlsTemplate template);
@ -280,14 +257,10 @@ public interface ObjectAccessControlsApi {
*
* @return {@link ObjectAccessControls }
*/
@Named("ObjectAccessControls:update")
@PUT
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@Produces(APPLICATION_JSON)
@Path("/b/{bucket}/o/{object}/acl/{entity}")
@OAuthScopes(STORAGE_FULLCONTROL_SCOPE)
@Fallback(NullOnNotFoundOr404.class)
ObjectAccessControls updateObjectAccessControls(@PathParam("bucket") String bucketName,
@PathParam("object") String objectName, @PathParam("entity") String entity,
@BinderParam(BindToJsonPayload.class) ObjectAccessControlsTemplate template,
@ -308,14 +281,10 @@ public interface ObjectAccessControlsApi {
*
* @return an {@link ObjectAccessControls }
*/
@Named("ObjectAccessControls:patch")
@PATCH
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@Produces(APPLICATION_JSON)
@Path("/b/{bucket}/o/{object}/acl/{entity}")
@OAuthScopes(STORAGE_FULLCONTROL_SCOPE)
@Fallback(NullOnNotFoundOr404.class)
ObjectAccessControls patchObjectAccessControls(@PathParam("bucket") String bucketName,
@PathParam("object") String objectName, @PathParam("entity") String entity,
@BinderParam(BindToJsonPayload.class) ObjectAccessControlsTemplate template);
@ -337,17 +306,12 @@ public interface ObjectAccessControlsApi {
*
* @return {@link ObjectAccessControls }
*/
@Named("ObjectAccessControls:patch")
@PATCH
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@Produces(APPLICATION_JSON)
@Path("/b/{bucket}/o/{object}/acl/{entity}")
@OAuthScopes(STORAGE_FULLCONTROL_SCOPE)
@Fallback(NullOnNotFoundOr404.class)
ObjectAccessControls patchObjectAccessControls(@PathParam("bucket") String bucketName,
@PathParam("object") String objectName, @PathParam("entity") String entity,
@BinderParam(BindToJsonPayload.class) ObjectAccessControlsTemplate template,
@QueryParam("generation") Long generation);
}

View File

@ -16,8 +16,7 @@
*/
package org.jclouds.googlecloudstorage.features;
import static org.jclouds.googlecloudstorage.reference.GoogleCloudStorageConstants.STORAGE_FULLCONTROL_SCOPE;
import static org.jclouds.googlecloudstorage.reference.GoogleCloudStorageConstants.STORAGE_WRITEONLY_SCOPE;
import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
import javax.inject.Named;
import javax.ws.rs.Consumes;
@ -29,7 +28,6 @@ import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import org.jclouds.Fallbacks.FalseOnNotFoundOr404;
import org.jclouds.Fallbacks.NullOnNotFoundOr404;
@ -52,7 +50,6 @@ import org.jclouds.googlecloudstorage.parser.ParseToPayloadEnclosing;
import org.jclouds.io.Payload;
import org.jclouds.io.PayloadEnclosing;
import org.jclouds.javax.annotation.Nullable;
import org.jclouds.oauth.v2.config.OAuthScopes;
import org.jclouds.oauth.v2.filters.OAuthAuthenticator;
import org.jclouds.rest.annotations.BinderParam;
import org.jclouds.rest.annotations.Fallback;
@ -70,7 +67,6 @@ import org.jclouds.rest.binders.BindToJsonPayload;
*
* @see <a href="https://developers.google.com/storage/docs/json_api/v1/objects"/>
*/
@SkipEncoding({ '/', '=' })
@RequestFilters(OAuthAuthenticator.class)
public interface ObjectApi {
@ -87,12 +83,10 @@ public interface ObjectApi {
*/
@Named("Object:Exist")
@GET
@Consumes(MediaType.APPLICATION_JSON)
@Path("storage/v1/b/{bucket}/o/{object}")
@OAuthScopes(STORAGE_FULLCONTROL_SCOPE)
@Fallback(FalseOnNotFoundOr404.class)
@Nullable
boolean objectExist(@PathParam("bucket") String bucketName, @PathParam("object") String objectName);
boolean objectExists(@PathParam("bucket") String bucketName, @PathParam("object") String objectName);
/**
* Retrieve an object metadata
@ -106,10 +100,8 @@ public interface ObjectApi {
*/
@Named("Object:get")
@GET
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@Path("storage/v1/b/{bucket}/o/{object}")
@OAuthScopes(STORAGE_FULLCONTROL_SCOPE)
@Consumes(APPLICATION_JSON)
@Fallback(NullOnNotFoundOr404.class)
@Nullable
GCSObject getObject(@PathParam("bucket") String bucketName, @PathParam("object") String objectName);
@ -128,10 +120,8 @@ public interface ObjectApi {
*/
@Named("Object:get")
@GET
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@Path("storage/v1/b/{bucket}/o/{object}")
@OAuthScopes(STORAGE_FULLCONTROL_SCOPE)
@Consumes(APPLICATION_JSON)
@Fallback(NullOnNotFoundOr404.class)
@Nullable
GCSObject getObject(@PathParam("bucket") String bucketName, @PathParam("object") String objectName,
@ -151,7 +141,6 @@ public interface ObjectApi {
@GET
@QueryParams(keys = "alt", values = "media")
@Path("storage/v1/b/{bucket}/o/{object}")
@OAuthScopes(STORAGE_FULLCONTROL_SCOPE)
@ResponseParser(ParseToPayloadEnclosing.class)
@Fallback(NullOnNotFoundOr404.class)
@Nullable
@ -172,11 +161,8 @@ public interface ObjectApi {
@Named("Object:get")
@GET
@QueryParams(keys = "alt", values = "media")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@Path("storage/v1/b/{bucket}/o/{object}")
@ResponseParser(ParseToPayloadEnclosing.class)
@OAuthScopes(STORAGE_FULLCONTROL_SCOPE)
@Fallback(NullOnNotFoundOr404.class)
@Nullable PayloadEnclosing download(@PathParam("bucket") String bucketName, @PathParam("object") String objectName,
GetObjectOptions options);
@ -196,9 +182,8 @@ public interface ObjectApi {
@Named("Object:simpleUpload")
@POST
@QueryParams(keys = "uploadType", values = "media")
@Consumes(MediaType.APPLICATION_JSON)
@Consumes(APPLICATION_JSON)
@Path("/upload/storage/v1/b/{bucket}/o")
@OAuthScopes(STORAGE_FULLCONTROL_SCOPE)
@MapBinder(UploadBinder.class)
GCSObject simpleUpload(@PathParam("bucket") String bucketName, @HeaderParam("Content-Type") String contentType,
@HeaderParam("Content-Length") Long contentLength, @PayloadParam("payload") Payload payload,
@ -214,11 +199,9 @@ public interface ObjectApi {
*/
@Named("Object:delete")
@DELETE
@Consumes(MediaType.APPLICATION_JSON)
@Path("storage/v1/b/{bucket}/o/{object}")
@Fallback(TrueOnNotFoundOr404.class)
@OAuthScopes(STORAGE_WRITEONLY_SCOPE)
boolean deleteObject(@PathParam("bucket") String bucketName, @PathParam("object") String objectName);
boolean deleteObject(@PathParam("bucket") String bucketName, @PathParam("object") String objectName);
/**
* Deletes an object and its metadata. Deletions are permanent if versioning is not enabled for the bucket, or if the
@ -233,10 +216,8 @@ public interface ObjectApi {
*/
@Named("Object:delete")
@DELETE
@Consumes(MediaType.APPLICATION_JSON)
@Path("storage/v1/b/{bucket}/o/{object}")
@Fallback(TrueOnNotFoundOr404.class)
@OAuthScopes(STORAGE_WRITEONLY_SCOPE)
boolean deleteObject(@PathParam("bucket") String bucketName, @PathParam("object") String objectName,
DeleteObjectOptions options);
@ -250,10 +231,8 @@ public interface ObjectApi {
*/
@Named("Object:list")
@GET
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@Consumes(APPLICATION_JSON)
@Path("storage/v1/b/{bucket}/o")
@OAuthScopes(STORAGE_FULLCONTROL_SCOPE)
@Fallback(EmptyListPageOnNotFoundOr404.class)
ListPage<GCSObject> listObjects(@PathParam("bucket") String bucketName);
@ -268,12 +247,9 @@ public interface ObjectApi {
*/
@Named("Object:list")
@GET
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@Consumes(APPLICATION_JSON)
@Path("storage/v1/b/{bucket}/o")
@OAuthScopes(STORAGE_FULLCONTROL_SCOPE)
@Fallback(NullOnNotFoundOr404.class)
@Nullable
@Fallback(EmptyListPageOnNotFoundOr404.class)
ListPage<GCSObject> listObjects(@PathParam("bucket") String bucketName, ListObjectOptions options);
/**
@ -290,10 +266,9 @@ public interface ObjectApi {
*/
@Named("Object:update")
@PUT
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@Consumes(APPLICATION_JSON)
@Produces(APPLICATION_JSON)
@Path("storage/v1/b/{bucket}/o/{object}")
@OAuthScopes(STORAGE_FULLCONTROL_SCOPE)
@Fallback(NullOnNotFoundOr404.class)
GCSObject updateObject(@PathParam("bucket") String bucketName, @PathParam("object") String objectName,
@BinderParam(BindToJsonPayload.class) ObjectTemplate objectTemplate);
@ -314,10 +289,9 @@ public interface ObjectApi {
*/
@Named("Object:update")
@PUT
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@Consumes(APPLICATION_JSON)
@Produces(APPLICATION_JSON)
@Path("storage/v1/b/{bucket}/o/{object}")
@OAuthScopes(STORAGE_FULLCONTROL_SCOPE)
@Fallback(NullOnNotFoundOr404.class)
GCSObject updateObject(@PathParam("bucket") String bucketName, @PathParam("object") String objectName,
@BinderParam(BindToJsonPayload.class) ObjectTemplate objectTemplate, UpdateObjectOptions options);
@ -336,10 +310,9 @@ public interface ObjectApi {
*/
@Named("Object:patch")
@PATCH
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@Consumes(APPLICATION_JSON)
@Produces(APPLICATION_JSON)
@Path("storage/v1/b/{bucket}/o/{object}")
@OAuthScopes(STORAGE_FULLCONTROL_SCOPE)
@Fallback(NullOnNotFoundOr404.class)
GCSObject patchObject(@PathParam("bucket") String bucketName, @PathParam("object") String objectName,
@BinderParam(BindToJsonPayload.class) ObjectTemplate objectTemplate);
@ -360,10 +333,9 @@ public interface ObjectApi {
*/
@Named("Object:patch")
@PUT
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@Consumes(APPLICATION_JSON)
@Produces(APPLICATION_JSON)
@Path("storage/v1/b/{bucket}/o/{object}")
@OAuthScopes(STORAGE_FULLCONTROL_SCOPE)
@Fallback(NullOnNotFoundOr404.class)
GCSObject patchObject(@PathParam("bucket") String bucketName, @PathParam("object") String objectName,
@BinderParam(BindToJsonPayload.class) ObjectTemplate objectTemplate, UpdateObjectOptions options);
@ -382,9 +354,8 @@ public interface ObjectApi {
*/
@Named("Object:compose")
@POST
@Consumes(MediaType.APPLICATION_JSON)
@Consumes(APPLICATION_JSON)
@Path("storage/v1/b/{destinationBucket}/o/{destinationObject}/compose")
@OAuthScopes(STORAGE_FULLCONTROL_SCOPE)
GCSObject composeObjects(@PathParam("destinationBucket") String destinationBucket,
@PathParam("destinationObject") String destinationObject,
@BinderParam(BindToJsonPayload.class) ComposeObjectTemplate composeObjectTemplate);
@ -405,9 +376,8 @@ public interface ObjectApi {
*/
@Named("Object:compose")
@POST
@Consumes(MediaType.APPLICATION_JSON)
@Consumes(APPLICATION_JSON)
@Path("storage/v1/b/{destinationBucket}/o/{destinationObject}/compose")
@OAuthScopes(STORAGE_FULLCONTROL_SCOPE)
GCSObject composeObjects(@PathParam("destinationBucket") String destinationBucket,
@PathParam("destinationObject") String destinationObject,
@BinderParam(BindToJsonPayload.class) ComposeObjectTemplate composeObjectTemplate,
@ -429,9 +399,8 @@ public interface ObjectApi {
*/
@Named("Object:copy")
@POST
@Consumes(MediaType.APPLICATION_JSON)
@Consumes(APPLICATION_JSON)
@Path("/storage/v1/b/{sourceBucket}/o/{sourceObject}/copyTo/b/{destinationBucket}/o/{destinationObject}")
@OAuthScopes(STORAGE_FULLCONTROL_SCOPE)
GCSObject copyObject(@PathParam("destinationBucket") String destinationBucket,
@PathParam("destinationObject") String destinationObject, @PathParam("sourceBucket") String sourceBucket,
@PathParam("sourceObject") String sourceObject);
@ -454,9 +423,8 @@ public interface ObjectApi {
*/
@Named("Object:copy")
@POST
@Consumes(MediaType.APPLICATION_JSON)
@Consumes(APPLICATION_JSON)
@Path("/storage/v1/b/{sourceBucket}/o/{sourceObject}/copyTo/b/{destinationBucket}/o/{destinationObject}")
@OAuthScopes(STORAGE_FULLCONTROL_SCOPE)
GCSObject copyObject(@PathParam("destinationBucket") String destinationBucket,
@PathParam("destinationObject") String destinationObject, @PathParam("sourceBucket") String sourceBucket,
@PathParam("sourceObject") String sourceObject, CopyObjectOptions options);
@ -476,9 +444,8 @@ public interface ObjectApi {
@Named("Object:multipartUpload")
@POST
@QueryParams(keys = "uploadType", values = "multipart")
@Consumes(MediaType.APPLICATION_JSON)
@Consumes(APPLICATION_JSON)
@Path("/upload/storage/v1/b/{bucket}/o")
@OAuthScopes(STORAGE_FULLCONTROL_SCOPE)
@MapBinder(MultipartUploadBinder.class)
GCSObject multipartUpload(@PathParam("bucket") String bucketName,
@PayloadParam("template") ObjectTemplate objectTemplate,

View File

@ -16,7 +16,7 @@
*/
package org.jclouds.googlecloudstorage.features;
import static org.jclouds.googlecloudstorage.reference.GoogleCloudStorageConstants.STORAGE_FULLCONTROL_SCOPE;
import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
import javax.inject.Named;
import javax.ws.rs.Consumes;
@ -27,7 +27,6 @@ import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
import org.jclouds.googlecloudstorage.binders.UploadBinder;
import org.jclouds.googlecloudstorage.domain.ResumableUpload;
@ -35,7 +34,6 @@ import org.jclouds.googlecloudstorage.domain.templates.ObjectTemplate;
import org.jclouds.googlecloudstorage.options.InsertObjectOptions;
import org.jclouds.googlecloudstorage.parser.ParseToResumableUpload;
import org.jclouds.io.Payload;
import org.jclouds.oauth.v2.config.OAuthScopes;
import org.jclouds.oauth.v2.filters.OAuthAuthenticator;
import org.jclouds.rest.annotations.BinderParam;
import org.jclouds.rest.annotations.MapBinder;
@ -52,9 +50,9 @@ import org.jclouds.rest.binders.BindToJsonPayload;
* @see <a href="https://developers.google.com/storage/docs/json_api/v1/objects"/>
* @see <a href="https://developers.google.com/storage/docs/json_api/v1/how-tos/upload#resumable"/>
*/
@SkipEncoding({ '/', '=' })
@RequestFilters(OAuthAuthenticator.class)
@Consumes(APPLICATION_JSON)
public interface ResumableUploadApi {
/**
@ -76,9 +74,7 @@ public interface ResumableUploadApi {
@Named("Object:initResumableUpload")
@POST
@QueryParams(keys = "uploadType", values = "resumable")
@Consumes(MediaType.APPLICATION_JSON)
@Path("/upload/storage/v1/b/{bucket}/o")
@OAuthScopes(STORAGE_FULLCONTROL_SCOPE)
@ResponseParser(ParseToResumableUpload.class)
ResumableUpload initResumableUpload(@PathParam("bucket") String bucketName, @QueryParam("name") String objectName,
@HeaderParam("X-Upload-Content-Type") String contentType,
@ -103,9 +99,7 @@ public interface ResumableUploadApi {
@Named("Object:resumableUpload")
@POST
@QueryParams(keys = "uploadType", values = "resumable")
@Consumes(MediaType.APPLICATION_JSON)
@Path("/upload/storage/v1/b/{bucket}/o")
@OAuthScopes(STORAGE_FULLCONTROL_SCOPE)
@ResponseParser(ParseToResumableUpload.class)
ResumableUpload initResumableUpload(@PathParam("bucket") String bucketName,
@HeaderParam("X-Upload-Content-Type") String contentType,
@ -126,10 +120,8 @@ public interface ResumableUploadApi {
*/
@Named("Object:resumableUpload")
@PUT
@Consumes(MediaType.APPLICATION_JSON)
@QueryParams(keys = "uploadType", values = "resumable")
@Path("/upload/storage/v1/b/{bucket}/o")
@OAuthScopes(STORAGE_FULLCONTROL_SCOPE)
@MapBinder(UploadBinder.class)
@ResponseParser(ParseToResumableUpload.class)
ResumableUpload upload(@PathParam("bucket") String bucketName, @QueryParam("upload_id") String uploadId,
@ -158,10 +150,8 @@ public interface ResumableUploadApi {
*/
@Named("Object:Upload")
@PUT
@Consumes(MediaType.APPLICATION_JSON)
@QueryParams(keys = "uploadType", values = "resumable")
@Path("/upload/storage/v1/b/{bucket}/o")
@OAuthScopes(STORAGE_FULLCONTROL_SCOPE)
@MapBinder(UploadBinder.class)
@ResponseParser(ParseToResumableUpload.class)
ResumableUpload chunkUpload(@PathParam("bucket") String bucketName, @QueryParam("upload_id") String uploadId,
@ -185,11 +175,9 @@ public interface ResumableUploadApi {
@Named("Object:Upload")
@PUT
@Consumes(MediaType.APPLICATION_JSON)
@DefaultValue("0")
@QueryParams(keys = "uploadType", values = "resumable")
@Path("/upload/storage/v1/b/{bucket}/o")
@OAuthScopes(STORAGE_FULLCONTROL_SCOPE)
@ResponseParser(ParseToResumableUpload.class)
ResumableUpload checkStatus(@PathParam("bucket") String bucketName, @QueryParam("upload_id") String uploadId,
@HeaderParam("Content-Range") String contentRange);

View File

@ -16,10 +16,6 @@
*/
package org.jclouds.googlecloudstorage.reference;
import org.jclouds.domain.Location;
import org.jclouds.domain.LocationBuilder;
import org.jclouds.domain.LocationScope;
import com.google.common.annotations.Beta;
public final class GoogleCloudStorageConstants {
@ -29,28 +25,15 @@ public final class GoogleCloudStorageConstants {
public static final String GCS_PROVIDER_NAME = "google-cloud-storage";
public static final String STORAGE_READONLY_SCOPE = "https://www.googleapis.com/auth/devstorage.read_only";
public static final String STORAGE_WRITEONLY_SCOPE = "https://www.googleapis.com/auth/devstorage.write_only";
public static final String STORAGE_READWRITE_SCOPE = "https://www.googleapis.com/auth/devstorage.read_write";
public static final String STORAGE_FULLCONTROL_SCOPE = "https://www.googleapis.com/auth/devstorage.full_control";
/**
* The total time, in msecs, to wait for an operation to complete.
*/
@Beta
public static final String OPERATION_COMPLETE_TIMEOUT = "jclouds.google-cloud-storage.operation-complete-timeout";
/**
* The interval, in msecs, between calls to check whether an operation has completed.
*/
@Beta
public static final String OPERATION_COMPLETE_INTERVAL = "jclouds.google-cloud-storage.operation-complete-interval";
public static final Location GOOGLE_PROVIDER_LOCATION = new LocationBuilder().scope(LocationScope.PROVIDER).id
(GCS_PROVIDER_NAME).description(GCS_PROVIDER_NAME).build();
}

View File

@ -16,7 +16,6 @@
*/
package org.jclouds.googlecloudstorage;
import org.jclouds.googlecloudstorage.reference.GoogleCloudStorageConstants;
import org.jclouds.oauth.v2.internal.BaseOAuthAuthenticatedApiLiveTest;
import org.testng.annotations.Test;
@ -30,6 +29,6 @@ public class GoogleCloudStorageAuthenticatedRestContextLiveTest extends
@Override
public String getScopes() {
return GoogleCloudStorageConstants.STORAGE_FULLCONTROL_SCOPE;
return "https://www.googleapis.com/auth/devstorage.full_control";
}
}

View File

@ -17,7 +17,6 @@
package org.jclouds.googlecloudstorage.features;
import static org.jclouds.googlecloudstorage.reference.GoogleCloudStorageConstants.STORAGE_FULLCONTROL_SCOPE;
import static org.testng.Assert.assertEquals;
import static org.testng.AssertJUnit.assertNull;
@ -34,7 +33,7 @@ import org.jclouds.http.HttpRequest;
import org.jclouds.http.HttpResponse;
import org.testng.annotations.Test;
@Test(groups = "unit")
@Test(groups = "unit", testName = "BucketAccessControlsApiExpectTest")
public class BucketAccessControlsApiExpectTest extends BaseGoogleCloudStorageApiExpectTest {
private static final String EXPECTED_TEST_BUCKET = "jcloudtestbucket";

View File

@ -14,11 +14,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jclouds.googlecloudstorage.features;
import static org.jclouds.googlecloudstorage.reference.GoogleCloudStorageConstants.STORAGE_FULLCONTROL_SCOPE;
import static org.jclouds.googlecloudstorage.reference.GoogleCloudStorageConstants.STORAGE_READONLY_SCOPE;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertTrue;
import static org.testng.AssertJUnit.assertNull;
@ -40,7 +37,7 @@ import org.jclouds.http.HttpRequest;
import org.jclouds.http.HttpResponse;
import org.testng.annotations.Test;
@Test(groups = "unit")
@Test(groups = "unit", testName = "BucketApiExpectTest")
public class BucketApiExpectTest extends BaseGoogleCloudStorageApiExpectTest {
private static final String EXPECTED_TEST_BUCKET = "bhashbucket";
@ -103,7 +100,7 @@ public class BucketApiExpectTest extends BaseGoogleCloudStorageApiExpectTest {
// Test listBucket without options
public void testListBucketWithNoOptionsResponseIs2xx() throws Exception {
BucketApi api = requestsSendResponses(requestForScopes(STORAGE_FULLCONTROL_SCOPE), TOKEN_RESPONSE,
BucketApi api = requestsSendResponses(requestForScopes(STORAGE_READONLY_SCOPE), TOKEN_RESPONSE,
LIST_BUCKET_REQUEST, LIST_BUCKET_RESPONSE).getBucketApi();
assertEquals(api.listBucket(EXPECTED_TEST_PROJECT_NUMBER), new NoAclBucketListTest().expected());
@ -112,7 +109,7 @@ public class BucketApiExpectTest extends BaseGoogleCloudStorageApiExpectTest {
public void testListBucketWithOptionsResponseIs2xx() throws Exception {
BucketApi api = requestsSendResponses(requestForScopes(STORAGE_FULLCONTROL_SCOPE), TOKEN_RESPONSE,
BucketApi api = requestsSendResponses(requestForScopes(STORAGE_READONLY_SCOPE), TOKEN_RESPONSE,
LIST_BUCKET_REQUEST_WITHOPTIONS, LIST_BUCKET_RESPONSE).getBucketApi();
ListOptions options = new ListOptions().maxResults(2).pageToken("jcloudtestbucket500");
@ -124,7 +121,7 @@ public class BucketApiExpectTest extends BaseGoogleCloudStorageApiExpectTest {
public void testListBucketResponseIs4xx() throws Exception {
HttpResponse listResponse = HttpResponse.builder().statusCode(404).build();
BucketApi api = requestsSendResponses(requestForScopes(STORAGE_FULLCONTROL_SCOPE), TOKEN_RESPONSE,
BucketApi api = requestsSendResponses(requestForScopes(STORAGE_READONLY_SCOPE), TOKEN_RESPONSE,
LIST_BUCKET_REQUEST, listResponse).getBucketApi();
assertTrue(api.listBucket(EXPECTED_TEST_PROJECT_NUMBER).isEmpty());
@ -143,7 +140,7 @@ public class BucketApiExpectTest extends BaseGoogleCloudStorageApiExpectTest {
.payload(payloadFromResourceWithContentType("/bucket_insert_request_payload.json",
MediaType.APPLICATION_JSON)).build();
BucketApi api = requestsSendResponses(requestForScopes(STORAGE_FULLCONTROL_SCOPE), TOKEN_RESPONSE,
BucketApi api = requestsSendResponses(requestForScopes(STORAGE_READWRITE_SCOPE), TOKEN_RESPONSE,
createRequest, BUCKET_RESPONSE).getBucketApi();
BucketTemplate template = new BucketTemplate().name("bhashbucket");
@ -171,7 +168,7 @@ public class BucketApiExpectTest extends BaseGoogleCloudStorageApiExpectTest {
HttpResponse updateResponse = HttpResponse.builder().statusCode(200)
.payload(staticPayloadFromResource("/bucket_update_response.json")).build();
BucketApi api = requestsSendResponses(requestForScopes(STORAGE_FULLCONTROL_SCOPE), TOKEN_RESPONSE,
BucketApi api = requestsSendResponses(requestForScopes(STORAGE_READWRITE_SCOPE), TOKEN_RESPONSE,
updateRequest, updateResponse).getBucketApi();
assertEquals(api.updateBucket(EXPECTED_TEST_BUCKET, template), new BucketUpdateTest().expected());
@ -199,7 +196,7 @@ public class BucketApiExpectTest extends BaseGoogleCloudStorageApiExpectTest {
HttpResponse updateResponse = HttpResponse.builder().statusCode(200)
.payload(staticPayloadFromResource("/bucket_update_response.json")).build();
BucketApi api = requestsSendResponses(requestForScopes(STORAGE_FULLCONTROL_SCOPE), TOKEN_RESPONSE,
BucketApi api = requestsSendResponses(requestForScopes(STORAGE_READWRITE_SCOPE), TOKEN_RESPONSE,
updateRequest, updateResponse).getBucketApi();
assertEquals(api.updateBucket(EXPECTED_TEST_BUCKET, template, options), new BucketUpdateTest().expected());
@ -224,7 +221,7 @@ public class BucketApiExpectTest extends BaseGoogleCloudStorageApiExpectTest {
HttpResponse patchResponse = HttpResponse.builder().statusCode(200)
.payload(staticPayloadFromResource("/bucket_update_response.json")).build();
BucketApi api = requestsSendResponses(requestForScopes(STORAGE_FULLCONTROL_SCOPE), TOKEN_RESPONSE, patchRequest,
BucketApi api = requestsSendResponses(requestForScopes(STORAGE_READWRITE_SCOPE), TOKEN_RESPONSE, patchRequest,
patchResponse).getBucketApi();
assertEquals(api.patchBucket(EXPECTED_TEST_BUCKET, template), new BucketUpdateTest().expected());
@ -252,7 +249,7 @@ public class BucketApiExpectTest extends BaseGoogleCloudStorageApiExpectTest {
HttpResponse patchResponse = HttpResponse.builder().statusCode(200)
.payload(staticPayloadFromResource("/bucket_update_response.json")).build();
BucketApi api = requestsSendResponses(requestForScopes(STORAGE_FULLCONTROL_SCOPE), TOKEN_RESPONSE, patchRequest,
BucketApi api = requestsSendResponses(requestForScopes(STORAGE_READWRITE_SCOPE), TOKEN_RESPONSE, patchRequest,
patchResponse).getBucketApi();
assertEquals(api.updateBucket(EXPECTED_TEST_BUCKET, template, options), new BucketUpdateTest().expected());

View File

@ -31,10 +31,10 @@ import org.jclouds.googlecloudstorage.domain.Bucket.Cors;
import org.jclouds.googlecloudstorage.domain.Bucket.Logging;
import org.jclouds.googlecloudstorage.domain.Bucket.Versioning;
import org.jclouds.googlecloudstorage.domain.BucketAccessControls;
import org.jclouds.googlecloudstorage.domain.BucketAccessControls.Role;
import org.jclouds.googlecloudstorage.domain.DomainResourceReferences.Location;
import org.jclouds.googlecloudstorage.domain.DomainResourceReferences.ObjectRole;
import org.jclouds.googlecloudstorage.domain.DomainResourceReferences.Projection;
import org.jclouds.googlecloudstorage.domain.BucketAccessControls.Role;
import org.jclouds.googlecloudstorage.domain.DomainResourceReferences.StorageClass;
import org.jclouds.googlecloudstorage.domain.ListPage;
import org.jclouds.googlecloudstorage.domain.ObjectAccessControls;

View File

@ -17,7 +17,6 @@
package org.jclouds.googlecloudstorage.features;
import static org.jclouds.googlecloudstorage.reference.GoogleCloudStorageConstants.STORAGE_FULLCONTROL_SCOPE;
import static org.testng.Assert.assertEquals;
import static org.testng.AssertJUnit.assertNull;
@ -34,7 +33,7 @@ import org.jclouds.http.HttpRequest;
import org.jclouds.http.HttpResponse;
import org.testng.annotations.Test;
@Test(groups = "unit")
@Test(groups = "unit", testName = "DefaultObjectAccessControlsApiExpectTest")
public class DefaultObjectAccessControlsApiExpectTest extends BaseGoogleCloudStorageApiExpectTest {
private static final String EXPECTED_TEST_BUCKET = "jcloudtestbucket";

View File

@ -18,7 +18,6 @@
package org.jclouds.googlecloudstorage.features;
import static org.jclouds.googlecloudstorage.domain.DomainResourceReferences.ObjectRole.OWNER;
import static org.jclouds.googlecloudstorage.reference.GoogleCloudStorageConstants.STORAGE_FULLCONTROL_SCOPE;
import static org.testng.Assert.assertEquals;
import static org.testng.AssertJUnit.assertNull;
@ -34,7 +33,7 @@ import org.jclouds.http.HttpRequest;
import org.jclouds.http.HttpResponse;
import org.testng.annotations.Test;
@Test(groups = "unit")
@Test(groups = "unit", testName = "ObjectAccessControlsApiExpectTest")
public class ObjectAccessControlsApiExpectTest extends BaseGoogleCloudStorageApiExpectTest {
private static final String EXPECTED_TEST_BUCKET = "jcloudtestbucket";

View File

@ -46,7 +46,9 @@ import java.util.concurrent.atomic.AtomicInteger;
import javax.ws.rs.core.MediaType;
import org.jclouds.apis.ApiMetadata;
import org.jclouds.crypto.Crypto;
import org.jclouds.googlecloudstorage.GoogleCloudStorageApiMetadata;
import org.jclouds.http.HttpRequest;
import org.jclouds.http.HttpResponse;
import org.jclouds.io.Payload;
@ -65,6 +67,11 @@ import com.google.inject.Module;
import com.google.inject.TypeLiteral;
public class BaseGoogleCloudStorageExpectTest<T> extends BaseRestApiExpectTest<T> {
protected static final String STORAGE_READONLY_SCOPE = "https://www.googleapis.com/auth/devstorage.read_only";
protected static final String STORAGE_READWRITE_SCOPE = "https://www.googleapis.com/auth/devstorage.read_write";
protected static final String STORAGE_FULLCONTROL_SCOPE = "https://www.googleapis.com/auth/devstorage.full_control";
private static final String header = "{\"alg\":\"none\",\"typ\":\"JWT\"}";
@ -87,7 +94,6 @@ public class BaseGoogleCloudStorageExpectTest<T> extends BaseRestApiExpectTest<T
@Override
protected Module createModule() {
return new Module() {
@Override
public void configure(Binder binder) {
@ -129,7 +135,6 @@ public class BaseGoogleCloudStorageExpectTest<T> extends BaseRestApiExpectTest<T
});
}
};
}
@Override
@ -140,6 +145,10 @@ public class BaseGoogleCloudStorageExpectTest<T> extends BaseRestApiExpectTest<T
return props;
}
@Override protected ApiMetadata createApiMetadata(){
return new GoogleCloudStorageApiMetadata();
}
@Override
protected HttpRequestComparisonType compareHttpRequestAsType(HttpRequest input) {
HttpRequestComparisonType reqType = HttpRequestComparisonType.DEFAULT;
@ -168,5 +177,4 @@ public class BaseGoogleCloudStorageExpectTest<T> extends BaseRestApiExpectTest<T
protected Payload staticPayloadFromResource(String resource) {
return new ByteSourcePayload(Resources.asByteSource(Resources.getResource(getClass(), resource)));
}
}