Example 2: Add users to a workspace |
This example adds a user to a Workspace. It requires three separate method calls. (Note the different permissions required for each step).
This returns a RoomsJson object that represents the room that was created.
Resource.Workspaces workspaces = apiSession.GetWorkspacesResource(); // Create the JSON object needed for the method call, and set its values. CreateRoomJson createRoomJson = new CreateRoomJson { Name = name, Description = description, Administrators = administrators }; // Call the method, and get a JSON object back RoomJson roomJson = workspaces.CreateRoomV30(createRoomJson);
Resource.Workspaces workspaces = apiSession.GetWorkspacesResource(); // Create a JSON object the represents the new group and set its values PermittedEntityFromUserJson permittedEntityFromUserJson = new PermittedEntityFromUserJson { Address = groupName, EntityType = EntityType.GROUP }; // Create a new permissions JSON with default values PermissionFromUserJson permissionFromUserJson = new PermissionFromUserJson(); // The JSON object needed for the resource method call AddEntityVdrJson addEntityVdrJson = new AddEntityVdrJson { PermittedEntity = permittedEntityFromUserJson, NewPermissions = permissionFromUserJson }; // Make the call to the Rooms resource and return "success" return workspaces.AddEntityV30(workspaceId, addEntityVdrJson);
Resource.Workspaces workspaces = apiSession.GetWorkspacesResource(); List<AddMemberToGroupJson> memberList = new List<AddMemberToGroupJson>(); // Loop through the List<String> userAddresses foreach (string currentAddress in userAddresses) { PermittedEntityFromUserJson currentEntity = new PermittedEntityFromUserJson { Address = currentAddress, EntityType = EntityType.USER }; //make a AddMemberToGroupJson for each user AddMemberToGroupJson currentMemberJson = new AddMemberToGroupJson { Entity = currentEntity }; memberList.Add(currentMemberJson); } // Set the group name to be a string and roomId is the integer identifying the room AddMembersToGroupWithGroupJson groupMemberJson = new AddMembersToGroupWithGroupJson { MembersList = memberList, RoomId = roomId, GroupName = groupName }; // Make the call to the Rooms resource and return "success" string result = workspaces.AddMembersToGroupV30(groupMemberJson);