public void TestListUsersMaxResults() { string username1 = IAMUtil.CreateTestUser(Client); string username2 = IAMUtil.CreateTestUser(Client); string username3 = IAMUtil.CreateTestUser(Client); string username4 = IAMUtil.CreateTestUser(Client); try { ListUsersResponse response = Client.ListUsers(new ListUsersRequest() { MaxItems = 2, PathPrefix = IAMUtil.TEST_PATH }); Assert.AreEqual(2, response.Users.Count()); Assert.AreEqual(true, response.IsTruncated); int matches = 0; foreach (User u in response.Users) { if (u.UserName.Equals(username1)) { matches |= 1; } if (u.UserName.Equals(username2)) { matches |= 2; } if (u.UserName.Equals(username4)) { matches |= 3; } if (u.UserName.Equals(username3)) { matches |= 4; } } string marker = response.Marker; response = Client.ListUsers(new ListUsersRequest() { PathPrefix = IAMUtil.TEST_PATH, Marker = marker }); Assert.AreEqual(2, response.Users.Count()); Assert.AreEqual(false, response.IsTruncated); foreach (User u in response.Users) { if (u.UserName.Equals(username1)) { matches |= 1; } if (u.UserName.Equals(username2)) { matches |= 2; } if (u.UserName.Equals(username4)) { matches |= 3; } if (u.UserName.Equals(username3)) { matches |= 4; } } Assert.AreEqual(7, matches); } finally { IAMUtil.DeleteTestUsers(Client, username1, username2, username3, username4); } }
public static ListUsersResponse Unmarshall(UnmarshallerContext _ctx) { ListUsersResponse listUsersResponse = new ListUsersResponse(); listUsersResponse.HttpResponse = _ctx.HttpResponse; listUsersResponse.Code = _ctx.StringValue("ListUsers.Code"); listUsersResponse.HttpStatusCode = _ctx.IntegerValue("ListUsers.HttpStatusCode"); listUsersResponse.Message = _ctx.StringValue("ListUsers.Message"); listUsersResponse.RequestId = _ctx.StringValue("ListUsers.RequestId"); List <string> listUsersResponse_params = new List <string>(); for (int i = 0; i < _ctx.Length("ListUsers.Params.Length"); i++) { listUsersResponse_params.Add(_ctx.StringValue("ListUsers.Params[" + i + "]")); } listUsersResponse._Params = listUsersResponse_params; ListUsersResponse.ListUsers_Data data = new ListUsersResponse.ListUsers_Data(); data.PageNumber = _ctx.IntegerValue("ListUsers.Data.PageNumber"); data.PageSize = _ctx.IntegerValue("ListUsers.Data.PageSize"); data.TotalCount = _ctx.IntegerValue("ListUsers.Data.TotalCount"); List <ListUsersResponse.ListUsers_Data.ListUsers_UserDetail> data_list = new List <ListUsersResponse.ListUsers_Data.ListUsers_UserDetail>(); for (int i = 0; i < _ctx.Length("ListUsers.Data.List.Length"); i++) { ListUsersResponse.ListUsers_Data.ListUsers_UserDetail userDetail = new ListUsersResponse.ListUsers_Data.ListUsers_UserDetail(); userDetail.DisplayName = _ctx.StringValue("ListUsers.Data.List[" + i + "].DisplayName"); userDetail.Email = _ctx.StringValue("ListUsers.Data.List[" + i + "].Email"); userDetail.LoginName = _ctx.StringValue("ListUsers.Data.List[" + i + "].LoginName"); userDetail.Mobile = _ctx.StringValue("ListUsers.Data.List[" + i + "].Mobile"); userDetail.RoleId = _ctx.StringValue("ListUsers.Data.List[" + i + "].RoleId"); userDetail.RoleName = _ctx.StringValue("ListUsers.Data.List[" + i + "].RoleName"); userDetail.UserId = _ctx.StringValue("ListUsers.Data.List[" + i + "].UserId"); userDetail.WorkMode = _ctx.StringValue("ListUsers.Data.List[" + i + "].WorkMode"); List <ListUsersResponse.ListUsers_Data.ListUsers_UserDetail.ListUsers_PhoneNumber> userDetail_personalOutboundNumberList = new List <ListUsersResponse.ListUsers_Data.ListUsers_UserDetail.ListUsers_PhoneNumber>(); for (int j = 0; j < _ctx.Length("ListUsers.Data.List[" + i + "].PersonalOutboundNumberList.Length"); j++) { ListUsersResponse.ListUsers_Data.ListUsers_UserDetail.ListUsers_PhoneNumber phoneNumber = new ListUsersResponse.ListUsers_Data.ListUsers_UserDetail.ListUsers_PhoneNumber(); phoneNumber.Active = _ctx.BooleanValue("ListUsers.Data.List[" + i + "].PersonalOutboundNumberList[" + j + "].Active"); phoneNumber.City = _ctx.StringValue("ListUsers.Data.List[" + i + "].PersonalOutboundNumberList[" + j + "].City"); phoneNumber.Number = _ctx.StringValue("ListUsers.Data.List[" + i + "].PersonalOutboundNumberList[" + j + "].Number"); phoneNumber.Province = _ctx.StringValue("ListUsers.Data.List[" + i + "].PersonalOutboundNumberList[" + j + "].Province"); phoneNumber.Usage = _ctx.StringValue("ListUsers.Data.List[" + i + "].PersonalOutboundNumberList[" + j + "].Usage"); userDetail_personalOutboundNumberList.Add(phoneNumber); } userDetail.PersonalOutboundNumberList = userDetail_personalOutboundNumberList; List <ListUsersResponse.ListUsers_Data.ListUsers_UserDetail.ListUsers_UserSkillLevel> userDetail_skillLevelList = new List <ListUsersResponse.ListUsers_Data.ListUsers_UserDetail.ListUsers_UserSkillLevel>(); for (int j = 0; j < _ctx.Length("ListUsers.Data.List[" + i + "].SkillLevelList.Length"); j++) { ListUsersResponse.ListUsers_Data.ListUsers_UserDetail.ListUsers_UserSkillLevel userSkillLevel = new ListUsersResponse.ListUsers_Data.ListUsers_UserDetail.ListUsers_UserSkillLevel(); userSkillLevel.SkillGroupId = _ctx.StringValue("ListUsers.Data.List[" + i + "].SkillLevelList[" + j + "].SkillGroupId"); userSkillLevel.SkillGroupName = _ctx.StringValue("ListUsers.Data.List[" + i + "].SkillLevelList[" + j + "].SkillGroupName"); userSkillLevel.SkillLevel = _ctx.IntegerValue("ListUsers.Data.List[" + i + "].SkillLevelList[" + j + "].SkillLevel"); userDetail_skillLevelList.Add(userSkillLevel); } userDetail.SkillLevelList = userDetail_skillLevelList; data_list.Add(userDetail); } data.List = data_list; listUsersResponse.Data = data; return(listUsersResponse); }
public void TestListUsersByPath() { string username1 = "sdk-testuser1-" + DateTime.Now.Ticks; string username2 = "sdk-testuser2-" + DateTime.Now.Ticks; string username3 = "sdk-testuser3-" + DateTime.Now.Ticks; string username4 = "sdk-testuser4-" + DateTime.Now.Ticks; string pathA = IAMUtil.MakePath("A"); string pathB = IAMUtil.MakePath("B"); try { Client.CreateUser(new CreateUserRequest() { UserName = username1, Path = pathA }); Client.CreateUser(new CreateUserRequest() { UserName = username2, Path = pathA }); Client.CreateUser(new CreateUserRequest() { UserName = username3, Path = pathB }); Client.CreateUser(new CreateUserRequest() { UserName = username4, Path = pathA }); ListUsersResponse response = Client.ListUsers(new ListUsersRequest() { PathPrefix = pathA }); Assert.AreEqual(3, response.Users.Count()); int matches = 0; foreach (User u in response.Users) { if (u.UserName.Equals(username1)) { matches |= 1; } if (u.UserName.Equals(username2)) { matches |= 2; } if (u.UserName.Equals(username4)) { matches |= 4; } if (u.UserName.Equals(username3)) { Assert.Fail(); } } Assert.AreEqual(7, matches); response = Client.ListUsers(new ListUsersRequest() { PathPrefix = pathB }); Assert.AreEqual(1, response.Users.Count()); matches = 0; foreach (User u in response.Users) { if (u.UserName.Equals(username1)) { Assert.Fail(); } if (u.UserName.Equals(username2)) { Assert.Fail(); } if (u.UserName.Equals(username4)) { Assert.Fail(); } if (u.UserName.Equals(username3)) { matches = 1; } } Assert.AreEqual(1, matches); response = Client.ListUsers(new ListUsersRequest() { PathPrefix = IAMUtil.TEST_PATH }); Assert.AreEqual(4, response.Users.Count()); } finally { IAMUtil.DeleteTestUsers(Client, username1, username2, username3, username4); } }
public static ListUsersResponse Unmarshall(UnmarshallerContext _ctx) { ListUsersResponse listUsersResponse = new ListUsersResponse(); listUsersResponse.HttpResponse = _ctx.HttpResponse; listUsersResponse.RequestId = _ctx.StringValue("ListUsers.RequestId"); listUsersResponse.Success = _ctx.BooleanValue("ListUsers.Success"); listUsersResponse.Code = _ctx.StringValue("ListUsers.Code"); listUsersResponse.Message = _ctx.StringValue("ListUsers.Message"); listUsersResponse.HttpStatusCode = _ctx.IntegerValue("ListUsers.HttpStatusCode"); ListUsersResponse.ListUsers_Users users = new ListUsersResponse.ListUsers_Users(); users.TotalCount = _ctx.IntegerValue("ListUsers.Users.TotalCount"); users.PageNumber = _ctx.IntegerValue("ListUsers.Users.PageNumber"); users.PageSize = _ctx.IntegerValue("ListUsers.Users.PageSize"); List <ListUsersResponse.ListUsers_Users.ListUsers_User> users_list = new List <ListUsersResponse.ListUsers_Users.ListUsers_User>(); for (int i = 0; i < _ctx.Length("ListUsers.Users.List.Length"); i++) { ListUsersResponse.ListUsers_Users.ListUsers_User user = new ListUsersResponse.ListUsers_Users.ListUsers_User(); user.UserId = _ctx.StringValue("ListUsers.Users.List[" + i + "].UserId"); user.RamId = _ctx.StringValue("ListUsers.Users.List[" + i + "].RamId"); user.InstanceId = _ctx.StringValue("ListUsers.Users.List[" + i + "].InstanceId"); user.Primary = _ctx.BooleanValue("ListUsers.Users.List[" + i + "].Primary"); user.PrivateOutboundNumberId = _ctx.StringValue("ListUsers.Users.List[" + i + "].PrivateOutboundNumberId"); ListUsersResponse.ListUsers_Users.ListUsers_User.ListUsers_Detail detail = new ListUsersResponse.ListUsers_Users.ListUsers_User.ListUsers_Detail(); detail.LoginName = _ctx.StringValue("ListUsers.Users.List[" + i + "].Detail.LoginName"); detail.DisplayName = _ctx.StringValue("ListUsers.Users.List[" + i + "].Detail.DisplayName"); detail.Phone = _ctx.StringValue("ListUsers.Users.List[" + i + "].Detail.Phone"); detail.Email = _ctx.StringValue("ListUsers.Users.List[" + i + "].Detail.Email"); detail.Department = _ctx.StringValue("ListUsers.Users.List[" + i + "].Detail.Department"); user.Detail = detail; List <ListUsersResponse.ListUsers_Users.ListUsers_User.ListUsers_Role> user_roles = new List <ListUsersResponse.ListUsers_Users.ListUsers_User.ListUsers_Role>(); for (int j = 0; j < _ctx.Length("ListUsers.Users.List[" + i + "].Roles.Length"); j++) { ListUsersResponse.ListUsers_Users.ListUsers_User.ListUsers_Role role = new ListUsersResponse.ListUsers_Users.ListUsers_User.ListUsers_Role(); role.RoleId = _ctx.StringValue("ListUsers.Users.List[" + i + "].Roles[" + j + "].RoleId"); role.InstanceId = _ctx.StringValue("ListUsers.Users.List[" + i + "].Roles[" + j + "].InstanceId"); role.RoleName = _ctx.StringValue("ListUsers.Users.List[" + i + "].Roles[" + j + "].RoleName"); role.RoleDescription = _ctx.StringValue("ListUsers.Users.List[" + i + "].Roles[" + j + "].RoleDescription"); user_roles.Add(role); } user.Roles = user_roles; List <ListUsersResponse.ListUsers_Users.ListUsers_User.ListUsers_SkillLevel> user_skillLevels = new List <ListUsersResponse.ListUsers_Users.ListUsers_User.ListUsers_SkillLevel>(); for (int j = 0; j < _ctx.Length("ListUsers.Users.List[" + i + "].SkillLevels.Length"); j++) { ListUsersResponse.ListUsers_Users.ListUsers_User.ListUsers_SkillLevel skillLevel = new ListUsersResponse.ListUsers_Users.ListUsers_User.ListUsers_SkillLevel(); skillLevel.SkillLevelId = _ctx.StringValue("ListUsers.Users.List[" + i + "].SkillLevels[" + j + "].SkillLevelId"); skillLevel.Level = _ctx.IntegerValue("ListUsers.Users.List[" + i + "].SkillLevels[" + j + "].Level"); ListUsersResponse.ListUsers_Users.ListUsers_User.ListUsers_SkillLevel.ListUsers_Skill skill = new ListUsersResponse.ListUsers_Users.ListUsers_User.ListUsers_SkillLevel.ListUsers_Skill(); skill.SkillGroupId = _ctx.StringValue("ListUsers.Users.List[" + i + "].SkillLevels[" + j + "].Skill.SkillGroupId"); skill.InstanceId = _ctx.StringValue("ListUsers.Users.List[" + i + "].SkillLevels[" + j + "].Skill.InstanceId"); skill.SkillGroupName = _ctx.StringValue("ListUsers.Users.List[" + i + "].SkillLevels[" + j + "].Skill.SkillGroupName"); skill.SkillGroupDescription = _ctx.StringValue("ListUsers.Users.List[" + i + "].SkillLevels[" + j + "].Skill.SkillGroupDescription"); skillLevel.Skill = skill; user_skillLevels.Add(skillLevel); } user.SkillLevels = user_skillLevels; users_list.Add(user); } users.List = users_list; listUsersResponse.Users = users; return(listUsersResponse); }