| 213 | return (self.method_string, resource, self.headers) |
| 214 | |
| 215 | class S3(object): |
| 216 | http_methods = BidirMap( |
| 217 | GET = 0x01, |
| 218 | PUT = 0x02, |
| 219 | HEAD = 0x04, |
| 220 | DELETE = 0x08, |
| 221 | POST = 0x10, |
| 222 | MASK = 0x1F, |
| 223 | ) |
| 224 | |
| 225 | targets = BidirMap( |
| 226 | SERVICE = 0x0100, |
| 227 | BUCKET = 0x0200, |
| 228 | OBJECT = 0x0400, |
| 229 | BATCH = 0x0800, |
| 230 | MASK = 0x0700, |
| 231 | ) |
| 232 | |
| 233 | operations = BidirMap( |
| 234 | UNDEFINED = 0x0000, |
| 235 | LIST_ALL_BUCKETS = targets["SERVICE"] | http_methods["GET"], |
| 236 | BUCKET_CREATE = targets["BUCKET"] | http_methods["PUT"], |
| 237 | BUCKET_LIST = targets["BUCKET"] | http_methods["GET"], |
| 238 | BUCKET_DELETE = targets["BUCKET"] | http_methods["DELETE"], |
| 239 | OBJECT_PUT = targets["OBJECT"] | http_methods["PUT"], |
| 240 | OBJECT_GET = targets["OBJECT"] | http_methods["GET"], |
| 241 | OBJECT_HEAD = targets["OBJECT"] | http_methods["HEAD"], |
| 242 | OBJECT_DELETE = targets["OBJECT"] | http_methods["DELETE"], |
| 243 | OBJECT_POST = targets["OBJECT"] | http_methods["POST"], |
| 244 | BATCH_DELETE = targets["BATCH"] | http_methods["POST"], |
| 245 | ) |
| 246 | |
| 247 | codes = { |
| 248 | "NoSuchBucket" : "Bucket '%s' does not exist", |
| 249 | "AccessDenied" : "Access to bucket '%s' was denied", |
| 250 | "BucketAlreadyExists" : "Bucket '%s' already exists", |
| 251 | } |
| 252 | |
| 253 | def __init__(self, config): |
| 254 | self.config = config |
| 255 | self.fallback_to_signature_v2 = False |
| 256 | self.endpoint_requires_signature_v4 = False |
| 257 | self.expect_continue_not_supported = False |
| 258 | |
| 259 | def storage_class(self): |
| 260 | # Note - you cannot specify GLACIER here |
| 261 | # https://docs.aws.amazon.com/AmazonS3/latest/dev/storage-class-intro.html |
| 262 | cls = 'STANDARD' |
| 263 | if self.config.storage_class != "": |
| 264 | return self.config.storage_class |
| 265 | if self.config.reduced_redundancy: |
| 266 | cls = 'REDUCED_REDUNDANCY' |
| 267 | return cls |
| 268 | |
| 269 | def get_hostname(self, bucket): |
| 270 | if bucket and bucket in S3Request.redir_map: |
| 271 | host = S3Request.redir_map[bucket] |
| 272 | elif bucket and check_bucket_name_dns_support(self.config.host_bucket, bucket): |
no test coverage detected