Grassroots Infrastructure
The Grassroots Infrastructure is a suite of computing tools to help users and developers use scientific data infrastructure that can easily be interconnected.
web_service_util.h
Go to the documentation of this file.
1 /*
2 ** Copyright 2014-2016 The Earlham Institute
3 **
4 ** Licensed under the Apache License, Version 2.0 (the "License");
5 ** you may not use this file except in compliance with the License.
6 ** You may obtain a copy of the License at
7 **
8 ** http://www.apache.org/licenses/LICENSE-2.0
9 **
10 ** Unless required by applicable law or agreed to in writing, software
11 ** distributed under the License is distributed on an "AS IS" BASIS,
12 ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 ** See the License for the specific language governing permissions and
14 ** limitations under the License.
15 */
16 
21 /*
22  * web_service_util.h
23  *
24  * Created on: 17 Feb 2015
25  * Author: tyrrells
26  */
27 
28 #ifndef WEB_SERVICE_UTIL_H_
29 #define WEB_SERVICE_UTIL_H_
30 
31 #include "jansson.h"
32 
34 #include "service.h"
35 #include "parameter_set.h"
36 #include "byte_buffer.h"
37 #include "curl_tools.h"
38 #include "service_job.h"
39 
40 
46 typedef enum MatchType
47 {
50 
53 
56 
59 } MatchType;
60 
61 
68 typedef enum SubmissionMethod
69 {
71  SM_UNKNOWN = -1,
72 
75 
78 
84 
88 
89 
100 typedef struct WebServiceData
101 {
104 
108  json_t *wsd_config_p;
109 
111  const char *wsd_name_s;
112 
114  const char *wsd_description_s;
115 
117  const char *wsd_alias_s;
118 
120  const char *wsd_info_uri_s;
121 
124 
127 
129  const char *wsd_base_uri_s;
130 
133 
137 
138 
139 #ifdef __cplusplus
140 extern "C"
141 {
142 #endif
143 
144 
153 
154 
164 GRASSROOTS_SERVICE_API bool InitWebServiceData (WebServiceData * const data_p, json_t *op_json_p);
165 
166 
174 
175 
184 
185 
195 
196 
206 
207 
217 
218 
227 
228 
236 
237 
238 #ifdef __cplusplus
239 }
240 #endif
241 
242 
243 #endif /* WEB_SERVICE_UTIL_H_ */
WebServiceData::wsd_info_uri_s
const char * wsd_info_uri_s
The uri for more information about this WebService.
Definition: web_service_util.h:120
WebServiceData::wsd_base_uri_s
const char * wsd_base_uri_s
The uri that the WebService will submit its query to.
Definition: web_service_util.h:129
WebServiceData::wsd_config_p
json_t * wsd_config_p
The configuration from the reference service.
Definition: web_service_util.h:108
SM_NUM_METHODS
The number of SubmissionMethods.
Definition: web_service_util.h:86
WebServiceData::AddParametersToPostWebService
bool AddParametersToPostWebService(WebServiceData *data_p, ParameterSet *param_set_p)
Add parameters to the HTTP POST request used by the given WebServiceData.
service.h
CurlTool
A tool for making http(s) requests and responses.
Definition: curl_tools.h:74
grassroots_service_library.h
parameter_set.h
GRASSROOTS_SERVICE_API
#define GRASSROOTS_SERVICE_API
Definition: grassroots_service_library.h:49
WebServiceData::wsd_alias_s
const char * wsd_alias_s
The alias of the WebService.
Definition: web_service_util.h:117
SubmissionMethod
SubmissionMethod
An enumeration of the different web-based submission methods.
Definition: web_service_util.h:68
WebServiceData::AddParametersToBodyWebService
bool AddParametersToBodyWebService(WebServiceData *data_p, ParameterSet *param_set_p)
Add parameters to an HTTP POST request with a JSON fragment in its body used by the given WebServiceD...
MT_OR
Treat the parameters as a set of options to be OR'ed together.
Definition: web_service_util.h:55
MatchType
MatchType
An enumeration detailing how to combine different parameters upon submission to a web service.
Definition: web_service_util.h:46
GetMatchTypeParameterValue
MatchType GetMatchTypeParameterValue(ParameterSet *const param_set_p)
Get the value of the MatchType parameter from a ParameterSet.
SM_POST
An HTTP POST request.
Definition: web_service_util.h:74
WebServiceData::AddParametersToGetWebService
bool AddParametersToGetWebService(WebServiceData *data_p, ParameterSet *param_set_p)
Add parameters to the HTTP GET request used by the given WebServiceData.
WebServiceData::wsd_params_p
ParameterSet * wsd_params_p
The ParameterSet for this WebService.
Definition: web_service_util.h:123
WebServiceData
The configuration data for a WebService.
Definition: web_service_util.h:100
WebServiceData::wsd_method
SubmissionMethod wsd_method
The SubmissionMethod to use to submit the query.
Definition: web_service_util.h:132
SM_GET
An HTTP GET request.
Definition: web_service_util.h:77
WebServiceData::wsd_buffer_p
ByteBuffer * wsd_buffer_p
This is used to store the data when building the submission uri.
Definition: web_service_util.h:126
MT_NUM_MATCH_TYPES
The number of MatchTypes.
Definition: web_service_util.h:58
WebServiceData::InitWebServiceData
bool InitWebServiceData(WebServiceData *const data_p, json_t *op_json_p)
Initialise a WebServiceData.
byte_buffer.h
service_job.h
WebServiceData::wsd_name_s
const char * wsd_name_s
The name of the WebService.
Definition: web_service_util.h:111
SM_UNKNOWN
An invalid SubmissionMethod.
Definition: web_service_util.h:71
MT_EXACT_MATCH
The user requires an exact match of the parameter values.
Definition: web_service_util.h:49
MT_AND
The user wants the parameters AND'ed together.
Definition: web_service_util.h:52
WebServiceData::ClearWebServiceData
void ClearWebServiceData(WebServiceData *const data_p)
Clear a WebServiceData and free any associated memory.
SM_BODY
An HTTP POST request where the body of the request uses JSON.
Definition: web_service_util.h:83
ByteBuffer
A datatype to allow an automatically growing buffer for appending data to.
Definition: byte_buffer.h:35
WebServiceData::CallCurlWebservice
bool CallCurlWebservice(WebServiceData *data_p)
Make the request to the web service uri and store the response.
WebServiceData::wsd_curl_data_p
CurlTool * wsd_curl_data_p
The CurlTool used to send the request and receive the results.
Definition: web_service_util.h:135
ServiceData
A datatype for holding the configuration data for a Service.
Definition: service.h:126
curl_tools.h
WebServiceData::wsd_description_s
const char * wsd_description_s
The description of the WebService.
Definition: web_service_util.h:114
WebServiceData::wsd_base_data
ServiceData wsd_base_data
The base ServiceData.
Definition: web_service_util.h:103
GetSubmissionMethod
SubmissionMethod GetSubmissionMethod(const json_t *op_json_p)
Get the requested SubmissionMethod from a reference service.
ParameterSet
A set of Parameters along with an optional name and description.
Definition: parameter_set.h:46
AddMatchTypeParameter
bool AddMatchTypeParameter(WebServiceData *data_p, ParameterSet *param_set_p)
Add a Parameter giving the choice of MatchTypes to a ParameterSet.