CloudPlugs REST Library  1.0.0
for ANSI C
cp_rest.h
Go to the documentation of this file.
1 /*
2 Copyright 2014 CloudPlugs Inc.
3 
4 Licensed to the Apache Software Foundation (ASF) under one
5 or more contributor license agreements. See the NOTICE file
6 distributed with this work for additional information
7 regarding copyright ownership. The ASF licenses this file
8 to you under the Apache License, Version 2.0 (the
9 "License"); you may not use this file except in compliance
10 with the License. You may obtain a copy of the License at
11 
12  http://www.apache.org/licenses/LICENSE-2.0
13 
14 Unless required by applicable law or agreed to in writing,
15 software distributed under the License is distributed on an
16 "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 KIND, either express or implied. See the License for the
18 specific language governing permissions and limitations
19 under the License.
20 */
21 #ifndef CP_REST_H
22 #define CP_REST_H
23 
24 #include <stddef.h>
25 
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29 
30 
31 typedef struct _cloudplugs_session* cp_session;
33 #define CP_OK 0
34 #define CP_FAIL 1
35 typedef int cp_res;
37 typedef int cp_bool;
38 #define CP_TRUE 1
39 #define CP_FALSE 0
40 
41 
42 
44  CP_HTTP_OK = 200,
74  };
75 
76 
77 typedef enum _CP_ERR_CODE CP_ERR_CODE;
85 cp_res cloudplugs_global_init();
86 
94 
102 cp_res cloudplugs_set_base_url(cp_session cps, const char* url);
103 
111 cp_res cloudplugs_set_cacert(cp_session cps, const char* filename);
112 
119 const char* cloudplugs_get_base_url(cp_session cps);
120 
128 cp_res cloudplugs_set_timeout(cp_session cps, int timeout);
129 
136 int cloudplugs_get_timeout(cp_session cps);
137 
144 const char* cloudplugs_get_last_err_string(cp_session cps);
145 
152 CP_ERR_CODE cloudplugs_get_last_err_code(cp_session cps);
153 
160 const char* cloudplugs_get_last_http_result_string(cp_session cps);
161 
168 CP_HTTP_RESULT cloudplugs_get_last_http_result(cp_session cps);
169 
170 
176 cp_session cloudplugs_create_session();
177 
187 cp_res cloudplugs_set_auth(cp_session cps, const char* id, const char* pass, cp_bool is_master);
188 
196 cp_res cloudplugs_ssl_verify(cp_session cps, cp_bool is_verified);
197 
204 cp_bool cloudplugs_has_ssl_verify(cp_session cps);
205 
213 cp_res cloudplugs_enable_ssl(cp_session cps, cp_bool is_enabled);
214 
221 cp_bool cloudplugs_has_ssl(cp_session cps);
222 
231 cp_res cloudplugs_get_auth_id(cp_session cps, char* id, size_t size);
232 
241 cp_res cloudplugs_get_auth_pass(cp_session cps, char* password, size_t size);
242 
249 cp_bool cloudplugs_is_auth_master(cp_session cps);
250 
257 cp_res cloudplugs_destroy_session(cp_session cps);
258 
269 cp_bool cloudplugs_extract_string_from_json(char **json, const char* key, char *res, const int n);
270 
286 cp_res cloudplugs_enroll_product(cp_session cps, const char* body, char** result, size_t* result_length);
287 
304 cp_res cloudplugs_enroll_prototype(cp_session cps, const char* body, char** result, size_t* result_length);
305 
322 cp_res cloudplugs_enroll_ctrl(cp_session cps, const char* body, char** result, size_t* result_length);
323 
338 cp_res cloudplugs_control_device(cp_session cps, const char* body, char** result, size_t* result_length);
339 
350 cp_res cloudplugs_uncontrol_device(cp_session cps, const char* plugid, const char* plugid_controlled, char** result, size_t* result_length);
351 
361 cp_res cloudplugs_get_device(cp_session cps, const char* plugid, char** result, size_t* result_length);
362 
373 cp_res cloudplugs_get_device_prop(cp_session cps, const char* plugid, const char* prop, char** result, size_t* result_length);
374 
384 cp_res cloudplugs_set_device_prop(cp_session cps, const char* plugid, const char* prop, const char* value);
385 
394 cp_res cloudplugs_remove_device_prop(cp_session cps, const char* plugid, const char* prop);
395 
412 cp_res cloudplugs_set_device(cp_session cps, const char* plugid, const char* value, char** result, size_t* result_length);
413 
423 cp_res cloudplugs_unenroll(cp_session cps, const char* plugid, char** result, size_t* result_length);
424 
441 cp_res cloudplugs_get_channel(cp_session cps, const char* channel_mask, const char* query, char** result, size_t* result_length);
442 
459 cp_res cloudplugs_retrieve_data(cp_session cps, const char* channel_mask, const char* query, char** result, size_t* result_length);
460 
481 cp_res cloudplugs_publish_data(cp_session cps, const char* channel, const char* body, char** result, size_t* result_length);
482 
500 cp_res cloudplugs_remove_data(cp_session cps, const char* channel_mask, const char* body, char** result, size_t* result_length);
501 
514 cp_res cloudplugs_set_device_location(cp_session cps, const char* plugid, double longitude, double latitude, double altitude, double accuracy, double timestamp);
524 cp_res cloudplugs_get_device_location(cp_session cps, const char* plugid, char** result, size_t* result_length);
525 
526 #ifdef __cplusplus
527 }
528 #endif
529 
530 #endif //CP_REST_H
Definition: cp_rest.h:65
Definition: cp_rest.h:69
cp_res cloudplugs_unenroll(cp_session cps, const char *plugid, char **result, size_t *result_length)
cp_res cloudplugs_set_timeout(cp_session cps, int timeout)
cp_res cloudplugs_set_auth(cp_session cps, const char *id, const char *pass, cp_bool is_master)
Definition: cp_rest.h:46
CP_HTTP_RESULT cloudplugs_get_last_http_result(cp_session cps)
cp_res cloudplugs_control_device(cp_session cps, const char *body, char **result, size_t *result_length)
cp_res cloudplugs_get_auth_pass(cp_session cps, char *password, size_t size)
Definition: cp_rest.h:70
cp_res cloudplugs_publish_data(cp_session cps, const char *channel, const char *body, char **result, size_t *result_length)
cp_res cloudplugs_get_auth_id(cp_session cps, char *id, size_t size)
enum _CP_HTTP_RESULT CP_HTTP_RESULT
Definition: cp_rest.h:58
cp_res cloudplugs_global_init()
Definition: cp_rest.h:47
_CP_HTTP_RESULT
Definition: cp_rest.h:43
cp_res cloudplugs_set_cacert(cp_session cps, const char *filename)
cp_res cloudplugs_get_channel(cp_session cps, const char *channel_mask, const char *query, char **result, size_t *result_length)
_CP_ERR_CODE
Definition: cp_rest.h:62
const char * cloudplugs_get_base_url(cp_session cps)
Definition: cp_rest.h:50
cp_res cloudplugs_set_device_prop(cp_session cps, const char *plugid, const char *prop, const char *value)
enum _CP_ERR_CODE CP_ERR_CODE
Definition: cp_rest.h:77
cp_res cloudplugs_enroll_ctrl(cp_session cps, const char *body, char **result, size_t *result_length)
cp_res cloudplugs_ssl_verify(cp_session cps, cp_bool is_verified)
Definition: cp_rest.h:54
Definition: cp_rest.h:55
cp_res cloudplugs_destroy_session(cp_session cps)
int cp_res
Definition: cp_rest.h:35
cp_bool cloudplugs_extract_string_from_json(char **json, const char *key, char *res, const int n)
int cloudplugs_get_timeout(cp_session cps)
cp_bool cloudplugs_has_ssl_verify(cp_session cps)
cp_res cloudplugs_set_base_url(cp_session cps, const char *url)
const char * cloudplugs_get_last_err_string(cp_session cps)
Definition: cp_rest.h:51
Definition: cp_rest.h:66
Definition: cp_rest.h:49
cp_res cloudplugs_get_device_location(cp_session cps, const char *plugid, char **result, size_t *result_length)
Definition: cp_rest.h:48
cp_res cloudplugs_remove_device_prop(cp_session cps, const char *plugid, const char *prop)
Definition: cp_rest.h:73
cp_res cloudplugs_get_device(cp_session cps, const char *plugid, char **result, size_t *result_length)
cp_res cloudplugs_get_device_prop(cp_session cps, const char *plugid, const char *prop, char **result, size_t *result_length)
CP_ERR_CODE cloudplugs_get_last_err_code(cp_session cps)
Definition: cp_rest.h:56
Definition: cp_rest.h:72
struct _cloudplugs_session * cp_session
Definition: cp_rest.h:31
cp_session cloudplugs_create_session()
Definition: cp_rest.h:63
cp_res cloudplugs_enroll_prototype(cp_session cps, const char *body, char **result, size_t *result_length)
cp_res cloudplugs_remove_data(cp_session cps, const char *channel_mask, const char *body, char **result, size_t *result_length)
Definition: cp_rest.h:71
cp_res cloudplugs_enable_ssl(cp_session cps, cp_bool is_enabled)
cp_res cloudplugs_uncontrol_device(cp_session cps, const char *plugid, const char *plugid_controlled, char **result, size_t *result_length)
Definition: cp_rest.h:68
Definition: cp_rest.h:44
Definition: cp_rest.h:62
cp_res cloudplugs_enroll_product(cp_session cps, const char *body, char **result, size_t *result_length)
int cp_bool
Definition: cp_rest.h:37
Definition: cp_rest.h:57
const char * cloudplugs_get_last_http_result_string(cp_session cps)
cp_bool cloudplugs_is_auth_master(cp_session cps)
cp_res cloudplugs_set_device(cp_session cps, const char *plugid, const char *value, char **result, size_t *result_length)
cp_bool cloudplugs_has_ssl(cp_session cps)
Definition: cp_rest.h:45
cp_res cloudplugs_retrieve_data(cp_session cps, const char *channel_mask, const char *query, char **result, size_t *result_length)
Definition: cp_rest.h:64
Definition: cp_rest.h:53
cp_res cloudplugs_global_shutdown()
Definition: cp_rest.h:52
cp_res cloudplugs_set_device_location(cp_session cps, const char *plugid, double longitude, double latitude, double altitude, double accuracy, double timestamp)
Definition: cp_rest.h:67