| 1 | /** |
| 2 | * Licensed to jclouds, Inc. (jclouds) under one or more |
| 3 | * contributor license agreements. See the NOTICE file |
| 4 | * distributed with this work for additional information |
| 5 | * regarding copyright ownership. jclouds licenses this file |
| 6 | * to you under the Apache License, Version 2.0 (the |
| 7 | * "License"); you may not use this file except in compliance |
| 8 | * with the License. You may obtain a copy of the License at |
| 9 | * |
| 10 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | * |
| 12 | * Unless required by applicable law or agreed to in writing, |
| 13 | * software distributed under the License is distributed on an |
| 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 | * KIND, either express or implied. See the License for the |
| 16 | * specific language governing permissions and limitations |
| 17 | * under the License. |
| 18 | */ |
| 19 | package org.jclouds.cloudfiles.options; |
| 20 | |
| 21 | import static com.google.common.base.Preconditions.checkNotNull; |
| 22 | import static com.google.common.base.Preconditions.checkState; |
| 23 | |
| 24 | import org.jclouds.http.options.BaseHttpRequestOptions; |
| 25 | |
| 26 | |
| 27 | /** |
| 28 | * Contains options supported in the REST API for the GET CDN containers operation. |
| 29 | */ |
| 30 | public class ListCdnContainerOptions extends BaseHttpRequestOptions { |
| 31 | public static final ListCdnContainerOptions NONE = new ListCdnContainerOptions(); |
| 32 | |
| 33 | public ListCdnContainerOptions enabledOnly() { |
| 34 | queryParameters.put("enabled_only", "true"); |
| 35 | return this; |
| 36 | } |
| 37 | |
| 38 | /** |
| 39 | * Indicates where to begin listing the identity's containers. The list will only include |
| 40 | * containers whose names occur lexicographically after the marker. This is convenient for |
| 41 | * pagination: To get the next page of results use the last container name of the current |
| 42 | * page as the marker. |
| 43 | */ |
| 44 | public ListCdnContainerOptions afterMarker(String marker) { |
| 45 | queryParameters.put("marker", checkNotNull(marker, "marker")); |
| 46 | return this; |
| 47 | } |
| 48 | |
| 49 | |
| 50 | /** |
| 51 | * The maximum number of containers that will be included in the response body. |
| 52 | * The server might return fewer than this many containers, but will not return more. |
| 53 | */ |
| 54 | public ListCdnContainerOptions maxResults(int limit) { |
| 55 | checkState(limit >= 0, "limit must be >= 0"); |
| 56 | checkState(limit <= 10000, "limit must be <= 10000"); |
| 57 | queryParameters.put("limit", Integer.toString(limit)); |
| 58 | return this; |
| 59 | } |
| 60 | |
| 61 | public static class Builder { |
| 62 | |
| 63 | public static ListCdnContainerOptions enabledOnly() { |
| 64 | ListCdnContainerOptions options = new ListCdnContainerOptions(); |
| 65 | return options.enabledOnly(); |
| 66 | } |
| 67 | |
| 68 | /** |
| 69 | * @see ListCdnContainerOptions#afterMarker(String) |
| 70 | */ |
| 71 | public static ListCdnContainerOptions afterMarker(String marker) { |
| 72 | ListCdnContainerOptions options = new ListCdnContainerOptions(); |
| 73 | return options.afterMarker(marker); |
| 74 | } |
| 75 | |
| 76 | /** |
| 77 | * @see ListCdnContainerOptions#limit(int) |
| 78 | */ |
| 79 | public static ListCdnContainerOptions maxResults(int limit) { |
| 80 | ListCdnContainerOptions options = new ListCdnContainerOptions(); |
| 81 | return options.maxResults(limit); |
| 82 | } |
| 83 | |
| 84 | } |
| 85 | |
| 86 | } |