paired_service.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 
22 /*
23  * paired_service.h
24  *
25  * Created on: 1 Feb 2016
26  * Author: billy
27  */
28 
29 #ifndef PAIRED_SERVICE_H_
30 #define PAIRED_SERVICE_H_
31 
32 
33 
34 #include "jansson.h"
35 #include "uuid/uuid.h"
36 
37 #include "parameter_set.h"
38 #include "linked_list.h"
40 
41 #include "providers_state_table.h"
42 #include "parameter_set.h"
43 #include "service_job.h"
44 
45 
46 /* forward declarations */
47 struct Service;
48 struct ServiceData;
49 struct RemoteServiceJob;
50 
51 
59 typedef struct PairedService
60 {
63 
65  char *ps_name_s;
66 
69 
72 
74  json_t *ps_provider_p;
75 
79 
80 
88 typedef struct PairedServiceNode
89 {
92 
96 
97 
98 #ifdef __cplusplus
99 extern "C"
100 {
101 #endif
102 
103 
116 GRASSROOTS_SERVICE_API PairedService *AllocatePairedService (const uuid_t id, const char *name_s, const char *server_uri_s, const char *server_name_s, const json_t *service_json_p, const json_t *provider_p);
117 
118 
125 GRASSROOTS_SERVICE_API void FreePairedService (PairedService *paired_service_p);
126 
127 
135 GRASSROOTS_SERVICE_API PairedServiceNode *AllocatePairedServiceNode (PairedService *paired_service_p);
136 
137 
151 GRASSROOTS_SERVICE_API PairedServiceNode *AllocatePairedServiceNodeByParts (const uuid_t id, const char *name_s, const char *server_uri_s, const char *server_name_s, const json_t *op_p, const json_t *provider_p);
152 
153 
160 GRASSROOTS_SERVICE_API void FreePairedServiceNode (ListItem *node_p);
161 
162 
173 GRASSROOTS_SERVICE_API json_t *MakeRemotePairedServiceCall (const char * const service_name_s, ParameterSet *params_p, const char * const paired_service_uri_s, ProvidersStateTable *providers_p, GrassrootsServer *grassroots_p);
174 
175 
176 
193 GRASSROOTS_SERVICE_API int32 RunPairedServices (struct Service *service_p, ParameterSet *param_set_p, ProvidersStateTable *providers_p, bool (*save_job_fn) (struct RemoteServiceJob *job_p, const struct ServiceData *service_data_p));
194 
195 
214 GRASSROOTS_SERVICE_API int32 AddRemoteResultsToServiceJobs (const json_t *server_response_p, struct Service *service_p, const char * const remote_service_s, const char * const remote_uri_s, const struct ServiceData *service_data_p, bool (*save_job_fn) (struct RemoteServiceJob *job_p, const struct ServiceData *service_data_p));
215 
216 
217 
218 #ifdef __cplusplus
219 }
220 #endif
221 
222 #endif /* PAIRED_SERVICE_H_ */
A doubly-linked node that points to its predecessor and successor.
Definition: linked_list.h:43
A datatype describing a ServiceJob that is run on a remote Grassroots Server.
Definition: remote_service_job.h:65
A datatype for describing a remote Service that can be used in conjunction with a local Service.
Definition: paired_service.h:59
PairedService * AllocatePairedService(const uuid_t id, const char *name_s, const char *server_uri_s, const char *server_name_s, const json_t *service_json_p, const json_t *provider_p)
Allocate a PairedService.
void FreePairedServiceNode(ListItem *node_p)
Free a PairedServiceNode.
char * ps_server_name_s
The name of the ExternalServer.
Definition: paired_service.h:68
A doubly-linked list.
PairedServiceNode * AllocatePairedServiceNodeByParts(const uuid_t id, const char *name_s, const char *server_uri_s, const char *server_name_s, const json_t *op_p, const json_t *provider_p)
Allocate a PairedService and attach it to a PairedServiceNode.
PairedServiceNode * AllocatePairedServiceNode(PairedService *paired_service_p)
Allocate a PairedServiceNode.
A datatype for holding the configuration data for a Service.
Definition: service.h:126
A datatype which defines an available service, its capabilities and its parameters.
Definition: service.h:153
char * ps_name_s
The name of the PairedService.
Definition: paired_service.h:65
ListItem psn_node
The base list node.
Definition: paired_service.h:91
json_t * MakeRemotePairedServiceCall(const char *const service_name_s, ParameterSet *params_p, const char *const paired_service_uri_s, ProvidersStateTable *providers_p, GrassrootsServer *grassroots_p)
Call the PairedService and get its JSON response.
uuid_t ps_extenal_server_id
The UUID for the ExternalServer that runs the PairedService.
Definition: paired_service.h:62
void FreePairedService(PairedService *paired_service_p)
Free a PairedService.
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
int32 RunPairedServices(struct Service *service_p, ParameterSet *param_set_p, ProvidersStateTable *providers_p, bool(*save_job_fn)(struct RemoteServiceJob *job_p, const struct ServiceData *service_data_p))
Run all of the PairedServices for a given Service.
json_t * ps_provider_p
The JSON fragment detailing the Provider of this PairedService.
Definition: paired_service.h:74
Definition: grassroots_server.h:44
char * ps_server_uri_s
The URI of the ExternalServer's Grassroots service.
Definition: paired_service.h:71
int32 AddRemoteResultsToServiceJobs(const json_t *server_response_p, struct Service *service_p, const char *const remote_service_s, const char *const remote_uri_s, const struct ServiceData *service_data_p, bool(*save_job_fn)(struct RemoteServiceJob *job_p, const struct ServiceData *service_data_p))
Add the results of running PairedServices as RemoteServiceJobs to the ServiceJobSet of a given Servic...
A datatype for storing PairedServices on a LinkedList.
Definition: paired_service.h:88
A set of Parameters along with an optional name and description.
Definition: parameter_set.h:46
PairedService * psn_paired_service_p
The PairedService.
Definition: paired_service.h:94
ParameterSet * ps_params_p
The ParameterSet for this PairedService.
Definition: paired_service.h:77