View Javadoc

1   /**
2    *
3    * Copyright (C) 2011 Cloud Conscious, LLC. <info@cloudconscious.com>
4    *
5    * ====================================================================
6    * Licensed under the Apache License, Version 2.0 (the "License");
7    * you may not use this file except in compliance with the License.
8    * 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, software
13   * distributed under the License is distributed on an "AS IS" BASIS,
14   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15   * See the License for the specific language governing permissions and
16   * limitations under the License.
17   * ====================================================================
18   */
19  package org.jclouds.blobstore;
20  
21  import org.jclouds.blobstore.domain.Blob;
22  import org.jclouds.blobstore.domain.BlobBuilder;
23  import org.jclouds.blobstore.internal.RequestSigningUnsupported;
24  import org.jclouds.blobstore.options.GetOptions;
25  import org.jclouds.http.HttpRequest;
26  
27  import com.google.inject.ImplementedBy;
28  
29  /**
30   * Generates signed requests for blobs. useful in other tools such as backup utilities.
31   * 
32   * @author Adrian Cole
33   */
34  @ImplementedBy(RequestSigningUnsupported.class)
35  public interface BlobRequestSigner {
36  
37     /**
38      * gets a signed request, including headers as necessary, to access a blob from an external
39      * client.
40      * 
41      * @param container
42      *           container where the blob resides
43      * @param directory
44      *           full path to the blob
45      * @throws UnsupportedOperationException
46      *            if not supported by the provider
47      */
48     HttpRequest signGetBlob(String container, String name);
49  
50     /**
51      * @param options
52      * @see #signGetBlob(String, String)
53      */
54     HttpRequest signGetBlob(String container, String name, GetOptions options);
55  
56     /**
57      * gets a signed request, including headers as necessary, to delete a blob from an external
58      * client.
59      * 
60      * @param container
61      *           container where the blob resides
62      * @param directory
63      *           full path to the blob
64      * @throws UnsupportedOperationException
65      *            if not supported by the provider
66      */
67     HttpRequest signRemoveBlob(String container, String name);
68  
69     /**
70      * gets a signed request, including headers as necessary, to upload a blob from an external
71      * client.
72      * 
73      * <pre>
74      * Blob blob = context.getBlobStore.blobBuilder().name(&quot;name&quot;).forSigning().contentType(&quot;text/plain&quot;)
75      *          .contentLength(length).build();
76      * </pre>
77      * 
78      * @param container
79      *           container where the blob resides
80      * @param blob
81      *           what to upload
82      * @throws UnsupportedOperationException
83      *            if not supported by the provider
84      * @see BlobBuilder#forSigning
85      */
86     HttpRequest signPutBlob(String container, Blob blob);
87  }