Difference between revisions of "GeoFence library"
(→updateInstanceByName(String instanceName, String username, String password, String baseURL, String description)) |
(→deleteInstanceByName(String instanceName, boolean removeAllRules)) |
||
Line 447: | Line 447: | ||
Parameters List : | Parameters List : | ||
*"instanceName" : [String value] It's the name of Instance object; | *"instanceName" : [String value] It's the name of Instance object; | ||
− | *" | + | *"removeAllRules" : [boolean value] It's a parameter to removes all rules together the Instance object; |
'''Invocation example''' | '''Invocation example''' |
Revision as of 18:08, 21 November 2017
This section aims to describe the Geofence library in order to help developers to manage users, groups, rules and instances in Geofence server. After configuring between Geofence server with GeoServer, for instance, it's possible create an user in Geofence and automatically it's possible to login (with this user) in GeoServer. Following is a list of methods, with all details to uderstand how invoke them.
Contents
- 1 Constructor
- 2 User section
- 2.1 getUserById(String id)
- 2.2 getUserByUsername(String userName)
- 2.3 createUser(User user)
- 2.4 updateUser(User user)
- 2.5 updateUserById(String id, String password, String email, boolean admin, boolean enabled)
- 2.6 updateUserByUsername(String userName, String password, String email, boolean admin, boolean enabled)
- 2.7 deleteUserById(String id, boolean removeAllRules)
- 2.8 deleteUserByUsername(String userName, boolean removeAllRules)
- 2.9 getUserList()
- 3 UserGroup section
- 3.1 createUserGroup(UserGroup userGroup)
- 3.2 getUserGroupById(String id)
- 3.3 getUserGroupByName(String userName)
- 3.4 updateUserGroup(Group group)
- 3.5 updateUserGroupById(String id, boolean enabled)
- 3.6 updateUserGroupByName(String name, boolean enabled)
- 3.7 deleteUserGroupById(String groupId)
- 3.8 deleteUserGroupByName(String groupName)
- 3.9 getUserGroupList()
- 3.10 assignToUserGroupByUserIdGroupId(String userId, String groupId)
- 3.11 assignToUserGroupByUserIdGroupName(String userId, String groupName)
- 3.12 assignToUserGroupByUserNameGroupId(String userName, String groupId)
- 3.13 assignToUserGroupByUserNameGroupName(String userName, String groupName)
- 3.14 removeUserGroupByUserIdGroupId(String userId, String groupId)
- 3.15 removeUserGroupByUserIdGroupName(String userId, String groupName)
- 3.16 removeUserGroupByUserNameGroupId(String userName, String groupId)
- 3.17 removeUserGroupByUserNameGroupName(String userName, String groupName)
- 4 Instance section
- 4.1 createInstance(Instance instance)
- 4.2 getInstanceById(String instanceId)
- 4.3 getInstanceByName(String instanceName)
- 4.4 updateInstance(Instance instance)
- 4.5 updateInstanceById(String id, String username, String password, String baseURL, String description)
- 4.6 updateInstanceByName(String instanceName, String username, String password, String baseURL, String description)
- 4.7 deleteInstanceById(String instanceId)
- 4.8 deleteInstanceByName(String instanceName, boolean removeAllRules)
Constructor
Parameters List :
- "geofenceRestUrl" : [String value] The URL of Geofence instance;
Invocation example
GeoFence gf = new GeoFence("http://geofenceRestUrl/");
User section
getUserById(String id)
Parameters List :
- "id" : [String value] It's the userId of user you are looking for;
Invocation example
String id = ...; GSUser user = gf.getUserById(id); String userName = user.getName();
getUserByUsername(String userName)
Parameters List :
- "userName" : [String value] It's the name of user you are looking for;
Invocation example
String userName = ...; GSUser user = gf.getUserByUsername(userName); String id = user.getId();
createUser(User user)
Parameters List :
- "user" : [User value] It's the org.gcube.data.access.bean.User object you are creating;
Invocation example
User user = new User(); user.setExtId("id_1"); user.setName("test_1"); user.setPassword("test"); ... HttpStatus status = gf.createUser(user);
updateUser(User user)
Parameters List :
- "user" : [User value] It's the org.gcube.data.access.bean.User object you are updating;
Invocation example
User user = new User(); user.setExtId("id_1"); user.setName("test_1"); user.setPassword("test_1"); user.setEmailAddress("test@email.com"); ... HttpStatus status = gf.updateUser(user);
updateUserById(String id, String password, String email, boolean admin, boolean enabled)
Parameters List :
- "id" : [String value] It's the id of user;
- "password" : [String value] It's the password of user.
- "email" : [String value] It's the email of user.
- "admin" : [boolean value] It's the boolean flag to define if user is administrator or not.
- "enabled" : [boolean value] It's the boolean flag to define if user is enabled or not.
Invocation example
String id = ...; HttpStatus status = gf.updateUserById(id, "new_pass", "test@email.com", false, false);
updateUserByUsername(String userName, String password, String email, boolean admin, boolean enabled)
Parameters List :
- "userName" : [String value] It's the userName of user;
- "password" : [String value] It's the password of user.
- "email" : [String value] It's the email of user.
- "admin" : [boolean value] It's the boolean flag to define if user is administrator or not.
- "enabled" : [boolean value] It's the boolean flag to define if user is enabled or not.
Invocation example
String userName= ...; HttpStatus status = gf.updateUserByUsername(userName, "new_pass", "test@email.com", true, true);
deleteUserById(String id, boolean removeAllRules)
Parameters List :
- "id" : [String value] It's the userId of user you are looking for;
- "removeAllRules" : [boolean value] It's a flag to remove all rules together to the user;
Invocation example
String id = ...; HttpStatus status = gf.deleteUserById(id, true);
deleteUserByUsername(String userName, boolean removeAllRules)
Parameters List :
- "userName" : [String value] It's the userName of user you are looking for;
- "removeAllRules" : [boolean value] It's a flag to remove all rules together to the user;
Invocation example
String userName = ...; HttpStatus status = gf.deleteUserById(userName, false);
getUserList()
Invocation example
UserList userList = gf.getUserList(); List<Users> users = userList.getUsers(); int size = users.size();
UserGroup section
createUserGroup(UserGroup userGroup)
Parameters List :
- "userGroup " : [UserGroup value] - It's the org.gcube.data.access.bean.UserGroup object you are creating.
Invocation example
UserGroup group = new UserGroup(); group.setExtId("ext_id_1"); group.setName("My group"); group.setDateCreation(new Date()); group.setEnabled(false); HttpStatus status = gf.createUserGroup(group);
getUserGroupById(String id)
Parameters List :
- "id" : [String value] It's the id of group you are looking for;
Invocation example
String id = ...; Group g = gf.getUserGroupById(id); String name = g.getName();
getUserGroupByName(String userName)
Parameters List :
- "userName" : [String value] It's the userName of group you are looking for;
Invocation example
String userName = ...; Group g = gf.getUserGroupByName(userName); String id = g.getId();
updateUserGroup(Group group)
Parameters List :
- "group" : [Group value] It's the Group object you are updating;
Invocation example
Group g = ... g.setEnabled(false); HttpStatus status = gf.updateUserGroup(g);
updateUserGroupById(String id, boolean enabled)
Parameters List :
- "id" : [String value] It's the userId of user you are looking for;
- "enabled" : [boolean value] It's the enabled flag of group;
Invocation example
String id = ... HttpStatus status = gf.updateUserGroupById(id, true);
updateUserGroupByName(String name, boolean enabled)
Parameters List :
- "name" : [String value] It's the userId of user you are looking for;
- "enabled" : [boolean value] It's the enabled flag of group;
Invocation example
String name = ... HttpStatus status = gf.updateUserGroupByName(name, false);
deleteUserGroupById(String groupId)
Parameters List :
- "groupId" : [String value] It's the groupId of group;
Invocation example
String groupId = ...; HttpStatus status = gf.deleteUserGroupById(groupId);
deleteUserGroupByName(String groupName)
Parameters List :
- "groupName" : [String value] It's the groupName of group;
Invocation example
String groupName = ...; HttpStatus status = gf.deleteUserGroupByName(groupName);
getUserGroupList()
Invocation example
UserGroupList ugl = gf.getUserGroupList(); List<UserGroups> ugs = ugl.getUserGroups(); int size = ugs.size();
assignToUserGroupByUserIdGroupId(String userId, String groupId)
Parameters List :
- "userId" : [String value] It's the id of user;
- "groupId" : [String value] It's the id of group;
Invocation example
String userId = ... String groupId = ... HttpStatus status = gf.assignToUserGroupByUserIdGroupId(userId, groupId);
assignToUserGroupByUserIdGroupName(String userId, String groupName)
Parameters List :
- "userId" : [String value] It's the id of user;
- "groupName" : [String value] It's the name of group;
Invocation example
String userId = ... String groupName = ... HttpStatus status = gf.assignToUserGroupByUserIdGroupId(userId, groupName);
assignToUserGroupByUserNameGroupId(String userName, String groupId)
Parameters List :
- "userName" : [String value] It's the username of use;
- "groupId" : [String value] It's the id of group;
Invocation example
String userName = ... String groupId = ... HttpStatus status = gf.assignToUserGroupByUserNameGroupId(userName, groupId);
assignToUserGroupByUserNameGroupName(String userName, String groupName)
Parameters List :
- "userName" : [String value] It's the username of user;
- "groupName" : [String value] It's the name of group;
Invocation example
String userName = ... String groupName = ... HttpStatus status = gf.assignToUserGroupByUserNameGroupName(userName, groupName);
removeUserGroupByUserIdGroupId(String userId, String groupId)
Parameters List :
- "userId" : [String value] It's the id of user;
- "groupId" : [String value] It's the id of group;
Invocation example
String userId = ...; String groupId = ...; HttpStatus status = gf.removeUserGroupByUserIdGroupId(userId, groupId);
removeUserGroupByUserIdGroupName(String userId, String groupName)
Parameters List :
- "userId" : [String value] It's the id of user;
- "groupName" : [String value] It's the name of group;
Invocation example
String userId = ...; String groupName = ...; HttpStatus status = gf.removeUserGroupByUserIdGroupName(userId, groupName);
removeUserGroupByUserNameGroupId(String userName, String groupId)
Parameters List :
- "userName" : [String value] It's the name of user;
- "groupId" : [String value] It's the id of group;
Invocation example
String userName = ...; String groupId = ...; HttpStatus status = gf.removeUserGroupByUserNameGroupId(userName, groupId);
removeUserGroupByUserNameGroupName(String userName, String groupName)
Parameters List :
- "userName" : [String value] It's the name of user;
- "groupName" : [String value] It's the name of group;
Invocation example
String userName = ...; String groupName = ...; HttpStatus status = gf.removeUserGroupByUserNameGroupName(userName, groupName);
Instance section
createInstance(Instance instance)
Parameters List :
- "instance" : [Instance value] - It's the org.gcube.data.access.bean.Instance object you are creating.
Invocation example
Instance instance = new Instance(); instance.setBaseURL("https://geoserver.org/geoserver"); instance.setName("geoserver"); instance.setPassword("geoserver"); instance.setUsername("admin"); instance.setDescription("A geoserver test"); instance.setDateCreation(new Date()); HttpStatus status = gf.createInstance(instance);
getInstanceById(String instanceId)
Parameters List :
- "instanceId" : [String value] It's the id of Instance object;
Invocation example
String id = ...; GSInstance ins = gf.getInstanceById(id); String name = ins.getName();
getInstanceByName(String instanceName)
Parameters List :
- "instanceName" : [String value] It's the name of Instance object;
Invocation example
String name = ...; GSUser user = gf.getInstanceByName(name); String id = user.getId();
updateInstance(Instance instance)
Parameters List :
- "instance" : [Instance value] It's the Instance object;
Invocation example
Instance instance = new Instance(); ... instance.setDescription("My geoserver update"); HttpStatus status = gf.updateInstance(instance);
updateInstanceById(String id, String username, String password, String baseURL, String description)
Parameters List :
- "id" : [String value] It's the id of Instance object, not editable;
- "username" : [String value] It's the username of Instance object;
- "password" : [String value] It's the password of Instance object;
- "baseURL" : [String value] It's the baseURL of Instance object;
- "description" : [String value] It's the description of Instance object;
Invocation example
String id = ...; HttpStatus status = gf.updateInstanceById(id, "admin", "geoserver", "https://geoserver.org/geoserver", "geoserver");
updateInstanceByName(String instanceName, String username, String password, String baseURL, String description)
Parameters List :
- "instanceName" : [String value] It's the name of Instance object, not editable;
- "username" : [String value] It's the username of Instance object;
- "password" : [String value] It's the password of Instance object;
- "baseURL" : [String value] It's the baseURL of Instance object;
- "description" : [String value] It's the description of Instance object;
Invocation example
String id = ...; HttpStatus status = gf.updateInstanceById(id, "admin", "geoserver", "https://geoserver.org/geoserver", "geoserver");
deleteInstanceById(String instanceId)
Parameters List :
- "instanceId" : [String value] It's the id of Instance object;
Invocation example
String id = ...; HttpStatus status = gf.deleteInstanceById(id);
deleteInstanceByName(String instanceName, boolean removeAllRules)
Parameters List :
- "instanceName" : [String value] It's the name of Instance object;
- "removeAllRules" : [boolean value] It's a parameter to removes all rules together the Instance object;
Invocation example
String name = ...; HttpStatus status = gf.deleteInstanceByName(name, false);