| 1 | #ifndef AWS_S3_LIST_PARTS_H |
| 2 | #define AWS_S3_LIST_PARTS_H |
| 3 | |
| 4 | /** |
| 5 | * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. |
| 6 | * SPDX-License-Identifier: Apache-2.0. |
| 7 | */ |
| 8 | |
| 9 | #include <aws/s3/private/s3_paginator.h> |
| 10 | #include <aws/s3/s3_client.h> |
| 11 | |
| 12 | #include <aws/common/date_time.h> |
| 13 | #include <aws/common/string.h> |
| 14 | |
| 15 | /** Struct representing part info as returned from ListParts call. */ |
| 16 | struct aws_s3_part_info { |
| 17 | /** |
| 18 | * Size of the object in bytes. |
| 19 | */ |
| 20 | uint64_t size; |
| 21 | /** |
| 22 | * Part number of the given part. |
| 23 | */ |
| 24 | uint32_t part_number; |
| 25 | /** |
| 26 | * Timestamp from S3 on the latest modification, if you have a reliable clock on your machine, you COULD use this |
| 27 | * to implement caching. |
| 28 | */ |
| 29 | struct aws_date_time last_modified; |
| 30 | /** |
| 31 | * Etag for the object, usually an MD5 hash. you COULD also use this to implement caching. |
| 32 | */ |
| 33 | struct aws_byte_cursor e_tag; |
| 34 | |
| 35 | /** |
| 36 | * CRC32 checksum for the part. Optional. |
| 37 | */ |
| 38 | struct aws_byte_cursor checksumCRC32; |
| 39 | |
| 40 | /** |
| 41 | * CRC32C checksum for the part. Optional. |
| 42 | */ |
| 43 | struct aws_byte_cursor checksumCRC32C; |
| 44 | |
| 45 | /** |
| 46 | * SHA1 checksum for the part. Optional. |
| 47 | */ |
| 48 | struct aws_byte_cursor checksumSHA1; |
| 49 | |
| 50 | /** |
| 51 | * SHA256 checksum for the part. Optional. |
| 52 | */ |
| 53 | struct aws_byte_cursor checksumSHA256; |
| 54 | }; |
| 55 | |
| 56 | /** |
| 57 | * Invoked when a part is encountered during ListParts call. |
| 58 | * Return AWS_OP_ERR (after an error has been raised) to fail the list operation. |
| 59 | * Return AWS_OP_SUCCESS to continue until at least the current page is iterated. |
| 60 | */ |
| 61 | typedef int(aws_s3_on_part_fn)(const struct aws_s3_part_info *info, void *user_data); |
| 62 | |
| 63 | /** |
| 64 | * Parameters for calling aws_s3_list_parts_operation_new(). All values are copied out or re-seated and reference |
| 65 | * counted. |
| 66 | */ |
| 67 | struct aws_s3_list_parts_params { |
| 68 | /** |
| 69 | * Must not be NULL. The internal call will increment the reference count on client. |
| 70 | */ |
| 71 | struct aws_s3_client *client; |
| 72 | /** |
| 73 | * Must not be empty. Name of the bucket to list. |
| 74 | */ |
| 75 | struct aws_byte_cursor bucket_name; |
| 76 | /** |
| 77 | * Must not be empty. Key with which multipart upload was initiated. |
| 78 | */ |
| 79 | struct aws_byte_cursor key; |
| 80 | /** |
| 81 | * Must not be empty. Id identifying multipart upload. |
| 82 | */ |
| 83 | struct aws_byte_cursor upload_id; |
| 84 | /** |
| 85 | * Must not be empty. The endpoint for the S3 bucket to hit. Can be virtual or path style. |
| 86 | */ |
| 87 | struct aws_byte_cursor endpoint; |
| 88 | /** |
| 89 | * Callback to invoke on each part that's listed. |
| 90 | */ |
| 91 | aws_s3_on_part_fn *on_part; |
| 92 | /** |
| 93 | * Associated user data. |
| 94 | */ |
| 95 | void *user_data; |
| 96 | }; |
| 97 | |
| 98 | AWS_EXTERN_C_BEGIN |
| 99 | |
| 100 | AWS_S3_API struct aws_s3_paginated_operation *aws_s3_list_parts_operation_new( |
| 101 | struct aws_allocator *allocator, |
| 102 | const struct aws_s3_list_parts_params *params); |
| 103 | |
| 104 | AWS_EXTERN_C_END |
| 105 | |
| 106 | #endif /* AWS_S3_LIST_PARTS_H */ |