]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/src/c-apps/oils_utils.h
added simple request utilty to display fieldmapper objects
[Evergreen.git] / Open-ILS / src / c-apps / oils_utils.h
1 #include "objson/object.h"
2 #include "opensrf/log.h"
3 #include "openils/fieldmapper_lookup.h"
4 #include "oils_event.h"
5 #include "oils_constants.h"
6 #include "opensrf/osrf_app_session.h"
7
8 /**
9   Returns the string value for field 'field' in the given object.
10   This method calls jsonObjectToSimpleString so numbers will be
11   returned as strings.
12   @param object The object to inspect
13   @param field The field whose value is requsted
14   @return The string at the given position, if none exists, 
15   then NULL is returned.  The caller must free the returned string
16   */
17 char* oilsFMGetString( jsonObject* object, char* field );
18
19
20 /**
21   Returns the jsonObject found at the specified field in the
22   given object.
23   @param object The object to inspect
24   @param field The field whose value is requsted
25   @return The found object or NULL if none exists.  Do NOT free the 
26   returned object.
27   */
28 jsonObject* oilsFMGetObject( jsonObject* object, char* field );
29
30 /**
31   Sets the given field in the given object to the given string
32   @param object The object to update
33   @param field The field to change
34   @param string The new data
35   @return 0 if the field was updated successfully, -1 on error
36   */
37 int oilsFMSetString( jsonObject* object, char* field, char* string );
38
39 /**
40  * Returns the data stored in the id field of the object if it exists
41  * returns -1 if the id field or the id value is not found
42  */
43 long oilsFMGetObjectId( jsonObject* obj );
44
45
46 /**
47  * Checks if the user has each permission at the given org unit
48  * Passing in a -1 for the orgid means to use the top level org unit
49  * The first permission that fails causes the corresponding permission
50  * failure event to be returned
51  * returns NULL if all permissions succeed
52  */
53 oilsEvent* oilsUtilsCheckPerms( int userid, int orgid, char* permissions[], int size );
54
55
56 /**
57  * Performs a single request and returns the resulting data
58  * Caller is responsible for freeing the returned response object
59  */
60 jsonObject* oilsUtilsQuickReq( char* service, char* method, jsonObject* params );
61
62 /**
63  * Searches the storage server for a user with the given username 
64  * Caller is responsible for freeing the returned object
65  */
66 jsonObject* oilsUtilsFetchUserByUsername( char* name );
67
68
69 /**
70  * Returns the setting value
71  * Caller must free the returned string
72  */
73 char* oilsUtilsFetchOrgSetting( int orgid, char* setting );
74
75
76 /**
77  * Logs into the auth server with the given username and password
78  * @return The authtoken string which must be de-allocated by the caller
79  */
80 char* oilsUtilsLogin( char* uname, char* passwd, char* type, int orgId );
81