| 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.azureblob.options; |
| 20 | |
| 21 | import org.jclouds.azure.storage.options.ListOptions; |
| 22 | |
| 23 | /** |
| 24 | * Contains options supported in the REST API for the List Blobs operation. <h2> |
| 25 | * Usage</h2> The recommended way to instantiate a ListBlobsOptions object is to statically import |
| 26 | * ListBlobsOptions.* and invoke a static creation method followed by an instance mutator (if |
| 27 | * needed): |
| 28 | * <p/> |
| 29 | * <code> |
| 30 | * import static org.jclouds.azureblob.options.ListBlobsOptions.Builder.* |
| 31 | * import org.jclouds.azureblob.AzureBlobClient; |
| 32 | * <p/> |
| 33 | * AzureBlobClient connection = // get connection |
| 34 | * Set<BlobMetadata> blobs = connection.listBlobs("containerName", delimiter("/")); |
| 35 | * <code> * |
| 36 | * |
| 37 | * @see <a href="http://msdn.microsoft.com/en-us/library/dd179466.aspx" /> |
| 38 | * @author Adrian Cole |
| 39 | */ |
| 40 | public class ListBlobsOptions extends ListOptions { |
| 41 | |
| 42 | /** |
| 43 | * When the request includes this parameter, the operation returns a {@code BlobPrefix} element |
| 44 | * in the response body that acts as a placeholder for all blobs whose names begin with the same |
| 45 | * substring up to the appearance of the delimiter character. |
| 46 | * |
| 47 | * @param delimiter |
| 48 | * a single character or a string. |
| 49 | */ |
| 50 | public ListBlobsOptions delimiter(String delimiter) { |
| 51 | this.queryParameters.put("delimiter", delimiter); |
| 52 | return this; |
| 53 | } |
| 54 | |
| 55 | public String getDelimiter() { |
| 56 | return this.getFirstQueryOrNull("delimiter"); |
| 57 | } |
| 58 | |
| 59 | public static class Builder { |
| 60 | |
| 61 | /** |
| 62 | * @see ListBlobsOptions#delimiter(String) |
| 63 | */ |
| 64 | public static ListBlobsOptions delimiter(String delimiter) { |
| 65 | ListBlobsOptions options = new ListBlobsOptions(); |
| 66 | return options.delimiter(delimiter); |
| 67 | } |
| 68 | |
| 69 | /** |
| 70 | * @see ListOptions#includeMetadata() |
| 71 | */ |
| 72 | public static ListBlobsOptions includeMetadata() { |
| 73 | ListBlobsOptions options = new ListBlobsOptions(); |
| 74 | return options.includeMetadata(); |
| 75 | } |
| 76 | |
| 77 | /** |
| 78 | * @see ListOptions#prefix(String) |
| 79 | */ |
| 80 | public static ListBlobsOptions prefix(String prefix) { |
| 81 | ListBlobsOptions options = new ListBlobsOptions(); |
| 82 | return options.prefix(prefix); |
| 83 | } |
| 84 | |
| 85 | /** |
| 86 | * @see ListOptions#marker(String) |
| 87 | */ |
| 88 | public static ListBlobsOptions marker(String marker) { |
| 89 | ListBlobsOptions options = new ListBlobsOptions(); |
| 90 | return options.marker(marker); |
| 91 | } |
| 92 | |
| 93 | /** |
| 94 | * @see ListOptions#maxResults(long) |
| 95 | */ |
| 96 | public static ListBlobsOptions maxResults(int maxKeys) { |
| 97 | ListBlobsOptions options = new ListBlobsOptions(); |
| 98 | return options.maxResults(maxKeys); |
| 99 | } |
| 100 | } |
| 101 | |
| 102 | /** |
| 103 | * {@inheritDoc} |
| 104 | */ |
| 105 | @Override |
| 106 | public ListBlobsOptions includeMetadata() { |
| 107 | return (ListBlobsOptions) super.includeMetadata(); |
| 108 | } |
| 109 | |
| 110 | /** |
| 111 | * {@inheritDoc} |
| 112 | */ |
| 113 | @Override |
| 114 | public ListBlobsOptions marker(String marker) { |
| 115 | return (ListBlobsOptions) super.marker(marker); |
| 116 | } |
| 117 | |
| 118 | /** |
| 119 | * {@inheritDoc} |
| 120 | */ |
| 121 | @Override |
| 122 | public ListBlobsOptions maxResults(int maxresults) { |
| 123 | return (ListBlobsOptions) super.maxResults(maxresults); |
| 124 | } |
| 125 | |
| 126 | /** |
| 127 | * {@inheritDoc} |
| 128 | */ |
| 129 | @Override |
| 130 | public ListBlobsOptions prefix(String prefix) { |
| 131 | return (ListBlobsOptions) super.prefix(prefix); |
| 132 | } |
| 133 | } |