http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/a4acb11f/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/blobstore/functions/BlobStoreListContainerOptionsToListObjectOptions.java ---------------------------------------------------------------------- diff --git a/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/blobstore/functions/BlobStoreListContainerOptionsToListObjectOptions.java b/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/blobstore/functions/BlobStoreListContainerOptionsToListObjectOptions.java deleted file mode 100644 index 15b5f4f..0000000 --- a/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/blobstore/functions/BlobStoreListContainerOptionsToListObjectOptions.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * 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.blobstore.functions; - -import static com.google.common.base.Preconditions.checkNotNull; - -import org.jclouds.blobstore.options.ListContainerOptions; -import org.jclouds.googlecloudstorage.options.ListObjectOptions; - -import com.google.common.base.Function; - -public class BlobStoreListContainerOptionsToListObjectOptions implements - Function<ListContainerOptions, ListObjectOptions> { - public ListObjectOptions apply(ListContainerOptions from) { - if (from.getDir() != null && (from.getPrefix() != null || from.getDelimiter() != null)) { - throw new IllegalArgumentException("Cannot pass both directory and prefix/delimiter"); - } - checkNotNull(from, "set options to instance NONE instead of passing null"); - ListObjectOptions httpOptions = new ListObjectOptions(); - - if (!from.isRecursive() && from.getDelimiter() == null) { - httpOptions = httpOptions.delimiter("/"); - } - if (from.getDelimiter() != null) { - httpOptions = httpOptions.delimiter(from.getDelimiter()); - } - if (from.getDir() != null) { - String path = from.getDir(); - if (!path.endsWith("/")) - path += "/"; - httpOptions = httpOptions.prefix(path); - } - if (from.getPrefix() != null) { - httpOptions.prefix(from.getPrefix()); - } - if (from.getMarker() != null) { - httpOptions = httpOptions.pageToken(from.getMarker()); - } - if (from.getMaxResults() != null) { - httpOptions = httpOptions.maxResults(from.getMaxResults()); - } - return httpOptions; - } -}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/a4acb11f/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/blobstore/functions/BucketToStorageMetadata.java ---------------------------------------------------------------------- diff --git a/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/blobstore/functions/BucketToStorageMetadata.java b/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/blobstore/functions/BucketToStorageMetadata.java deleted file mode 100644 index f96462a..0000000 --- a/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/blobstore/functions/BucketToStorageMetadata.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * 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.blobstore.functions; - -import javax.inject.Inject; - -import org.jclouds.blobstore.domain.MutableStorageMetadata; -import org.jclouds.blobstore.domain.StorageMetadata; -import org.jclouds.blobstore.domain.StorageType; -import org.jclouds.blobstore.domain.internal.MutableStorageMetadataImpl; -import org.jclouds.domain.Location; -import org.jclouds.googlecloudstorage.domain.Bucket; - -import com.google.common.base.Function; -import com.google.common.base.Supplier; - -public class BucketToStorageMetadata implements Function<Bucket, StorageMetadata> { - private Supplier<Location> defaultLocation; - - @Inject BucketToStorageMetadata(Supplier<Location> defaultLocation) { - this.defaultLocation = defaultLocation; - } - - public StorageMetadata apply(Bucket from) { - MutableStorageMetadata to = new MutableStorageMetadataImpl(); - to.setName(from.name()); - to.setLocation(defaultLocation.get()); - to.setType(StorageType.CONTAINER); - return to; - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/a4acb11f/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/blobstore/functions/ObjectListToStorageMetadata.java ---------------------------------------------------------------------- diff --git a/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/blobstore/functions/ObjectListToStorageMetadata.java b/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/blobstore/functions/ObjectListToStorageMetadata.java deleted file mode 100644 index 4f7f1d0..0000000 --- a/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/blobstore/functions/ObjectListToStorageMetadata.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * 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.blobstore.functions; - -import java.util.SortedSet; - -import javax.inject.Inject; - -import org.jclouds.blobstore.domain.MutableStorageMetadata; -import org.jclouds.blobstore.domain.PageSet; -import org.jclouds.blobstore.domain.StorageMetadata; -import org.jclouds.blobstore.domain.StorageType; -import org.jclouds.blobstore.domain.internal.MutableStorageMetadataImpl; -import org.jclouds.blobstore.domain.internal.PageSetImpl; -import org.jclouds.googlecloudstorage.domain.GoogleCloudStorageObject; -import org.jclouds.googlecloudstorage.domain.ListPageWithPrefixes; - -import com.google.common.base.Function; -import com.google.common.collect.Iterables; -import com.google.common.collect.Sets; - -public class ObjectListToStorageMetadata - implements Function<ListPageWithPrefixes<GoogleCloudStorageObject>, PageSet<? extends StorageMetadata>> { - private final ObjectToBlobMetadata object2blobMd; - - @Inject public ObjectListToStorageMetadata(ObjectToBlobMetadata object2blobMd) { - this.object2blobMd = object2blobMd; - } - - public PageSet<? extends StorageMetadata> apply(ListPageWithPrefixes<GoogleCloudStorageObject> from) { - if (from == null) { - from = ListPageWithPrefixes.create(null, null, null); - } - - SortedSet<StorageMetadata> results = Sets.<StorageMetadata> newTreeSet(Iterables.transform(from, object2blobMd)); - for (String prefix : from.prefixes()) { - MutableStorageMetadata metadata = new MutableStorageMetadataImpl(); - metadata.setType(StorageType.RELATIVE_PATH); - metadata.setName(prefix); - results.add(metadata); - } - return new PageSetImpl<StorageMetadata>(results, from.nextPageToken()); - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/a4acb11f/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/blobstore/functions/ObjectToBlobMetadata.java ---------------------------------------------------------------------- diff --git a/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/blobstore/functions/ObjectToBlobMetadata.java b/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/blobstore/functions/ObjectToBlobMetadata.java deleted file mode 100644 index 4a6cf7d..0000000 --- a/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/blobstore/functions/ObjectToBlobMetadata.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * 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.blobstore.functions; - - -import org.jclouds.blobstore.domain.MutableBlobMetadata; -import org.jclouds.blobstore.domain.StorageType; -import org.jclouds.blobstore.domain.internal.MutableBlobMetadataImpl; -import org.jclouds.googlecloudstorage.domain.GoogleCloudStorageObject; -import org.jclouds.javax.annotation.Nullable; - -import com.google.common.base.Function; -import com.google.common.hash.HashCode; -import com.google.common.io.BaseEncoding; - -public class ObjectToBlobMetadata implements Function<GoogleCloudStorageObject, MutableBlobMetadata> { - - public MutableBlobMetadata apply(GoogleCloudStorageObject from) { - if (from == null) { - return null; - } - MutableBlobMetadata to = new MutableBlobMetadataImpl(); - to.getContentMetadata().setContentMD5(toHashCode(from.md5Hash())); - to.getContentMetadata().setContentType(from.contentType()); - to.getContentMetadata().setContentDisposition(from.contentDisposition()); - to.getContentMetadata().setContentEncoding(from.contentEncoding()); - to.getContentMetadata().setContentLanguage(from.contentLanguage()); - to.getContentMetadata().setContentLength(from.size()); - to.setLastModified(from.updated()); - to.setContainer(from.bucket()); - to.setUserMetadata(from.metadata()); - to.setETag(from.etag()); - to.setName(from.name()); - to.setUri(from.selfLink()); - to.setId(from.id()); - to.setPublicUri(from.mediaLink()); - to.setType(StorageType.BLOB); - to.setSize(from.size()); - return to; - } - - private static HashCode toHashCode(@Nullable String hashCode) { - return hashCode == null ? null : HashCode.fromBytes(BaseEncoding.base64().decode(hashCode)); - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/a4acb11f/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/config/GoogleCloudStorageHttpApiModule.java ---------------------------------------------------------------------- diff --git a/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/config/GoogleCloudStorageHttpApiModule.java b/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/config/GoogleCloudStorageHttpApiModule.java deleted file mode 100644 index 862f38f..0000000 --- a/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/config/GoogleCloudStorageHttpApiModule.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * 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 javax.inject.Singleton; - -import org.jclouds.domain.Credentials; -import org.jclouds.googlecloud.config.CurrentProject; -import org.jclouds.googlecloudstorage.GoogleCloudStorageApi; -import org.jclouds.googlecloudstorage.handlers.GoogleCloudStorageErrorHandler; -import org.jclouds.http.HttpErrorHandler; -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.ConfiguresHttpApi; -import org.jclouds.rest.config.HttpApiModule; - -import com.google.common.base.Function; -import com.google.common.base.Supplier; -import com.google.common.base.Suppliers; -import com.google.inject.Provides; - -@ConfiguresHttpApi -public class GoogleCloudStorageHttpApiModule extends HttpApiModule<GoogleCloudStorageApi> { - - @Override public void configure(){ - super.configure(); - bind(OAuthScopes.class).toInstance(GoogleCloudStorageOAuthScopes.create()); - } - - @Override - protected void bindErrorHandlers() { - bind(HttpErrorHandler.class).annotatedWith(Redirection.class).to(GoogleCloudStorageErrorHandler.class); - bind(HttpErrorHandler.class).annotatedWith(ClientError.class).to(GoogleCloudStorageErrorHandler.class); - bind(HttpErrorHandler.class).annotatedWith(ServerError.class).to(GoogleCloudStorageErrorHandler.class); - } - - @Provides - @Singleton @CurrentProject - public Supplier<String> supplyProject(@Provider final Supplier<Credentials> creds) { - return Suppliers.compose(new Function<Credentials, String>() { - @Override public String apply(Credentials in) { - return CurrentProject.ClientEmail.toProjectNumber(in.identity); - } - }, creds); - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/a4acb11f/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/config/GoogleCloudStorageOAuthScopes.java ---------------------------------------------------------------------- diff --git a/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/config/GoogleCloudStorageOAuthScopes.java b/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/config/GoogleCloudStorageOAuthScopes.java deleted file mode 100644 index 358c9a0..0000000 --- a/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/config/GoogleCloudStorageOAuthScopes.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * 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(); - } else if (input.getMethod().equalsIgnoreCase("PUT") || input.getMethod().equalsIgnoreCase("PATCH")) { - return fullControlScopes(); - } - return readOrWriteScopes().forRequest(input); - } - - GoogleCloudStorageOAuthScopes() { - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/a4acb11f/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/config/GoogleCloudStorageParserModule.java ---------------------------------------------------------------------- diff --git a/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/config/GoogleCloudStorageParserModule.java b/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/config/GoogleCloudStorageParserModule.java deleted file mode 100644 index 77933a7..0000000 --- a/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/config/GoogleCloudStorageParserModule.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * 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.lang.reflect.Type; -import java.util.Map; -import java.util.Set; - -import javax.inject.Singleton; - -import org.jclouds.googlecloud.config.ListPageAdapterFactory; -import org.jclouds.googlecloudstorage.domain.templates.BucketTemplate; -import org.jclouds.json.config.GsonModule; - -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableSet; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonSerializationContext; -import com.google.gson.JsonSerializer; -import com.google.gson.TypeAdapterFactory; -import com.google.inject.AbstractModule; -import com.google.inject.Provides; - -public class GoogleCloudStorageParserModule extends AbstractModule { - - @Override protected void configure() { - bind(GsonModule.DateAdapter.class).to(GsonModule.Iso8601DateAdapter.class); - } - - @Provides @Singleton public Map<Type, Object> typeAdapters() { - return new ImmutableMap.Builder<Type, Object>() - .put(BucketTemplate.class, new BucketTemplateTypeAdapter()) - .build(); - } - - // TODO: change jclouds core to use collaborative set bindings - @Provides @Singleton Set<TypeAdapterFactory> typeAdapterFactories() { - return ImmutableSet.<TypeAdapterFactory>of(new ListPageAdapterFactory()); - } - - private static class BucketTemplateTypeAdapter implements JsonSerializer<BucketTemplate> { - - @Override - public JsonElement serialize(BucketTemplate src, Type typeOfSrc, JsonSerializationContext context) { - BucketTemplateInternal template = new BucketTemplateInternal(src); - JsonObject bucketTemplate = (JsonObject) context.serialize(template, BucketTemplateInternal.class); - - // deal with bucketAccessControls - if (!(src.acl() == null) && (src.acl().isEmpty())) { - bucketTemplate.add("acl", null); - } - // deal with DefaultObjectAccessControls - if (!(src.defaultObjectAccessControls() == null) && (src.defaultObjectAccessControls().isEmpty())) { - bucketTemplate.add("defaultObjectAccessControls", null); - } - - // deal with Cors - if (!(src.cors() == null) && (src.cors().isEmpty())) { - bucketTemplate.add("cors", null); - } - - return bucketTemplate; - } - - private static class BucketTemplateInternal extends BucketTemplate { - private BucketTemplateInternal(BucketTemplate template) { - name(template.name()).projectNumber(template.projectNumber()).acl(template.acl()) - .defaultObjectAccessControls(template.defaultObjectAccessControls()).owner(template.owner()) - .location(template.location()).website(template.website()).logging(template.logging()) - .versioning(template.versioning()).cors(template.cors()).lifeCycle(template.lifeCycle()) - .storageClass(template.storageClass()); - } - } - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/a4acb11f/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/Bucket.java ---------------------------------------------------------------------- diff --git a/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/Bucket.java b/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/Bucket.java deleted file mode 100644 index d0f4b33..0000000 --- a/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/Bucket.java +++ /dev/null @@ -1,181 +0,0 @@ -/* - * 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 org.jclouds.googlecloud.internal.NullSafeCopies.copyOf; - -import java.util.Date; -import java.util.List; - -import org.jclouds.googlecloudstorage.domain.DomainResourceReferences.Location; -import org.jclouds.googlecloudstorage.domain.DomainResourceReferences.StorageClass; -import org.jclouds.javax.annotation.Nullable; -import org.jclouds.json.SerializedNames; - -import com.google.auto.value.AutoValue; - -/** - * The Bucket represents a bucket in Google Cloud Storage. There is a single global namespace shared by all buckets. - * - * @see <a href = " https://developers.google.com/storage/docs/json_api/v1/buckets"/> - */ -@AutoValue -public abstract class Bucket { - @AutoValue - public abstract static class Cors { - public abstract List<String> origin(); - - public abstract List<String> method(); - - public abstract List<String> responseHeader(); - - public abstract Integer maxAgeSeconds(); - - @SerializedNames({ "origin", "method", "responseHeader", "maxAgeSeconds" }) - public static Cors create(List<String> origin, List<String> method, List<String> responseHeader, - Integer maxAgeSeconds) { - return new AutoValue_Bucket_Cors(copyOf(origin), copyOf(method), copyOf(responseHeader), maxAgeSeconds); - } - } - - @AutoValue - public abstract static class Logging { - public abstract String logBucket(); - - @Nullable public abstract String logObjectPrefix(); - - @SerializedNames({ "logBucket", "logObjectPrefix" }) - public static Logging create(String logBucket, String logObjectPrefix) { - return new AutoValue_Bucket_Logging(logBucket, logObjectPrefix); - } - } - - @AutoValue - public abstract static class LifeCycle { - - @AutoValue - public abstract static class Rule { - - @AutoValue - public abstract static class Action { - public abstract String type(); - - @SerializedNames("type") - public static Action create(String type) { - return new AutoValue_Bucket_LifeCycle_Rule_Action(type); - } - } - - @AutoValue - public abstract static class Condition { - @Nullable public abstract Integer age(); - - @Nullable public abstract Date createdBefore(); - - @Nullable public abstract Boolean isLive(); - - @Nullable public abstract Integer numNewerVersions(); - - @SerializedNames({ "age", "createdBefore", "isLive", "numNewerVersions" }) - public static Condition create(Integer age, Date createdBefore, Boolean isLive, Integer numNewerVersions) { - return new AutoValue_Bucket_LifeCycle_Rule_Condition(age, createdBefore, isLive, numNewerVersions); - } - } - - public abstract Action action(); - - public abstract Condition condition(); - - @SerializedNames({ "action", "condition" }) - public static Rule create(Action action, Condition condition) { - return new AutoValue_Bucket_LifeCycle_Rule(action, condition); - } - } - - public abstract List<Rule> rules(); - - @SerializedNames("rules") - public static LifeCycle create(List<Rule> rules) { - return new AutoValue_Bucket_LifeCycle(copyOf(rules)); - } - } - - @AutoValue - public abstract static class Website { - @Nullable public abstract String mainPageSuffix(); - - @Nullable public abstract String notFoundPage(); - - @SerializedNames({ "mainPageSuffix", "notFoundPage" }) - public static Website create(String mainPageSuffix, String notFoundPage) { - return new AutoValue_Bucket_Website(mainPageSuffix, notFoundPage); - } - } - - @AutoValue - public abstract static class Versioning { - public abstract Boolean enabled(); - - @SerializedNames("enabled") - public static Versioning create(Boolean enabled) { - return new AutoValue_Bucket_Versioning(enabled); - } - } - - public abstract String id(); - - public abstract String name(); - - @Nullable public abstract Long projectNumber(); - - public abstract Date timeCreated(); - - public abstract Long metageneration(); - - public abstract List<BucketAccessControls> acl(); - - public abstract List<ObjectAccessControls> defaultObjectAcl(); - - @Nullable public abstract Owner owner(); - - @Nullable public abstract Location location(); - - @Nullable public abstract Website website(); - - @Nullable public abstract Logging logging(); - - @Nullable public abstract Versioning versioning(); - - public abstract List<Cors> cors(); - - @Nullable public abstract LifeCycle lifeCycle(); - - @Nullable public abstract StorageClass storageClass(); - - @SerializedNames( - { "id", "name", "projectNumber", "timeCreated", "metageneration", "acl", "defaultObjectAcl", "owner", - "location", "website", "logging", "versioning", "cors", "lifeCycle", "storageClass" }) - public static Bucket create(String id, String name, Long projectNumber, Date timeCreated, Long metageneration, - List<BucketAccessControls> acl, List<ObjectAccessControls> defaultObjectAcl, Owner owner, - Location location, Website website, Logging logging, Versioning versioning, List<Cors> cors, - LifeCycle lifeCycle, StorageClass storageClass) { - return new AutoValue_Bucket(id, name, projectNumber, timeCreated, metageneration, copyOf(acl), - copyOf(defaultObjectAcl), owner, location, website, logging, versioning, copyOf(cors), lifeCycle, - storageClass); - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/a4acb11f/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 deleted file mode 100644 index 732057a..0000000 --- a/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/BucketAccessControls.java +++ /dev/null @@ -1,122 +0,0 @@ -/* - * 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.javax.annotation.Nullable; -import org.jclouds.json.SerializedNames; - -import com.google.auto.value.AutoValue; - -/** - * Represents a BucketAccessControls Resource - * - * @see <a href= "https://developers.google.com/storage/docs/json_api/v1/bucketAccessControls" /> - */ -@AutoValue -public abstract class BucketAccessControls { - - public enum Role { - READER, WRITER, OWNER - } - - // TODO: ensure this is actually needed on input. - public abstract String kind(); - - public abstract String id(); - - public abstract String bucket(); - - public abstract String entity(); - - @Nullable public abstract String entityId(); - - public abstract Role role(); - - @Nullable public abstract String email(); - - @Nullable public abstract String domain(); - - @Nullable public abstract ProjectTeam projectTeam(); - - @SerializedNames({ "kind", "id", "bucket", "entity", "entityId", "role", "email", "domain", "projectTeam" }) - static BucketAccessControls create(String kind, String id, String bucket, String entity, String entityId, Role role, - String email, String domain, ProjectTeam projectTeam) { - return new AutoValue_BucketAccessControls(kind, - id == null ? (bucket + "/" + entity) : id, bucket, entity, entityId, role, email, domain, projectTeam); - } - - public static Builder builder() { - return new Builder(); - } - - public static final class Builder { - - private String id; - private String bucket; - private String entity; - private String entityId; - private Role role; - private String email; - private String domain; - private ProjectTeam projectTeam; - - public Builder id(String id) { - this.id = id; - return this; - } - - public Builder bucket(String bucket) { - this.bucket = bucket; - 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(Role 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 BucketAccessControls build() { - return BucketAccessControls - .create("storage#bucketAccessControl", id, bucket, entity, entityId, role, email, domain, projectTeam); - } - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/a4acb11f/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/DomainResourceReferences.java ---------------------------------------------------------------------- diff --git a/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/DomainResourceReferences.java b/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/DomainResourceReferences.java deleted file mode 100644 index cc3b9dc..0000000 --- a/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/DomainResourceReferences.java +++ /dev/null @@ -1,105 +0,0 @@ -/* - * 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 com.google.common.base.CaseFormat; - -public final class DomainResourceReferences { - - private DomainResourceReferences() { - } - - public enum ObjectRole { - READER, OWNER - } - - public enum Location { - ASIA, EU, US, ASIA_EAST1, US_CENTRAL1, US_CENTRAL2, US_EAST1, US_EAST2, US_EAST3, US_WEST1; - - public String value() { - return name().replace('_', '-'); - } - - @Override - public String toString() { - return value(); - } - - public static Location fromValue(String location) { - return valueOf(location.replace('-', '_')); - } - } - - public enum StorageClass { - COLDLINE, - DURABLE_REDUCED_AVAILABILITY, - MULTI_REGIONAL, - NEARLINE, - STANDARD; - } - - public enum Projection { - NO_ACL, FULL; - - public String value() { - return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, name()); - } - - @Override - public String toString() { - return value(); - } - - public static Projection fromValue(String projection) { - return valueOf(CaseFormat.LOWER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, projection)); - } - } - - public enum PredefinedAcl { - AUTHENTICATED_READ, PRIVATE, PROJEECT_PRIVATE, PUBLIC_READ, PUBLIC_READ_WRITE; - - public String value() { - return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, name()); - } - - @Override - public String toString() { - return value(); - } - - public static PredefinedAcl fromValue(String predefinedAcl) { - return valueOf(CaseFormat.LOWER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, predefinedAcl)); - } - } - - public enum DestinationPredefinedAcl { - AUTHENTICATED_READ, BUCKET_OWNER_FULLCONTROL, BUCKET_OWNER_READ, PRIVATE, PROJECT_PRIVATE, PUBLIC_READ; - - public String value() { - return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, name()); - } - - @Override - public String toString() { - return value(); - } - - public static DestinationPredefinedAcl fromValue(String destinationPredefinedAcl) { - return valueOf(CaseFormat.LOWER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, destinationPredefinedAcl)); - } - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/a4acb11f/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/GoogleCloudStorageObject.java ---------------------------------------------------------------------- diff --git a/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/GoogleCloudStorageObject.java b/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/GoogleCloudStorageObject.java deleted file mode 100644 index ce48e4f..0000000 --- a/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/GoogleCloudStorageObject.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * 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 org.jclouds.googlecloud.internal.NullSafeCopies.copyOf; - -import java.net.URI; -import java.util.Date; -import java.util.List; -import java.util.Map; - -import org.jclouds.googlecloudstorage.domain.DomainResourceReferences.StorageClass; -import org.jclouds.javax.annotation.Nullable; -import org.jclouds.json.SerializedNames; - -import com.google.auto.value.AutoValue; - -/** - * This class represent an object in a Google Cloud Storage Bucket. - * - * @see <a href = "https://developers.google.com/storage/docs/json_api/v1/Objects"/> - */ -@AutoValue -// TODO: nullable sweep -public abstract class GoogleCloudStorageObject { - - public abstract String id(); - public abstract URI selfLink(); - public abstract String etag(); - public abstract String name(); - public abstract String bucket(); - public abstract long generation(); - public abstract long metageneration(); - @Nullable public abstract String contentType(); - public abstract Date updated(); - @Nullable public abstract Date timeDeleted(); - public abstract StorageClass storageClass(); - public abstract long size(); - @Nullable public abstract String md5Hash(); - public abstract URI mediaLink(); - public abstract Map<String, String> metadata(); - @Nullable public abstract String contentEncoding(); - @Nullable public abstract String contentDisposition(); - @Nullable public abstract String contentLanguage(); - @Nullable public abstract String cacheControl(); - public abstract List<ObjectAccessControls> acl(); - @Nullable public abstract Owner owner(); - @Nullable public abstract String crc32c(); - @Nullable public abstract Integer componentCount(); - - @SerializedNames( - { "id", "selfLink", "etag", "name", "bucket", "generation", "metageneration", "contentType", "updated", - "timeDeleted", "storageClass", "size", "md5Hash", "mediaLink", "metadata", "contentEncoding", - "contentDisposition", "contentLanguage", "cacheControl", "acl", "owner", "crc32c", "componentCount" }) - public static GoogleCloudStorageObject create(String id, URI selfLink, String etag, String name, String bucket, long generation, - long metageneration, String contentType, Date updated, Date timeDeleted, StorageClass storageClass, long size, - String md5Hash, URI mediaLink, Map<String, String> metadata, String contentEncoding, String contentDisposition, - String contentLanguage, String cacheControl, List<ObjectAccessControls> acl, Owner owner, String crc32c, - Integer componentCount) { - return new AutoValue_GoogleCloudStorageObject(id, selfLink, etag, name, bucket, generation, metageneration, contentType, updated, - timeDeleted, storageClass, size, md5Hash, mediaLink, copyOf(metadata), contentEncoding, contentDisposition, - contentLanguage, cacheControl, copyOf(acl), owner, crc32c, componentCount); - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/a4acb11f/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/ListPageWithPrefixes.java ---------------------------------------------------------------------- diff --git a/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/ListPageWithPrefixes.java b/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/ListPageWithPrefixes.java deleted file mode 100644 index dddb3ec..0000000 --- a/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/ListPageWithPrefixes.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * 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 org.jclouds.googlecloud.internal.NullSafeCopies.copyOf; - -import java.beans.ConstructorProperties; -import java.util.List; - -import org.jclouds.googlecloud.domain.ListPage; -import org.jclouds.javax.annotation.Nullable; - -import com.google.common.collect.ForwardingList; - -/** An immutable list that includes a token, if there is another page available. */ -public final class ListPageWithPrefixes<T> extends ForwardingList<T> implements ListPage<T> { - - private final List<T> items; - private final String nextPageToken; - private final List<String> prefixes; - - public static <T> ListPageWithPrefixes<T> create(List<T> items, String nextPageToken, List<String> prefixes) { - return new ListPageWithPrefixes<T>(items, nextPageToken, prefixes); - } - - @ConstructorProperties({ "items", "nextPageToken", "prefixes" }) - public ListPageWithPrefixes(List<T> items, String nextPageToken, List<String> prefixes) { - this.items = copyOf(items); - this.nextPageToken = nextPageToken; - this.prefixes = copyOf(prefixes); - } - - @Override @Nullable public String nextPageToken() { - return nextPageToken; - } - - public List<String> prefixes() { - return prefixes; - } - - @Override protected List<T> delegate() { - return items; - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/a4acb11f/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 deleted file mode 100644 index 6d34f4c..0000000 --- a/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/ObjectAccessControls.java +++ /dev/null @@ -1,133 +0,0 @@ -/* - * 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.DomainResourceReferences.ObjectRole; -import org.jclouds.javax.annotation.Nullable; -import org.jclouds.json.SerializedNames; - -import com.google.auto.value.AutoValue; - -/** - * Represents a Object Access Control Resource. - * - * @see <a href= "https://developers.google.com/storage/docs/json_api/v1/objectAccessControls"/> - */ -@AutoValue -public abstract class ObjectAccessControls { - private final String kind = "storage#objectAccessControl"; - - @Nullable public abstract String id(); - - @Nullable public abstract String bucket(); - - @Nullable public abstract String object(); - - @Nullable public abstract Long generation(); - - public abstract String entity(); - - @Nullable public abstract String entityId(); - - public abstract ObjectRole role(); - - @Nullable public abstract String email(); - - @Nullable public abstract String domain(); - - @Nullable public abstract ProjectTeam projectTeam(); - - @SerializedNames( - { "id", "bucket", "object", "generation", "entity", "entityId", "role", "email", "domain", "projectTeam" }) - public static ObjectAccessControls create(String id, String bucket, String object, Long generation, String entity, - String entityId, ObjectRole role, String email, String domain, ProjectTeam projectTeam) { - return new AutoValue_ObjectAccessControls(id, bucket, object, generation, entity, entityId, role, email, domain, - projectTeam); - } - - public static Builder builder() { - return new Builder(); - } - - public static final class Builder { - private String id; - private String object; - private Long generation; - private String bucket; - private String entity; - private String entityId; - private ObjectRole role; - private String email; - private String domain; - private ProjectTeam projectTeam; - - public Builder id(String id) { - this.id = id; - return this; - } - - 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 ObjectAccessControls - .create(id, bucket, object, generation, entity, entityId, role, email, domain, projectTeam); - } - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/a4acb11f/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/Owner.java ---------------------------------------------------------------------- diff --git a/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/Owner.java b/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/Owner.java deleted file mode 100644 index 57137e6..0000000 --- a/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/Owner.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * 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.javax.annotation.Nullable; -import org.jclouds.json.SerializedNames; - -import com.google.auto.value.AutoValue; - -@AutoValue -public abstract class Owner { - public abstract String entity(); - - @Nullable public abstract String entityId(); - - @SerializedNames({"entity", "entityId"}) - public static Owner create(String entity, String entityId) { - return new AutoValue_Owner(entity, entityId); - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/a4acb11f/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/ProjectTeam.java ---------------------------------------------------------------------- diff --git a/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/ProjectTeam.java b/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/ProjectTeam.java deleted file mode 100644 index 538e4c8..0000000 --- a/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/ProjectTeam.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * 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.json.SerializedNames; - -import com.google.auto.value.AutoValue; - -/** - * The bucket's logging configuration, which defines the destination bucket and optional name prefix for the current - * bucket's logs. - */ -@AutoValue -public abstract class ProjectTeam { - - public enum Team { - OWNERS, EDITORS, VIEWERS; - - public String value() { - return name().toLowerCase(); - } - - @Override - public String toString() { - return value(); - } - - public static Team fromValue(String team) { - return valueOf(team.toUpperCase()); - } - } - - public abstract String projectNumber(); - - public abstract Team team(); - - @SerializedNames({ "projectNumber", "team" }) - public static ProjectTeam create(String projectNumber, Team team) { - return new AutoValue_ProjectTeam(projectNumber, team); - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/a4acb11f/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/ResumableUpload.java ---------------------------------------------------------------------- diff --git a/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/ResumableUpload.java b/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/ResumableUpload.java deleted file mode 100644 index 556347a..0000000 --- a/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/ResumableUpload.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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.javax.annotation.Nullable; - -import com.google.auto.value.AutoValue; - -/** - * Represents results of resumable upload response. - */ -@AutoValue -public abstract class ResumableUpload { - - public abstract int statusCode(); - - @Nullable public abstract String uploadId(); - - @Nullable public abstract String contentLength(); - - @Nullable public abstract Long rangeUpperValue(); - - @Nullable public abstract Long rangeLowerValue(); - - public static ResumableUpload create(int statusCode, String uploadId, String contentLength, Long rangeLowerValue, - Long rangeUpperValue) { - return new AutoValue_ResumableUpload(statusCode, uploadId, contentLength, rangeLowerValue, rangeUpperValue); - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/a4acb11f/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/RewriteResponse.java ---------------------------------------------------------------------- diff --git a/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/RewriteResponse.java b/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/RewriteResponse.java deleted file mode 100644 index 8f37193..0000000 --- a/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/RewriteResponse.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * 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.javax.annotation.Nullable; -import org.jclouds.json.SerializedNames; - -import com.google.auto.value.AutoValue; - -@AutoValue -public abstract class RewriteResponse { - // TODO(broudy): should these be UnsignedLong? - public abstract long totalBytesRewritten(); - public abstract long objectSize(); - public abstract boolean done(); - @Nullable public abstract String rewriteToken(); - public abstract GoogleCloudStorageObject resource(); - - @SerializedNames({"totalBytesRewritten", "objectSize", "done", "rewriteToken", "resource"}) - public static RewriteResponse create(long totalBytesRewritten, long objectSize, - boolean done, String rewriteToken, GoogleCloudStorageObject resource) { - return new AutoValue_RewriteResponse(totalBytesRewritten, objectSize, done, rewriteToken, resource); - } - - RewriteResponse() { - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/a4acb11f/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/templates/BucketAccessControlsTemplate.java ---------------------------------------------------------------------- diff --git a/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/templates/BucketAccessControlsTemplate.java b/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/templates/BucketAccessControlsTemplate.java deleted file mode 100644 index 04221aa..0000000 --- a/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/templates/BucketAccessControlsTemplate.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * 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.templates; - -import org.jclouds.googlecloudstorage.domain.BucketAccessControls.Role; - -import com.google.auto.value.AutoValue; - -@AutoValue -public abstract class BucketAccessControlsTemplate { - - public abstract String entity(); - - public abstract Role role(); - - public static BucketAccessControlsTemplate create(String entity, Role role) { - return new AutoValue_BucketAccessControlsTemplate(entity, role); - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/a4acb11f/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/templates/BucketTemplate.java ---------------------------------------------------------------------- diff --git a/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/templates/BucketTemplate.java b/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/templates/BucketTemplate.java deleted file mode 100644 index 7434757..0000000 --- a/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/templates/BucketTemplate.java +++ /dev/null @@ -1,172 +0,0 @@ -/* - * 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.templates; - -import java.util.List; - -import org.jclouds.googlecloudstorage.domain.Bucket.Cors; -import org.jclouds.googlecloudstorage.domain.Bucket.LifeCycle; -import org.jclouds.googlecloudstorage.domain.Bucket.Logging; -import org.jclouds.googlecloudstorage.domain.Bucket.Versioning; -import org.jclouds.googlecloudstorage.domain.Bucket.Website; -import org.jclouds.googlecloudstorage.domain.BucketAccessControls; -import org.jclouds.googlecloudstorage.domain.DomainResourceReferences.Location; -import org.jclouds.googlecloudstorage.domain.DomainResourceReferences.StorageClass; -import org.jclouds.googlecloudstorage.domain.ObjectAccessControls; -import org.jclouds.googlecloudstorage.domain.Owner; - -import com.google.common.collect.Lists; - -public class BucketTemplate { - - private String name; - private Long projectNumber; - private List<BucketAccessControls> acl = Lists.newArrayList(); - private List<ObjectAccessControls> defaultObjectAccessControls = Lists.newArrayList(); - private Owner owner; - private Location location; - private Website website; - private Logging logging; - private Versioning versioning; - private List<Cors> cors = Lists.newArrayList(); - private LifeCycle lifeCycle; - private StorageClass storageClass; - - public BucketTemplate name(String name) { - this.name = name; - return this; - } - - public BucketTemplate projectNumber(Long projectNumber) { - this.projectNumber = projectNumber; - return this; - } - - public BucketTemplate owner(Owner owner) { - this.owner = owner; - return this; - } - - public BucketTemplate location(Location location) { - this.location = location; - return this; - } - - public BucketTemplate website(Website website) { - this.website = website; - return this; - } - - public BucketTemplate logging(Logging logging) { - this.logging = logging; - return this; - } - - public BucketTemplate versioning(Versioning versioning) { - this.versioning = versioning; - return this; - } - - public BucketTemplate lifeCycle(LifeCycle lifeCycle) { - this.lifeCycle = lifeCycle; - return this; - } - - public BucketTemplate storageClass(StorageClass storageClass) { - this.storageClass = storageClass; - return this; - } - - public BucketTemplate addAcl(BucketAccessControls bucketAccessControls) { - this.acl.add(bucketAccessControls); - return this; - } - - public BucketTemplate acl(List<BucketAccessControls> acl) { - this.acl.addAll(acl); - return this; - } - - public BucketTemplate addDefaultObjectAccessControls(ObjectAccessControls oac) { - this.defaultObjectAccessControls.add(oac); - return this; - } - - public BucketTemplate defaultObjectAccessControls(List<ObjectAccessControls> defaultObjectAcl) { - this.defaultObjectAccessControls.addAll(defaultObjectAcl); - return this; - } - - public BucketTemplate addCORS(Cors cors) { - this.cors.add(cors); - return this; - } - - public BucketTemplate cors(List<Cors> cors) { - this.cors.addAll(cors); - return this; - } - - public Long projectNumber() { - return projectNumber; - } - - public String name() { - return name; - } - - public List<BucketAccessControls> acl() { - return acl; - } - - public List<ObjectAccessControls> defaultObjectAccessControls() { - return defaultObjectAccessControls; - } - - public Owner owner() { - return owner; - } - - public Location location() { - return location; - } - - public Website website() { - return website; - } - - public Logging logging() { - return logging; - } - - public Versioning versioning() { - return versioning; - } - - public List<Cors> cors() { - return cors; - } - - public LifeCycle lifeCycle() { - return lifeCycle; - } - - public StorageClass storageClass() { - return storageClass; - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/a4acb11f/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/templates/ComposeObjectTemplate.java ---------------------------------------------------------------------- diff --git a/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/templates/ComposeObjectTemplate.java b/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/templates/ComposeObjectTemplate.java deleted file mode 100644 index 3f333d8..0000000 --- a/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/templates/ComposeObjectTemplate.java +++ /dev/null @@ -1,123 +0,0 @@ -/* - * 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.templates; - -import static com.google.common.base.Preconditions.checkNotNull; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; - -import org.jclouds.googlecloudstorage.domain.GoogleCloudStorageObject; -import org.jclouds.javax.annotation.Nullable; -import org.jclouds.json.SerializedNames; - -import com.google.auto.value.AutoValue; -import com.google.common.collect.ImmutableList; - -@AutoValue -public abstract class ComposeObjectTemplate { - - @AutoValue - public abstract static class SourceObject { - - @AutoValue - public abstract static class ObjectPreconditions { - public abstract long ifGenerationMatch(); - - @SerializedNames({"ifGenerationMatch"}) - public static ObjectPreconditions create(long ifGenerationMatch){ - return new AutoValue_ComposeObjectTemplate_SourceObject_ObjectPreconditions(ifGenerationMatch); - } - - ObjectPreconditions(){ - } - } - - public abstract String name(); - @Nullable public abstract Long generation(); - @Nullable public abstract ObjectPreconditions objectPreconditions(); - - public static SourceObject nameOnly(String name){ - return create(name, null, null); - } - - public static SourceObject createWithPrecondition(String name, Long generation, Long objectPreconditions){ - return create(name, generation, ObjectPreconditions.create(objectPreconditions)); - } - - @SerializedNames({ "name", "generation", "objectPreconditions"}) - public static SourceObject create(String name, @Nullable Long generation, - @Nullable ObjectPreconditions objectPreconditions) { - return new AutoValue_ComposeObjectTemplate_SourceObject(name, generation, objectPreconditions); - } - - SourceObject(){ - } - } - - public abstract List<SourceObject> sourceObjects(); - public abstract ObjectTemplate destination(); - - @SerializedNames({"sourceObjects", "destination"}) - public static ComposeObjectTemplate create(List<SourceObject> sourceObjects, ObjectTemplate destination) { - return new AutoValue_ComposeObjectTemplate(sourceObjects, destination); - } - - public static Builder builder(){ - return new Builder(); - } - - ComposeObjectTemplate() { - } - - public static class Builder { - private ImmutableList<SourceObject> sourceObjects; - private ObjectTemplate destination; - - Builder() { - } - - public Builder fromGoogleCloudStorageObject(Collection<GoogleCloudStorageObject> objects) { - ImmutableList.Builder<SourceObject> sourceObjects = new ImmutableList.Builder<ComposeObjectTemplate.SourceObject>(); - for (GoogleCloudStorageObject obj : objects) { - sourceObjects.add(SourceObject.createWithPrecondition(obj.name(), obj.generation(), obj.generation())); - } - this.sourceObjects = sourceObjects.build(); - return this; - } - - public Builder fromNames(List<String> SourceObjectNames) { - ArrayList<SourceObject> sourceObjects = new ArrayList<SourceObject>(); - for (String name : SourceObjectNames) { - sourceObjects.add(SourceObject.nameOnly(name)); - } - this.sourceObjects = ImmutableList.copyOf(sourceObjects); - return this; - } - - public Builder destination(ObjectTemplate destination) { - checkNotNull(destination, "destination"); - this.destination = destination; - return this; - } - - public ComposeObjectTemplate build() { - return ComposeObjectTemplate.create(sourceObjects, destination); - } - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/a4acb11f/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/templates/ObjectAccessControlsTemplate.java ---------------------------------------------------------------------- diff --git a/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/templates/ObjectAccessControlsTemplate.java b/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/templates/ObjectAccessControlsTemplate.java deleted file mode 100644 index a8e1afb..0000000 --- a/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/templates/ObjectAccessControlsTemplate.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * 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.templates; - -import org.jclouds.googlecloudstorage.domain.DomainResourceReferences.ObjectRole; - -import com.google.auto.value.AutoValue; - -@AutoValue -public abstract class ObjectAccessControlsTemplate { - - public abstract String entity(); - - public abstract ObjectRole role(); - - public static ObjectAccessControlsTemplate create(String entity, ObjectRole role) { - return new AutoValue_ObjectAccessControlsTemplate(entity, role); - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/a4acb11f/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/templates/ObjectTemplate.java ---------------------------------------------------------------------- diff --git a/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/templates/ObjectTemplate.java b/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/templates/ObjectTemplate.java deleted file mode 100644 index 1cd5aaf..0000000 --- a/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/templates/ObjectTemplate.java +++ /dev/null @@ -1,178 +0,0 @@ -/* - * 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.templates; - -import java.util.List; -import java.util.Map; - -import org.jclouds.googlecloudstorage.domain.ObjectAccessControls; - -import com.google.common.base.Objects; -import com.google.common.collect.Lists; -import com.google.common.collect.Maps; -import com.google.common.net.MediaType; - -public class ObjectTemplate { - - private String name; - private Long size; - private String cacheControl; - private String contentDisposition; - private String contentEncoding; - private String contentLanguage; - private String contentType; - private String crc32c; - private String md5Hash; - private Map<String, String> metadata; - private List<ObjectAccessControls> acl; - - public ObjectTemplate name(String name) { - this.name = name; - return this; - } - - public ObjectTemplate size(Long size) { - this.size = size; - return this; - } - - public ObjectTemplate cacheControl(String cacheControl) { - this.cacheControl = cacheControl; - return this; - } - - public ObjectTemplate contentDisposition(String contentDisposition) { - this.contentDisposition = contentDisposition; - return this; - } - - public ObjectTemplate contentEncoding(String contentEncoding) { - this.contentEncoding = contentEncoding; - return this; - } - - public ObjectTemplate contentLanguage(String contentLanguage) { - this.contentLanguage = contentLanguage; - return this; - } - - public ObjectTemplate contentType(MediaType contentType) { - this.contentType = contentType.toString(); - return this; - } - - public ObjectTemplate contentType(String contentType) { - this.contentType = contentType; - return this; - } - - public ObjectTemplate customMetadata(Map<String, String> metadata) { - if (this.metadata == null) { - this.metadata = Maps.newLinkedHashMap(); - } - this.metadata.putAll(metadata); - return this; - } - - public ObjectTemplate customMetadata(String key, String value) { - if (this.metadata == null) { - this.metadata = Maps.newLinkedHashMap(); - } - this.metadata.put(key, value); - return this; - } - - public ObjectTemplate crc32c(String crc32c) { - this.crc32c = crc32c; - return this; - } - - public ObjectTemplate md5Hash(String md5Hash) { - this.md5Hash = md5Hash; - return this; - } - - public ObjectTemplate addAcl(ObjectAccessControls acl) { - if (this.acl == null) { - this.acl = Lists.newArrayList(); - } - this.acl.add(acl); - return this; - } - - public ObjectTemplate acl(List<ObjectAccessControls> acl) { - if (this.acl == null) { - this.acl = Lists.newArrayList(); - } - this.acl.addAll(acl); - return this; - } - - public String cacheControl() { - return cacheControl; - } - - public String contentDisposition() { - return contentDisposition; - } - - public String contentEncoding() { - return contentEncoding; - } - - public String contentLanguage() { - return contentLanguage; - } - - public String contentType() { - return contentType; - } - - public Map<String, String> metadata() { - return metadata; - } - - public String name() { - return name; - } - - public Long size() { - return size; - } - - public List<ObjectAccessControls> acl() { - return acl; - } - - @Override - public String toString() { - return Objects.toStringHelper(this) - .add("name", name) - .add("size", size) - .add("cacheControl", cacheControl) - .add("contentDisposition", contentDisposition) - .add("contentEncoding", contentEncoding) - .add("contentLanguage", contentLanguage) - .add("contentType", contentType) - .add("crc32c", crc32c) - .add("md5Hash", md5Hash) - .add("metadata", metadata) - .add("acl", acl) - .toString(); - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/a4acb11f/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/features/BucketAccessControlsApi.java ---------------------------------------------------------------------- diff --git a/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/features/BucketAccessControlsApi.java b/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/features/BucketAccessControlsApi.java deleted file mode 100644 index 8bad4de..0000000 --- a/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/features/BucketAccessControlsApi.java +++ /dev/null @@ -1,172 +0,0 @@ -/* - * 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 javax.ws.rs.core.MediaType.APPLICATION_JSON; - -import java.util.List; - -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 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.filters.OAuthFilter; -import org.jclouds.rest.annotations.BinderParam; -import org.jclouds.rest.annotations.Fallback; -import org.jclouds.rest.annotations.PATCH; -import org.jclouds.rest.annotations.RequestFilters; -import org.jclouds.rest.annotations.SelectJson; -import org.jclouds.rest.annotations.SkipEncoding; -import org.jclouds.rest.binders.BindToJsonPayload; - -/** - * Provides access to BucketAccessControl entities via their REST API. - * - * @see <a href = " https://developers.google.com/storage/docs/json_api/v1/bucketAccessControls "/> - */ - -@SkipEncoding({ '/', '=' }) -@RequestFilters(OAuthFilter.class) -@Consumes(APPLICATION_JSON) -public interface BucketAccessControlsApi { - - /** - * Returns the ACL entry for the specified entity on the specified bucket. - * - * @param bucketName - * Name of the bucket which ACL is related - * @param entity - * The entity holding the permission. Can be user-userId, user-emailAddress, group-groupId, - * group-emailAddress, allUsers, or allAuthenticatedUsers. - * - * @return a BucketAccessControls resource - */ - - @Named("BucketAccessControls:get") - @GET - @Path("/b/{bucket}/acl/{entity}") - @Fallback(NullOnNotFoundOr404.class) - @Nullable - BucketAccessControls getBucketAccessControls(@PathParam("bucket") String bucketName, - @PathParam("entity") String entity); - - /** - * Creates a new ACL entry on the specified bucket. - * - * @param bucketName - * Name of the bucket of which ACL to be created - * - * @param template - * In the request body,supply a {@link BucketAccessControlsTemplate} resource with role and entity - * - * @return If successful, this method returns a BucketAccessControls resource in the response body - */ - - @Named("BucketAccessControls:insert") - @POST - @Path("/b/{bucket}/acl") - BucketAccessControls createBucketAccessControls(@PathParam("bucket") String bucketName, - @BinderParam(BindToJsonPayload.class) BucketAccessControlsTemplate template); - - /** - * Permanently deletes the ACL entry for the specified entity on the specified bucket. - * - * @param bucketName - * Name of the bucket of that ACL is related - * @return If successful, this method returns an empty response body. - */ - - @Named("BucketAccessControls:delete") - @DELETE - @Path("/b/{bucket}/acl/{entity}") - @Fallback(NullOnNotFoundOr404.class) - @Nullable - HttpResponse deleteBucketAccessControls(@PathParam("bucket") String bucketName, @PathParam("entity") String entity); - - /** - * Retrieves all ACL entries on a specified bucket - * - * @param bucketName - * Name of the bucket which ACL is related - * - * @return ListBucketAccessControls resource - */ - - @Named("BucketAccessControls:list") - @GET - @Produces(APPLICATION_JSON) - @Path("/b/{bucket}/acl") - @Fallback(NullOnNotFoundOr404.class) - @Nullable - @SelectJson("items") - List<BucketAccessControls> listBucketAccessControls(@PathParam("bucket") String bucketName); - - /** - * Updates an ACL entry on the specified bucket - * - * @param bucketName - * Name of the bucket which ACL to be created - * @param entity - * The entity holding the permission. Can be user-userId, user-emailAddress, group-groupId, - * group-emailAddress, allUsers, or allAuthenticatedUsers. In the request body, supply a - * {@link BucketAccessControlsTemplate} resource with role - * - * @return If successful, this method returns a {@link BucketAccessControlsTemplate} resource in the response body - */ - @Named("BucketAccessControls:update") - @PUT - @Produces(APPLICATION_JSON) - @Path("/b/{bucket}/acl/{entity}") - @Fallback(NullOnNotFoundOr404.class) - BucketAccessControls updateBucketAccessControls(@PathParam("bucket") String bucketName, - @PathParam("entity") String entity, - @BinderParam(BindToJsonPayload.class) BucketAccessControlsTemplate template); - - /** - * Updates an ACL entry on the specified bucket. - * - * @param bucketName - * Name of the bucket which ACL to be created - * @param entity - * The entity holding the permission. Can be user-userId, user-emailAddress, group-groupId, - * group-emailAddress, allUsers, or allAuthenticatedUsers - * - * @param template - * In the request body, supply a {@link BucketAccessControlsTemplate} resource with role - * - * @return If successful, this method returns a BucketAccessControls resource in the response body - */ - @Named("BucketAccessControls:patch") - @PATCH - @Produces(APPLICATION_JSON) - @Path("/b/{bucket}/acl/{entity}") - @Fallback(NullOnNotFoundOr404.class) - BucketAccessControls patchBucketAccessControls(@PathParam("bucket") String bucketName, - @PathParam("entity") String entity, - @BinderParam(BindToJsonPayload.class) BucketAccessControlsTemplate template); -}
