X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=device-src%2Fs3.h;h=49cb00a6593ec2140d9b6e07b5e9b29590f26b85;hb=691567b16c13087b31ee4c2b6d038e57872fae82;hp=1e883a8c4465f01d37c0de9716970f2a67d51a71;hpb=b116e9366c7b2ea2c2eb53b0a13df4090e176235;p=debian%2Famanda diff --git a/device-src/s3.h b/device-src/s3.h index 1e883a8..49cb00a 100644 --- a/device-src/s3.h +++ b/device-src/s3.h @@ -1,9 +1,10 @@ /* - * Copyright (c) 2008, 2009, 2010 Zmanda, Inc. All Rights Reserved. + * Copyright (c) 2008-2012 Zmanda, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 as published - * by the Free Software Foundation. + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY @@ -27,6 +28,14 @@ * Data types */ +typedef enum { + S3_API_S3, + S3_API_SWIFT_1, + S3_API_SWIFT_2, + S3_API_OAUTH2, + S3_API_CASTOR +} S3_api; + /* An opaque handle. S3Handles should only be accessed from a single * thread at any given time, although it is fine to use different handles * in different threads simultaneously. */ @@ -115,7 +124,7 @@ typedef curl_progress_callback s3_progress_func; /* This preprocessor magic will enumerate constants named S3_ERROR_XxxYyy for * each of the errors in parentheses. * - * see http://docs.amazonwebservices.com/AmazonS3/2006-03-01/ErrorCodeList.html + * see http://docs.amazonwebservices.com/AmazonS3/latest/API/ErrorResponses.html * for Amazon's breakdown of error responses. */ #define S3_ERROR_LIST \ @@ -153,6 +162,7 @@ typedef curl_progress_callback s3_progress_func; S3_ERROR(MissingSecurityHeader), \ S3_ERROR(NoLoggingStatusForKey), \ S3_ERROR(NoSuchBucket), \ + S3_ERROR(NoSuchEntity), \ S3_ERROR(NoSuchKey), \ S3_ERROR(NotImplemented), \ S3_ERROR(NotSignedUp), \ @@ -165,6 +175,12 @@ typedef curl_progress_callback s3_progress_func; S3_ERROR(UnexpectedContent), \ S3_ERROR(UnresolvableGrantByEmailAddress), \ S3_ERROR(Unknown), \ + S3_ERROR(Unauthorized), \ + S3_ERROR(Created), \ + S3_ERROR(Accepted), \ + S3_ERROR(Forbidden), \ + S3_ERROR(Conflict), \ + S3_ERROR(AuthenticationRequired), \ S3_ERROR(END) typedef enum { @@ -232,8 +248,35 @@ s3_init(void); * @returns: the new S3Handle */ S3Handle * -s3_open(const char * access_key, const char *secret_key, const char * user_token, - const char * bucket_location, const char * storage_class, const char * ca_info); +s3_open(const char * access_key, const char *secret_key, + const char *swift_account_id, const char *swift_access_key, + const char *host, + const char *service_path, gboolean use_subdomain, + const char * user_token, + const char * bucket_location, const char * storage_class, + const char * ca_info, const char * server_side_encryption, + const char *proxy, + const S3_api s3_api, + const char *username, + const char *password, + const char *tenant_id, + const char *tenant_name, + const char *client_id, + const char *client_secret, + const char *refresh_token, + const gboolean reuse_connection, + const char *reps, + const char *reps_bucket); + +/* latest step of setting up the S3Handle. + * + * Must be done after all properties are set. + * + * @param hdl: the S3Handle to set up. + * @returns: false if an error occured + */ +gboolean +s3_open2(S3Handle *hdl); /* Deallocate an S3Handle * @@ -365,6 +408,7 @@ s3_upload(S3Handle *hdl, * @param prefix: the prefix * @param delimiter: delimiter (any length string) * @param list: (output) the list of files + * @param total_size: (output) sum of size of files * @returns: FALSE if an error occurs */ gboolean @@ -372,7 +416,8 @@ s3_list_keys(S3Handle *hdl, const char *bucket, const char *prefix, const char *delimiter, - GSList **list); + GSList **list, + guint64 *total_size); /* Read an entire file, passing the contents to write_func buffer * by buffer. @@ -409,6 +454,19 @@ s3_delete(S3Handle *hdl, const char *bucket, const char *key); +/* Delete multiple file. + * + * @param hdl: the S3Handle object + * @param bucket: the bucket to delete from + * @param key: the key array to delete + * @returns: 0 on sucess, 1 if multi_delete is not supported, 2 if an error + * occurs; a non-existent file is I{not} considered an error. + */ +int +s3_multi_delete(S3Handle *hdl, + const char *bucket, + const char **key); + /* Create a bucket. * * @param hdl: the S3Handle object @@ -417,7 +475,19 @@ s3_delete(S3Handle *hdl, */ gboolean s3_make_bucket(S3Handle *hdl, - const char *bucket); + const char *bucket, + const char *project_id); + +/* Check if a bucket exists. + * + * @param hdl: the S3Handle object + * @param bucket: the bucket to create + * @returns: FALSE if an error occur + */ +gboolean +s3_is_bucket_exists(S3Handle *hdl, + const char *bucket, + const char *project_id); /* Delete a bucket *