VirtualBox

source: vbox/trunk/include/iprt/s3.h@ 77118

Last change on this file since 77118 was 76585, checked in by vboxsync, 6 years ago

*: scm --fix-header-guard-endif

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 8.6 KB
Line 
1/* $Id: s3.h 76585 2019-01-01 06:31:29Z vboxsync $ */
2/** @file
3 * IPRT - Simple Storage Service (S3) Communication API.
4 */
5
6/*
7 * Copyright (C) 2009-2019 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 *
17 * The contents of this file may alternatively be used under the terms
18 * of the Common Development and Distribution License Version 1.0
19 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
20 * VirtualBox OSE distribution, in which case the provisions of the
21 * CDDL are applicable instead of those of the GPL.
22 *
23 * You may elect to license modified versions of this file under the
24 * terms and conditions of either the GPL or the CDDL or both.
25 */
26
27#ifndef IPRT_INCLUDED_s3_h
28#define IPRT_INCLUDED_s3_h
29#ifndef RT_WITHOUT_PRAGMA_ONCE
30# pragma once
31#endif
32
33#include <iprt/types.h>
34
35RT_C_DECLS_BEGIN
36
37/** @defgroup grp_rt_s3 RTS3 - Simple Storage Service (S3) Communication API
38 * @ingroup grp_rt
39 * @{
40 */
41
42/** @todo the following three definitions may move the iprt/types.h later. */
43/** RTS3 interface handle. */
44typedef R3PTRTYPE(struct RTS3INTERNAL *) RTS3;
45/** Pointer to a RTS3 interface handle. */
46typedef RTS3 *PRTS3;
47/** Nil RTS3 interface handle. */
48#define NIL_RTS3 ((RTS3)0)
49
50
51/**
52 * S3 progress callback.
53 *
54 * @returns Reserved, must be 0.
55 *
56 * @param uPercent The process completion percentage.
57 * @param pvUser The user parameter given to RTS3SetProgressCallback.
58 */
59typedef DECLCALLBACK(int) FNRTS3PROGRESS(unsigned uPercent, void *pvUser);
60/** Pointer to a S3 progress callback. */
61typedef FNRTS3PROGRESS *PFNRTS3PROGRESS;
62
63
64/** Pointer to an S3 bucket entry. */
65typedef struct RTS3BUCKETENTRY *PRTS3BUCKETENTRY;
66/** Pointer to a const S3 bucket entry. */
67typedef struct RTS3BUCKETENTRY const *PCRTS3BUCKETENTRY;
68/**
69 * RTS3 bucket entry.
70 *
71 * Represent a bucket of the S3 storage server. Bucket entries are chained as a
72 * doubly linked list using the pPrev & pNext member.
73 *
74 * @todo Consider making the entire list const unless there are plans for
75 * more APIs using this structure which requires the caller to create
76 * or modify it.
77 */
78typedef struct RTS3BUCKETENTRY
79{
80 /** The previous element. */
81 PRTS3BUCKETENTRY pPrev;
82 /** The next element. */
83 PRTS3BUCKETENTRY pNext;
84
85 /** The name of the bucket. */
86 char const *pszName;
87 /** The creation date of the bucket as string. */
88 char const *pszCreationDate;
89} RTS3BUCKETENTRY;
90
91
92/** Pointer to an S3 key entry. */
93typedef struct RTS3KEYENTRY *PRTS3KEYENTRY;
94/** Pointer to a const S3 key entry. */
95typedef struct RTS3KEYENTRY const *PCRTS3KEYENTRY;
96/**
97 * RTS3 key entry.
98 *
99 * Represent a key of the S3 storage server. Key entries are chained as a doubly
100 * linked list using the pPrev & pNext member.
101 *
102 * @todo Consider making the entire list const unless there are plans for
103 * more APIs using this structure which requires the caller to create
104 * or modify it.
105 */
106typedef struct RTS3KEYENTRY
107{
108 /** The previous element. */
109 PRTS3KEYENTRY pPrev;
110 /** The next element. */
111 PRTS3KEYENTRY pNext;
112
113 /** The name of the key. */
114 char const *pszName;
115 /** The date this key was last modified as string. */
116 char const *pszLastModified;
117 /** The size of the file behind this key in bytes. */
118 uint64_t cbFile;
119} RTS3KEYENTRY;
120
121
122/**
123 * Creates a RTS3 interface handle.
124 *
125 * @returns iprt status code.
126 *
127 * @param phS3 Where to store the RTS3 handle.
128 * @param pszAccessKey The access key for the S3 storage server.
129 * @param pszSecretKey The secret access key for the S3 storage server.
130 * @param pszBaseUrl The base URL of the S3 storage server.
131 * @param pszUserAgent An optional user agent string used in the HTTP
132 * communication.
133 */
134RTR3DECL(int) RTS3Create(PRTS3 phS3, const char *pszAccessKey, const char *pszSecretKey, const char *pszBaseUrl, const char *pszUserAgent);
135
136/**
137 * Destroys a RTS3 interface handle.
138 *
139 * @returns iprt status code.
140 *
141 * @param hS3 Handle to the RTS3 interface.
142 */
143RTR3DECL(void) RTS3Destroy(RTS3 hS3);
144
145/**
146 * Sets an optional progress callback.
147 *
148 * This callback function will be called when the completion percentage of an S3
149 * operation changes.
150 *
151 * @returns iprt status code.
152 *
153 * @param hS3 Handle to the RTS3 interface.
154 * @param pfnProgressCB The pointer to the progress function.
155 * @param pvUser The pvUser arg of FNRTS3PROGRESS.
156 */
157RTR3DECL(void) RTS3SetProgressCallback(RTS3 hS3, PFNRTS3PROGRESS pfnProgressCB, void *pvUser);
158
159/**
160 * Gets a list of all available buckets on the S3 storage server.
161 *
162 * You have to delete ppBuckets after usage with RTS3BucketsDestroy.
163 *
164 * @returns iprt status code.
165 *
166 * @param hS3 Handle to the RTS3 interface.
167 * @param ppBuckets Where to store the pointer to the head of the
168 * returned bucket list. Consider the entire list
169 * read-only.
170 */
171RTR3DECL(int) RTS3GetBuckets(RTS3 hS3, PCRTS3BUCKETENTRY *ppBuckets);
172
173/**
174 * Destroys the bucket list returned by RTS3GetBuckets.
175 *
176 * @returns iprt status code.
177 *
178 * @param pBuckets Pointer to the first bucket entry.
179 */
180RTR3DECL(int) RTS3BucketsDestroy(PCRTS3BUCKETENTRY pBuckets);
181
182/**
183 * Creates a new bucket on the S3 storage server.
184 *
185 * This name have to be unique over all accounts on the S3 storage server.
186 *
187 * @returns iprt status code.
188 *
189 * @param hS3 Handle to the RTS3 interface.
190 * @param pszBucketName Name of the new bucket.
191 */
192RTR3DECL(int) RTS3CreateBucket(RTS3 hS3, const char *pszBucketName);
193
194/**
195 * Deletes a bucket on the S3 storage server.
196 *
197 * The bucket must be empty.
198 *
199 * @returns iprt status code.
200 *
201 * @param hS3 Handle to the RTS3 interface.
202 * @param pszBucketName Name of the bucket to delete.
203 */
204RTR3DECL(int) RTS3DeleteBucket(RTS3 hS3, const char *pszBucketName);
205
206/**
207 * Gets a list of all available keys in a bucket on the S3 storage server.
208 *
209 * You have to delete ppKeys after usage with RTS3KeysDestroy.
210 *
211 * @returns iprt status code.
212 *
213 * @param hS3 Handle to the RTS3 interface.
214 * @param pszBucketName Name of the bucket to delete.
215 * @param ppKeys Where to store the pointer to the head of the
216 * returned key list. Consider the entire list
217 * read-only.
218 */
219RTR3DECL(int) RTS3GetBucketKeys(RTS3 hS3, const char *pszBucketName, PCRTS3KEYENTRY *ppKeys);
220
221/**
222 * Delete the key list returned by RTS3GetBucketKeys.
223 *
224 * @returns iprt status code.
225 *
226 * @param pKeys Pointer to the first key entry.
227 */
228RTR3DECL(int) RTS3KeysDestroy(PCRTS3KEYENTRY pKeys);
229
230/**
231 * Deletes a key in a bucket on the S3 storage server.
232 *
233 * @returns iprt status code.
234 *
235 * @param hS3 Handle to the RTS3 interface.
236 * @param pszBucketName Name of the bucket contains pszKeyName.
237 * @param pszKeyName Name of the key to delete.
238 */
239RTR3DECL(int) RTS3DeleteKey(RTS3 hS3, const char *pszBucketName, const char *pszKeyName);
240
241/**
242 * Downloads a key from a bucket into a file.
243 *
244 * The file must not exists.
245 *
246 * @returns iprt status code.
247 *
248 * @param hS3 Handle to the RTS3 interface.
249 * @param pszBucketName Name of the bucket that contains pszKeyName.
250 * @param pszKeyName Name of the key to download.
251 * @param pszFilename Name of the file to store the downloaded key as.
252 */
253RTR3DECL(int) RTS3GetKey(RTS3 hS3, const char *pszBucketName, const char *pszKeyName, const char *pszFilename);
254
255/**
256 * Uploads the content of a file into a key in the specified bucked.
257 *
258 * @returns iprt status code.
259 *
260 * @param hS3 Handle to the RTS3 interface.
261 * @param pszBucketName Name of the bucket where the new key should be
262 * created.
263 * @param pszKeyName Name of the new key.
264 * @param pszFilename Name of the file to upload the content of.
265 */
266RTR3DECL(int) RTS3PutKey(RTS3 hS3, const char *pszBucketName, const char *pszKeyName, const char *pszFilename);
267
268/** @} */
269
270RT_C_DECLS_END
271
272#endif /* !IPRT_INCLUDED_s3_h */
273
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette