github.com/apache/beam/sdks/v2@v2.48.2/python/apache_beam/io/aws/clients/s3/messages.py (about) 1 # 2 # Licensed to the Apache Software Foundation (ASF) under one or more 3 # contributor license agreements. See the NOTICE file distributed with 4 # this work for additional information regarding copyright ownership. 5 # The ASF licenses this file to You under the Apache License, Version 2.0 6 # (the "License"); you may not use this file except in compliance with 7 # the License. You may obtain a copy of the License at 8 # 9 # http://www.apache.org/licenses/LICENSE-2.0 10 # 11 # Unless required by applicable law or agreed to in writing, software 12 # distributed under the License is distributed on an "AS IS" BASIS, 13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 # See the License for the specific language governing permissions and 15 # limitations under the License. 16 # 17 18 # pytype: skip-file 19 20 21 class GetRequest(): 22 """ 23 S3 request object for `Get` command 24 """ 25 def __init__(self, bucket, object): 26 self.bucket = bucket 27 self.object = object 28 29 30 class UploadResponse(): 31 """ 32 S3 response object for `StartUpload` command 33 """ 34 def __init__(self, upload_id): 35 self.upload_id = upload_id 36 37 38 class UploadRequest(): 39 """ 40 S3 request object for `StartUpload` command 41 """ 42 def __init__(self, bucket, object, mime_type): 43 self.bucket = bucket 44 self.object = object 45 self.mime_type = mime_type 46 47 48 class UploadPartRequest(): 49 """ 50 S3 request object for `UploadPart` command 51 """ 52 def __init__(self, bucket, object, upload_id, part_number, bytes): 53 self.bucket = bucket 54 self.object = object 55 self.upload_id = upload_id 56 self.part_number = part_number 57 self.bytes = bytes 58 # self.mime_type = mime_type 59 60 61 class UploadPartResponse(): 62 """ 63 S3 response object for `UploadPart` command 64 """ 65 def __init__(self, etag, part_number): 66 self.etag = etag 67 self.part_number = part_number 68 69 70 class CompleteMultipartUploadRequest(): 71 """ 72 S3 request object for `UploadPart` command 73 """ 74 def __init__(self, bucket, object, upload_id, parts): 75 # parts is a list of objects of the form 76 # {'ETag': response.etag, 'PartNumber': response.part_number} 77 self.bucket = bucket 78 self.object = object 79 self.upload_id = upload_id 80 self.parts = parts 81 # self.mime_type = mime_type 82 83 84 class ListRequest(): 85 """ 86 S3 request object for `List` command 87 """ 88 def __init__(self, bucket, prefix, continuation_token=None): 89 self.bucket = bucket 90 self.prefix = prefix 91 self.continuation_token = continuation_token 92 93 94 class ListResponse(): 95 """ 96 S3 response object for `List` command 97 """ 98 def __init__(self, items, next_token=None): 99 self.items = items 100 self.next_token = next_token 101 102 103 class Item(): 104 """ 105 An item in S3 106 """ 107 def __init__(self, etag, key, last_modified, size, mime_type=None): 108 self.etag = etag 109 self.key = key 110 self.last_modified = last_modified 111 self.size = size 112 self.mime_type = mime_type 113 114 115 class DeleteRequest(): 116 """ 117 S3 request object for `Delete` command 118 """ 119 def __init__(self, bucket, object): 120 self.bucket = bucket 121 self.object = object 122 123 124 class DeleteBatchRequest(): 125 def __init__(self, bucket, objects): 126 # `objects` is a list of strings corresponding to the keys to be deleted 127 # in the bucket 128 self.bucket = bucket 129 self.objects = objects 130 131 132 class DeleteBatchResponse(): 133 def __init__(self, deleted, failed, errors): 134 # `deleted` is a list of strings corresponding to the keys that were deleted 135 # `failed` is a list of strings corresponding to the keys that caused errors 136 # `errors` is a list of S3ClientErrors, aligned with the order of `failed` 137 self.deleted = deleted 138 self.failed = failed 139 self.errors = errors 140 141 142 class CopyRequest(): 143 def __init__(self, src_bucket, src_key, dest_bucket, dest_key): 144 self.src_bucket = src_bucket 145 self.src_key = src_key 146 self.dest_bucket = dest_bucket 147 self.dest_key = dest_key 148 149 150 class S3ClientError(Exception): 151 def __init__(self, message=None, code=None): 152 self.message = message 153 self.code = code