Update create-container to take more options.

* location is now optional, given through the :location keyword.
* public-read? option, can be set to true to create a publically readable
  container.
This commit is contained in:
David Santiago 2011-04-05 18:57:28 -05:00
parent 793740b9be
commit ee339e109b
2 changed files with 7 additions and 6 deletions

View File

@ -48,7 +48,7 @@ See http://code.google.com/p/jclouds for details."
AsyncBlobStore domain.BlobBuilder BlobStore BlobStoreContext AsyncBlobStore domain.BlobBuilder BlobStore BlobStoreContext
BlobStoreContextFactory domain.BlobMetadata domain.StorageMetadata BlobStoreContextFactory domain.BlobMetadata domain.StorageMetadata
domain.Blob domain.internal.BlobBuilderImpl domain.Blob domain.internal.BlobBuilderImpl
options.ListContainerOptions] options.CreateContainerOptions options.ListContainerOptions]
org.jclouds.io.Payloads org.jclouds.io.Payloads
java.util.Arrays java.util.Arrays
[java.security DigestOutputStream MessageDigest] [java.security DigestOutputStream MessageDigest]
@ -182,10 +182,10 @@ Options can also be specified for extension modules
(defn create-container (defn create-container
"Create a container." "Create a container."
([blobstore container-name] [^BlobStore blobstore container-name & {:keys [location public-read?]}]
(create-container blobstore container-name nil)) (let [cco (CreateContainerOptions.)
([^BlobStore blobstore container-name location] cco (if public-read? (.publicRead cco) cco)]
(.createContainerInLocation blobstore location container-name))) (.createContainerInLocation blobstore location container-name cco)))
(defn clear-container (defn clear-container
"Clear a container." "Clear a container."

View File

@ -55,7 +55,8 @@
(deftest locations-test (deftest locations-test
(is (not (empty? (locations *blobstore*)))) (is (not (empty? (locations *blobstore*))))
(is (create-container *blobstore* "fred" (first (locations *blobstore*))))) (is (create-container *blobstore* "fred"
:location (first (locations *blobstore*)))))
(deftest containers-test (deftest containers-test
(is (empty? (containers *blobstore*))) (is (empty? (containers *blobstore*)))