| 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.s3.domain; |
| 20 | |
| 21 | import com.google.common.base.CaseFormat; |
| 22 | |
| 23 | /** |
| 24 | * Specifies who pays for the download and request fees. |
| 25 | * <p/> |
| 26 | * In general, bucket owners pay for all Amazon S3 storage and data transfer costs associated with |
| 27 | * their bucket. A bucket owner, however, can configure a bucket to be a Requester Pays bucket. With |
| 28 | * Requester Pays buckets, the requester instead of the bucket owner pays the cost of the request |
| 29 | * and the data download from the bucket. The bucket owner always pays the cost of storing data. |
| 30 | * <p/> |
| 31 | * Typically, you configure buckets to be Requester Pays when you want to share data but not incur |
| 32 | * charges associated with others accessing the data. You might, for example, use Requester Pays |
| 33 | * buckets when making available large data sets, such as zip code directories, reference data, |
| 34 | * geospatial information, or web crawling data. |
| 35 | * <h3>Important</h3> If you enable Requester Pays on a bucket, anonymous access to that bucket is |
| 36 | * not allowed. |
| 37 | * <p/> |
| 38 | * You must authenticate all requests involving Requester Pays buckets. The request authentication |
| 39 | * enables Amazon S3 to identify and charge the requester for their use of the Requester Pays |
| 40 | * bucket. |
| 41 | * <p/> |
| 42 | * After you configure a bucket to be a Requester Pays bucket, requesters must include |
| 43 | * x-amz-request-payer in their requests either in the header, for POST and GET requests, or as a |
| 44 | * parameter in a REST request to show that they understand that they will be charged for the |
| 45 | * request and the data download. |
| 46 | * <p/> |
| 47 | * Requester Pays buckets do not support the following. |
| 48 | * <ul> |
| 49 | * <li>Anonymous requests</li> |
| 50 | * <li>BitTorrent</li> |
| 51 | * <li>SOAP requests</li> |
| 52 | * </ul> |
| 53 | * |
| 54 | * You cannot use a Requester Pays bucket as the target bucket for end user logging, or vice versa. |
| 55 | * However, you can turn on end user logging on a Requester Pays bucket where the target bucket is a |
| 56 | * non Requester Pays bucket. |
| 57 | * |
| 58 | * @author Adrian Cole |
| 59 | * @see <a href= |
| 60 | * "http://docs.amazonwebservices.com/AmazonS3/latest/index.html?RESTrequestPaymentGET.html" /> |
| 61 | */ |
| 62 | public enum Payer { |
| 63 | REQUESTER, BUCKET_OWNER, UNRECOGNIZED; |
| 64 | |
| 65 | public String value() { |
| 66 | return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, name()); |
| 67 | } |
| 68 | |
| 69 | public static Payer fromValue(String payer) { |
| 70 | try { |
| 71 | return valueOf(CaseFormat.UPPER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, payer)); |
| 72 | } catch (IllegalArgumentException e) { |
| 73 | return UNRECOGNIZED; |
| 74 | } |
| 75 | } |
| 76 | } |