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.
Network Library

The datatypes and methods for network functionality. More...

Data Structures

struct  Connection
 The base class for building a Server-Client connection. More...
 
struct  WebConnection
 A Connection that uses http(s) communication. More...
 
struct  CurlTool
 A tool for making http(s) requests and responses. More...
 
struct  KeyValuePair
 A pair of strings. More...
 
struct  KeyValuePairNode
 A datatype used for storing a KeyValuePair on a LinkedList. More...
 

Enumerations

enum  ConnectionType { CT_RAW, CT_WEB, CT_NUM_TYPES }
 An enumeration listing the different types of Connections. More...
 
enum  CurlMode { CM_MEMORY, CM_FILE, CM_NUM_MODES }
 An enum specifying where any resultant data from running a CurlTool will be stored. More...
 

Functions

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. More...
 
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. More...
 
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 Resource. More...
 
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. More...
 
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 Service. More...
 
bool AddClientConfigToJSON (json_t *root_p, const User *user_p)
 Add the given credentials in the correct position in a JSON fragment. More...
 
json_t * GetOperationAsJSON (Operation op, const SchemaVersion *const sv_p)
 Get the JSON fragment for a given Operation. More...
 
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. More...
 
json_t * MakeRemoteJsonCall (json_t *req_p, Connection *connection_p)
 Send a JSON-based request to the server and get the JSON-based response. More...
 
const char * GetUserUUIDStringFromJSON (const json_t *credentials_p)
 Get the User uuid from a JSON fragment. More...
 
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. More...
 
bool GetStatusFromJSON (const json_t *service_json_p, OperationStatus *status_p)
 Get the current OperationStatus for a Service from its JSON fragment. More...
 
json_t * GetInitialisedMessage (const SchemaVersion *const sv_p)
 Create a response object with a valid header. More...
 

Detailed Description

The datatypes and methods for network functionality.

Enumeration Type Documentation

◆ ConnectionType

An enumeration listing the different types of Connections.

Enumerator
CT_RAW 

A raw socket-based connection.

CT_WEB 

A connection using http(s)

CT_NUM_TYPES 

The number of possible ConnectionTypes.

◆ CurlMode

enum CurlMode

An enum specifying where any resultant data from running a CurlTool will be stored.

Enumerator
CM_MEMORY 

The data will be stored in memory.

CM_FILE 

The data will be written to disk.

CM_NUM_MODES 

The number of available modes.

Function Documentation

◆ 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.

Parameters
user_pAn optional User.
sv_pIf you wish to create a JSON fragment for a different version of the Grassroots system, then you can set this value to the version that you require. If this is NULL, then the current version of the running Grassroots system will be used.
Returns
The JSON fragment to send to the Server or NULL upon error.

◆ 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.

Parameters
user_pThe User for the credentials that will be added.
provider_sThe name of the system that we are requesting the username and password for.
username_ssPointer to the username to update.
password_ssPointer to the encrypted password to update.
Returns
true if the credentials were extracted from the JSON fragment successfully, false otherwise.

◆ 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 Resource.

Parameters
user_pThe User for the credentials that will be added.
protocol_sThe Resource protocol.
filename_sThe filename of the Resource.
sv_pIf you wish to create a JSON fragment for a different version of the Grassroots system, then you can set this value to the version that you require. If this is NULL, then the current version of the running Grassroots system will be used.
Returns
The JSON fragment to send to the Server or NULL upon error.

◆ 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.

Parameters
user_pThe User for the credentials that will be added.
service_name_sThe name of the Service.
sv_pIf you wish to create a JSON fragment for a different version of the Grassroots system, then you can set this value to the version that you require. If this is NULL, then the current version of the running Grassroots system will be used.
Returns
The JSON fragment to send to the Server or NULL upon error.

◆ 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 Service.

Parameters
user_pThe User for the credentials that will be added.
service_name_sThe name of the Service.
sv_pIf you wish to create a JSON fragment for a different version of the Grassroots system, then you can set this value to the version that you require. If this is NULL, then the current version of the running Grassroots system will be used.
Returns
The JSON fragment to send to the Server or NULL upon error.

◆ AddClientConfigToJSON()

bool AddClientConfigToJSON ( json_t *  root_p,
const User user_p 
)

Add the given credentials in the correct position in a JSON fragment.

Parameters
root_pThe JSON fragment to update.
user_pThe User for the credentials that will be added.
Returns
true if the JSON fragment was updated successfully, false otherwise.

◆ GetOperationAsJSON()

json_t* GetOperationAsJSON ( Operation  op,
const SchemaVersion *const  sv_p 
)

Get the JSON fragment for a given Operation.

Parameters
opThe Operation to generate the JSON for.
sv_pIf you wish to create a JSON fragment for a different version of the Grassroots system, then you can set this value to the version that you require. If this is NULL, then the current version of the running Grassroots system will be used.
Returns
The JSON fragment or NULL upon error.

◆ 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.

Parameters
user_pThe User for the credentials that will be added.
opThe Operation to perform.
op_key_sThe key to be used to attach the associated Operation-specific data with.
See also
KEY_IRODS
KEY_FILE_DATA
KEY_QUERY
KEY_FILENAME
KEY_DIRNAME
KEY_PROTOCOL
KEY_INTERVAL
Parameters
op_data_pThe Operation-specific data.
sv_pIf you wish to create a JSON fragment for a different version of the Grassroots system, then you can set this value to the version that you require. If this is NULL, then the current version of the running Grassroots system will be used.
Returns
The json_t for the request or NULL upon error.

◆ 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.

Parameters
req_pThe JSON request to send to the Server.
connection_pThe Connection to the Server.
Returns
The JSON response or NULL upon error.

◆ GetUserUUIDStringFromJSON()

const char* GetUserUUIDStringFromJSON ( const json_t *  credentials_p)

Get the User uuid from a JSON fragment.

Parameters
credentials_pThe JSON fragment to parse.
Returns
The user's uuid or NULL if it could not be found.

◆ 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.

Parameters
ids_ppAn array of uuid_ts, one for each operation .
num_idsThe number of ids in ids_pp.
connection_pThe Connection to the Server.
sv_pIf you wish to create a JSON fragment for a different version of the Grassroots system, then you can set this value to the version that you require. If this is NULL, then the current version of the running Grassroots system will be used.
Returns
The JSON fragment to send to the Server or NULL upon error.

◆ GetStatusFromJSON()

bool GetStatusFromJSON ( const json_t *  service_json_p,
OperationStatus status_p 
)

Get the current OperationStatus for a Service from its JSON fragment.

Parameters
service_json_pThe JSON fragment of the response from the Server.
status_pPointer to the OperationStatus value that will be updated.
Returns
true if the OperationStatus value was updated successfully, false otherwise.

◆ GetInitialisedMessage()

json_t* GetInitialisedMessage ( const SchemaVersion *const  sv_p)

Create a response object with a valid header.

The returned object will contain a header section with details such as the schema version.

Parameters
sv_pIf you wish to create a JSON fragment for a different version of the Grassroots system, then you can set this value to the version that you require. If this is NULL, then the current version of the running Grassroots system will be used.
Returns
The response or NULL upon error.