#compdef s3sync

autoload -U is-at-least

_s3sync() {
    typeset -A opt_args
    typeset -a _arguments_options
    local ret=1

    if is-at-least 5.2; then
        _arguments_options=(-s -S -C)
    else
        _arguments_options=(-s -C)
    fi

    local context curcontext="$curcontext" state line
    _arguments "${_arguments_options[@]}" : \
'--aws-config-file=[Location of the file that the AWS CLI uses to store configuration profiles]:FILE:_files' \
'--aws-shared-credentials-file=[Location of the file that the AWS CLI uses to store access keys]:FILE:_files' \
'(--source-access-key --source-secret-access-key --source-session-token)--source-profile=[Source AWS CLI profile]:SOURCE_PROFILE:_default' \
'(--source-profile)--source-access-key=[Source access key]:SOURCE_ACCESS_KEY:_default' \
'(--source-profile)--source-secret-access-key=[Source secret access key]:SOURCE_SECRET_ACCESS_KEY:_default' \
'(--source-profile)--source-session-token=[Source session token]:SOURCE_SESSION_TOKEN:_default' \
'--source-region=[Source region]:SOURCE_REGION:_default' \
'--source-endpoint-url=[Source endpoint url]:SOURCE_ENDPOINT_URL:_default' \
'(--target-access-key --target-secret-access-key --target-session-token)--target-profile=[Target AWS CLI profile]:TARGET_PROFILE:_default' \
'(--target-profile)--target-access-key=[Target access key]:TARGET_ACCESS_KEY:_default' \
'(--target-profile)--target-secret-access-key=[Target secret access key]:TARGET_SECRET_ACCESS_KEY:_default' \
'(--target-profile)--target-session-token=[Target session token]:TARGET_SESSION_TOKEN:_default' \
'--target-region=[Target region]:TARGET_REGION:_default' \
'--target-endpoint-url=[Target endpoint url]:TARGET_ENDPOINT_URL:_default' \
'--storage-class=[]:STORAGE_CLASS:_default' \
'--filter-mtime-before=[]:FILTER_MTIME_BEFORE:_default' \
'--filter-mtime-after=[]:FILTER_MTIME_AFTER:_default' \
'--filter-smaller-size=[]:FILTER_SMALLER_SIZE:_default' \
'--filter-larger-size=[]:FILTER_LARGER_SIZE:_default' \
'--filter-include-regex=[Sync only objects that match a given regular expression]:FILTER_INCLUDE_REGEX:_default' \
'--filter-exclude-regex=[Do not sync objects that match a given regular expression]:FILTER_EXCLUDE_REGEX:_default' \
'--filter-include-content-type-regex=[]:FILTER_INCLUDE_CONTENT_TYPE_REGEX:_default' \
'--filter-exclude-content-type-regex=[]:FILTER_EXCLUDE_CONTENT_TYPE_REGEX:_default' \
'--filter-include-metadata-regex=[]:FILTER_INCLUDE_METADATA_REGEX:_default' \
'--filter-exclude-metadata-regex=[]:FILTER_EXCLUDE_METADATA_REGEX:_default' \
'--filter-include-tag-regex=[]:FILTER_INCLUDE_TAG_REGEX:_default' \
'--filter-exclude-tag-regex=[]:FILTER_EXCLUDE_TAG_REGEX:_default' \
'(--enable-versioning --check-size --check-etag --check-mtime-and-etag --check-mtime-and-additional-checksum)--check-additional-checksum=[Use additional checksum for update checking]:CHECK_ADDITIONAL_CHECKSUM:_default' \
'(--enable-versioning --remove-modified-filter --check-size --check-etag --check-mtime-and-etag --check-additional-checksum)--check-mtime-and-additional-checksum=[]:CHECK_MTIME_AND_ADDITIONAL_CHECKSUM:_default' \
'--additional-checksum-algorithm=[Additional checksum algorithm for upload]:ADDITIONAL_CHECKSUM_ALGORITHM:_default' \
'--worker-size=[Number of workers for synchronization]:WORKER_SIZE:_default' \
'--max-parallel-uploads=[Maximum number of parallel multipart uploads/downloads]:MAX_PARALLEL_UPLOADS:_default' \
'--max-parallel-listings=[]:MAX_PARALLEL_LISTINGS:_default' \
'--max-parallel-listing-max-depth=[]:MAX_PARALLEL_LISTING_MAX_DEPTH:_default' \
'--object-listing-queue-size=[Queue size for object listings]:OBJECT_LISTING_QUEUE_SIZE:_default' \
'--rate-limit-objects=[Rate limit objects per second]:RATE_LIMIT_OBJECTS:_default' \
'--rate-limit-bandwidth=[Rate limit bandwidth(bytes per sec). Allow suffixes\: MB, MiB, GB, GiB]:RATE_LIMIT_BANDWIDTH:_default' \
'(--auto-chunksize)--multipart-threshold=[]:MULTIPART_THRESHOLD:_default' \
'(--auto-chunksize)--multipart-chunksize=[]:MULTIPART_CHUNKSIZE:_default' \
'--cache-control=[Cache-Control HTTP header to set on the target object]:CACHE_CONTROL:_default' \
'--content-disposition=[Content-Disposition HTTP header to set on the target object]:CONTENT_DISPOSITION:_default' \
'--content-encoding=[Content-Encoding HTTP header to set on the target object]:CONTENT_ENCODING:_default' \
'--content-language=[Content-Language HTTP header to set on the target object]:CONTENT_LANGUAGE:_default' \
'--content-type=[Content-Type HTTP header to set on the target object]:CONTENT_TYPE:_default' \
'--expires=[]:EXPIRES:_default' \
'--metadata=[]:METADATA:_default' \
'--website-redirect=[x-amz-website-redirect-location header to set on the target object]:WEBSITE_REDIRECT:_default' \
'(--disable-tagging --sync-latest-tagging)--tagging=[]:TAGGING:_default' \
'(--delete --head-each-target --enable-versioning --check-etag --check-mtime-and-etag --check-size --check-mtime-and-additional-checksum)--point-in-time=[]:POINT_IN_TIME:_default' \
'--sse=[Server-side encryption. Valid choices\: AES256 | aws\:kms | aws\:kms\:dsse]:SSE:_default' \
'--sse-kms-key-id=[SSE KMS ID key]:SSE_KMS_KEY_ID:_default' \
'(--sse --sse-kms-key-id)--source-sse-c=[Source SSE-C algorithm. Valid choices\: AES256]:SOURCE_SSE_C:_default' \
'--source-sse-c-key=[Source SSE-C customer-provided encryption key(256bit key. must be base64 encoded)]:SOURCE_SSE_C_KEY:_default' \
'--source-sse-c-key-md5=[Source base64 encoded MD5 digest of source_sse_c_key]:SOURCE_SSE_C_KEY_MD5:_default' \
'(--sse --sse-kms-key-id)--target-sse-c=[Target SSE-C algorithm. Valid choices\: AES256]:TARGET_SSE_C:_default' \
'--target-sse-c-key=[Target SSE-C customer-provided encryption key(256bit key. must be base64 encoded)]:TARGET_SSE_C_KEY:_default' \
'--target-sse-c-key-md5=[Target base64 encoded MD5 digest of target-sse-c-key]:TARGET_SSE_C_KEY_MD5:_default' \
'--aws-max-attempts=[Maximum retry attempts that s3sync retry handler use]:max_attempts:_default' \
'--initial-backoff-milliseconds=[]:initial_backoff:_default' \
'--force-retry-count=[Maximum force retry attempts that s3sync retry handler use]:FORCE_RETRY_COUNT:_default' \
'--force-retry-interval-milliseconds=[]:force_retry_interval:_default' \
'--operation-timeout-milliseconds=[]:operation_timeout:_default' \
'--operation-attempt-timeout-milliseconds=[]:operation_attempt_timeout:_default' \
'--connect-timeout-milliseconds=[]:connect_timeout:_default' \
'--read-timeout-milliseconds=[]:read_timeout:_default' \
'--acl=[]:ACL:_default' \
'--max-keys=[Maximum number of objects returned in a single list object request]:MAX_KEYS:_default' \
'--auto-complete-shell=[]:SHELL:_default' \
'--max-delete=[Don'\''t delete more than a specified number of objects]:MAX_DELETE:_default' \
'--preprocess-callback-lua-script=[]:PREPROCESS_CALLBACK_LUA_SCRIPT:_default' \
'--event-callback-lua-script=[]:EVENT_CALLBACK_LUA_SCRIPT:_default' \
'--filter-callback-lua-script=[]:FILTER_CALLBACK_LUA_SCRIPT:_default' \
'--lua-vm-memory-limit=[]:LUA_VM_MEMORY_LIMIT:_default' \
'--lua-callback-timeout-milliseconds=[]:LUA_CALLBACK_TIMEOUT_MILLISECONDS:_default' \
'--dry-run[A simulation mode. No actions will be performed]' \
'--show-no-progress[Don'\''t show the progress bar]' \
'--server-side-copy[]' \
'--source-accelerate[Use Amazon S3 Transfer Acceleration for the source bucket]' \
'--source-request-payer[Use request payer for the source bucket]' \
'--source-force-path-style[Force path-style addressing for source endpoint]' \
'--target-accelerate[Use Amazon S3 Transfer Acceleration for the target bucket]' \
'--target-request-payer[Use request payer for the target bucket]' \
'--target-force-path-style[Force path-style addressing for target endpoint]' \
'(--enable-versioning)--remove-modified-filter[Do not update checking(ListObjectsV2) for modification in the target storage]' \
'(--enable-versioning --check-etag --check-mtime-and-etag --check-mtime-and-additional-checksum)--check-size[Use object size for update checking]' \
'(--enable-versioning --check-size --check-mtime-and-etag --check-mtime-and-additional-checksum --source-sse-c-key --target-sse-c-key)--check-etag[Use ETag for update checking]' \
'(--enable-versioning --remove-modified-filter --check-size --check-etag --source-sse-c-key --target-sse-c-key)--check-mtime-and-etag[]' \
'--full-object-checksum[]' \
'--enable-additional-checksum[Enable additional checksum for download]' \
'--disable-multipart-verify[Disable multipart upload verification with ETag/additional checksum]' \
'--disable-etag-verify[Disable ETag verification]' \
'--disable-additional-checksum-verify[]' \
'--allow-parallel-listings-in-express-one-zone[]' \
'(--multipart-threshold --multipart-chunksize)--auto-chunksize[]' \
'--no-sync-system-metadata[]' \
'--no-sync-user-defined-metadata[Do not sync user-defined metadata]' \
'--disable-tagging[Do not copy tagging]' \
'(--enable-versioning --disable-tagging)--sync-latest-tagging[]' \
'(--delete --head-each-target --remove-modified-filter)--enable-versioning[]' \
'*-v[Increase logging verbosity]' \
'*--verbose[Increase logging verbosity]' \
'(-v --verbose)*-q[Decrease logging verbosity]' \
'(-v --verbose)*--quiet[Decrease logging verbosity]' \
'(--dry-run --delete --enable-versioning --head-each-target)--report-sync-status[]' \
'--report-metadata-sync-status[]' \
'--report-tagging-sync-status[]' \
'--json-tracing[Show trace as json format]' \
'--aws-sdk-tracing[Enable aws sdk tracing]' \
'--span-events-tracing[Show span event tracing]' \
'--disable-color-tracing[Disable ANSI terminal colors]' \
'--warn-as-error[Treat warnings as errors(except for the case of ETag/checksum mismatch, etc.)]' \
'--ignore-symlinks[Ignore symbolic links]' \
'(--enable-versioning)--head-each-target[]' \
'--no-guess-mime-type[Do not try to guess the mime type of local file]' \
'--put-last-modified-metadata[Put last modified of the source to metadata]' \
'--disable-stalled-stream-protection[Disable stalled stream protection]' \
'--disable-payload-signing[Disable payload signing for object uploads]' \
'--disable-content-md5-header[]' \
'--disable-express-one-zone-additional-checksum[]' \
'--delete-excluded[]' \
'(--enable-versioning --point-in-time)--if-match[]' \
'(--enable-versioning --point-in-time)--copy-source-if-match[]' \
'(--enable-versioning --point-in-time --if-match)--if-none-match[]' \
'--ignore-glacier-warnings[Suppress warnings related to Amazon S3 Glacier storage class objects during GetObject requests]' \
'(--allow-lua-unsafe-vm)--allow-lua-os-library[]' \
'(--allow-lua-os-library)--allow-lua-unsafe-vm[]' \
'(--enable-versioning)--delete[]' \
'--allow-both-local-storage[Unit test purpose only]' \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
'-V[Print version]' \
'--version[Print version]' \
'::source -- s3\://<BUCKET_NAME>\[/prefix\] or local path:_default' \
'::target -- s3\://<BUCKET_NAME>\[/prefix\] or local path:_default' \
&& ret=0
}

(( $+functions[_s3sync_commands] )) ||
_s3sync_commands() {
    local commands; commands=()
    _describe -t commands 's3sync commands' commands "$@"
}

if [ "$funcstack[1]" = "_s3sync" ]; then
    _s3sync "$@"
else
    compdef _s3sync s3sync
fi
