-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathuplink_definitions.h
334 lines (266 loc) · 8.11 KB
/
uplink_definitions.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
#pragma once
// Copyright (C) 2020 Storj Labs, Inc.
// See LICENSE for copying information.
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include "uplink_compat.h"
typedef const char uplink_const_char;
typedef struct UplinkHandle {
size_t _handle;
} UplinkHandle;
typedef struct UplinkAccess {
size_t _handle;
} UplinkAccess;
typedef struct UplinkProject {
size_t _handle;
} UplinkProject;
typedef struct UplinkDownload {
size_t _handle;
} UplinkDownload;
typedef struct UplinkUpload {
size_t _handle;
} UplinkUpload;
typedef struct UplinkEncryptionKey {
size_t _handle;
} UplinkEncryptionKey;
typedef struct UplinkPartUpload {
size_t _handle;
} UplinkPartUpload;
typedef struct UplinkConfig {
const char *user_agent;
int32_t dial_timeout_milliseconds;
// temp_directory specifies where to save data during downloads to use less memory.
const char *temp_directory;
} UplinkConfig;
typedef struct UplinkBucket {
char *name;
int64_t created;
} UplinkBucket;
typedef struct UplinkSystemMetadata {
int64_t created;
int64_t expires;
int64_t content_length;
} UplinkSystemMetadata;
typedef struct UplinkCustomMetadataEntry {
char *key;
size_t key_length;
char *value;
size_t value_length;
} UplinkCustomMetadataEntry;
typedef struct UplinkCustomMetadata {
UplinkCustomMetadataEntry *entries;
size_t count;
} UplinkCustomMetadata;
typedef struct UplinkObject {
char *key;
bool is_prefix;
UplinkSystemMetadata system;
UplinkCustomMetadata custom;
} UplinkObject;
typedef struct UplinkUploadOptions {
// When expires is 0 or negative, it means no expiration.
int64_t expires;
} UplinkUploadOptions;
typedef struct UplinkDownloadOptions {
// When offset is negative it will read the suffix of the blob.
// Combining negative offset and positive length is not supported.
int64_t offset;
// When length is negative, it will read until the end of the blob.
int64_t length;
} UplinkDownloadOptions;
typedef struct UplinkListObjectsOptions {
const char *prefix;
const char *cursor;
bool recursive;
bool system;
bool custom;
} UplinkListObjectsOptions;
typedef struct UplinkListUploadsOptions {
const char *prefix;
const char *cursor;
bool recursive;
bool system;
bool custom;
} UplinkListUploadsOptions;
typedef struct UplinkListBucketsOptions {
const char *cursor;
} UplinkListBucketsOptions;
typedef struct UplinkObjectIterator {
size_t _handle;
} UplinkObjectIterator;
typedef struct UplinkBucketIterator {
size_t _handle;
} UplinkBucketIterator;
typedef struct UplinkUploadIterator {
size_t _handle;
} UplinkUploadIterator;
typedef struct UplinkPartIterator {
size_t _handle;
} UplinkPartIterator;
typedef struct UplinkPermission {
bool allow_download;
bool allow_upload;
bool allow_list;
bool allow_delete;
// unix time in seconds when the permission becomes valid.
// disabled when 0.
int64_t not_before;
// unix time in seconds when the permission becomes invalid.
// disabled when 0.
int64_t not_after;
} UplinkPermission;
typedef struct UplinkPart {
uint32_t part_number;
size_t size; // plain size of a part.
int64_t modified;
char *etag;
size_t etag_length;
} UplinkPart;
typedef struct UplinkSharePrefix {
const char *bucket;
// prefix is the prefix of the shared object keys.
const char *prefix;
} UplinkSharePrefix;
typedef struct UplinkError {
int32_t code;
char *message;
} UplinkError;
#define UPLINK_ERROR_INTERNAL 0x02
#define UPLINK_ERROR_CANCELED 0x03
#define UPLINK_ERROR_INVALID_HANDLE 0x04
#define UPLINK_ERROR_TOO_MANY_REQUESTS 0x05
#define UPLINK_ERROR_BANDWIDTH_LIMIT_EXCEEDED 0x06
#define UPLINK_ERROR_STORAGE_LIMIT_EXCEEDED 0x07
#define UPLINK_ERROR_SEGMENTS_LIMIT_EXCEEDED 0x08
#define UPLINK_ERROR_PERMISSION_DENIED 0x09
#define UPLINK_ERROR_BUCKET_NAME_INVALID 0x10
#define UPLINK_ERROR_BUCKET_ALREADY_EXISTS 0x11
#define UPLINK_ERROR_BUCKET_NOT_EMPTY 0x12
#define UPLINK_ERROR_BUCKET_NOT_FOUND 0x13
#define UPLINK_ERROR_OBJECT_KEY_INVALID 0x20
#define UPLINK_ERROR_OBJECT_NOT_FOUND 0x21
#define UPLINK_ERROR_UPLOAD_DONE 0x22
#define EDGE_ERROR_AUTH_DIAL_FAILED 0x30
#define EDGE_ERROR_REGISTER_ACCESS_FAILED 0x31
typedef struct UplinkAccessResult {
UplinkAccess *access;
UplinkError *error;
} UplinkAccessResult;
typedef struct UplinkProjectResult {
UplinkProject *project;
UplinkError *error;
} UplinkProjectResult;
typedef struct UplinkBucketResult {
UplinkBucket *bucket;
UplinkError *error;
} UplinkBucketResult;
typedef struct UplinkObjectResult {
UplinkObject *object;
UplinkError *error;
} UplinkObjectResult;
typedef struct UplinkUploadResult {
UplinkUpload *upload;
UplinkError *error;
} UplinkUploadResult;
typedef struct UplinkPartUploadResult {
UplinkPartUpload *part_upload;
UplinkError *error;
} UplinkPartUploadResult;
typedef struct UplinkDownloadResult {
UplinkDownload *download;
UplinkError *error;
} UplinkDownloadResult;
typedef struct UplinkWriteResult {
size_t bytes_written;
UplinkError *error;
} UplinkWriteResult;
typedef struct UplinkReadResult {
size_t bytes_read;
UplinkError *error;
} UplinkReadResult;
typedef struct UplinkStringResult {
char *string;
UplinkError *error;
} UplinkStringResult;
typedef struct UplinkEncryptionKeyResult {
UplinkEncryptionKey *encryption_key;
UplinkError *error;
} UplinkEncryptionKeyResult;
typedef struct UplinkUploadInfo {
char *upload_id;
char *key;
bool is_prefix;
UplinkSystemMetadata system;
UplinkCustomMetadata custom;
} UplinkUploadInfo;
typedef struct UplinkUploadInfoResult {
UplinkUploadInfo *info;
UplinkError *error;
} UplinkUploadInfoResult;
typedef struct UplinkCommitUploadOptions {
UplinkCustomMetadata custom_metadata;
} UplinkCommitUploadOptions;
typedef struct UplinkCommitUploadResult {
UplinkObject *object;
UplinkError *error;
} UplinkCommitUploadResult;
typedef struct UplinkPartResult {
UplinkPart *part;
UplinkError *error;
} UplinkPartResult;
typedef struct UplinkListUploadPartsOptions {
uint32_t cursor;
} UplinkListUploadPartsOptions;
// Parameters when connecting to edge services
typedef struct EdgeConfig {
// DRPC server e.g. auth.[eu|ap|us]1.storjshare.io:7777
// Mandatory for now because this is no agreement on how to derive this
const char *auth_service_address;
// Root certificate(s) or chain(s) against which Uplink checks
// the auth service.
// In PEM format.
// Intended to test against a self-hosted auth service
// or to improve security.
const char *certificate_pem;
// Controls whether a client uses unencrypted connection.
bool insecure_unencrypted_connection;
} EdgeConfig;
typedef struct EdgeRegisterAccessOptions {
// Wether objects can be read using only the access_key_id.
bool is_public;
} EdgeRegisterAccessOptions;
// Gateway credentials in S3 format
typedef struct EdgeCredentials {
// Is also used in the linkshare url path
const char *access_key_id;
const char *secret_key;
// Base HTTP(S) URL to the gateway.
// The gateway and linkshare service are different endpoints.
const char *endpoint;
} EdgeCredentials;
typedef struct EdgeCredentialsResult {
EdgeCredentials *credentials;
UplinkError *error;
} EdgeCredentialsResult;
typedef struct EdgeShareURLOptions {
// Serve the file directly rather than through a landing page.
bool raw;
} EdgeShareURLOptions;
// we need to suppress 'pedantic' validation because struct is empty for now
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wpedantic"
typedef struct UplinkMoveObjectOptions {
} UplinkMoveObjectOptions;
#pragma GCC diagnostic pop
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wpedantic"
typedef struct UplinkUploadObjectMetadataOptions {
} UplinkUploadObjectMetadataOptions;
#pragma GCC diagnostic pop
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wpedantic"
typedef struct UplinkCopyObjectOptions {
} UplinkCopyObjectOptions;
#pragma GCC diagnostic pop