You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jclouds.apache.org by ga...@apache.org on 2014/08/25 23:09:48 UTC
[2/2] git commit: JCLOUDS-458: Ad Object Access Controls live tests
JCLOUDS-458: Ad Object Access Controls live tests
Project: http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/repo
Commit: http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/commit/38e05f6c
Tree: http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/tree/38e05f6c
Diff: http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/diff/38e05f6c
Branch: refs/heads/master
Commit: 38e05f6cdf33b5e42d893dd35fbf5717a2cd9213
Parents: 9c98ab1
Author: hsbhathiya <hs...@gmail.com>
Authored: Sun Jul 27 03:50:09 2014 +0530
Committer: Andrew Gaul <ga...@apache.org>
Committed: Mon Aug 25 14:09:14 2014 -0700
----------------------------------------------------------------------
.../GoogleCloudStorageApi.java | 8 +
.../domain/BucketAccessControls.java | 3 +-
.../domain/ListObjectAccessControls.java | 112 ++++++
.../domain/ObjectAccessControls.java | 208 +++++++++++
.../domain/ObjectAccessControlsTemplate.java | 65 ++++
.../domain/internal/ProjectTeam.java | 26 +-
.../features/ObjectAccessControlsApi.java | 365 +++++++++++++++++++
.../GoogleCloudStorageErrorHandler.java | 10 +
.../handlers/ObjectAccessControlsBinder.java | 43 +++
.../BucketAccessControlsApiLiveTest.java | 112 ++++++
...efaultObjectAccessControlsApiExpectTest.java | 20 +-
.../DefaultObjectAccessControlsApiLiveTest.java | 117 ++++++
.../ObjectAccessControlsApiExpectTest.java | 282 ++++++++++++++
.../parse/BucketAclListTest.java | 2 +-
.../parse/DefaultObjectAclGetTest.java | 2 +-
.../parse/DefaultObjectAclListTest.java | 2 +-
.../parse/FullBucketGetTest.java | 2 +-
.../parse/ObjectAclGetTest.java | 54 +++
.../parse/ObjectAclInsertTest.java | 49 +++
.../parse/ObjectAclListTest.java | 55 +++
.../parse/ObjectAclUpdateTest.java | 44 +++
.../src/test/resources/objectacl_get.json | 15 +
.../objectacl_insert_requestpayload.json | 4 +
.../resources/objectacl_insert_response.json | 10 +
.../src/test/resources/objectacl_list.json | 17 +
.../resources/objectacl_request_payload.json | 4 +
.../resources/objectacl_update_initial.json | 9 +
.../resources/objectacl_update_response.json | 9 +
28 files changed, 1621 insertions(+), 28 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/38e05f6c/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/GoogleCloudStorageApi.java
----------------------------------------------------------------------
diff --git a/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/GoogleCloudStorageApi.java b/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/GoogleCloudStorageApi.java
index f92efbf..5381880 100644
--- a/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/GoogleCloudStorageApi.java
+++ b/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/GoogleCloudStorageApi.java
@@ -23,6 +23,7 @@ import javax.ws.rs.Path;
import org.jclouds.googlecloudstorage.features.BucketAccessControlsApi;
import org.jclouds.googlecloudstorage.features.BucketApi;
import org.jclouds.googlecloudstorage.features.DefaultObjectAccessControlsApi;
+import org.jclouds.googlecloudstorage.features.ObjectAccessControlsApi;
import org.jclouds.rest.annotations.Delegate;
/**
@@ -52,4 +53,11 @@ public interface GoogleCloudStorageApi extends Closeable {
@Delegate
@Path("")
BucketApi getBucketApi();
+
+ /**
+ * Provides access to Object Access Control features
+ */
+ @Delegate
+ @Path("")
+ ObjectAccessControlsApi getObjectAccessControlsApi();
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/38e05f6c/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/BucketAccessControls.java
----------------------------------------------------------------------
diff --git a/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/BucketAccessControls.java b/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/BucketAccessControls.java
index 76876cf..e81f297 100644
--- a/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/BucketAccessControls.java
+++ b/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/BucketAccessControls.java
@@ -92,7 +92,8 @@ public class BucketAccessControls extends Resource {
if (obj == null || getClass() != obj.getClass())
return false;
BucketAccessControls that = BucketAccessControls.class.cast(obj);
- return equal(this.kind, that.kind) && equal(this.bucket, that.bucket) && equal(this.entity, that.entity);
+ return equal(this.kind, that.kind) && equal(this.bucket, that.bucket) && equal(this.entity, that.entity)
+ && equal(this.id, that.id);
}
protected MoreObjects.ToStringHelper string() {
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/38e05f6c/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/ListObjectAccessControls.java
----------------------------------------------------------------------
diff --git a/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/ListObjectAccessControls.java b/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/ListObjectAccessControls.java
new file mode 100644
index 0000000..a33d5bc
--- /dev/null
+++ b/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/ListObjectAccessControls.java
@@ -0,0 +1,112 @@
+/*
+ * 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.domain;
+
+import static com.google.common.base.MoreObjects.toStringHelper;
+import static com.google.common.base.Objects.equal;
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.util.Set;
+
+import org.jclouds.googlecloudstorage.domain.Resource.Kind;
+
+import com.google.common.base.MoreObjects.ToStringHelper;
+import com.google.common.base.Objects;
+import com.google.common.collect.ImmutableSet;
+
+public class ListObjectAccessControls {
+
+ protected final Kind kind;
+ protected final Set<ObjectAccessControls> items;
+
+ protected ListObjectAccessControls(Kind kind, Set<ObjectAccessControls> items) {
+
+ this.kind = checkNotNull(kind, "kind");
+ this.items = checkNotNull(items, "items");
+ }
+
+ public Kind getKind() {
+ return kind;
+ }
+
+ public Set<ObjectAccessControls> getItems() {
+ return items;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(kind, items);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null || getClass() != obj.getClass())
+ return false;
+ ListObjectAccessControls that = ListObjectAccessControls.class.cast(obj);
+ return equal(this.kind, that.kind) && equal(this.items, that.items);
+
+ }
+
+ protected ToStringHelper string() {
+ return toStringHelper(this).omitNullValues().add("kind", kind).add("items", items);
+ }
+
+ @Override
+ public String toString() {
+ return string().toString();
+ }
+
+ public static Builder builder() {
+ return new Builder();
+ }
+
+ public Builder toBuilder() {
+ return new Builder().fromListObjectAccessControls(this);
+ }
+
+ public static final class Builder {
+
+ private Kind kind;
+ private ImmutableSet.Builder<ObjectAccessControls> items = ImmutableSet.builder();
+
+ public Builder kind(Kind kind) {
+ this.kind = checkNotNull(kind , "kind");
+ return this;
+ }
+
+ public Builder addItems(ObjectAccessControls bucketAccessControls) {
+ this.items.add(bucketAccessControls);
+ return this;
+ }
+
+ public Builder items(Set<ObjectAccessControls> items) {
+ this.items.addAll(items);
+ return this;
+ }
+
+ public ListObjectAccessControls build() {
+ return new ListObjectAccessControls(this.kind, items.build());
+ }
+
+ public Builder fromListObjectAccessControls(ListObjectAccessControls in) {
+ return this.kind(in.getKind()).items(in.getItems());
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/38e05f6c/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/ObjectAccessControls.java
----------------------------------------------------------------------
diff --git a/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/ObjectAccessControls.java b/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/ObjectAccessControls.java
new file mode 100644
index 0000000..f9b735e
--- /dev/null
+++ b/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/ObjectAccessControls.java
@@ -0,0 +1,208 @@
+/*
+ * 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.domain;
+
+import static com.google.common.base.Objects.equal;
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.net.URI;
+
+import org.jclouds.googlecloudstorage.domain.DomainResourceRefferences.ObjectRole;
+import org.jclouds.googlecloudstorage.domain.internal.ProjectTeam;
+import org.jclouds.javax.annotation.Nullable;
+
+import com.google.common.base.MoreObjects;
+import com.google.common.base.Objects;
+
+/**
+ * Represents a Object Access Control Resource.
+ *
+ * @see <a href= "https://developers.google.com/storage/docs/json_api/v1/objectAccessControls"/>
+ */
+public class ObjectAccessControls extends Resource {
+
+ protected final String bucket;
+ protected final String entity;
+ protected final String object;
+ protected final Long generation;
+ protected final ObjectRole role;
+ protected final String email;
+ protected final String entityId;
+ protected final String domain;
+ protected final ProjectTeam projectTeam;
+
+ protected ObjectAccessControls(@Nullable String id, @Nullable URI selfLink, @Nullable String etag, String bucket,
+ @Nullable String object, @Nullable Long generation, String entity, @Nullable String entityId,
+ ObjectRole role, @Nullable String email, @Nullable String domain, @Nullable ProjectTeam projectTeam) {
+ super(Kind.OBJECT_ACCESS_CONTROL, id, selfLink, etag);
+
+ this.bucket = bucket;
+ this.entity = checkNotNull(entity, "entity");
+ this.object = object;
+ this.generation = generation;
+ this.entityId = entityId;
+ this.role = checkNotNull(role, "role");
+ this.email = email;
+ this.domain = domain;
+ this.projectTeam = projectTeam;
+ }
+
+ public String getBucket() {
+ return bucket;
+ }
+
+ public String getEntity() {
+ return entity;
+ }
+
+ public ObjectRole getRole() {
+ return role;
+ }
+
+ public String getEmail() {
+ return email;
+ }
+
+ public String getObject() {
+ return object;
+ }
+
+ public Long getGeneration() {
+ return generation;
+ }
+
+ public String getDomain() {
+ return domain;
+ }
+
+ public String getEntityId() {
+ return entityId;
+ }
+
+ public ProjectTeam getProjectTeam() {
+ return projectTeam;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null || getClass() != obj.getClass())
+ return false;
+ ObjectAccessControls that = ObjectAccessControls.class.cast(obj);
+ return equal(this.kind, that.kind) && equal(this.bucket, that.bucket) && equal(this.object, that.object)
+ && equal(this.entity, that.entity) && equal(this.id , that.id);
+ }
+
+ protected MoreObjects.ToStringHelper string() {
+ return super.string().omitNullValues().add("bucket", bucket).add("entity", entity).add("entityId", entityId)
+ .add("object", object).add("generation", generation).add("role", role).add("email", email)
+ .add("domain", domain).add("projectTeam", projectTeam);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(kind, bucket, object, entity);
+ }
+
+ @Override
+ public String toString() {
+ return string().toString();
+ }
+
+ public static Builder builder() {
+ return new Builder();
+ }
+
+ public Builder toBuilder() {
+ return new Builder().fromObjectAccessControls(this);
+ }
+
+ public static final class Builder extends Resource.Builder<Builder> {
+
+ protected String object;
+ protected Long generation;
+ protected String bucket;
+ protected String entity;
+ protected String entityId;
+ protected ObjectRole role;
+ protected String email;
+ protected String domain;
+ protected ProjectTeam projectTeam;
+
+ public Builder bucket(String bucket) {
+ this.bucket = bucket;
+ return this;
+ }
+
+ public Builder object(String object) {
+ this.object = object;
+ return this;
+ }
+
+ public Builder generation(Long generation) {
+ this.generation = generation;
+ return this;
+ }
+
+ public Builder entity(String entity) {
+ this.entity = entity;
+ return this;
+ }
+
+ public Builder entityId(String entityId) {
+ this.entityId = entityId;
+ return this;
+ }
+
+ public Builder role(ObjectRole role) {
+ this.role = role;
+ return this;
+ }
+
+ public Builder email(String email) {
+ this.email = email;
+ return this;
+ }
+
+ public Builder domain(String domain) {
+ this.domain = domain;
+ return this;
+ }
+
+ public Builder projectTeam(ProjectTeam projectTeam) {
+ this.projectTeam = projectTeam;
+ return this;
+ }
+
+ public ObjectAccessControls build() {
+ return new ObjectAccessControls(super.id, super.selfLink, super.etag, bucket, object, generation, entity,
+ entityId, role, email, domain, projectTeam);
+ }
+
+ public Builder fromObjectAccessControls(ObjectAccessControls in) {
+ return super.fromResource(in).bucket(in.getBucket()).entity(in.getEntity()).entityId(in.getEntityId())
+ .role(in.getRole()).email(in.getEmail()).domain(in.getDomain()).object(in.getObject())
+ .generation(in.getGeneration()).projectTeam(in.getProjectTeam());
+ }
+
+ @Override
+ protected Builder self() {
+ return this;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/38e05f6c/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/ObjectAccessControlsTemplate.java
----------------------------------------------------------------------
diff --git a/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/ObjectAccessControlsTemplate.java b/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/ObjectAccessControlsTemplate.java
new file mode 100644
index 0000000..7740207
--- /dev/null
+++ b/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/ObjectAccessControlsTemplate.java
@@ -0,0 +1,65 @@
+/*
+ * 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.domain;
+
+import org.jclouds.googlecloudstorage.domain.DomainResourceRefferences.ObjectRole;
+
+/**
+ * Represents a Object Access Control Resource.
+ *
+ * @see <a href= "https://developers.google.com/storage/docs/json_api/v1/objectAccessControls"/>
+ */
+public class ObjectAccessControlsTemplate {
+
+ protected String entity;
+ protected ObjectRole role;
+
+ public ObjectAccessControlsTemplate role(ObjectRole role) {
+ this.role = role;
+ return this;
+ }
+
+ public ObjectAccessControlsTemplate entity(String entity) {
+ this.entity = entity;
+ return this;
+ }
+
+ public String getEntity() {
+ return entity;
+ }
+
+ public ObjectRole getRole() {
+ return role;
+ }
+
+ public static Builder builder() {
+ return new Builder();
+ }
+
+ public static ObjectAccessControlsTemplate fromObjectAccessControlsTemplate(
+ ObjectAccessControlsTemplate objectAccessControlsTemplate) {
+ return Builder.fromObjectAccessControlsTemplate(objectAccessControlsTemplate);
+ }
+
+ public static class Builder {
+
+ public static ObjectAccessControlsTemplate fromObjectAccessControlsTemplate(ObjectAccessControlsTemplate in) {
+ return new ObjectAccessControlsTemplate().role(in.getRole()).entity(in.getEntity());
+ }
+
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/38e05f6c/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/internal/ProjectTeam.java
----------------------------------------------------------------------
diff --git a/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/internal/ProjectTeam.java b/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/internal/ProjectTeam.java
index e53ea4e..1022b3e 100644
--- a/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/internal/ProjectTeam.java
+++ b/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/internal/ProjectTeam.java
@@ -46,17 +46,17 @@ public final class ProjectTeam {
}
}
- private final String projectId;
+ private final String projectNumber;
private final Team team;
- private ProjectTeam(String projectId, Team team) {
- this.projectId = projectId;
+ private ProjectTeam(String projectNumber, Team team) {
+ this.projectNumber = projectNumber;
this.team = team;
}
- public String getProjectId() {
- return projectId;
+ public String getProjectNumber() {
+ return projectNumber;
}
public Team getTeam() {
@@ -65,7 +65,7 @@ public final class ProjectTeam {
@Override
public int hashCode() {
- return Objects.hashCode(projectId, team);
+ return Objects.hashCode(projectNumber, team);
}
@Override
@@ -75,11 +75,11 @@ public final class ProjectTeam {
if (obj == null || getClass() != obj.getClass())
return false;
ProjectTeam that = ProjectTeam.class.cast(obj);
- return equal(this.projectId, that.projectId) && equal(this.team, that.team);
+ return equal(this.projectNumber, that.projectNumber) && equal(this.team, that.team);
}
protected MoreObjects.ToStringHelper string() {
- return toStringHelper(this).add("projectId", projectId).add("team", team);
+ return toStringHelper(this).add("projectNumber", projectNumber).add("team", team);
}
@Override
@@ -93,11 +93,11 @@ public final class ProjectTeam {
public static class Builder {
- private String projectId;
+ private String projectNumber;
private Team team;
- public Builder projectId(String projectId) {
- this.projectId = projectId;
+ public Builder projectNumber(String projectNumber) {
+ this.projectNumber = projectNumber;
return this;
}
@@ -107,11 +107,11 @@ public final class ProjectTeam {
}
public ProjectTeam build() {
- return new ProjectTeam(this.projectId, this.team);
+ return new ProjectTeam(this.projectNumber, this.team);
}
public Builder fromProjectTeam(ProjectTeam in) {
- return this.projectId(in.getProjectId()).team(in.getTeam());
+ return this.projectNumber(in.getProjectNumber()).team(in.getTeam());
}
}
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/38e05f6c/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/features/ObjectAccessControlsApi.java
----------------------------------------------------------------------
diff --git a/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/features/ObjectAccessControlsApi.java b/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/features/ObjectAccessControlsApi.java
new file mode 100644
index 0000000..87503a2
--- /dev/null
+++ b/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/features/ObjectAccessControlsApi.java
@@ -0,0 +1,365 @@
+/*
+ * 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.features;
+
+import static org.jclouds.googlecloudstorage.reference.GoogleCloudStorageConstants.STORAGE_FULLCONTROL_SCOPE;
+
+import javax.inject.Named;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+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.ListObjectAccessControls;
+import org.jclouds.googlecloudstorage.domain.ObjectAccessControls;
+import org.jclouds.googlecloudstorage.domain.ObjectAccessControlsTemplate;
+import org.jclouds.googlecloudstorage.handlers.ObjectAccessControlsBinder;
+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;
+import org.jclouds.rest.annotations.MapBinder;
+import org.jclouds.rest.annotations.PATCH;
+import org.jclouds.rest.annotations.PayloadParam;
+import org.jclouds.rest.annotations.RequestFilters;
+import org.jclouds.rest.annotations.SkipEncoding;
+import org.jclouds.rest.binders.BindToJsonPayload;
+
+/**
+ * Provides access to ObjectAccessControl entities via their REST API.
+ *
+ * @see <a href = " https://developers.google.com/storage/docs/json_api/v1/objectAccessControls "/>
+ */
+
+@SkipEncoding({ '/', '=' })
+@RequestFilters(OAuthAuthenticator.class)
+public interface ObjectAccessControlsApi {
+
+ /**
+ * Returns the acl entry for the specified entity on the specified object.
+ *
+ * @param bucketName
+ * Name of the bucket which contains the object
+ * @param objectName
+ * Name of the bucket of that acl is related
+ * @param entity
+ * The entity holding the permission. Can be user-userId, user-emailAddress, group-groupId,
+ * group-emailAddress, allUsers, or allAuthenticatedUsers
+ *
+ * @return an {@link ObjectAccessControls }
+ */
+
+ @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,
+ @PathParam("object") String objectName, @PathParam("entity") String entity);
+
+ /**
+ * Returns the acl entry for the specified entity on the specified object.
+ *
+ * @param bucketName
+ * Name of the bucket which contains the object
+ * @param objectName
+ * Name of the object of that acl is related
+ * @param entity
+ * The entity holding the permission. Can be user-userId, user-emailAddress, group-groupId,
+ * group-emailAddress, allUsers, or allAuthenticatedUsers
+ * @param generation
+ * If present, selects a specific revision of this object
+ *
+ * @return an {@link ObjectAccessControls }
+ */
+
+ @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,
+ @PathParam("object") String objectName, @PathParam("entity") String entity,
+ @QueryParam("generation") Long generation);
+
+ /**
+ * Creates a new acl entry for specified object
+ *
+ * @param bucketName
+ * Name of the bucket of that acl to be created In the request body, supply a ObjectAccessControls resource
+ * with the following properties
+ * @param objectName
+ * Name of the bucket of that acl is related
+ *
+ * @return an {@link ObjectAccessControls }
+ */
+
+ @Named("ObjectAccessControls:insert")
+ @POST
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ @Path("/b/{bucket}/o/{object}/acl")
+ @OAuthScopes(STORAGE_FULLCONTROL_SCOPE)
+ @MapBinder(ObjectAccessControlsBinder.class)
+ ObjectAccessControls createObjectAccessControls(@PathParam("bucket") String bucketName,
+ @PathParam("object") String objectName, @PayloadParam("template") ObjectAccessControlsTemplate template);
+
+ /**
+ * Creates a new acl entry for specified object
+ *
+ * @param bucketName
+ * Name of the bucket of that acl to be created In the request body, supply a ObjectAccessControls resource
+ * with the following properties
+ * @param objectName
+ * Name of the bucket of that acl is related
+ * @param generation
+ * If present, selects a specific revision of this object
+ *
+ * @return an {@link ObjectAccessControls }
+ */
+
+ @Named("ObjectAccessControls:insert")
+ @POST
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ @Path("/b/{bucket}/o/{object}/acl")
+ @OAuthScopes(STORAGE_FULLCONTROL_SCOPE)
+ @MapBinder(ObjectAccessControlsBinder.class)
+ ObjectAccessControls createObjectAccessControls(@PathParam("bucket") String bucketName,
+ @PathParam("object") String objectName, @PayloadParam("template") ObjectAccessControlsTemplate template,
+ @QueryParam("generation") Long generation);
+
+ /**
+ * Permanently deletes the acl entry for the specified entity on the specified bucket.
+ *
+ * @param bucketName
+ * Name of the bucket which contains the object
+ * @param objectName
+ * Name of the bucket of which acl is related
+ * @param entity
+ * 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);
+
+ /**
+ * Permanently deletes the acl entry for the specified entity on the specified bucket.
+ *
+ * @param bucketName
+ * Name of the bucket which contains the object
+ * @param objectName
+ * Name of the bucket of that acl is related
+ * @param generation
+ * If present, selects a specific revision of this object
+ * @param entity
+ * 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, @QueryParam("generation") Long generation);
+
+ /**
+ * Retrieves acl entries on a specified object
+ *
+ * @param bucketName
+ * Name of the bucket which contains the object
+ * @param objectName
+ * Name of the bucket of that acl is related
+ * @param generation
+ * If present, selects a specific revision of this object
+ *
+ * @return {@link ListObjectAccessControls } resource
+ *
+ */
+
+ @Named("ObjectAccessControls:list")
+ @GET
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ @Path("/b/{bucket}/o/{object}/acl")
+ @OAuthScopes(STORAGE_FULLCONTROL_SCOPE)
+ @Fallback(NullOnNotFoundOr404.class)
+ @Nullable
+ ListObjectAccessControls listObjectAccessControls(@PathParam("bucket") String bucketName,
+ @PathParam("object") String objectName);
+
+ /**
+ * Retrieves acl entries on a specified object
+ *
+ * @param bucketName
+ * Name of the bucket which contains the object
+ * @param objectName
+ * Name of the bucket of that acl is related
+ * @param generation
+ * If present, selects a specific revision of this object
+ *
+ * @return a {@link ListObjectAccessControls }
+ *
+ */
+
+ @Named("ObjectAccessControls:list")
+ @GET
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ @Path("/b/{bucket}/o/{object}/acl")
+ @OAuthScopes(STORAGE_FULLCONTROL_SCOPE)
+ @Fallback(NullOnNotFoundOr404.class)
+ @Nullable
+ ListObjectAccessControls listObjectAccessControls(@PathParam("bucket") String bucketName,
+ @PathParam("object") String objectName, @QueryParam("generation") Long generation);
+
+ /**
+ * Updates an acl entry on the specified object
+ *
+ * @param bucketName
+ * Name of the bucket of which contains the object
+ * @param objectName
+ * Name of the object which acl is related
+ * @param entity
+ * The entity holding the permission. Can be user-userId, user-emailAddress, group-groupId,
+ * group-emailAddress, allUsers, or allAuthenticatedUsers.
+ * @param template
+ * Supply an {@link ObjectAccessControlsTemplate}
+ *
+ * @return an {@link ObjectAccessControls }
+ */
+
+ @Named("ObjectAccessControls:update")
+ @PUT
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.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);
+
+ /**
+ * Updates an acl entry on the specified object
+ *
+ * @param bucketName
+ * Name of the bucket of which contains the object
+ * @param objectName
+ * Name of the object which acl is related *
+ * @param entity
+ * The entity holding the permission. Can be user-userId, user-emailAddress, group-groupId,
+ * group-emailAddress, allUsers, or allAuthenticatedUsers
+ * @param template
+ * Supply an {@link ObjectAccessControlsTemplate}
+ * @param generation
+ * If present, selects a specific revision of this object
+ *
+ * @return {@link ObjectAccessControls }
+ */
+
+ @Named("ObjectAccessControls:update")
+ @PUT
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.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,
+ @QueryParam("generation") Long generation);
+
+ /**
+ * Updates an acl entry on the specified object
+ *
+ * @param bucketName
+ * Name of the bucket of which contains the object
+ * @param objectName
+ * Name of the object which acl is related
+ * @param template
+ * Supply an {@link ObjectAccessControlsTemplate}
+ * @param entity
+ * The entity holding the permission. Can be user-userId, user-emailAddress, group-groupId,
+ * group-emailAddress, allUsers, or allAuthenticatedUsers.
+ *
+ * @return an {@link ObjectAccessControls }
+ */
+
+ @Named("ObjectAccessControls:patch")
+ @PATCH
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.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);
+
+ /**
+ * Updates an acl entry on the specified object
+ *
+ * @param bucketName
+ * Name of the bucket of which contains the object
+ * @param objectName
+ * Name of the object which acl is related
+ * @param entity
+ * The entity holding the permission. Can be user-userId, user-emailAddress, group-groupId,
+ * group-emailAddress, allUsers, or allAuthenticatedUsers
+ * @param template
+ * Supply an {@link ObjectAccessControlsTemplate}
+ * @param generation
+ * If present, selects a specific revision of this object
+ *
+ * @return {@link ObjectAccessControls }
+ */
+
+ @Named("ObjectAccessControls:patch")
+ @PATCH
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.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);
+
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/38e05f6c/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/handlers/GoogleCloudStorageErrorHandler.java
----------------------------------------------------------------------
diff --git a/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/handlers/GoogleCloudStorageErrorHandler.java b/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/handlers/GoogleCloudStorageErrorHandler.java
index 9198618..f7e24e9 100644
--- a/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/handlers/GoogleCloudStorageErrorHandler.java
+++ b/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/handlers/GoogleCloudStorageErrorHandler.java
@@ -41,6 +41,10 @@ public class GoogleCloudStorageErrorHandler implements HttpErrorHandler {
: new HttpResponseException(command, response);
message = message != null ? message : String.format("%s -> %s", command.getCurrentRequest().getRequestLine(),
response.getStatusLine());
+
+ String message411 = "MissingContentLength: You must provide the Content-Length HTTP header.\n";
+ String message412 = "PreconditionFailed: At least one of the pre-conditions you specified did not hold.\n";
+
switch (response.getStatusCode()) {
case 401:
case 403:
@@ -52,6 +56,12 @@ public class GoogleCloudStorageErrorHandler implements HttpErrorHandler {
case 409:
exception = new IllegalStateException(message, exception);
break;
+ case 411:
+ exception = new IllegalStateException(message411 + message, exception);
+ break;
+ case 412:
+ exception = new IllegalStateException(message412 + message, exception);
+ break;
}
command.setException(exception);
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/38e05f6c/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/handlers/ObjectAccessControlsBinder.java
----------------------------------------------------------------------
diff --git a/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/handlers/ObjectAccessControlsBinder.java b/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/handlers/ObjectAccessControlsBinder.java
new file mode 100644
index 0000000..e1f4eda
--- /dev/null
+++ b/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/handlers/ObjectAccessControlsBinder.java
@@ -0,0 +1,43 @@
+/*
+ * 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.handlers;
+
+import java.util.Map;
+
+import javax.inject.Inject;
+
+import org.jclouds.googlecloudstorage.domain.ObjectAccessControlsTemplate;
+import org.jclouds.http.HttpRequest;
+import org.jclouds.rest.MapBinder;
+import org.jclouds.rest.binders.BindToJsonPayload;
+
+public class ObjectAccessControlsBinder implements MapBinder {
+
+ @Inject
+ private BindToJsonPayload jsonBinder;
+
+ @Override
+ public <R extends HttpRequest> R bindToRequest(R request, Map<String, Object> postParams) throws IllegalArgumentException{
+ ObjectAccessControlsTemplate postBucket = (ObjectAccessControlsTemplate) postParams.get("template");
+ return bindToRequest(request, postBucket);
+ }
+
+ @Override
+ public <R extends HttpRequest> R bindToRequest(R request, Object input) {
+ return jsonBinder.bindToRequest(request, input);
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/38e05f6c/google-cloud-storage/src/test/java/org/jclouds/googlecloudstorage/features/BucketAccessControlsApiLiveTest.java
----------------------------------------------------------------------
diff --git a/google-cloud-storage/src/test/java/org/jclouds/googlecloudstorage/features/BucketAccessControlsApiLiveTest.java b/google-cloud-storage/src/test/java/org/jclouds/googlecloudstorage/features/BucketAccessControlsApiLiveTest.java
new file mode 100644
index 0000000..ea3010c
--- /dev/null
+++ b/google-cloud-storage/src/test/java/org/jclouds/googlecloudstorage/features/BucketAccessControlsApiLiveTest.java
@@ -0,0 +1,112 @@
+/*
+ * 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.features;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNotNull;
+
+import java.util.UUID;
+
+import org.jclouds.googlecloudstorage.domain.Bucket;
+import org.jclouds.googlecloudstorage.domain.BucketAccessControls;
+import org.jclouds.googlecloudstorage.domain.BucketTemplate;
+import org.jclouds.googlecloudstorage.domain.DomainResourceRefferences.Role;
+import org.jclouds.googlecloudstorage.domain.ListBucketAccessControls;
+import org.jclouds.googlecloudstorage.domain.Resource.Kind;
+import org.jclouds.googlecloudstorage.internal.BaseGoogleCloudStorageApiLiveTest;
+import org.testng.annotations.Test;
+
+public class BucketAccessControlsApiLiveTest extends BaseGoogleCloudStorageApiLiveTest {
+
+ protected static final String BUCKET_NAME = "jcloudstestbucketacl" + UUID.randomUUID();
+
+ private BucketAccessControlsApi api() {
+ return api.getBucketAccessControlsApi();
+ }
+
+ private void createBucket(String BucketName) {
+ BucketTemplate template = new BucketTemplate().name(BucketName);
+ Bucket response = api.getBucketApi().createBucket(PROJECT_NUMBER, template);
+ assertNotNull(response);
+ }
+
+ @Test(groups = "live")
+ public void testCreateBucketAcl() {
+ createBucket(BUCKET_NAME);
+ BucketAccessControls bucketAcl = BucketAccessControls.builder().bucket(BUCKET_NAME).entity("allUsers")
+ .role(Role.READER).build();
+ BucketAccessControls response = api().createBucketAccessControls(BUCKET_NAME, bucketAcl);
+
+ assertNotNull(response);
+ assertEquals(response.getId(), BUCKET_NAME + "/allUsers");
+ }
+
+ @Test(groups = "live", dependsOnMethods = "testCreateBucketAcl")
+ public void testUpdateBucketAcl() {
+ BucketAccessControls bucketAcl = BucketAccessControls.builder().bucket(BUCKET_NAME).entity("allUsers")
+ .role(Role.WRITER).build();
+ BucketAccessControls response = api().updateBucketAccessControls(BUCKET_NAME, "allUsers", bucketAcl);
+
+ assertNotNull(response);
+ assertEquals(response.getId(), BUCKET_NAME + "/allUsers");
+ assertEquals(response.getRole(), Role.WRITER);
+ }
+
+ @Test(groups = "live", dependsOnMethods = "testUpdateBucketAcl")
+ public void testGetBucketAcl() {
+ BucketAccessControls response = api().getBucketAccessControls(BUCKET_NAME, "allUsers");
+
+ assertNotNull(response);
+ assertEquals(response.getId(), BUCKET_NAME + "/allUsers");
+ assertEquals(response.getRole(), Role.WRITER);
+ }
+
+ @Test(groups = "live", dependsOnMethods = "testUpdateBucketAcl")
+ public void testListBucketAcl() {
+ ListBucketAccessControls response = api().listBucketAccessControls(BUCKET_NAME);
+
+ assertNotNull(response);
+ assertEquals(response.getKind(), Kind.BUCKET_ACCESS_CONTROLS);
+ assertNotNull(response.getItems());
+ }
+
+ @Test(groups = "live", dependsOnMethods = "testUpdateBucketAcl")
+ public void testPatchBucketAcl() {
+ BucketAccessControls bucketAcl = BucketAccessControls.builder().bucket(BUCKET_NAME).entity("allUsers")
+ .role(Role.READER).build();
+ BucketAccessControls response = api().patchBucketAccessControls(BUCKET_NAME, "allUsers", bucketAcl);
+
+ assertNotNull(response);
+ assertEquals(response.getId(), BUCKET_NAME + "/allUsers");
+ assertEquals(response.getRole(), Role.READER);
+ }
+
+ @Test(groups = "live", dependsOnMethods = "testPatchBucketAcl")
+ public void testDeleteBucketAcl() {
+ api().deleteBucketAccessControls(BUCKET_NAME, "allUsers");
+ deleteBucket(BUCKET_NAME);
+ }
+
+ @Test(groups = "live", dependsOnMethods = "testDeleteBucketAcl")
+ public void testDeleteNotExistingBucketAccessControls() {
+ api().deleteBucketAccessControls(BUCKET_NAME, "allUsers");
+ }
+
+ private void deleteBucket(String BucketName) {
+ api.getBucketApi().deleteBucket(BucketName);
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/38e05f6c/google-cloud-storage/src/test/java/org/jclouds/googlecloudstorage/features/DefaultObjectAccessControlsApiExpectTest.java
----------------------------------------------------------------------
diff --git a/google-cloud-storage/src/test/java/org/jclouds/googlecloudstorage/features/DefaultObjectAccessControlsApiExpectTest.java b/google-cloud-storage/src/test/java/org/jclouds/googlecloudstorage/features/DefaultObjectAccessControlsApiExpectTest.java
index 0659847..987605d 100644
--- a/google-cloud-storage/src/test/java/org/jclouds/googlecloudstorage/features/DefaultObjectAccessControlsApiExpectTest.java
+++ b/google-cloud-storage/src/test/java/org/jclouds/googlecloudstorage/features/DefaultObjectAccessControlsApiExpectTest.java
@@ -40,31 +40,31 @@ public class DefaultObjectAccessControlsApiExpectTest extends BaseGoogleCloudSto
private static final String EXPECTED_TEST_BUCKET = "jcloudtestbucket";
private static final String EXPECTED_TEST_GROUP_ENTITY = "group-00b4903a971ec6cff233284d6d24f5bf5cba904c4ade4d43ebd6a5d33800e68b";
- private static final HttpRequest GET_DEFAULT_OBJECTACL_REQUEST = HttpRequest
+ private static final HttpRequest GET_DEFAULT_OBJECT_ACL_REQUEST = HttpRequest
.builder()
.method("GET")
.endpoint(
"https://www.googleapis.com/storage/v1/b/jcloudtestbucket/defaultObjectAcl/group-00b4903a971ec6cff233284d6d24f5bf5cba904c4ade4d43ebd6a5d33800e68b")
.addHeader("Accept", "application/json").addHeader("Authorization", "Bearer " + TOKEN).build();
- private final HttpResponse GET_DEFAULT_OBJECTACL_RESPONSE = HttpResponse.builder().statusCode(200)
+ private final HttpResponse GET_DEFAULT_OBJECT_ACL_RESPONSE = HttpResponse.builder().statusCode(200)
.payload(staticPayloadFromResource("/default_objectacl_get.json")).build();
- private final HttpResponse CREATE_DEFAULT_OBJECTACL_RESPONSE = HttpResponse.builder().statusCode(200)
+ private final HttpResponse CREATE_DEFAULT_OBJECT_ACL_RESPONSE = HttpResponse.builder().statusCode(200)
.payload(staticPayloadFromResource("/default_objectacl_insert_response.json")).build();
- public final HttpRequest LIST_DEFAULT_OBJECTACL_REQUEST = HttpRequest.builder().method("GET")
+ public final HttpRequest LIST_DEFAULT_OBJECT_ACL_REQUEST = HttpRequest.builder().method("GET")
.endpoint("https://www.googleapis.com/storage/v1/b/jcloudtestbucket/defaultObjectAcl")
.addHeader("Accept", "application/json").addHeader("Authorization", "Bearer " + TOKEN).build();
- private final HttpResponse LIST_DEFAULT_OBJECTACL_RESPONSE = HttpResponse.builder().statusCode(200)
+ private final HttpResponse LIST_DEFAULT_OBJECT_ACL_RESPONSE = HttpResponse.builder().statusCode(200)
.payload(staticPayloadFromResource("/default_objectacl_list.json")).build();
// Test getDefaultObjectAccessControls
public void testGetDefaultObjectAclResponseIs2xx() throws Exception {
DefaultObjectAccessControlsApi api = requestsSendResponses(requestForScopes(STORAGE_FULLCONTROL_SCOPE),
- TOKEN_RESPONSE, GET_DEFAULT_OBJECTACL_REQUEST, GET_DEFAULT_OBJECTACL_RESPONSE)
+ TOKEN_RESPONSE, GET_DEFAULT_OBJECT_ACL_REQUEST, GET_DEFAULT_OBJECT_ACL_RESPONSE)
.getDefaultObjectAccessControlsApi();
assertEquals(api.getDefaultObjectAccessControls(EXPECTED_TEST_BUCKET, EXPECTED_TEST_GROUP_ENTITY),
@@ -76,7 +76,7 @@ public class DefaultObjectAccessControlsApiExpectTest extends BaseGoogleCloudSto
HttpResponse getResponse = HttpResponse.builder().statusCode(404).build();
DefaultObjectAccessControlsApi api = requestsSendResponses(requestForScopes(STORAGE_FULLCONTROL_SCOPE),
- TOKEN_RESPONSE, GET_DEFAULT_OBJECTACL_REQUEST, getResponse).getDefaultObjectAccessControlsApi();
+ TOKEN_RESPONSE, GET_DEFAULT_OBJECT_ACL_REQUEST, getResponse).getDefaultObjectAccessControlsApi();
assertNull(api.getDefaultObjectAccessControls(EXPECTED_TEST_BUCKET, EXPECTED_TEST_GROUP_ENTITY));
}
@@ -85,7 +85,7 @@ public class DefaultObjectAccessControlsApiExpectTest extends BaseGoogleCloudSto
public void testListDefaultObjectAclWithNoOptionsResponseIs2xx() throws Exception {
DefaultObjectAccessControlsApi api = requestsSendResponses(requestForScopes(STORAGE_FULLCONTROL_SCOPE),
- TOKEN_RESPONSE, LIST_DEFAULT_OBJECTACL_REQUEST, LIST_DEFAULT_OBJECTACL_RESPONSE)
+ TOKEN_RESPONSE, LIST_DEFAULT_OBJECT_ACL_REQUEST, LIST_DEFAULT_OBJECT_ACL_RESPONSE)
.getDefaultObjectAccessControlsApi();
assertEquals(api.listDefaultObjectAccessControls(EXPECTED_TEST_BUCKET), new DefaultObjectAclListTest().expected());
@@ -96,7 +96,7 @@ public class DefaultObjectAccessControlsApiExpectTest extends BaseGoogleCloudSto
HttpResponse listResponse = HttpResponse.builder().statusCode(404).build();
DefaultObjectAccessControlsApi api = requestsSendResponses(requestForScopes(STORAGE_FULLCONTROL_SCOPE),
- TOKEN_RESPONSE, LIST_DEFAULT_OBJECTACL_REQUEST, listResponse).getDefaultObjectAccessControlsApi();
+ TOKEN_RESPONSE, LIST_DEFAULT_OBJECT_ACL_REQUEST, listResponse).getDefaultObjectAccessControlsApi();
assertNull(api.listDefaultObjectAccessControls(EXPECTED_TEST_BUCKET));
}
@@ -113,7 +113,7 @@ public class DefaultObjectAccessControlsApiExpectTest extends BaseGoogleCloudSto
MediaType.APPLICATION_JSON)).build();
DefaultObjectAccessControlsApi api = requestsSendResponses(requestForScopes(STORAGE_FULLCONTROL_SCOPE),
- TOKEN_RESPONSE, insertRequest, CREATE_DEFAULT_OBJECTACL_RESPONSE).getDefaultObjectAccessControlsApi();
+ TOKEN_RESPONSE, insertRequest, CREATE_DEFAULT_OBJECT_ACL_RESPONSE).getDefaultObjectAccessControlsApi();
DefaultObjectAccessControlsTemplate template = new DefaultObjectAccessControlsTemplate().entity("allUsers").role(
ObjectRole.OWNER);
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/38e05f6c/google-cloud-storage/src/test/java/org/jclouds/googlecloudstorage/features/DefaultObjectAccessControlsApiLiveTest.java
----------------------------------------------------------------------
diff --git a/google-cloud-storage/src/test/java/org/jclouds/googlecloudstorage/features/DefaultObjectAccessControlsApiLiveTest.java b/google-cloud-storage/src/test/java/org/jclouds/googlecloudstorage/features/DefaultObjectAccessControlsApiLiveTest.java
new file mode 100644
index 0000000..0f31914
--- /dev/null
+++ b/google-cloud-storage/src/test/java/org/jclouds/googlecloudstorage/features/DefaultObjectAccessControlsApiLiveTest.java
@@ -0,0 +1,117 @@
+/*
+ * 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.features;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNotNull;
+
+import java.util.UUID;
+
+import org.jclouds.googlecloudstorage.domain.Bucket;
+import org.jclouds.googlecloudstorage.domain.BucketTemplate;
+import org.jclouds.googlecloudstorage.domain.DefaultObjectAccessControls;
+import org.jclouds.googlecloudstorage.domain.DefaultObjectAccessControlsTemplate;
+import org.jclouds.googlecloudstorage.domain.DomainResourceRefferences.ObjectRole;
+import org.jclouds.googlecloudstorage.domain.ListDefaultObjectAccessControls;
+import org.jclouds.googlecloudstorage.domain.Resource.Kind;
+import org.jclouds.googlecloudstorage.internal.BaseGoogleCloudStorageApiLiveTest;
+import org.testng.annotations.Test;
+
+public class DefaultObjectAccessControlsApiLiveTest extends BaseGoogleCloudStorageApiLiveTest {
+
+ protected static final String BUCKET_NAME = "jcloudtestbucketdefaultoacl" + UUID.randomUUID();
+
+ private DefaultObjectAccessControlsApi api() {
+ return api.getDefaultObjectAccessControlsApi();
+ }
+
+ private void createBucket(String BucketName) {
+ BucketTemplate template = new BucketTemplate().name(BucketName);
+ Bucket response = api.getBucketApi().createBucket(PROJECT_NUMBER, template);
+ assertNotNull(response);
+ }
+
+ @Test(groups = "live")
+ public void testCreateDefaultObjectAcl() {
+ createBucket(BUCKET_NAME);
+ DefaultObjectAccessControlsTemplate template = new DefaultObjectAccessControlsTemplate().entity("allUsers").role(
+ ObjectRole.READER);
+
+ DefaultObjectAccessControls response = api().createDefaultObjectAccessControls(BUCKET_NAME, template);
+
+ assertNotNull(response);
+ assertEquals(response.getEntity(), "allUsers");
+ assertEquals(response.getRole(), ObjectRole.READER);
+ }
+
+ @Test(groups = "live", dependsOnMethods = "testCreateDefaultObjectAcl")
+ public void testUpdateDefaultObjectAcl() {
+ DefaultObjectAccessControls defaultObjectAcl = DefaultObjectAccessControls.builder().bucket(BUCKET_NAME)
+ .entity("allUsers").role(ObjectRole.OWNER).build();
+ DefaultObjectAccessControls response = api().updateDefaultObjectAccessControls(BUCKET_NAME, "allUsers",
+ defaultObjectAcl);
+
+ assertNotNull(response);
+ assertEquals(response.getEntity(), "allUsers");
+ assertEquals(response.getRole(), ObjectRole.OWNER);
+ }
+
+ @Test(groups = "live", dependsOnMethods = "testUpdateDefaultObjectAcl")
+ public void testGetDefaultObjectAcl() {
+ DefaultObjectAccessControls response = api().getDefaultObjectAccessControls(BUCKET_NAME, "allUsers");
+
+ assertNotNull(response);
+ assertEquals(response.getEntity(), "allUsers");
+ assertEquals(response.getRole(), ObjectRole.OWNER);
+ }
+
+ @Test(groups = "live", dependsOnMethods = "testUpdateDefaultObjectAcl")
+ public void testListDefaultObjectAcl() {
+ ListDefaultObjectAccessControls response = api().listDefaultObjectAccessControls(BUCKET_NAME);
+
+ assertNotNull(response);
+ assertEquals(response.getKind(), Kind.OBJECT_ACCESS_CONTROLS);
+ assertNotNull(response.getItems());
+ }
+
+ @Test(groups = "live", dependsOnMethods = "testUpdateDefaultObjectAcl")
+ public void testPatchDefaultObjectAcl() {
+ DefaultObjectAccessControls defaultObjectAcl = DefaultObjectAccessControls.builder().bucket(BUCKET_NAME)
+ .entity("allUsers").role(ObjectRole.READER).build();
+ DefaultObjectAccessControls response = api().patchDefaultObjectAccessControls(BUCKET_NAME, "allUsers",
+ defaultObjectAcl);
+
+ assertNotNull(response);
+ assertEquals(response.getEntity(), "allUsers");
+ assertEquals(response.getRole(), ObjectRole.READER);
+ }
+
+ @Test(groups = "live", dependsOnMethods = "testPatchDefaultObjectAcl")
+ public void testDeleteBucketAcl() {
+ api().deleteDefaultObjectAccessControls(BUCKET_NAME, "allUsers");
+ deleteBucket(BUCKET_NAME);
+ }
+
+ @Test(groups = "live", dependsOnMethods = "testDeleteBucketAcl")
+ public void testDeleteNotExistingBucketAccessControls() {
+ api().deleteDefaultObjectAccessControls(BUCKET_NAME, "allUsers");
+ }
+
+ private void deleteBucket(String bucketName) {
+ api.getBucketApi().deleteBucket(bucketName);
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/38e05f6c/google-cloud-storage/src/test/java/org/jclouds/googlecloudstorage/features/ObjectAccessControlsApiExpectTest.java
----------------------------------------------------------------------
diff --git a/google-cloud-storage/src/test/java/org/jclouds/googlecloudstorage/features/ObjectAccessControlsApiExpectTest.java b/google-cloud-storage/src/test/java/org/jclouds/googlecloudstorage/features/ObjectAccessControlsApiExpectTest.java
new file mode 100644
index 0000000..7f87e45
--- /dev/null
+++ b/google-cloud-storage/src/test/java/org/jclouds/googlecloudstorage/features/ObjectAccessControlsApiExpectTest.java
@@ -0,0 +1,282 @@
+/*
+ * 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.features;
+
+import static org.jclouds.googlecloudstorage.reference.GoogleCloudStorageConstants.STORAGE_FULLCONTROL_SCOPE;
+import static org.testng.Assert.assertEquals;
+import static org.testng.AssertJUnit.assertNull;
+
+import javax.ws.rs.core.MediaType;
+
+import org.jclouds.googlecloudstorage.domain.DomainResourceRefferences.ObjectRole;
+import org.jclouds.googlecloudstorage.domain.ObjectAccessControlsTemplate;
+import org.jclouds.googlecloudstorage.internal.BaseGoogleCloudStorageApiExpectTest;
+import org.jclouds.googlecloudstorage.parse.ObjectAclGetTest;
+import org.jclouds.googlecloudstorage.parse.ObjectAclInsertTest;
+import org.jclouds.googlecloudstorage.parse.ObjectAclListTest;
+import org.jclouds.googlecloudstorage.parse.ObjectAclUpdateTest;
+import org.jclouds.http.HttpRequest;
+import org.jclouds.http.HttpResponse;
+import org.testng.annotations.Test;
+
+@Test(groups = "unit")
+public class ObjectAccessControlsApiExpectTest extends BaseGoogleCloudStorageApiExpectTest {
+
+ private static final String EXPECTED_TEST_BUCKET = "jcloudtestbucket";
+ private static final String EXPECTED_TEST_OBJECT = "foo.txt";
+ private static final String EXPECTED_TEST_GROUP_ENTITY = "group-00b4903a971ec6cff233284d6d24f5bf5cba904c4ade4d43ebd6a5d33800e68b";
+ private static final String EXPECTED_TEST_USER_ENTITY = "user-00b4903a97adfde729f0650133a7379693099d8d85d6b1b18255ca70bf89e31d";
+
+ public static final HttpRequest GET_OBJECT_ACL_REQUEST = HttpRequest
+ .builder()
+ .method("GET")
+ .endpoint(
+ "https://www.googleapis.com/storage/v1/b/jcloudtestbucket/o/foo.txt/acl/group-00b4903a971ec6cff233284d6d24f5bf5cba904c4ade4d43ebd6a5d33800e68b")
+ .addHeader("Accept", "application/json").addHeader("Authorization", "Bearer " + TOKEN).build();
+
+ public static final HttpRequest GET_OBJECT_ACL_REQUEST_WITHOPTIONS = HttpRequest
+ .builder()
+ .method("GET")
+ .endpoint(
+ "https://www.googleapis.com/storage/v1/b/jcloudtestbucket/o/foo.txt/acl/group-00b4903a971ec6cff233284d6d24f5bf5cba904c4ade4d43ebd6a5d33800e68b")
+ .addQueryParam("generation", "100").addHeader("Accept", "application/json")
+ .addHeader("Authorization", "Bearer " + TOKEN).build();
+
+ public final HttpResponse GET_OBJECT_ACL_RESPONSE = HttpResponse.builder().statusCode(200)
+ .payload(staticPayloadFromResource("/objectacl_get.json")).build();
+
+ public final HttpResponse CREATE_OBJECT_ACL_RESPONSE = HttpResponse.builder().statusCode(200)
+ .payload(staticPayloadFromResource("/objectacl_insert_response.json")).build();
+
+ public final HttpRequest LIST_OBJECT_ACL_REQUEST = HttpRequest.builder().method("GET")
+ .endpoint("https://www.googleapis.com/storage/v1/b/jcloudtestbucket/o/foo.txt/acl")
+ .addHeader("Accept", "application/json").addHeader("Authorization", "Bearer " + TOKEN).build();
+
+ public final HttpRequest LIST_OBJECT_ACL_REQUEST_WITHOPTIONS = HttpRequest.builder().method("GET")
+ .endpoint("https://www.googleapis.com/storage/v1/b/jcloudtestbucket/o/foo.txt/acl")
+ .addQueryParam("generation", "100").addHeader("Accept", "application/json")
+ .addHeader("Authorization", "Bearer " + TOKEN).build();
+
+ public final HttpResponse LIST_OBJECT_ACL_RESPONSE = HttpResponse.builder().statusCode(200)
+ .payload(staticPayloadFromResource("/objectacl_list.json")).build();
+
+ // Test getObjectAccessControls
+ public void testGetObjectaclWithNoOptionsResponseIs2xx() throws Exception {
+
+ ObjectAccessControlsApi api = requestsSendResponses(requestForScopes(STORAGE_FULLCONTROL_SCOPE), TOKEN_RESPONSE,
+ GET_OBJECT_ACL_REQUEST, GET_OBJECT_ACL_RESPONSE).getObjectAccessControlsApi();
+
+ assertEquals(api.getObjectAccessControls(EXPECTED_TEST_BUCKET, EXPECTED_TEST_OBJECT, EXPECTED_TEST_GROUP_ENTITY),
+ new ObjectAclGetTest().expected());
+ }
+
+ public void testGetObjectaclWithOptionsResponseIs2xx() throws Exception {
+
+ ObjectAccessControlsApi api = requestsSendResponses(requestForScopes(STORAGE_FULLCONTROL_SCOPE), TOKEN_RESPONSE,
+ GET_OBJECT_ACL_REQUEST_WITHOPTIONS, GET_OBJECT_ACL_RESPONSE).getObjectAccessControlsApi();
+
+ assertEquals(
+ api.getObjectAccessControls(EXPECTED_TEST_BUCKET, EXPECTED_TEST_OBJECT, EXPECTED_TEST_GROUP_ENTITY,
+ Long.valueOf(100)), new ObjectAclGetTest().expected());
+ }
+
+ public void testGetObjectaclResponseIs4xx() throws Exception {
+
+ HttpResponse getResponse = HttpResponse.builder().statusCode(404).build();
+
+ ObjectAccessControlsApi api = requestsSendResponses(requestForScopes(STORAGE_FULLCONTROL_SCOPE), TOKEN_RESPONSE,
+ GET_OBJECT_ACL_REQUEST, getResponse).getObjectAccessControlsApi();
+
+ assertNull(api.getObjectAccessControls(EXPECTED_TEST_BUCKET, EXPECTED_TEST_OBJECT, EXPECTED_TEST_GROUP_ENTITY));
+ }
+
+ // Test listObjectAccessControls
+ public void testListObjectaclWithNoOptionsResponseIs2xx() throws Exception {
+
+ ObjectAccessControlsApi api = requestsSendResponses(requestForScopes(STORAGE_FULLCONTROL_SCOPE), TOKEN_RESPONSE,
+ LIST_OBJECT_ACL_REQUEST, LIST_OBJECT_ACL_RESPONSE).getObjectAccessControlsApi();
+
+ assertEquals(api.listObjectAccessControls(EXPECTED_TEST_BUCKET, EXPECTED_TEST_OBJECT),
+ new ObjectAclListTest().expected());
+
+ }
+
+ // Test listObjectAccessControls
+ public void testListObjectaclWithOptionsResponseIs2xx() throws Exception {
+
+ ObjectAccessControlsApi api = requestsSendResponses(requestForScopes(STORAGE_FULLCONTROL_SCOPE), TOKEN_RESPONSE,
+ LIST_OBJECT_ACL_REQUEST_WITHOPTIONS, LIST_OBJECT_ACL_RESPONSE).getObjectAccessControlsApi();
+
+ assertEquals(api.listObjectAccessControls(EXPECTED_TEST_BUCKET, EXPECTED_TEST_OBJECT, Long.valueOf(100)),
+ new ObjectAclListTest().expected());
+
+ }
+
+ public void testListObjectaclResponseIs4xx() throws Exception {
+
+ HttpResponse listResponse = HttpResponse.builder().statusCode(404).build();
+
+ ObjectAccessControlsApi api = requestsSendResponses(requestForScopes(STORAGE_FULLCONTROL_SCOPE), TOKEN_RESPONSE,
+ LIST_OBJECT_ACL_REQUEST, listResponse).getObjectAccessControlsApi();
+
+ assertNull(api.listObjectAccessControls(EXPECTED_TEST_BUCKET, EXPECTED_TEST_OBJECT));
+ }
+
+ // Test insertObjectAccessControls
+ public void testInsertObjectaclWithNoOptionsResponseIs2xx() throws Exception {
+ HttpRequest insertRequest = HttpRequest
+ .builder()
+ .method("POST")
+ .endpoint("https://www.googleapis.com/storage/v1/b/jcloudtestbucket/o/foo.txt/acl")
+ .addHeader("Accept", "application/json")
+ .addHeader("Authorization", "Bearer " + TOKEN)
+ .payload(payloadFromResourceWithContentType("/objectacl_insert_requestpayload.json",
+ MediaType.APPLICATION_JSON)).build();
+
+ ObjectAccessControlsApi api = requestsSendResponses(requestForScopes(STORAGE_FULLCONTROL_SCOPE), TOKEN_RESPONSE,
+ insertRequest, CREATE_OBJECT_ACL_RESPONSE).getObjectAccessControlsApi();
+
+ ObjectAccessControlsTemplate template = new ObjectAccessControlsTemplate().entity(EXPECTED_TEST_USER_ENTITY)
+ .role(ObjectRole.OWNER);
+
+ assertEquals(api.createObjectAccessControls(EXPECTED_TEST_BUCKET, EXPECTED_TEST_OBJECT, template),
+ new ObjectAclInsertTest().expected());
+
+ }
+
+ public void testInsertObjectaclWithOptionsResponseIs2xx() throws Exception {
+ HttpRequest insertRequest = HttpRequest
+ .builder()
+ .method("POST")
+ .endpoint("https://www.googleapis.com/storage/v1/b/jcloudtestbucket/o/foo.txt/acl")
+ .addHeader("Accept", "application/json")
+ .addHeader("Authorization", "Bearer " + TOKEN)
+ .addQueryParam("generation", "100")
+ .payload(payloadFromResourceWithContentType("/objectacl_insert_requestpayload.json",
+ MediaType.APPLICATION_JSON)).build();
+
+ ObjectAccessControlsApi api = requestsSendResponses(requestForScopes(STORAGE_FULLCONTROL_SCOPE), TOKEN_RESPONSE,
+ insertRequest, CREATE_OBJECT_ACL_RESPONSE).getObjectAccessControlsApi();
+
+ ObjectAccessControlsTemplate template = new ObjectAccessControlsTemplate().entity(
+ "user-00b4903a97adfde729f0650133a7379693099d8d85d6b1b18255ca70bf89e31d").role(ObjectRole.OWNER);
+
+ assertEquals(
+ api.createObjectAccessControls(EXPECTED_TEST_BUCKET, EXPECTED_TEST_OBJECT, template, Long.valueOf(100)),
+ new ObjectAclInsertTest().expected());
+
+ }
+
+ // Test updateObjectAccessControls
+ public void testUpdateObjectaclWithNoOptionsResponseIs2xx() throws Exception {
+ HttpRequest update = HttpRequest
+ .builder()
+ .method("PUT")
+ .endpoint("https://www.googleapis.com/storage/v1/b/jcloudtestbucket/o/foo.txt/acl/allUsers")
+ .addHeader("Accept", "application/json")
+ .addHeader("Authorization", "Bearer " + TOKEN)
+ .payload(payloadFromResourceWithContentType("/objectacl_request_payload.json",
+ MediaType.APPLICATION_JSON)).build();
+
+ HttpResponse updateResponse = HttpResponse.builder().statusCode(200)
+ .payload(staticPayloadFromResource("/objectacl_update_initial.json")).build();
+
+ ObjectAccessControlsApi api = requestsSendResponses(requestForScopes(STORAGE_FULLCONTROL_SCOPE), TOKEN_RESPONSE,
+ update, updateResponse).getObjectAccessControlsApi();
+
+ ObjectAccessControlsTemplate template = new ObjectAccessControlsTemplate().entity("allUsers").role(
+ ObjectRole.OWNER);
+
+ assertEquals(api.updateObjectAccessControls(EXPECTED_TEST_BUCKET, EXPECTED_TEST_OBJECT, "allUsers", template),
+ new ObjectAclUpdateTest().expected());
+ }
+
+ public void testUpdateObjectaclWithOptionsResponseIs2xx() throws Exception {
+ HttpRequest update = HttpRequest
+ .builder()
+ .method("PUT")
+ .endpoint("https://www.googleapis.com/storage/v1/b/jcloudtestbucket/o/foo.txt/acl/allUsers")
+ .addQueryParam("generation", "100")
+ .addHeader("Accept", "application/json")
+ .addHeader("Authorization", "Bearer " + TOKEN)
+ .payload(payloadFromResourceWithContentType("/objectacl_request_payload.json",
+ MediaType.APPLICATION_JSON)).build();
+
+ HttpResponse updateResponse = HttpResponse.builder().statusCode(200)
+ .payload(staticPayloadFromResource("/objectacl_update_initial.json")).build();
+
+ ObjectAccessControlsApi api = requestsSendResponses(requestForScopes(STORAGE_FULLCONTROL_SCOPE), TOKEN_RESPONSE,
+ update, updateResponse).getObjectAccessControlsApi();
+
+ ObjectAccessControlsTemplate template = new ObjectAccessControlsTemplate().entity("allUsers").role(
+ ObjectRole.OWNER);
+
+ assertEquals(
+ api.updateObjectAccessControls(EXPECTED_TEST_BUCKET, EXPECTED_TEST_OBJECT, "allUsers", template,
+ Long.valueOf(100)), new ObjectAclUpdateTest().expected());
+ }
+
+ // Test updateObjectAccessControls
+ public void testPatchObjectaclWithNoOptionsResponseIs2xx() throws Exception {
+ HttpRequest patchRequest = HttpRequest
+ .builder()
+ .method("PATCH")
+ .endpoint("https://www.googleapis.com/storage/v1/b/jcloudtestbucket/o/foo.txt/acl/allUsers")
+ .addHeader("Accept", "application/json")
+ .addHeader("Authorization", "Bearer " + TOKEN)
+ .payload(payloadFromResourceWithContentType("/objectacl_request_payload.json",
+ MediaType.APPLICATION_JSON)).build();
+
+ HttpResponse patchResponse = HttpResponse.builder().statusCode(200)
+ .payload(staticPayloadFromResource("/objectacl_update_initial.json")).build();
+
+ ObjectAccessControlsApi api = requestsSendResponses(requestForScopes(STORAGE_FULLCONTROL_SCOPE), TOKEN_RESPONSE,
+ patchRequest, patchResponse).getObjectAccessControlsApi();
+
+ ObjectAccessControlsTemplate template = new ObjectAccessControlsTemplate().entity("allUsers").role(
+ ObjectRole.OWNER);
+
+ assertEquals(api.patchObjectAccessControls(EXPECTED_TEST_BUCKET, EXPECTED_TEST_OBJECT, "allUsers", template),
+ new ObjectAclUpdateTest().expected());
+ }
+
+ public void testPatchObjectaclWithOptionsResponseIs2xx() throws Exception {
+ HttpRequest patchRequest = HttpRequest
+ .builder()
+ .method("PATCH")
+ .endpoint("https://www.googleapis.com/storage/v1/b/jcloudtestbucket/o/foo.txt/acl/allUsers")
+ .addQueryParam("generation", "100")
+ .addHeader("Accept", "application/json")
+ .addHeader("Authorization", "Bearer " + TOKEN)
+ .payload(payloadFromResourceWithContentType("/objectacl_request_payload.json",
+ MediaType.APPLICATION_JSON)).build();
+
+ HttpResponse patchResponse = HttpResponse.builder().statusCode(200)
+ .payload(staticPayloadFromResource("/objectacl_update_initial.json")).build();
+
+ ObjectAccessControlsApi api = requestsSendResponses(requestForScopes(STORAGE_FULLCONTROL_SCOPE), TOKEN_RESPONSE,
+ patchRequest, patchResponse).getObjectAccessControlsApi();
+
+ ObjectAccessControlsTemplate template = new ObjectAccessControlsTemplate().entity("allUsers").role(
+ ObjectRole.OWNER);
+ assertEquals(
+ api.patchObjectAccessControls(EXPECTED_TEST_BUCKET, EXPECTED_TEST_OBJECT, "allUsers", template,
+ Long.valueOf(100)), new ObjectAclUpdateTest().expected());
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/38e05f6c/google-cloud-storage/src/test/java/org/jclouds/googlecloudstorage/parse/BucketAclListTest.java
----------------------------------------------------------------------
diff --git a/google-cloud-storage/src/test/java/org/jclouds/googlecloudstorage/parse/BucketAclListTest.java b/google-cloud-storage/src/test/java/org/jclouds/googlecloudstorage/parse/BucketAclListTest.java
index 19a1e27..8bdb0f4 100644
--- a/google-cloud-storage/src/test/java/org/jclouds/googlecloudstorage/parse/BucketAclListTest.java
+++ b/google-cloud-storage/src/test/java/org/jclouds/googlecloudstorage/parse/BucketAclListTest.java
@@ -42,7 +42,7 @@ public class BucketAclListTest extends BaseGoogleCloudStorageParseTest<ListBucke
.id("jcloudtestbucket/project-owners-1082289308625")
.selfLink(
URI.create("https://content.googleapis.com/storage/v1/b/jcloudtestbucket/acl/project-owners-1082289308625"))
- .projectTeam(ProjectTeam.builder().projectId("1082289308625").team(Team.OWNERS).build())
+ .projectTeam(ProjectTeam.builder().projectNumber("1082289308625").team(Team.OWNERS).build())
.bucket("jcloudtestbucket").entity("project-owners-1082289308625").role(Role.OWNER).etag("CAc=").build();
@Override
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/38e05f6c/google-cloud-storage/src/test/java/org/jclouds/googlecloudstorage/parse/DefaultObjectAclGetTest.java
----------------------------------------------------------------------
diff --git a/google-cloud-storage/src/test/java/org/jclouds/googlecloudstorage/parse/DefaultObjectAclGetTest.java b/google-cloud-storage/src/test/java/org/jclouds/googlecloudstorage/parse/DefaultObjectAclGetTest.java
index 69e74bc..dd5549d 100644
--- a/google-cloud-storage/src/test/java/org/jclouds/googlecloudstorage/parse/DefaultObjectAclGetTest.java
+++ b/google-cloud-storage/src/test/java/org/jclouds/googlecloudstorage/parse/DefaultObjectAclGetTest.java
@@ -36,7 +36,7 @@ public class DefaultObjectAclGetTest extends BaseGoogleCloudStorageParseTest<Def
@Consumes(MediaType.APPLICATION_JSON)
public DefaultObjectAccessControls expected() {
return DefaultObjectAccessControls.builder().entity("project-owners-1082289308625").role(ObjectRole.OWNER)
- .etag("CAk=").projectTeam(ProjectTeam.builder().projectId("1082289308625").team(Team.OWNERS).build())
+ .etag("CAk=").projectTeam(ProjectTeam.builder().projectNumber("1082289308625").team(Team.OWNERS).build())
.build();
}
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/38e05f6c/google-cloud-storage/src/test/java/org/jclouds/googlecloudstorage/parse/DefaultObjectAclListTest.java
----------------------------------------------------------------------
diff --git a/google-cloud-storage/src/test/java/org/jclouds/googlecloudstorage/parse/DefaultObjectAclListTest.java b/google-cloud-storage/src/test/java/org/jclouds/googlecloudstorage/parse/DefaultObjectAclListTest.java
index 5ed276e..06e53b6 100644
--- a/google-cloud-storage/src/test/java/org/jclouds/googlecloudstorage/parse/DefaultObjectAclListTest.java
+++ b/google-cloud-storage/src/test/java/org/jclouds/googlecloudstorage/parse/DefaultObjectAclListTest.java
@@ -33,7 +33,7 @@ public class DefaultObjectAclListTest extends BaseGoogleCloudStorageParseTest<Li
private DefaultObjectAccessControls item_1 = DefaultObjectAccessControls.builder()
.entity("project-owners-1082289308625").role(ObjectRole.OWNER)
- .projectTeam(ProjectTeam.builder().projectId("1082289308625").team(Team.OWNERS).build()).etag("CAk=")
+ .projectTeam(ProjectTeam.builder().projectNumber("1082289308625").team(Team.OWNERS).build()).etag("CAk=")
.build();
@Override
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/38e05f6c/google-cloud-storage/src/test/java/org/jclouds/googlecloudstorage/parse/FullBucketGetTest.java
----------------------------------------------------------------------
diff --git a/google-cloud-storage/src/test/java/org/jclouds/googlecloudstorage/parse/FullBucketGetTest.java b/google-cloud-storage/src/test/java/org/jclouds/googlecloudstorage/parse/FullBucketGetTest.java
index 473ba93..4673721 100644
--- a/google-cloud-storage/src/test/java/org/jclouds/googlecloudstorage/parse/FullBucketGetTest.java
+++ b/google-cloud-storage/src/test/java/org/jclouds/googlecloudstorage/parse/FullBucketGetTest.java
@@ -43,7 +43,7 @@ public class FullBucketGetTest extends BaseGoogleCloudStorageParseTest<Bucket> {
.selfLink(
URI.create("https://www.googleapis.com/storage/v1/b/jcloudtestbucket3500/acl/project-owners-1082289308625"))
.bucket("jcloudtestbucket3500").entity("project-owners-1082289308625").role(Role.OWNER)
- .projectTeam(ProjectTeam.builder().projectId("1082289308625").team(Team.OWNERS).build()).etag("CAo=")
+ .projectTeam(ProjectTeam.builder().projectNumber("1082289308625").team(Team.OWNERS).build()).etag("CAo=")
.build();
private final DefaultObjectAccessControls defObjectAcl = DefaultObjectAccessControls.builder()
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/38e05f6c/google-cloud-storage/src/test/java/org/jclouds/googlecloudstorage/parse/ObjectAclGetTest.java
----------------------------------------------------------------------
diff --git a/google-cloud-storage/src/test/java/org/jclouds/googlecloudstorage/parse/ObjectAclGetTest.java b/google-cloud-storage/src/test/java/org/jclouds/googlecloudstorage/parse/ObjectAclGetTest.java
new file mode 100644
index 0000000..bafdf8e
--- /dev/null
+++ b/google-cloud-storage/src/test/java/org/jclouds/googlecloudstorage/parse/ObjectAclGetTest.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 org.jclouds.googlecloudstorage.parse;
+
+import java.net.URI;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.core.MediaType;
+
+import org.jclouds.googlecloudstorage.domain.DomainResourceRefferences.ObjectRole;
+import org.jclouds.googlecloudstorage.domain.ObjectAccessControls;
+import org.jclouds.googlecloudstorage.domain.internal.ProjectTeam;
+import org.jclouds.googlecloudstorage.domain.internal.ProjectTeam.Team;
+import org.jclouds.googlecloudstorage.internal.BaseGoogleCloudStorageParseTest;
+
+public class ObjectAclGetTest extends BaseGoogleCloudStorageParseTest<ObjectAccessControls> {
+
+ @Override
+ public String resource() {
+ return "/objectacl_get.json";
+ }
+
+ @Override
+ @Consumes(MediaType.APPLICATION_JSON)
+ public ObjectAccessControls expected() {
+ return ObjectAccessControls
+ .builder()
+ .bucket("jcloudtestbucket")
+ .object("foo.txt")
+ .generation(1394121608485000L)
+ .entity("project-owners-1082289308625")
+ .role(ObjectRole.OWNER)
+ .etag("CIix/dmj/rwCEAE=")
+ .projectTeam(ProjectTeam.builder().projectNumber("1082289308625").team(Team.OWNERS).build())
+ .selfLink(
+ URI.create("https://www.googleapis.com/storage/v1/b/jcloudtestbucket/o/foo.txt/acl/project-owners-1082289308625"))
+ .id("jcloudtestbucket/foo.txt/1394121608485000/project-owners-1082289308625").build();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/38e05f6c/google-cloud-storage/src/test/java/org/jclouds/googlecloudstorage/parse/ObjectAclInsertTest.java
----------------------------------------------------------------------
diff --git a/google-cloud-storage/src/test/java/org/jclouds/googlecloudstorage/parse/ObjectAclInsertTest.java b/google-cloud-storage/src/test/java/org/jclouds/googlecloudstorage/parse/ObjectAclInsertTest.java
new file mode 100644
index 0000000..229dcde
--- /dev/null
+++ b/google-cloud-storage/src/test/java/org/jclouds/googlecloudstorage/parse/ObjectAclInsertTest.java
@@ -0,0 +1,49 @@
+/*
+ * 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.parse;
+
+import java.net.URI;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.core.MediaType;
+
+import org.jclouds.googlecloudstorage.domain.DomainResourceRefferences.ObjectRole;
+import org.jclouds.googlecloudstorage.domain.ObjectAccessControls;
+import org.jclouds.googlecloudstorage.internal.BaseGoogleCloudStorageParseTest;
+
+public class ObjectAclInsertTest extends BaseGoogleCloudStorageParseTest<ObjectAccessControls> {
+
+ @Override
+ public String resource() {
+ return "/objectacl_insert_response.json";
+ }
+
+ @Override
+ @Consumes(MediaType.APPLICATION_JSON)
+ public ObjectAccessControls expected() {
+ return ObjectAccessControls
+ .builder()
+ .selfLink(
+ URI.create("https://www.googleapis.com/storage/v1/b/jcloudtestbucket/o/foo.txt/acl/user-00b4903a97adfde729f0650133a7379693099d8d85d6b1b18255ca70bf89e31d"))
+ .bucket("jcloudtestbucket").object("foo.txt")
+ .entity("user-00b4903a97adfde729f0650133a7379693099d8d85d6b1b18255ca70bf89e31d")
+ .entityId("00b4903a97adfde729f0650133a7379693099d8d85d6b1b18255ca70bf89e31d").role(ObjectRole.OWNER)
+ .etag("CIix/dmj/rwCEAE=").build();
+
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/38e05f6c/google-cloud-storage/src/test/java/org/jclouds/googlecloudstorage/parse/ObjectAclListTest.java
----------------------------------------------------------------------
diff --git a/google-cloud-storage/src/test/java/org/jclouds/googlecloudstorage/parse/ObjectAclListTest.java b/google-cloud-storage/src/test/java/org/jclouds/googlecloudstorage/parse/ObjectAclListTest.java
new file mode 100644
index 0000000..6cd98ae
--- /dev/null
+++ b/google-cloud-storage/src/test/java/org/jclouds/googlecloudstorage/parse/ObjectAclListTest.java
@@ -0,0 +1,55 @@
+/*
+ * 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.parse;
+
+import java.net.URI;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.core.MediaType;
+
+import org.jclouds.googlecloudstorage.domain.DomainResourceRefferences.ObjectRole;
+import org.jclouds.googlecloudstorage.domain.ListObjectAccessControls;
+import org.jclouds.googlecloudstorage.domain.ObjectAccessControls;
+import org.jclouds.googlecloudstorage.domain.Resource.Kind;
+import org.jclouds.googlecloudstorage.internal.BaseGoogleCloudStorageParseTest;
+
+import com.google.common.collect.ImmutableSet;
+
+public class ObjectAclListTest extends BaseGoogleCloudStorageParseTest<ListObjectAccessControls> {
+
+ private ObjectAccessControls item1 = ObjectAccessControls
+ .builder()
+ .id("jcloudtestbucket/foo.txt/1394121608485000/user-00b4903a97adfde729f0650133a7379693099d8d85d6b1b18255ca70bf89e31d")
+ .selfLink(
+ URI.create("https://www.googleapis.com/storage/v1/b/jcloudtestbucket/o/foo.txt/acl/user-00b4903a97adfde729f0650133a7379693099d8d85d6b1b18255ca70bf89e31d"))
+ .bucket("jcloudtestbucket").object("foo.txt").generation(Long.valueOf("1394121608485000"))
+ .entity("user-00b4903a97adfde729f0650133a7379693099d8d85d6b1b18255ca70bf89e31d")
+ .entityId("00b4903a97adfde729f0650133a7379693099d8d85d6b1b18255ca70bf89e31d").role(ObjectRole.OWNER)
+ .etag("CIix/dmj/rwCEAE=").build();
+
+ @Override
+ public String resource() {
+ return "/objectacl_list.json";
+ }
+
+ @Override
+ @Consumes(MediaType.APPLICATION_JSON)
+ public ListObjectAccessControls expected() {
+ return ListObjectAccessControls.builder().kind(Kind.OBJECT_ACCESS_CONTROLS).items(ImmutableSet.of(item1)).build();
+ }
+
+}