Skip to content

Commit 4d4e46e

Browse files
author
Rosen Nedyalkov
committed
Merge remote-tracking branch 'upstream/master'
2 parents 6cf9a14 + 8407407 commit 4d4e46e

File tree

100 files changed

+1092232
-2779
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

100 files changed

+1092232
-2779
lines changed

.gitignore

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ Makefile.in
2020
.deps/
2121
.dirstamp
2222
.libs/
23+
*.a
2324
*.o
2425
*.l[ao]
2526
*~
@@ -28,3 +29,18 @@ Makefile.in
2829
!/cpp_sample/Makefile
2930
/win32/output
3031
/win32/ds3.zip
32+
CMakeCache.txt
33+
CMakeFiles
34+
cmake_install.cmake
35+
*.vcxproj*
36+
*.sdf
37+
*.sln
38+
*.suo
39+
*.opensdf
40+
Debug/
41+
*.dir/
42+
*.exe
43+
*.ilk
44+
*.pdb
45+
ds3.dll
46+
/win32/output/bin

CMakeLists.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
cmake_minimum_required(VERSION 2.8)
2+
project(libds3)
3+
4+
set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/modules/")
5+
6+
set (DS3SDK_VERSION_MAJOR 3)
7+
set (DS3SDK_VERSION_MINOR 2)
8+
set (DS3SDK_VERSION_PATCH 0)
9+
10+
add_subdirectory(src)

Makefile.am

Lines changed: 0 additions & 4 deletions
This file was deleted.

README.md

Lines changed: 110 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
DS3 C SDK
2-
=========
1+
Spectra S3 C SDK
2+
================
33

4-
This project contains a C library for using the DS3 Deep Storage REST interface.
4+
[![Apache V2 License](http://img.shields.io/badge/license-Apache%20V2-blue.svg)](https://github.com/SpectraLogic/ds3_c_sdk/blob/master/LICENSE.md)
5+
6+
This project contains a C library for using the Spectra S3 Deep Storage REST interface.
57

68
Contact Us
79
==========
@@ -12,7 +14,7 @@ Windows
1214
=======
1315

1416
For Windows we release a binary version of the SDK for your convenience. See
15-
[win32/README.dm](win32/README.md) for more information about building from
17+
[win32/README.md](win32/README.md) for more information about building from
1618
source in Windows.
1719

1820
Release Zip
@@ -41,17 +43,50 @@ Unix/Linux
4143
==========
4244

4345
For Unix/Linux we distribute the SDK as source code. The release tarballs
44-
contain a simple build script that should work on most Unix/Linux systems.
46+
contain a simple build script that should work on most Unix/Linux systems. The
47+
build system is currently autotools.
48+
49+
To install autotools on Ubuntu use apt-get and install the following:
50+
51+
$ sudo apt-get install build-essential
52+
$ sudo apt-get install autoconf
53+
$ sudo apt-get install libtool
54+
55+
To install autotools on CentOS use yum and install the following:
56+
$ sudo yum install autoconf
57+
$ sudo yum install libtool
4558

4659
The SDK depends upon several open source libraries, so you'll need to ensure
4760
that you've installed the development header packages for each of them. For
48-
example, Linux systems often provide lib\*-dev or lib\*-devel packages. The DS3
61+
example, Linux systems often provide lib\*-dev or lib\*-devel packages. The Spectra S3
4962
dependencies are:
5063

5164
* libxml2
5265
* libcurl
5366
* libglib-2.0
5467

68+
On Ubuntu you can install them with apt-get:
69+
70+
$ sudo apt-get install libxml2-dev
71+
$ sudo apt-get install libcurl4-openssl-dev
72+
$ sudo apt-get install libglib2.0-dev
73+
74+
On CentOS you can install them with yum:
75+
76+
$ sudo yum install libxml2-devel
77+
$ sudo yum install libcurl-devel
78+
$ sudo yum install glib2-devel
79+
80+
For testing you will need the boost unit test library as well.
81+
82+
On Ubuntu this can be installed with:
83+
84+
$ sudo apt-get install libboost-test-dev
85+
86+
On CentOS this can be installed with:
87+
88+
$ sudo yum install boost-test
89+
5590
Release Tarball
5691
---------------
5792

@@ -61,6 +96,7 @@ terminal window.
6196
$ cd directory/containing/release/tarball
6297
$ tar zxf ds3_c_sdk-{version}.tgz
6398
$ cd ds3_c_sdk-{version}
99+
$ autoreconf --install
64100
$ ./configure
65101
$ make
66102
$ su
@@ -113,122 +149,102 @@ To build the sample, use the following commands:
113149
$ cd sample
114150
$ make deps # Builds the SDK and installs it into directory/containing/source/tree**/install**
115151
$ make
152+
153+
To run it, first ensure that DS3_ACCESS_KEY, DS3_SECRET_KEY, DS3_ENDPOINT (and optionally http:proxy) are set in environment variables to match the target device. For the simulator, see [Installation Instructions] (https://developer.spectralogic.com/sim-install/)
116154

117-
To run it, just use `make run`.
155+
$ make run-put-bulk # create "books" bucket and put files into it
156+
$ make run-get-service # list all buckets
157+
$ make run-get-bucket # list contents of "books" bucket
158+
$ make run-get-object # get first book and write to temp file
159+
160+
Documentation
161+
-------------
162+
For the list of API calls in the C SDK please see the documentation [here](http://spectralogic.github.io/ds3_c_sdk/index.html)
118163

119164
Code Samples
120165
------------
121166

122-
The following section contains several examples of using the DS3 C SDK. The first example shows how to get a list of all the buckets back from DS3:
167+
The following section contains several examples of using the DS3 C SDK. The first example shows how to get a list of all the buckets back from Spectra S3:
123168

124169
```c
125-
126170
#include <stdlib.h>
127-
#include <string.h>
128-
#include <stdint.h>
129171
#include <stdio.h>
130-
#include <sys/types.h>
131-
#include <sys/stat.h>
132172
// "ds3.h" is the only header that needs to be included to use the DS3 API.
133173
#include "ds3.h"
134174

135-
int main (int args, char * argv[]) {
136-
// Allocate space for the response pointer.
137-
// The DS3 client library will end up consuming this.
138-
ds3_get_service_response *response;
139-
uint64_t i;
175+
int main (void) {
176+
// Get Service
177+
ds3_client* client;
178+
ds3_request* request;
179+
ds3_error* error;
180+
ds3_list_all_my_buckets_result_response *response;
181+
uint64_t bucket_index;
182+
183+
// Create a client from environment variables
184+
error = ds3_create_client_from_env(&client);
185+
handle_error(error);
140186

141-
// Setup client credentials and then the actual client itself.
142-
ds3_creds * creds = ds3_create_creds("cnlhbg==","ZIjGDQAs");
143-
ds3_client * client = ds3_create_client("http://192.168.56.101:8080", creds);
144-
145-
// You can optionally set a proxy server that a request should be sent through
146-
//ds3_client_proxy(client, "192.168.56.1:8888");
147-
148187
// Create the get service request. All requests to a DS3 appliance start this way.
149188
// All ds3_init_* functions return a ds3_request struct
150-
151-
ds3_request* request = ds3_init_get_service();
152-
189+
request = ds3_init_get_service_request();
190+
153191
// This performs the request to a DS3 appliance.
154192
// If there is an error 'error' will not be NULL
155193
// If the request completed successfully then 'error' will be NULL
156-
ds3_error* error = ds3_get_service(client, request, &response);
157-
ds3_free_request(request);
158-
159-
// Check that the request completed successfully
160-
if(error != NULL) {
161-
if(error->error != NULL) {
162-
printf("Got an error (%lu): %s\n", error->error->status_code, error->message);
163-
printf("Message Body: %s\n", error->error->error_body);
164-
}
165-
else {
166-
printf("Got a runtime error: %s\n", error->message);
167-
}
168-
ds3_free_error(error);
169-
ds3_free_creds(creds);
170-
ds3_free_client(client);
171-
return 1;
172-
}
173-
174-
if (response == NULL) {
175-
printf("Response was null\n");
176-
ds3_free_creds(creds);
177-
ds3_free_client(client);
178-
return 1;
179-
}
194+
error = ds3_get_service_request(client, request, &response);
195+
ds3_request_free(request);
196+
handle_error(error);
180197

181198
if(response->num_buckets == 0) {
182199
printf("No buckets returned\n");
183-
ds3_free_creds(creds);
184-
ds3_free_client(client);
200+
ds3_list_all_my_buckets_result_response_free(response);
201+
ds3_creds_free(client->creds);
202+
ds3_client_free(client);
185203
return 0;
186204
}
187205

188-
for (i = 0; i < response->num_buckets; i++) {
189-
ds3_bucket bucket = response->buckets[i];
190-
printf("Bucket: (%s) created on %s\n", bucket.name->value, bucket.creation_date->value);
206+
for (bucket_index = 0; bucket_index < response->num_buckets; bucket_index++) {
207+
ds3_bucket_details_response* bucket = response->buckets[bucket_index];
208+
printf("Bucket: (%s) created on %s\n", bucket->name->value, bucket->creation_date->value);
191209
}
192-
193-
ds3_free_service_response(response);
194210

195-
ds3_free_creds(creds);
196-
ds3_free_client(client);
211+
ds3_list_all_my_buckets_result_response_free(response);
212+
ds3_creds_free(client->creds);
213+
ds3_client_free(client);
197214
ds3_cleanup();
198-
215+
199216
return 0;
200217
}
201218

219+
202220
```
203221
204222
The next demonstrates how to create a new bucket:
205223
206224
```c
207225
208226
#include <stdlib.h>
209-
#include <string.h>
210-
#include <stdint.h>
211227
#include <stdio.h>
212-
#include <sys/types.h>
213-
#include <sys/stat.h>
228+
// "ds3.h" is the only header that needs to be included to use the DS3 API.
214229
#include "ds3.h"
215230
216231
int main (int args, char * argv[]) {
217232
ds3_creds * creds = ds3_create_creds("cnlhbg==","ZIjGDQAs");
218233
ds3_client * client = ds3_create_client("http://192.168.56.101:8080", creds);
219234
220235
char * bucket = "books";
221-
ds3_request * create_bucket_request = ds3_init_put_bucket(bucket);
222-
ds3_error* error = ds3_put_bucket(client, create_bucket_request);
223-
ds3_free_request(create_bucket_request);
236+
ds3_request * create_bucket_request = ds3_init_put_bucket_request(bucket_name);
237+
ds3_error* error = ds3_put_bucket_request(client, create_bucket_request);
238+
ds3_request_free(create_bucket_request);
224239
225240
if(error != NULL) {
226241
if(error->error != NULL) {
227-
printf("Failed to create bucket with error (%lu): %s\n", error->error->status_code, error->message);
228-
printf("Message Body: %s\n", error->error->error_body);
242+
printf("Failed to create bucket with error (%lu): %s\n", error->error->http_error_code, error->message->value);
243+
printf("Message Body: %s\n", error->error->message->value);
244+
printf("Resource: %s\n", error->error->resource->value);
229245
}
230246
else {
231-
printf("Got a runtime error: %s\n", error->message);
247+
printf("Got a runtime error: %s\n", error->message->value);
232248
}
233249
ds3_free_error(error);
234250
ds3_free_creds(creds);
@@ -250,16 +266,12 @@ The following is an example of performing a get bucket:
250266
```c
251267

252268
#include <stdlib.h>
253-
#include <string.h>
254-
#include <stdint.h>
255269
#include <stdio.h>
256-
#include <sys/types.h>
257-
#include <sys/stat.h>
258270
// "ds3.h" is the only header that needs to be included to use the DS3 API.
259271
#include "ds3.h"
260272

261273
int main (int args, char * argv[]) {
262-
ds3_get_bucket_response *response;
274+
ds3_list_bucket_result_response* response;
263275
uint64_t i;
264276

265277
// Setup client credentials and then the actual client itself.
@@ -277,48 +289,50 @@ int main (int args, char * argv[]) {
277289
// This performs the request to a DS3 appliance.
278290
// If there is an error 'error' will not be NULL
279291
// If the request completed successfully then 'error' will be NULL
280-
ds3_error* error = ds3_get_bucket(client, request, &response);
281-
ds3_free_request(request);
292+
ds3_error* error = ds3_get_bucket_request(client, request, &response);
293+
ds3_request_free(request);
282294

283295
// Check that the request completed successfully
284296
if(error != NULL) {
285297
if(error->error != NULL) {
286-
printf("Got an error (%lu): %s\n", error->error->status_code, error->message);
287-
printf("Message Body: %s\n", error->error->error_body);
298+
printf("Failed to create bucket with error (%lu): %s\n", error->error->http_error_code, error->message->value);
299+
printf("Message Body: %s\n", error->error->message->value);
300+
printf("Resource: %s\n", error->error->resource->value);
288301
}
289302
else {
290-
printf("Got a runtime error: %s\n", error->message);
303+
printf("Got a runtime error: %s\n", error->message->value);
291304
}
292-
ds3_free_error(error);
293-
ds3_free_creds(creds);
294-
ds3_free_client(client);
305+
ds3_list_bucket_result_response_free(response);
306+
ds3_error_free(error);
307+
ds3_creds_free(creds);
308+
ds3_client_free(client);
295309
return 1;
296-
}
310+
}
297311

298312
if (response == NULL) {
299313
printf("Response was null\n");
300-
ds3_free_creds(creds);
301-
ds3_free_client(client);
314+
ds3_creds_free(creds);
315+
ds3_client_free(client);
302316
return 1;
303317
}
304318

305319
if(response->num_objects == 0) {
306320
printf("No objects returned\n");
307-
ds3_free_bucket_response(response);
308-
ds3_free_creds(creds);
309-
ds3_free_client(client);
321+
ds3_list_bucket_result_response_free(response);
322+
ds3_creds_free(creds);
323+
ds3_client_free(client);
310324
return 0;
311325
}
312326

313327
for (i = 0; i < response->num_objects; i++) {
314-
ds3_object object = response->objects[i];
315-
printf("Object: (%s) created on %s\n", object.name, object.last_modified);
328+
ds3_contents_response* object = response->objects[i];
329+
printf("Object: (%s) created on %s\n", object->name->value, object->last_modified->value);
316330
}
317331

318-
ds3_free_bucket_response(response);
332+
ds3_list_bucket_result_response_free(response);
319333

320-
ds3_free_creds(creds);
321-
ds3_free_client(client);
334+
ds3_creds_free(creds);
335+
ds3_client_free(client);
322336
ds3_cleanup();
323337
return 0;
324338
}

0 commit comments

Comments
 (0)