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.
json_tools.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 #ifndef JSON_TOOLS_H
22 #define JSON_TOOLS_H
23 
24 #include "network_library.h"
25 #include "jansson.h"
26 
27 #include "typedefs.h"
28 #include "operation.h"
29 #include "request_tools.h"
30 //#include "uuid/uuid.h"
31 #include "user_details.h"
32 #include "schema_version.h"
33 #include "grassroots_server.h"
34 
35 
36 
37 /* forward declaration */
38 struct ProvidersStateTable;
39 
40 #ifdef __cplusplus
41 extern "C"
42 {
43 #endif
44 
45 
58 GRASSROOTS_NETWORK_API json_t *GetAvailableServicesRequest (const User *user_p, const SchemaVersion * const sv_p);
59 
60 
74 GRASSROOTS_NETWORK_API bool GetUsernameAndPassword (const User * const user_p, const char *provider_s, const char **username_ss, const char **password_ss);
75 
76 
91 GRASSROOTS_NETWORK_API json_t *GetInterestedServicesRequest (const User *user_p, const char * const protocol_s, const char * const filename_s, const SchemaVersion * const sv_p);
92 
93 
107 GRASSROOTS_NETWORK_API json_t *GetNamedServicesRequest (const User *user_p, const char * const service_name_s, const SchemaVersion * const sv_p);
108 
109 
123 GRASSROOTS_NETWORK_API json_t *GetNamedServicesIndexingDataRequest (const User *user_p, const char * const service_names_s, const SchemaVersion * const sv_p);
124 
125 
136 GRASSROOTS_NETWORK_API bool AddClientConfigToJSON (json_t *root_p, const User *user_p);
137 
138 
150 GRASSROOTS_NETWORK_API json_t *GetOperationAsJSON (Operation op, const SchemaVersion * const sv_p);
151 
152 
174 GRASSROOTS_NETWORK_API json_t *GetServicesRequest (const User *user_p, const Operation op, const char * const op_key_s, json_t * const op_data_p, const SchemaVersion * const sv_p);
175 
176 
186 GRASSROOTS_NETWORK_API json_t *MakeRemoteJsonCall (json_t *req_p, Connection *connection_p);
187 
188 
197 GRASSROOTS_NETWORK_API const char *GetUserUUIDStringFromJSON (const json_t *credentials_p);
198 
199 
214 GRASSROOTS_NETWORK_API json_t *GetServicesResultsRequest (const uuid_t **ids_pp, const uint32 num_ids, Connection *connection_p, const SchemaVersion * const sv_p);
215 
216 
227 GRASSROOTS_NETWORK_API bool GetStatusFromJSON (const json_t *service_json_p, OperationStatus *status_p);
228 
229 
230 
231 
241 GRASSROOTS_NETWORK_API json_t *CallServices (json_t *client_results_p, const User *user_p, Connection *connection_p);
242 
243 
256 GRASSROOTS_NETWORK_API json_t *GetInitialisedMessage (const SchemaVersion * const sv_p);
257 
258 
259 
266 GRASSROOTS_NETWORK_API const char *GetServiceDescriptionFromJSON (const json_t * const root_p);
267 
268 
275 GRASSROOTS_NETWORK_API const char *GetServiceAliasFromJSON (const json_t * const root_p);
276 
277 
284 GRASSROOTS_NETWORK_API const char *GetServiceNameFromJSON (const json_t * const root_p);
285 
286 
293 GRASSROOTS_NETWORK_API const char *GetOperationDescriptionFromJSON (const json_t * const root_p);
294 
295 
302 GRASSROOTS_NETWORK_API const char *GetOperationNameFromJSON (const json_t * const root_p);
303 
304 
311 GRASSROOTS_NETWORK_API const char *GetOperationInformationURIFromJSON (const json_t * const root_p);
312 
313 
320 GRASSROOTS_NETWORK_API const char *GetOperationIconURIFromJSON (const json_t * const root_p);
321 
322 
323 
332 GRASSROOTS_NETWORK_API const json_t *GetProviderFromServiceJSON (const json_t *service_json_p);
333 
334 
335 
353 
354 
355 
356 
357 GRASSROOTS_NETWORK_API json_t *GetIndexingDataPayload (GrassrootsServer *grassroots_p, const char *service_s, json_t *params_array_json_p);
358 
359 
360 #ifdef __cplusplus
361 }
362 #endif
363 
364 #endif /* #ifndef JSON_TOOLS_H */
SchemaVersion
This is a datatype to store the versioning details for the Grassroots JSON schema that is being used.
Definition: schema_version.h:44
GetServicesRequest
json_t * GetServicesRequest(const User *user_p, const Operation op, const char *const op_key_s, json_t *const op_data_p, const SchemaVersion *const sv_p)
Generate the request to run an Operation.
GRASSROOTS_NETWORK_API
#define GRASSROOTS_NETWORK_API
Definition: network_library.h:46
GetStatusFromJSON
bool GetStatusFromJSON(const json_t *service_json_p, OperationStatus *status_p)
Get the current OperationStatus for a Service from its JSON fragment.
GetUsernameAndPassword
bool GetUsernameAndPassword(const User *const user_p, const char *provider_s, const char **username_ss, const char **password_ss)
Extract the user credentials from a JSON fragment.
Operation
Operation
The various Operations that a Server can perform.
Definition: operation.h:46
GetOperationDescriptionFromJSON
const char * GetOperationDescriptionFromJSON(const json_t *const root_p)
Get the description of an Operation.
GetNamedServicesRequest
json_t * GetNamedServicesRequest(const User *user_p, const char *const service_name_s, const SchemaVersion *const sv_p)
Generate the JSON fragment to send to the Server for getting the details of a particular Service.
GetOperationNameFromJSON
const char * GetOperationNameFromJSON(const json_t *const root_p)
Get the name of an Operation.
operation.h
schema_version.h
request_tools.h
network_library.h
grassroots_server.h
GetUserUUIDStringFromJSON
const char * GetUserUUIDStringFromJSON(const json_t *credentials_p)
Get the User uuid from a JSON fragment.
GetAvailableServicesRequest
json_t * GetAvailableServicesRequest(const User *user_p, const SchemaVersion *const sv_p)
Generate the JSON fragment to send to the Server for getting all available Services.
GetOperationAsJSON
json_t * GetOperationAsJSON(Operation op, const SchemaVersion *const sv_p)
Get the JSON fragment for a given Operation.
GetInitialisedMessage
json_t * GetInitialisedMessage(const SchemaVersion *const sv_p)
Create a response object with a valid header.
GetOperationInformationURIFromJSON
const char * GetOperationInformationURIFromJSON(const json_t *const root_p)
Get the URI of an Operation.
typedefs.h
Connection
The base class for building a Server-Client connection.
Definition: connection.h:65
Connection::CallServices
json_t * CallServices(json_t *client_results_p, const User *user_p, Connection *connection_p)
Make a call from a Client to a Server.
ProvidersStateTable
This is a datatype that is used to keep track of which servers and services have already been process...
Definition: providers_state_table.h:49
AddClientConfigToJSON
bool AddClientConfigToJSON(json_t *root_p, const User *user_p)
Add the given credentials in the correct position in a JSON fragment.
OperationStatus
OperationStatus
The current status of an Operation.
Definition: operation.h:96
GetIndexingDataPayload
json_t * GetIndexingDataPayload(GrassrootsServer *grassroots_p, const char *service_s, json_t *params_array_json_p)
GrassrootsServer
Definition: grassroots_server.h:45
GetServiceDescriptionFromJSON
const char * GetServiceDescriptionFromJSON(const json_t *const root_p)
Get the description of a Service.
User
A datatype to store user credentials.
Definition: user_details.h:40
user_details.h
GetServiceNameFromJSON
const char * GetServiceNameFromJSON(const json_t *const root_p)
Get the name of a Service.
GetServiceAliasFromJSON
const char * GetServiceAliasFromJSON(const json_t *const root_p)
Get the alias of a Service.
GetNamedServicesIndexingDataRequest
json_t * GetNamedServicesIndexingDataRequest(const User *user_p, const char *const service_names_s, const SchemaVersion *const sv_p)
Generate the JSON fragment to send to the Server for getting the indexing data of a particular Servic...
GetServicesResultsRequest
json_t * GetServicesResultsRequest(const uuid_t **ids_pp, const uint32 num_ids, Connection *connection_p, const SchemaVersion *const sv_p)
Generate the JSON fragment to send to the Server for getting the results of one or more Operations.
GetInterestedServicesRequest
json_t * GetInterestedServicesRequest(const User *user_p, const char *const protocol_s, const char *const filename_s, const SchemaVersion *const sv_p)
Generate the JSON fragment to send to the Server for getting Services that are viable for a given Res...
MakeRemoteJsonCall
json_t * MakeRemoteJsonCall(json_t *req_p, Connection *connection_p)
Send a JSON-based request to the server and get the JSON-based response.
GetProviderFromServiceJSON
const json_t * GetProviderFromServiceJSON(const json_t *service_json_p)
Get the JSON fragment specifying the Provider details from a JSON fragment representing a Service.
GetOperationFromTopLevelJSON
Operation GetOperationFromTopLevelJSON(const json_t *const json_p)
Get requested Operation from a JSON fragment.
GetOperationIconURIFromJSON
const char * GetOperationIconURIFromJSON(const json_t *const root_p)
Get the URI for an associated image icon an Operation.
uuid_t
Definition: windows_uuid.h:43