Group Users

A GroupUser is a record about membership of a User within a Group.

Creating GroupUsers

GroupUsers can be created via the normal create action. When using the update action, if the GroupUser record does not exist for the given user/group IDs it will be created.

List Group Users

SDK Function

GroupUser.list()

Return Object

ListIterator<GroupUser>

Authorization Requirement

Available to all authenticated keys or sessions.

Function Arguments

ArgumentDescription
group_id
int64
Group ID. If provided, will return group_users of this group.
user_id
int64
User ID. If provided, will return group_users of this user.

Additional Arguments

Example Request

import com.files.ListIterator;
import com.files.exceptions.*;
import com.files.exceptions.ApiErrorException.*;
import com.files.models.GroupUser;

try {
  HashMap<String, Object> parameters = new HashMap<>();
  parameters.put("group_id", 1);
  
  ListIterator<GroupUser> groupUsers = GroupUser.list(parameters);
  for (GroupUser groupUser : groupUsers.listAutoPaging()) {
    // Operate on groupUser
  }
} catch (NotAuthenticatedException e) {
  System.out.println("Authentication Error Occurred (" + e.getClass().getName() + "): " + e.getMessage());
} catch (SdkException e) {
  System.out.println("Unknown Error Occurred (" + e.getClass().getName() + "): " + e.getMessage());
}

Create Group User

SDK Function

GroupUser.create()

Return Object

GroupUser

Authorization Requirement

Requires either a Site-Wide API key or User API key or session from a User with Site Admin permissions.

Function Arguments

ArgumentDescription
group_id
int64
Required
Group ID to add user to.
user_id
int64
Required
User ID to add to group.
admin
boolean
Is the user a group administrator?

Example Request

import com.files.exceptions.*;
import com.files.exceptions.ApiErrorException.*;
import com.files.models.GroupUser;

try {
  HashMap<String, Object> parameters = new HashMap<>();
  parameters.put("group_id", 1);
  parameters.put("user_id", 1);
  
  GroupUser groupUser = GroupUser.create(parameters);
  // Operate on groupUser
} catch (NotAuthenticatedException e) {
  System.out.println("Authentication Error Occurred (" + e.getClass().getName() + "): " + e.getMessage());
} catch (SdkException e) {
  System.out.println("Unknown Error Occurred (" + e.getClass().getName() + "): " + e.getMessage());
}

Update Group User

SDK Function

groupUser.update();

Return Object

GroupUser

Authorization Requirement

Requires either a Site-Wide API key or User API key or session from a User with Site Admin permissions.

Attribute Setters

SetterDescription
setGroupId
int64
Required
Group ID to add user to.
setUserId
int64
Required
User ID to add to group.
setAdmin
boolean
Is the user a group administrator?

Example Request

import com.files.exceptions.*;
import com.files.exceptions.ApiErrorException.*;
import com.files.models.GroupUser;

try {
  GroupUser groupUser = GroupUser.list()[0];
  HashMap<String, Object> parameters = new HashMap<>();
  parameters.put("group_id", 1);
  parameters.put("user_id", 1);
  parameters.put("admin", false);
  groupUser.update(parameters);
} catch (NotAuthenticatedException e) {
  System.out.println("Authentication Error Occurred (" + e.getClass().getName() + "): " + e.getMessage());
} catch (SdkException e) {
  System.out.println("Unknown Error Occurred (" + e.getClass().getName() + "): " + e.getMessage());
}

Delete Group User

SDK Function

groupUser.delete();

Return Object

No return value.

Authorization Requirement

Requires either a Site-Wide API key or User API key or session from a User with Site Admin permissions.

Attribute Setters

SetterDescription
setGroupId
int64
Required
Group ID from which to remove user.
setUserId
int64
Required
User ID to remove from group.

Example Request

import com.files.exceptions.*;
import com.files.exceptions.ApiErrorException.*;
import com.files.models.GroupUser;

try {
  GroupUser groupUser = GroupUser.list()[0];
  HashMap<String, Object> parameters = new HashMap<>();
  parameters.put("group_id", 1);
  parameters.put("user_id", 1);
  groupUser.delete(parameters);
} catch (NotAuthenticatedException e) {
  System.out.println("Authentication Error Occurred (" + e.getClass().getName() + "): " + e.getMessage());
} catch (SdkException e) {
  System.out.println("Unknown Error Occurred (" + e.getClass().getName() + "): " + e.getMessage());
}

The GroupUser Object

Some of the functions above return a GroupUser object. The attributes of this object are listed below.

AttributeDescription
group_name
string
Group name
group_id
int64
Group ID
user_id
int64
User ID
admin
boolean
Is this user an administrator of this group?
username
string
Username of the user