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 
17 
22 #ifndef GRASSROOTS_SERVICE_H
23 #define GRASSROOTS_SERVICE_H
24 
26 
27 #include "byte_buffer.h"
28 #include "linked_list.h"
29 #include "parameter_set.h"
30 #include "typedefs.h"
31 #include "handler.h"
32 #include "user_details.h"
33 #include "operation.h"
34 #include "paired_service.h"
35 #include "linked_service.h"
36 #include "uuid/uuid.h"
37 #include "service_metadata.h"
38 #include "sync_data.h"
39 
40 #include "jansson.h"
41 
42 #include "providers_state_table.h"
43 
44 struct ExternalServer;
45 
46 /*
47  * The following preprocessor macros allow us to declare
48  * and define the variables in the same place. By default,
49  * they will expand to
50  *
51  * extern const char *SERVICE_NAME_S;
52  *
53  * however if ALLOCATE_JSON_TAGS is defined then it will
54  * become
55  *
56  * const char *SERVICE_NAME_S = "path";
57  *
58  * ALLOCATE_PATH_TAGS must be defined only once prior to
59  * including this header file. Currently this happens in
60  * service.c.
61  */
62 #ifndef DOXYGEN_SHOULD_SKIP_THIS
63 
64 #ifdef ALLOCATE_PATH_TAGS
65  #define PATH_PREFIX GRASSROOTS_SERVICE_API
66  #define PATH_VAL(x) = x
67 #else
68  #define PATH_PREFIX extern
69  #define PATH_VAL(x)
70 #endif
71 
72 #endif
73 
78 PATH_PREFIX const char *SERVICES_PATH_S PATH_VAL("services");
79 
80 
81 
88 /* forward declarations */
89 struct Plugin;
90 struct Service;
91 struct ServiceJob;
92 struct ServiceJobSet;
93 
94 
100 typedef enum
101 {
104 
110 
116 } Synchronicity;
117 
118 
125 typedef struct ServiceData
126 {
129 
134  json_t *sd_config_p;
135 
141 } ServiceData;
142 
143 
144 
145 
152 typedef struct Service
153 {
159 
168 
179  struct ServiceJobSet *(*se_run_fn) (struct Service *service_p, ParameterSet *param_set_p, UserDetails *user_p, ProvidersStateTable *providers_p);
180 
192  ParameterSet *(*se_match_fn) (struct Service *service_p, Resource *resource_p, Handler *handler_p);
193 
205  bool (*se_has_permissions_fn) (struct Service *service_p, ParameterSet *params_p, const UserDetails * const user_p);
206 
207 
211  const char *(*se_get_service_name_fn) (struct Service *service_p);
212 
216  const char *(*se_get_service_description_fn) (struct Service *service_p);
217 
221  const char *(*se_get_service_info_uri_fn) (struct Service *service_p);
222 
223 
227  ParameterSet *(*se_get_params_fn) (struct Service *service_p, Resource *resource_p, UserDetails *user_p);
228 
229 
240  void (*se_customise_service_job_fn) (struct Service *service_p, struct ServiceJob *job_p);
241 
242 
246  void (*se_release_params_fn) (struct Service *service_p, ParameterSet *params_p);
247 
255  bool (*se_close_fn) (struct Service *service_p);
256 
257 
267  struct ServiceJob *(*se_deserialise_job_json_fn) (struct Service *service_p, const json_t *service_job_json_p);
268 
269 
278  json_t *(*se_serialise_job_json_fn) (struct Service *service_p, struct ServiceJob *service_job_p, bool omit_results_flag);
279 
291  bool (*se_process_linked_services_fn) (struct Service *service_p, struct ServiceJob *job_p, LinkedService *linked_service_p);
292 
293 
303  bool (*se_get_parameter_type_fn) (struct Service *service_p, const char *param_name_s, ParameterType *pt_p);
304 
305 
310 
312  uuid_t se_id;
313 
316 
319 
325 
330 
337 
342 
343 
351  ServiceMetadata *(*se_get_metadata_fn) (struct Service *service_p);
352 
358 
364  void (*se_release_service_fn) (struct Service *service_p);
365 
366 
373  json_t *(*se_get_indexing_data_fn) (struct Service *service_p);
374 
375 
376 } Service;
377 
378 
386 typedef struct
387 {
390 
393 } ServiceNode;
394 
395 
401 typedef struct ServicesArray
402 {
405 
408 } ServicesArray;
409 
410 
411 
412 
413 
414 #ifdef __cplusplus
415 extern "C"
416 {
417 #endif
418 
427 GRASSROOTS_SERVICE_API ServicesArray *GetReferrableServicesFromPlugin (Plugin * const plugin_p, UserDetails *user_p, const json_t *service_config_p);
428 
436 GRASSROOTS_SERVICE_API ServicesArray *GetServicesFromPlugin (Plugin * const plugin_p, UserDetails *user_p);
437 
438 
464 GRASSROOTS_SERVICE_API bool InitialiseService (Service * const service_p,
465  const char *(*get_service_name_fn) (Service *service_p),
466  const char *(*get_service_description_fn) (Service *service_p),
467  const char *(*get_service_info_uri_fn) (struct Service *service_p),
468  struct ServiceJobSet *(*run_fn) (Service *service_p, ParameterSet *param_set_p, UserDetails *user_p, ProvidersStateTable *providers_p),
469  ParameterSet *(*match_fn) (Service *service_p, Resource *resource_p, Handler *handler_p),
470  ParameterSet *(*get_parameters_fn) (Service *service_p, Resource *resource_p, UserDetails *user_p),
471  bool (*get_parameter_type_fn) (struct Service *service_p, const char *param_name_s, ParameterType *pt_p),
472  void (*release_parameters_fn) (Service *service_p, ParameterSet *params_p),
473  bool (*close_fn) (struct Service *service_p),
474  void (*customise_service_job_fn) (Service *service_p, struct ServiceJob *job_p),
475  bool specific_flag,
476  Synchronicity synchronous,
477  ServiceData *data_p,
478  ServiceMetadata *(*get_metadata_fn) (struct Service *service_p),
479  json_t *(*get_indexing_data_fn) (struct Service *service_p),
480  GrassrootsServer *grassroots_p
481 );
482 
483 
498 GRASSROOTS_SERVICE_API struct ServiceJobSet *RunService (Service *service_p, ParameterSet *param_set_p, UserDetails *user_p, ProvidersStateTable *providers_p);
499 
500 
509 GRASSROOTS_SERVICE_API bool DoesServiceHaveCustomServiceJobSerialisation (struct Service *service_p);
510 
511 
521 GRASSROOTS_SERVICE_API struct ServiceJob *CreateSerialisedServiceJobFromService (struct Service *service_p, const json_t *service_job_json_p);
522 
523 
535 GRASSROOTS_SERVICE_API json_t *CreateSerialisedJSONForServiceJobFromService (struct Service *service_p, struct ServiceJob *service_job_p, bool omit_results_flag);
536 
537 
547 GRASSROOTS_SERVICE_API Service *GetServiceByName (GrassrootsServer *grassroots_p, const char * const service_name_s);
548 
549 
562 GRASSROOTS_SERVICE_API ParameterSet *IsServiceMatch (Service *service_p, Resource *resource_p, Handler *handler_p);
563 
564 
572 GRASSROOTS_SERVICE_API const char *GetServiceName (Service *service_p);
573 
574 
582 GRASSROOTS_SERVICE_API const char *GetServiceDescription (Service *service_p);
583 
584 
593 GRASSROOTS_SERVICE_API json_t *GetServiceIndexingData (Service *service_p);
594 
595 
603 GRASSROOTS_SERVICE_API const char *GetServiceInformationURI (Service *service_p);
604 
616 GRASSROOTS_SERVICE_API ParameterSet *GetServiceParameters (Service *service_p, Resource *resource_p, UserDetails *user_p);
617 
618 
619 
630 GRASSROOTS_SERVICE_API bool GetParameterTypeForNamedParameter (struct Service *service_p, const char *param_name_s, ParameterType *pt_p);
631 
632 
640 GRASSROOTS_SERVICE_API char *GetServiceUUIDAsString (Service *service_p);
641 
642 
649 GRASSROOTS_SERVICE_API void FreeService (Service *service_p);
650 
651 
659 GRASSROOTS_SERVICE_API void ReleaseService (Service *service_p);
660 
661 
662 
672 GRASSROOTS_SERVICE_API void SetServiceReleaseFunction (Service *service_p, void (*release_fn) (Service *service_p));
673 
674 
684 GRASSROOTS_SERVICE_LOCAL void ReleaseServiceData (ServiceData *data_p);
685 
693 GRASSROOTS_SERVICE_API ServiceNode *AllocateServiceNode (Service *service_p);
694 
695 
702 GRASSROOTS_SERVICE_API void FreeServiceNode (ListItem *node_p);
703 
704 
713 GRASSROOTS_SERVICE_API void LoadMatchingServicesByName (GrassrootsServer *grassroots_p, LinkedList *services_p, const char * const services_path_s, const char *service_name_s, UserDetails *user_p);
714 
715 
725 GRASSROOTS_SERVICE_API void LoadMatchingServices (GrassrootsServer *grassroots_p, LinkedList *services_p, const char * const services_path_s, Resource *resource_p, Handler *handler_p, UserDetails *user_p);
726 
727 
735 GRASSROOTS_SERVICE_API void LoadKeywordServices (GrassrootsServer *grassroots_p, LinkedList *services_p, const char * const services_path_s, UserDetails *user_p);
736 
737 
748 GRASSROOTS_SERVICE_API void AddReferenceServices (GrassrootsServer *grassroots_p, LinkedList *services_p, const char * const references_path_s, const char * const services_path_s, const char *operation_name_s, UserDetails *user_p);
749 
750 
758 GRASSROOTS_SERVICE_API bool CloseService (Service *service_p);
759 
760 
768 GRASSROOTS_SERVICE_API bool IsServiceLive (Service *service_p);
769 
770 
784 GRASSROOTS_SERVICE_API json_t *GetServiceAsJSON (Service * const service_p, Resource *resource_p, UserDetails *user_p, const bool add_id_flag);
785 
786 
794 GRASSROOTS_SERVICE_API const char *GetServiceIcon (Service *service_p);
795 
796 
803 GRASSROOTS_SERVICE_API bool DeallocatePluginService (Plugin * const plugin_p);
804 
805 
822 GRASSROOTS_SERVICE_API json_t *GetServicesListAsJSON (LinkedList *services_list_p, Resource *resource_p, UserDetails *user_p, const bool add_service_ids_flag, ProvidersStateTable *providers_p);
823 
824 
833 GRASSROOTS_SERVICE_API void ReleaseServiceParameters (Service *service_p, ParameterSet *params_p);
834 
835 
842 GRASSROOTS_SERVICE_API void FreeServicesArray (ServicesArray *services_p);
843 
844 
853 GRASSROOTS_SERVICE_API ServicesArray *AllocateServicesArray (const uint32 num_services);
854 
855 
863 GRASSROOTS_SERVICE_LOCAL void AssignPluginForServicesArray (ServicesArray *services_p, Plugin *plugin_p);
864 
865 
874 GRASSROOTS_SERVICE_API bool AddServiceResponseHeader (Service *service_p, json_t *result_json_p);
875 
876 
887 GRASSROOTS_SERVICE_API ServicesArray *GetReferenceServicesFromJSON (json_t *config_p, const char *plugin_name_s, Service *(*get_service_fn) (json_t *config_p, size_t i, GrassrootsServer *grassroots_p), GrassrootsServer *grassroots_p);
888 
889 
898 GRASSROOTS_SERVICE_API OperationStatus GetCurrentServiceStatus (Service *service_p, const uuid_t service_id);
899 
900 
908 GRASSROOTS_SERVICE_LOCAL OperationStatus DefaultGetServiceStatus (Service *service_p, const uuid_t service_id);
909 
910 
925 GRASSROOTS_SERVICE_API bool CreateAndAddPairedService (Service *service_p, struct ExternalServer *external_server_p, const char *remote_service_name_s, const json_t *op_p, const json_t *provider_p);
926 
927 
936 GRASSROOTS_SERVICE_API bool AddPairedService (Service *service_p, PairedService *paired_service_p);
937 
938 
947 GRASSROOTS_SERVICE_API bool CreateAndAddLinkedService (Service *service_p, const json_t *service_config_p, GrassrootsServer *grassroots_p);
948 
949 
958 GRASSROOTS_SERVICE_API bool AddLinkedService (Service *service_p, LinkedService *paired_service_p);
959 
960 
961 
976 GRASSROOTS_SERVICE_API json_t *GetServiceRunRequest (const char * const service_name_s, const ParameterSet *params_p, const SchemaVersion *sv_p, const bool run_flag, const ParameterLevel level);
977 
978 
992 GRASSROOTS_SERVICE_API json_t *GetServiceRefreshRequest (const char * const service_name_s, const ParameterSet *params_p, const SchemaVersion *sv_p, const bool run_flag, const ParameterLevel level);
993 
994 
1009 GRASSROOTS_SERVICE_API json_t *GetServiceRefreshRequest (const char * const service_name_s, const ParameterSet *params_p, const SchemaVersion *sv_p, const bool run_flag, const ParameterLevel level);
1010 
1011 
1012 
1032 GRASSROOTS_SERVICE_API json_t *GetInterestedServiceJSON (Service *service_p, const char *keyword_s, const ParameterSet * const params_p, const bool full_definition_flag);
1033 
1034 
1045 GRASSROOTS_SERVICE_API void SetServiceJobCustomFunctions (Service *service_p, struct ServiceJob *job_p);
1046 
1047 
1055 GRASSROOTS_SERVICE_API bool IsServiceRunning (Service *service_p);
1056 
1057 
1065 GRASSROOTS_SERVICE_API void SetServiceRunning (Service *service_p, bool b);
1066 
1067 
1077 GRASSROOTS_SERVICE_API void SetMetadataForService (Service *service_p, SchemaTerm *category_p, SchemaTerm *subcategory_p);
1078 
1079 
1080 
1081 
1093 GRASSROOTS_SERVICE_API bool AddServiceJobToService (Service *service_p, ServiceJob *job_p, bool require_lock_flag);
1094 
1095 
1105 GRASSROOTS_SERVICE_API bool RemoveServiceJobFromService (Service *service_p, ServiceJob *job_p);
1106 
1107 
1108 
1117 GRASSROOTS_SERVICE_API int32 GetNumberOfLiveJobs (Service *service_p);
1118 
1119 
1128 GRASSROOTS_SERVICE_API bool IsServiceLockable (const Service *service_p);
1129 
1130 
1140 GRASSROOTS_SERVICE_API bool LockService (Service *service_p);
1141 
1142 
1152 GRASSROOTS_SERVICE_API bool UnlockService (Service *service_p);
1153 
1154 
1155 GRASSROOTS_SERVICE_API bool SortServicesListByName (LinkedList *services_list_p);
1156 
1157 
1158 GRASSROOTS_SERVICE_API json_t *GetBaseServiceDataAsJSON (Service * const service_p, UserDetails *user_p);
1159 
1160 
1161 GRASSROOTS_SERVICE_API GrassrootsServer *GetGrassrootsServerFromService (const Service * const service_p);
1162 
1163 #ifdef __cplusplus
1164 }
1165 #endif
1166 
1167 
1168 #endif /* #ifndef GRASSROOTS_SERVICE_H */
OperationStatus GetCurrentServiceStatus(Service *service_p, const uuid_t service_id)
Get the OperationStatus for an operation in a Service.
bool se_running_flag
A flag to specify whether this Service is currently running.
Definition: service.h:336
ServicesArray * GetServicesFromPlugin(Plugin *const plugin_p, UserDetails *user_p)
Get the ServicesArray from a given Plugin.
void(* se_customise_service_job_fn)(struct Service *service_p, struct ServiceJob *job_p)
This function is used to customise any ServiceJob objects that this Service creates.
Definition: service.h:240
A datatype for specifying ontological terms as a way to describe the data that each of the Services c...
Definition: schema_term.h:38
bool AddPairedService(Service *service_p, PairedService *paired_service_p)
Add a PairedService to a Service.
A doubly-linked node that points to its predecessor and successor.
Definition: linked_list.h:43
A datatype for describing the type of application that a Service provides.
Definition: service_metadata.h:39
ParameterType
The different types that a Parameter can take.
Definition: parameter_type.h:35
Service * GetServiceByName(GrassrootsServer *grassroots_p, const char *const service_name_s)
Get a Service by its name.
uint32 sa_num_services
The number of Services in the array.
Definition: service.h:407
bool IsServiceLockable(const Service *service_p)
Is a given Service lockable with a mutex for use in a multi-threaded situation.
json_t * GetServiceIndexingData(Service *service_p)
Get a JSON document containing the data that can be parsed by an indexing app such as Lucene.
ServiceMetadata * se_metadata_p
The ServiceMetadata for this Service.
Definition: service.h:341
void LoadKeywordServices(GrassrootsServer *grassroots_p, LinkedList *services_p, const char *const services_path_s, UserDetails *user_p)
Load all Services that can be run upon a keyword parameter.
bool(* se_has_permissions_fn)(struct Service *service_p, ParameterSet *params_p, const UserDetails *const user_p)
Check whether the user have permissions to run the Service.
Definition: service.h:205
A datatype for describing a remote Service that can be used in conjunction with a local Service.
Definition: paired_service.h:59
A task that runs synchronously.
Definition: service.h:103
ServicesArray * GetReferenceServicesFromJSON(json_t *config_p, const char *plugin_name_s, Service *(*get_service_fn)(json_t *config_p, size_t i, GrassrootsServer *grassroots_p), GrassrootsServer *grassroots_p)
Get the ServicesArray generated from a Services reference file.
json_t * GetServiceRefreshRequest(const char *const service_name_s, const ParameterSet *params_p, const SchemaVersion *sv_p, const bool run_flag, const ParameterLevel level)
Get the JSON fragment for sending to a Grassroots Server detailing how to update the parameters for a...
void LoadMatchingServices(GrassrootsServer *grassroots_p, LinkedList *services_p, const char *const services_path_s, Resource *resource_p, Handler *handler_p, UserDetails *user_p)
Load the Services that are able to act upon a given Resource.
struct ServiceJob * CreateSerialisedServiceJobFromService(struct Service *service_p, const json_t *service_job_json_p)
Function to parse a JSON fragment from a previously serialised ServiceJob.
json_t * GetServiceAsJSON(Service *const service_p, Resource *resource_p, UserDetails *user_p, const bool add_id_flag)
Generate a json-based description of a Service.
bool UnlockService(Service *service_p)
Release the lock for a given Service in a multi-threaded situation.
bool IsServiceRunning(Service *service_p)
Check if a Service is currently running any ServiceJobs.
A datatype to represent a collection of ServiceJobs.
Definition: service_job.h:182
void ReleaseServiceParameters(Service *service_p, ParameterSet *params_p)
Free a ParameterSet that was got from a call to GetServiceParameters.
void FreeService(Service *service_p)
Free a Service and its associated Parameters and ServiceData.
json_t * GetServicesListAsJSON(LinkedList *services_list_p, Resource *resource_p, UserDetails *user_p, const bool add_service_ids_flag, ProvidersStateTable *providers_p)
Get the JSON fragment for exposing a list of Services to any interested Clients or ExternalServcers.
bool DeallocatePluginService(Plugin *const plugin_p)
Close a Services-based Plugin and free all of the Services.
A datatype to allow access to an external Grassroots Server.
Definition: servers_manager.h:48
SyncData * se_sync_data_p
If the Service's synchronicity is set to SY_ASYNCHRONOUS_ATTACHED, this is used as mutex to control a...
Definition: service.h:357
struct ServiceJobSet * se_jobs_p
The ServiceJobSet for this Service.
Definition: service.h:315
struct Service * sd_service_p
The service that owns this data.
Definition: service.h:128
Synchronicity
A datatye to define how a Service runs.
Definition: service.h:100
void FreeServiceNode(ListItem *node_p)
Free a ServiceNode.
void FreeServicesArray(ServicesArray *services_p)
Free a ServicesArray and each of its Services.
Service ** sa_services_pp
An array of pointers to Services.
Definition: service.h:404
Synchronicity se_synchronous
The synchronicity for how this Service runs.
Definition: service.h:309
This is a datatype to store the versioning details for the Grassroots JSON schema that is being used.
Definition: schema_version.h:44
void SetServiceReleaseFunction(Service *service_p, void(*release_fn)(Service *service_p))
For an asynchronous Service, set the function that will be called if ReleaseService() is called.
ServicesArray * AllocateServicesArray(const uint32 num_services)
Allocate an empty ServicesArray.
ListItem sn_node
The List Node.
Definition: service.h:389
bool(* se_get_parameter_type_fn)(struct Service *service_p, const char *param_name_s, ParameterType *pt_p)
Callback function used to get the ParameterType of a named Parameter used by the given Service.
Definition: service.h:303
bool IsServiceLive(Service *service_p)
Has the Service got any jobs still running?
struct Plugin * se_plugin_p
The platform-specific plugin that the code for the Service is stored in.
Definition: service.h:158
bool InitialiseService(Service *const service_p, const char *(*get_service_name_fn)(Service *service_p), const char *(*get_service_description_fn)(Service *service_p), const char *(*get_service_info_uri_fn)(struct Service *service_p), struct ServiceJobSet *(*run_fn)(Service *service_p, ParameterSet *param_set_p, UserDetails *user_p, ProvidersStateTable *providers_p), ParameterSet *(*match_fn)(Service *service_p, Resource *resource_p, Handler *handler_p), ParameterSet *(*get_parameters_fn)(Service *service_p, Resource *resource_p, UserDetails *user_p), bool(*get_parameter_type_fn)(struct Service *service_p, const char *param_name_s, ParameterType *pt_p), void(*release_parameters_fn)(Service *service_p, ParameterSet *params_p), bool(*close_fn)(struct Service *service_p), void(*customise_service_job_fn)(Service *service_p, struct ServiceJob *job_p), bool specific_flag, Synchronicity synchronous, ServiceData *data_p, ServiceMetadata *(*get_metadata_fn)(struct Service *service_p), json_t *(*get_indexing_data_fn)(struct Service *service_p), GrassrootsServer *grassroots_p)
Initialise the basic structure of a Service.
int32 GetNumberOfLiveJobs(Service *service_p)
Check if any ServiceJobs within Service are still running.
A doubly-linked list.
bool CloseService(Service *service_p)
Close a Service.
A datatype for holding the configuration data for a Service.
Definition: service.h:125
bool CreateAndAddLinkedService(Service *service_p, const json_t *service_config_p, GrassrootsServer *grassroots_p)
Create and add a LinkedService to a Service.
A datatype which defines an available service, its capabilities and its parameters.
Definition: service.h:152
bool se_is_specific_service_flag
Is the service self-contained.
Definition: service.h:167
bool AddServiceResponseHeader(Service *service_p, json_t *result_json_p)
Add a JSON fragment to the response for a given Service that has been run.
void ReleaseService(Service *service_p)
For an asynchronous Service, tell it that it is no longer needed by the Grassroots system.
A doubly-linked list that can be traversed in either direction.
Definition: linked_list.h:56
ParameterSet * GetServiceParameters(Service *service_p, Resource *resource_p, UserDetails *user_p)
Get a newly-created ParameterSet describing the parameters for a given Service.
A Plugin is a dynamically-loaded component to provide a piece of functionality.
Definition: plugin.h:151
ParameterSet * IsServiceMatch(Service *service_p, Resource *resource_p, Handler *handler_p)
Is the Service able to work upon the given Resource.
bool CreateAndAddPairedService(Service *service_p, struct ExternalServer *external_server_p, const char *remote_service_name_s, const json_t *op_p, const json_t *provider_p)
Create a new PairedService and add it to a Service.
A task that runs asynchronously outside of the Grassroots system such as e.g drmaa jobs.
Definition: service.h:109
bool AddLinkedService(Service *service_p, LinkedService *paired_service_p)
Add a LinkedService to a Service.
uuid_t se_id
Unique Id for this service.
Definition: service.h:312
void LoadMatchingServicesByName(GrassrootsServer *grassroots_p, LinkedList *services_p, const char *const services_path_s, const char *service_name_s, UserDetails *user_p)
Load the Service that matches a given service name.
ParameterLevel
The ParameterLevel defines the level that a user should be to adjust the Parameter.
Definition: parameter.h:54
A task runs asynchronously within the Grassroots system such as e.g threaded jobs.
Definition: service.h:115
bool(* se_close_fn)(struct Service *service_p)
Function to close this Service.
Definition: service.h:255
bool GetParameterTypeForNamedParameter(struct Service *service_p, const char *param_name_s, ParameterType *pt_p)
Get the ParameterType of a named Parameter used by the given Service.
json_t * CreateSerialisedJSONForServiceJobFromService(struct Service *service_p, struct ServiceJob *service_job_p, bool omit_results_flag)
Function to create a JSON fragment representing a serialised ServiceJob.
bool AddServiceJobToService(Service *service_p, ServiceJob *job_p, bool require_lock_flag)
Add a ServiceJob to a Service.
GRASSROOTS_SERVICE_API const char * SERVICES_PATH_S
This specifies the relative filesystem path to where the Service plugins are stored.
Definition: service.h:78
OperationStatus
The current status of an Operation.
Definition: operation.h:98
char * GetServiceUUIDAsString(Service *service_p)
Get the unique id of a service object.
ServiceData * se_data_p
Any custom data that the service needs to store.
Definition: service.h:329
bool DoesServiceHaveCustomServiceJobSerialisation(struct Service *service_p)
Does the Service use the default ServiceJob serialisation/deserialisation when storing ServiceJobs in...
A datatype that allows data to be shared between tasks (e.g.
Definition: unix_sync_data.h:30
void SetServiceJobCustomFunctions(Service *service_p, struct ServiceJob *job_p)
This function is used to customise any ServiceJob objects that a given Service creates.
A datatype to represent a running task.
Definition: service_job.h:72
const char * GetServiceIcon(Service *service_p)
Get the URL of an icon image to use for a given Service.
A datatype for having a set of Services.
Definition: service.h:401
A datatype for storing Services on a LinkedList.
Definition: service.h:386
struct ServiceJobSet * RunService(Service *service_p, ParameterSet *param_set_p, UserDetails *user_p, ProvidersStateTable *providers_p)
Run a Service.
A datatype to store user credentials.
Definition: user_details.h:76
void SetServiceRunning(Service *service_p, bool b)
Set if a Service is currently running any ServiceJobs or not.
LinkedList se_paired_services
Any remote Services that are paired with this Service.
Definition: service.h:318
void(* se_release_params_fn)(struct Service *service_p, ParameterSet *params_p)
Function to release the ParameterSet for this Service.
Definition: service.h:246
void SetMetadataForService(Service *service_p, SchemaTerm *category_p, SchemaTerm *subcategory_p)
Set the values of a Service's ServiceMetadata object.
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
bool RemoveServiceJobFromService(Service *service_p, ServiceJob *job_p)
Remove a ServiceJob from a Service.
bool(* se_process_linked_services_fn)(struct Service *service_p, struct ServiceJob *job_p, LinkedService *linked_service_p)
Callback function used when processing the results from running ServiceJobs for this Service as input...
Definition: service.h:291
bool sd_config_flag
If this is true, then this ServiceData will decrease the reference count on sd_config_p when this Ser...
Definition: service.h:140
Definition: grassroots_server.h:44
A Handler is a datatype for accessing data.
Definition: handler.h:72
A datatype representing a URI.
Definition: data_resource.h:40
json_t * GetInterestedServiceJSON(Service *service_p, const char *keyword_s, const ParameterSet *const params_p, const bool full_definition_flag)
Get the JSON fragment for a job result list registering that a Service could be run against the user'...
bool LockService(Service *service_p)
Lock a given Service with a mutex for use in a multi-threaded situation.
ServicesArray * GetReferrableServicesFromPlugin(Plugin *const plugin_p, UserDetails *user_p, const json_t *service_config_p)
Get the ServicesArray from a given Plugin.
Service * sn_service_p
The Service.
Definition: service.h:392
LinkedList se_linked_services
Any LinkedServices that will use the output from running this Service as input for itself.
Definition: service.h:324
json_t * sd_config_p
If this service has an entry in global server config it will be stored here.
Definition: service.h:134
A set of Parameters along with an optional name and description.
Definition: parameter_set.h:46
This datatype stores the data needed to get the required information from the output of one Service t...
Definition: linked_service.h:50
void(* se_release_service_fn)(struct Service *service_p)
A custom callback function to use to close the service if needed.
Definition: service.h:364
ServiceNode * AllocateServiceNode(Service *service_p)
Allocate a ServiceNode pointing to the given Service.
const char * GetServiceName(Service *service_p)
Get the user-friendly name of the service.
const char * GetServiceDescription(Service *service_p)
Get the user-friendly description of the service.
json_t * GetServiceRunRequest(const char *const service_name_s, const ParameterSet *params_p, const SchemaVersion *sv_p, const bool run_flag, const ParameterLevel level)
Get the JSON fragment for sending to a Grassroots Server detailing whether and how a user wants a Ser...
const char * GetServiceInformationURI(Service *service_p)
Get the address of a web page about the service.
void AddReferenceServices(GrassrootsServer *grassroots_p, LinkedList *services_p, const char *const references_path_s, const char *const services_path_s, const char *operation_name_s, UserDetails *user_p)
Add any reference Services to the list of available Services.