You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jclouds.apache.org by za...@apache.org on 2015/04/07 23:33:10 UTC
[12/32] jclouds git commit: JCLOUDS-547: Improved header and option
support for Swift/Cloud Files
JCLOUDS-547: Improved header and option support for Swift/Cloud Files
Project: http://git-wip-us.apache.org/repos/asf/jclouds/repo
Commit: http://git-wip-us.apache.org/repos/asf/jclouds/commit/46867d13
Tree: http://git-wip-us.apache.org/repos/asf/jclouds/tree/46867d13
Diff: http://git-wip-us.apache.org/repos/asf/jclouds/diff/46867d13
Branch: refs/heads/master
Commit: 46867d135372b130712bc0da33f95fe1e30cbbf0
Parents: 0c22936
Author: Jeremy Daggett <je...@rackspace.com>
Authored: Sun May 25 13:47:40 2014 -0700
Committer: Jeremy Daggett <je...@rackspace.com>
Committed: Sun May 25 22:08:36 2014 -0700
----------------------------------------------------------------------
.../rackspace/cloudfiles/v1/CloudFilesApi.java | 13 +++
.../cloudfiles/v1/features/CDNApi.java | 4 +-
.../v1/options/ListCDNContainerOptions.java | 86 ++++++++++++++++++++
.../v1/options/UpdateCDNContainerOptions.java | 4 +-
.../v1/reference/CloudFilesConstants.java | 27 ++++++
.../v1/reference/CloudFilesHeaders.java | 12 +--
.../v1/features/CloudFilesCDNApiLiveTest.java | 6 +-
.../v1/features/CloudFilesCDNApiMockTest.java | 6 +-
.../options/UpdateCDNContainerOptionsTest.java | 4 +-
9 files changed, 138 insertions(+), 24 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/jclouds/blob/46867d13/apis/rackspace-cloudfiles/src/main/java/org/jclouds/rackspace/cloudfiles/v1/CloudFilesApi.java
----------------------------------------------------------------------
diff --git a/apis/rackspace-cloudfiles/src/main/java/org/jclouds/rackspace/cloudfiles/v1/CloudFilesApi.java b/apis/rackspace-cloudfiles/src/main/java/org/jclouds/rackspace/cloudfiles/v1/CloudFilesApi.java
index 0d33913..e888725 100644
--- a/apis/rackspace-cloudfiles/src/main/java/org/jclouds/rackspace/cloudfiles/v1/CloudFilesApi.java
+++ b/apis/rackspace-cloudfiles/src/main/java/org/jclouds/rackspace/cloudfiles/v1/CloudFilesApi.java
@@ -48,4 +48,17 @@ public interface CloudFilesApi extends SwiftApi {
*/
@Delegate
CDNApi getCDNApiForRegion(@EndpointParam(parser = RegionToCDNEndpoint.class) @Nullable String region);
+
+ /**
+ * Provides access to Cloud Files CDN features.
+ *
+ * @param region the region to access the CDN API.
+ *
+ * @return the {@link CDNApi} for the specified region.
+ *
+ * @deprecated Please use {@link #getCDNApiForRegion(String)}. This method will be removed in jclouds 1.8.
+ */
+ @Deprecated
+ @Delegate
+ CDNApi cdnApiInRegion(@EndpointParam(parser = RegionToCDNEndpoint.class) @Nullable String region);
}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/46867d13/apis/rackspace-cloudfiles/src/main/java/org/jclouds/rackspace/cloudfiles/v1/features/CDNApi.java
----------------------------------------------------------------------
diff --git a/apis/rackspace-cloudfiles/src/main/java/org/jclouds/rackspace/cloudfiles/v1/features/CDNApi.java b/apis/rackspace-cloudfiles/src/main/java/org/jclouds/rackspace/cloudfiles/v1/features/CDNApi.java
index 306c66d..27a9e8c 100644
--- a/apis/rackspace-cloudfiles/src/main/java/org/jclouds/rackspace/cloudfiles/v1/features/CDNApi.java
+++ b/apis/rackspace-cloudfiles/src/main/java/org/jclouds/rackspace/cloudfiles/v1/features/CDNApi.java
@@ -39,12 +39,12 @@ import org.jclouds.Fallbacks.FalseOnNotFoundOr404;
import org.jclouds.Fallbacks.NullOnNotFoundOr404;
import org.jclouds.javax.annotation.Nullable;
import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest;
-import org.jclouds.openstack.swift.v1.options.ListContainerOptions;
import org.jclouds.rackspace.cloudfiles.v1.CloudFilesApi;
import org.jclouds.rackspace.cloudfiles.v1.binders.BindCDNPurgeEmailAddressesToHeaders;
import org.jclouds.rackspace.cloudfiles.v1.domain.CDNContainer;
import org.jclouds.rackspace.cloudfiles.v1.functions.ParseCDNContainerFromHeaders;
import org.jclouds.rackspace.cloudfiles.v1.functions.ParseCDNContainerURIFromHeaders;
+import org.jclouds.rackspace.cloudfiles.v1.options.ListCDNContainerOptions;
import org.jclouds.rackspace.cloudfiles.v1.options.UpdateCDNContainerOptions;
import org.jclouds.rackspace.cloudfiles.v1.reference.CloudFilesHeaders;
import org.jclouds.rest.annotations.BinderParam;
@@ -97,7 +97,7 @@ public interface CDNApi extends Closeable {
@QueryParams(keys = {"format", "enabled_only"}, values = {"json", "true"})
@Fallback(EmptyFluentIterableOnNotFoundOr404.class)
@Path("/")
- FluentIterable<CDNContainer> list(ListContainerOptions options);
+ FluentIterable<CDNContainer> list(ListCDNContainerOptions options);
/**
* Gets the specified CDN Container.
http://git-wip-us.apache.org/repos/asf/jclouds/blob/46867d13/apis/rackspace-cloudfiles/src/main/java/org/jclouds/rackspace/cloudfiles/v1/options/ListCDNContainerOptions.java
----------------------------------------------------------------------
diff --git a/apis/rackspace-cloudfiles/src/main/java/org/jclouds/rackspace/cloudfiles/v1/options/ListCDNContainerOptions.java b/apis/rackspace-cloudfiles/src/main/java/org/jclouds/rackspace/cloudfiles/v1/options/ListCDNContainerOptions.java
new file mode 100644
index 0000000..35baa53
--- /dev/null
+++ b/apis/rackspace-cloudfiles/src/main/java/org/jclouds/rackspace/cloudfiles/v1/options/ListCDNContainerOptions.java
@@ -0,0 +1,86 @@
+/*
+ * 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.rackspace.cloudfiles.v1.options;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+import static com.google.common.base.Preconditions.checkState;
+
+import org.jclouds.http.options.BaseHttpRequestOptions;
+
+/**
+ * Options for listing containers.
+ *
+ * @see {@link org.jclouds.rackspace.cloudfiles.v1.features.CDNAp#list(ListCDNContainerOptions) CDNApi.list(ListCDNContainerOptions)}
+ */
+public class ListCDNContainerOptions extends BaseHttpRequestOptions {
+
+ /**
+ * For an integer value <i>n</i>, limits the number of results to <i>n</n>.
+ */
+ public ListCDNContainerOptions limit(int limit) {
+ checkState(limit >= 0, "limit must be >= 0");
+ checkState(limit <= 10000, "limit must be <= 10000");
+ queryParameters.put("limit", Integer.toString(limit));
+ return this;
+ }
+
+ /**
+ * Given a string value <i>x</i>, returns container names greater in value than the specified
+ * {@code marker}. Only strings using UTF-8 encoding are valid. Using {@code marker} provides
+ * a mechanism for iterating through the entire list of containers.
+ */
+ public ListCDNContainerOptions marker(String marker) {
+ queryParameters.put("marker", checkNotNull(marker, "marker"));
+ return this;
+ }
+
+ /**
+ * Given a string value <i>x</i>, returns container names lesser in value than the specified
+ * end marker. Only strings using UTF-8 encoding are valid.
+ */
+ public ListCDNContainerOptions endMarker(String endMarker) {
+ queryParameters.put("end_marker", checkNotNull(endMarker, "endMarker"));
+ return this;
+ }
+
+ public static class Builder {
+
+ /**
+ * @see ListCDNContainerOptions#limit
+ */
+ public static ListCDNContainerOptions limit(int limit) {
+ ListCDNContainerOptions options = new ListCDNContainerOptions();
+ return options.limit(limit);
+ }
+
+ /**
+ * @see ListCDNContainerOptions#marker
+ */
+ public static ListCDNContainerOptions marker(String marker) {
+ ListCDNContainerOptions options = new ListCDNContainerOptions();
+ return options.marker(marker);
+ }
+
+ /**
+ * @see ListCDNContainerOptions#endMarker
+ */
+ public static ListCDNContainerOptions endMarker(String endMarker) {
+ ListCDNContainerOptions options = new ListCDNContainerOptions();
+ return options.endMarker(endMarker);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/46867d13/apis/rackspace-cloudfiles/src/main/java/org/jclouds/rackspace/cloudfiles/v1/options/UpdateCDNContainerOptions.java
----------------------------------------------------------------------
diff --git a/apis/rackspace-cloudfiles/src/main/java/org/jclouds/rackspace/cloudfiles/v1/options/UpdateCDNContainerOptions.java b/apis/rackspace-cloudfiles/src/main/java/org/jclouds/rackspace/cloudfiles/v1/options/UpdateCDNContainerOptions.java
index 0fcb177..5f6d396 100644
--- a/apis/rackspace-cloudfiles/src/main/java/org/jclouds/rackspace/cloudfiles/v1/options/UpdateCDNContainerOptions.java
+++ b/apis/rackspace-cloudfiles/src/main/java/org/jclouds/rackspace/cloudfiles/v1/options/UpdateCDNContainerOptions.java
@@ -23,11 +23,11 @@ import static org.jclouds.openstack.swift.v1.reference.SwiftHeaders.STATIC_WEB_E
import static org.jclouds.openstack.swift.v1.reference.SwiftHeaders.STATIC_WEB_INDEX;
import static org.jclouds.openstack.swift.v1.reference.SwiftHeaders.STATIC_WEB_LISTINGS;
import static org.jclouds.openstack.swift.v1.reference.SwiftHeaders.STATIC_WEB_LISTINGS_CSS;
+import static org.jclouds.rackspace.cloudfiles.v1.reference.CloudFilesConstants.CDN_TTL_MAX;
+import static org.jclouds.rackspace.cloudfiles.v1.reference.CloudFilesConstants.CDN_TTL_MIN;
import static org.jclouds.rackspace.cloudfiles.v1.reference.CloudFilesHeaders.CDN_ENABLED;
import static org.jclouds.rackspace.cloudfiles.v1.reference.CloudFilesHeaders.CDN_LOG_RETENTION;
import static org.jclouds.rackspace.cloudfiles.v1.reference.CloudFilesHeaders.CDN_TTL;
-import static org.jclouds.rackspace.cloudfiles.v1.reference.CloudFilesHeaders.CDN_TTL_MAX;
-import static org.jclouds.rackspace.cloudfiles.v1.reference.CloudFilesHeaders.CDN_TTL_MIN;
import org.jclouds.http.options.BaseHttpRequestOptions;
http://git-wip-us.apache.org/repos/asf/jclouds/blob/46867d13/apis/rackspace-cloudfiles/src/main/java/org/jclouds/rackspace/cloudfiles/v1/reference/CloudFilesConstants.java
----------------------------------------------------------------------
diff --git a/apis/rackspace-cloudfiles/src/main/java/org/jclouds/rackspace/cloudfiles/v1/reference/CloudFilesConstants.java b/apis/rackspace-cloudfiles/src/main/java/org/jclouds/rackspace/cloudfiles/v1/reference/CloudFilesConstants.java
new file mode 100644
index 0000000..095ea10
--- /dev/null
+++ b/apis/rackspace-cloudfiles/src/main/java/org/jclouds/rackspace/cloudfiles/v1/reference/CloudFilesConstants.java
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.rackspace.cloudfiles.v1.reference;
+
+
+/**
+ * Constants specified by Rackspace Cloud Files.
+ */
+public interface CloudFilesConstants {
+ int CDN_TTL_MIN = 900;
+ int CDN_TTL_MAX = 31536000;
+ int CDN_TTL_DEFAULT = 259200;
+}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/46867d13/apis/rackspace-cloudfiles/src/main/java/org/jclouds/rackspace/cloudfiles/v1/reference/CloudFilesHeaders.java
----------------------------------------------------------------------
diff --git a/apis/rackspace-cloudfiles/src/main/java/org/jclouds/rackspace/cloudfiles/v1/reference/CloudFilesHeaders.java b/apis/rackspace-cloudfiles/src/main/java/org/jclouds/rackspace/cloudfiles/v1/reference/CloudFilesHeaders.java
index c6d2bc5..c4f9983 100644
--- a/apis/rackspace-cloudfiles/src/main/java/org/jclouds/rackspace/cloudfiles/v1/reference/CloudFilesHeaders.java
+++ b/apis/rackspace-cloudfiles/src/main/java/org/jclouds/rackspace/cloudfiles/v1/reference/CloudFilesHeaders.java
@@ -19,13 +19,8 @@ package org.jclouds.rackspace.cloudfiles.v1.reference;
import org.jclouds.openstack.swift.v1.reference.SwiftHeaders;
/**
- * Additional headers specified by Rackspace Cloud Files CDN.
+ * Additional headers specified by Rackspace Cloud Files.
*
- * @see <a
- * href="http://docs.rackspace.com/files/api/v1/cf-devguide/content/index.html">
- * Cloud Files API</a>
- *
- * @author Jeremy Daggett
*/
public interface CloudFilesHeaders extends SwiftHeaders {
// Access logs
@@ -40,11 +35,6 @@ public interface CloudFilesHeaders extends SwiftHeaders {
String CDN_STREAMING_URI = "X-Cdn-Streaming-Uri";
String CDN_IOS_URI = "X-Cdn-Ios-Uri";
- // CDN TTL Limits
- int CDN_TTL_MIN = 900;
- int CDN_TTL_MAX = 31536000;
- int CDN_TTL_DEFAULT = 259200;
-
// CDN Purge
String CDN_PURGE_OBJECT_EMAIL = "X-Purge-Email";
String CDN_PURGE_OBJECT_FAILED = "X-Purge-Failed-Reason";
http://git-wip-us.apache.org/repos/asf/jclouds/blob/46867d13/apis/rackspace-cloudfiles/src/test/java/org/jclouds/rackspace/cloudfiles/v1/features/CloudFilesCDNApiLiveTest.java
----------------------------------------------------------------------
diff --git a/apis/rackspace-cloudfiles/src/test/java/org/jclouds/rackspace/cloudfiles/v1/features/CloudFilesCDNApiLiveTest.java b/apis/rackspace-cloudfiles/src/test/java/org/jclouds/rackspace/cloudfiles/v1/features/CloudFilesCDNApiLiveTest.java
index 785ae61..3c68bee 100644
--- a/apis/rackspace-cloudfiles/src/test/java/org/jclouds/rackspace/cloudfiles/v1/features/CloudFilesCDNApiLiveTest.java
+++ b/apis/rackspace-cloudfiles/src/test/java/org/jclouds/rackspace/cloudfiles/v1/features/CloudFilesCDNApiLiveTest.java
@@ -28,17 +28,15 @@ import org.jclouds.http.options.GetOptions;
import org.jclouds.io.Payload;
import org.jclouds.io.Payloads;
import org.jclouds.openstack.swift.v1.features.ObjectApi;
-import org.jclouds.openstack.swift.v1.options.CreateContainerOptions;
-import org.jclouds.openstack.swift.v1.options.ListContainerOptions;
import org.jclouds.rackspace.cloudfiles.v1.domain.CDNContainer;
import org.jclouds.rackspace.cloudfiles.v1.internal.BaseCloudFilesApiLiveTest;
+import org.jclouds.rackspace.cloudfiles.v1.options.ListCDNContainerOptions;
import org.jclouds.rackspace.cloudfiles.v1.options.UpdateCDNContainerOptions;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableMap;
import com.google.common.io.ByteSource;
@@ -101,7 +99,7 @@ public class CloudFilesCDNApiLiveTest extends BaseCloudFilesApiLiveTest {
public void testListWithOptions() throws Exception {
String lexicographicallyBeforeName = name.substring(0, name.length() - 1);
for (String regionId : regions) {
- ListContainerOptions options = ListContainerOptions.Builder.marker(lexicographicallyBeforeName);
+ ListCDNContainerOptions options = new ListCDNContainerOptions().marker(lexicographicallyBeforeName);
CDNContainer cdnContainer = api.getCDNApiForRegion(regionId).list(options).get(0);
assertCDNContainerNotNull(cdnContainer);
http://git-wip-us.apache.org/repos/asf/jclouds/blob/46867d13/apis/rackspace-cloudfiles/src/test/java/org/jclouds/rackspace/cloudfiles/v1/features/CloudFilesCDNApiMockTest.java
----------------------------------------------------------------------
diff --git a/apis/rackspace-cloudfiles/src/test/java/org/jclouds/rackspace/cloudfiles/v1/features/CloudFilesCDNApiMockTest.java b/apis/rackspace-cloudfiles/src/test/java/org/jclouds/rackspace/cloudfiles/v1/features/CloudFilesCDNApiMockTest.java
index f90204e..cb692bb 100644
--- a/apis/rackspace-cloudfiles/src/test/java/org/jclouds/rackspace/cloudfiles/v1/features/CloudFilesCDNApiMockTest.java
+++ b/apis/rackspace-cloudfiles/src/test/java/org/jclouds/rackspace/cloudfiles/v1/features/CloudFilesCDNApiMockTest.java
@@ -35,10 +35,10 @@ import static org.testng.Assert.assertTrue;
import java.net.URI;
import java.util.List;
-import org.jclouds.openstack.swift.v1.options.ListContainerOptions;
import org.jclouds.openstack.v2_0.internal.BaseOpenStackMockTest;
import org.jclouds.rackspace.cloudfiles.v1.CloudFilesApi;
import org.jclouds.rackspace.cloudfiles.v1.domain.CDNContainer;
+import org.jclouds.rackspace.cloudfiles.v1.options.ListCDNContainerOptions;
import org.testng.annotations.Test;
import com.google.common.collect.FluentIterable;
@@ -105,7 +105,7 @@ public class CloudFilesCDNApiMockTest extends BaseOpenStackMockTest<CloudFilesAp
try {
CloudFilesApi api = api(server.getUrl("/").toString(), "rackspace-cloudfiles");
- ListContainerOptions options = ListContainerOptions.Builder.marker("cdn-container-3");
+ ListCDNContainerOptions options = new ListCDNContainerOptions().marker("cdn-container-3");
ImmutableList<CDNContainer> containers = api.getCDNApiForRegion("DFW").list(options).toList();
for (CDNContainer container : containers) {
@@ -129,7 +129,7 @@ public class CloudFilesCDNApiMockTest extends BaseOpenStackMockTest<CloudFilesAp
try {
CloudFilesApi api = api(server.getUrl("/").toString(), "rackspace-cloudfiles");
- ListContainerOptions options = ListContainerOptions.Builder.marker("cdn-container-3");
+ ListCDNContainerOptions options = ListCDNContainerOptions.Builder.marker("cdn-container-3");
FluentIterable<CDNContainer> containers = api.getCDNApiForRegion("DFW").list(options);
assertEquals(server.getRequestCount(), 2);
http://git-wip-us.apache.org/repos/asf/jclouds/blob/46867d13/apis/rackspace-cloudfiles/src/test/java/org/jclouds/rackspace/cloudfiles/v1/options/UpdateCDNContainerOptionsTest.java
----------------------------------------------------------------------
diff --git a/apis/rackspace-cloudfiles/src/test/java/org/jclouds/rackspace/cloudfiles/v1/options/UpdateCDNContainerOptionsTest.java b/apis/rackspace-cloudfiles/src/test/java/org/jclouds/rackspace/cloudfiles/v1/options/UpdateCDNContainerOptionsTest.java
index 3ff8c00..8d7b7e0 100644
--- a/apis/rackspace-cloudfiles/src/test/java/org/jclouds/rackspace/cloudfiles/v1/options/UpdateCDNContainerOptionsTest.java
+++ b/apis/rackspace-cloudfiles/src/test/java/org/jclouds/rackspace/cloudfiles/v1/options/UpdateCDNContainerOptionsTest.java
@@ -21,10 +21,10 @@ import static org.jclouds.openstack.swift.v1.reference.SwiftHeaders.STATIC_WEB_E
import static org.jclouds.openstack.swift.v1.reference.SwiftHeaders.STATIC_WEB_INDEX;
import static org.jclouds.openstack.swift.v1.reference.SwiftHeaders.STATIC_WEB_LISTINGS;
import static org.jclouds.openstack.swift.v1.reference.SwiftHeaders.STATIC_WEB_LISTINGS_CSS;
+import static org.jclouds.rackspace.cloudfiles.v1.reference.CloudFilesConstants.CDN_TTL_MAX;
+import static org.jclouds.rackspace.cloudfiles.v1.reference.CloudFilesConstants.CDN_TTL_MIN;
import static org.jclouds.rackspace.cloudfiles.v1.reference.CloudFilesHeaders.CDN_LOG_RETENTION;
import static org.jclouds.rackspace.cloudfiles.v1.reference.CloudFilesHeaders.CDN_TTL;
-import static org.jclouds.rackspace.cloudfiles.v1.reference.CloudFilesHeaders.CDN_TTL_MAX;
-import static org.jclouds.rackspace.cloudfiles.v1.reference.CloudFilesHeaders.CDN_TTL_MIN;
import static org.testng.Assert.assertEquals;
import org.testng.annotations.Test;