public static ListGroupsResponse Unmarshall(UnmarshallerContext _ctx) { ListGroupsResponse listGroupsResponse = new ListGroupsResponse(); listGroupsResponse.HttpResponse = _ctx.HttpResponse; listGroupsResponse.RequestId = _ctx.StringValue("ListGroups.RequestId"); listGroupsResponse.Code = _ctx.IntegerValue("ListGroups.Code"); listGroupsResponse.Message = _ctx.StringValue("ListGroups.Message"); listGroupsResponse.Success = _ctx.BooleanValue("ListGroups.Success"); ListGroupsResponse.ListGroups_Data data = new ListGroupsResponse.ListGroups_Data(); List <ListGroupsResponse.ListGroups_Data.ListGroups_AppGroup> data_appGroups = new List <ListGroupsResponse.ListGroups_Data.ListGroups_AppGroup>(); for (int i = 0; i < _ctx.Length("ListGroups.Data.AppGroups.Length"); i++) { ListGroupsResponse.ListGroups_Data.ListGroups_AppGroup appGroup = new ListGroupsResponse.ListGroups_Data.ListGroups_AppGroup(); appGroup.AppName = _ctx.StringValue("ListGroups.Data.AppGroups[" + i + "].AppName"); appGroup.GroupId = _ctx.StringValue("ListGroups.Data.AppGroups[" + i + "].GroupId"); appGroup.AppKey = _ctx.StringValue("ListGroups.Data.AppGroups[" + i + "].AppKey"); appGroup.Description = _ctx.StringValue("ListGroups.Data.AppGroups[" + i + "].Description"); data_appGroups.Add(appGroup); } data.AppGroups = data_appGroups; listGroupsResponse.Data = data; return(listGroupsResponse); }
/// <summary> /// Unmarshaller the response from the service to the response class. /// </summary> /// <param name="context"></param> /// <returns></returns> public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context) { ListGroupsResponse response = new ListGroupsResponse(); context.Read(); int targetDepth = context.CurrentDepth; while (context.ReadAtDepth(targetDepth)) { if (context.TestExpression("GroupIdentifiers", targetDepth)) { var unmarshaller = new ListUnmarshaller <GroupIdentifier, GroupIdentifierUnmarshaller>(GroupIdentifierUnmarshaller.Instance); response.GroupIdentifiers = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("Groups", targetDepth)) { var unmarshaller = new ListUnmarshaller <Group, GroupUnmarshaller>(GroupUnmarshaller.Instance); response.Groups = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("NextToken", targetDepth)) { var unmarshaller = StringUnmarshaller.Instance; response.NextToken = unmarshaller.Unmarshall(context); continue; } } return(response); }
public override void Invoke(AWSCredentials creds, RegionEndpoint region, int maxItems) { AmazonIdentityManagementServiceConfig config = new AmazonIdentityManagementServiceConfig(); config.RegionEndpoint = region; ConfigureClient(config); AmazonIdentityManagementServiceClient client = new AmazonIdentityManagementServiceClient(creds, config); ListGroupsResponse resp = new ListGroupsResponse(); do { ListGroupsRequest req = new ListGroupsRequest { Marker = resp.Marker , MaxItems = maxItems }; resp = client.ListGroups(req); CheckError(resp.HttpStatusCode, "200"); foreach (var obj in resp.Groups) { AddObject(obj); } }while (!string.IsNullOrEmpty(resp.Marker)); }
public override AmazonWebServiceResponse Unmarshall(XmlUnmarshallerContext context) { ListGroupsResponse response = new ListGroupsResponse(); context.Read(); int targetDepth = context.CurrentDepth; while (context.ReadAtDepth(targetDepth)) { if (context.IsStartElement) { if (context.TestExpression("ListGroupsResult", 2)) { UnmarshallResult(context, response); continue; } if (context.TestExpression("ResponseMetadata", 2)) { response.ResponseMetadata = ResponseMetadataUnmarshaller.Instance.Unmarshall(context); } } } return(response); }
public static ListGroupsResponse Unmarshall(UnmarshallerContext context) { ListGroupsResponse listGroupsResponse = new ListGroupsResponse(); listGroupsResponse.HttpResponse = context.HttpResponse; listGroupsResponse.RequestId = context.StringValue("ListGroups.RequestId"); listGroupsResponse.IsTruncated = context.BooleanValue("ListGroups.IsTruncated"); listGroupsResponse.Marker = context.StringValue("ListGroups.Marker"); List <ListGroupsResponse.ListGroups_Group> listGroupsResponse_groups = new List <ListGroupsResponse.ListGroups_Group>(); for (int i = 0; i < context.Length("ListGroups.Groups.Length"); i++) { ListGroupsResponse.ListGroups_Group group = new ListGroupsResponse.ListGroups_Group(); group.GroupName = context.StringValue("ListGroups.Groups[" + i + "].GroupName"); group.Comments = context.StringValue("ListGroups.Groups[" + i + "].Comments"); group.CreateDate = context.StringValue("ListGroups.Groups[" + i + "].CreateDate"); group.UpdateDate = context.StringValue("ListGroups.Groups[" + i + "].UpdateDate"); listGroupsResponse_groups.Add(group); } listGroupsResponse.Groups = listGroupsResponse_groups; return(listGroupsResponse); }
public override void Invoke(AWSCredentials creds, RegionEndpoint region, int maxItems) { AmazonResourceGroupsConfig config = new AmazonResourceGroupsConfig(); config.RegionEndpoint = region; ConfigureClient(config); AmazonResourceGroupsClient client = new AmazonResourceGroupsClient(creds, config); ListGroupsResponse resp = new ListGroupsResponse(); do { ListGroupsRequest req = new ListGroupsRequest { NextToken = resp.NextToken , MaxResults = maxItems }; resp = client.ListGroups(req); CheckError(resp.HttpStatusCode, "200"); foreach (var obj in resp.GroupIdentifiers) { AddObject(obj); } }while (!string.IsNullOrEmpty(resp.NextToken)); }
public ListGroupsResponse GetListOfGroupsInGroupStage(int tournamentId) { var connectionString = _settings.TournamentDB; using (var dataStore = new DataStore(new SqlConnection(connectionString))) { ListGroupsResponse response = new ListGroupsResponse(); response.GroupsInTournament = dataStore.GetListOfGroupsInTournament(tournamentId, RoundTypes.GROUP); dataStore.Commit(); return(response); } }
public void ListGroupsResponse() { var response1 = new ListGroupsResponse { Groups = new[] { new ListGroupsResponseGroup { GroupId = Guid.NewGuid().ToString(), ProtocolType = Guid.NewGuid().ToString(), } } }; Stream binary1 = new MemoryStream(); response1.Serialize(binary1); binary1.Seek(0L, SeekOrigin.Begin); var response2 = new ListGroupsResponse(); response2.Deserialize(binary1); var compareLogic = new CompareLogic(); var result = compareLogic.Compare(response1, response2); Assert.True(result.AreEqual); Stream binary2 = new MemoryStream(); response2.Serialize(binary2); Assert.Equal(binary1.Length, binary2.Length); using (var stream1 = new MemoryStream()) using (var stream2 = new MemoryStream()) { binary1.Seek(0L, SeekOrigin.Begin); binary1.CopyTo(stream1); binary2.Seek(0L, SeekOrigin.Begin); binary2.CopyTo(stream2); Assert.Equal(stream1.Length, stream2.Length); stream1.Seek(0L, SeekOrigin.Begin); var bytes1 = stream1.ToArray(); stream2.Seek(0L, SeekOrigin.Begin); var bytes2 = stream2.ToArray(); Assert.Equal(bytes1.Length, bytes2.Length); for (int i = 0; i < bytes1.Length; i++) { Assert.Equal(bytes1[i], bytes2[i]); } } }
private static void UnmarshallResult(XmlUnmarshallerContext context, ListGroupsResponse response) { int originalDepth = context.CurrentDepth; int targetDepth = originalDepth + 1; if (context.IsStartOfDocument) { targetDepth += 2; } while (context.Read()) { if (context.IsStartElement || context.IsAttribute) { if (context.TestExpression("Groups/member", targetDepth)) { response.Groups.Add(GroupUnmarshaller.GetInstance().Unmarshall(context)); continue; } if (context.TestExpression("IsTruncated", targetDepth)) { response.IsTruncated = BoolUnmarshaller.GetInstance().Unmarshall(context); continue; } if (context.TestExpression("Marker", targetDepth)) { response.Marker = StringUnmarshaller.GetInstance().Unmarshall(context); continue; } } else if (context.IsEndElement && context.CurrentDepth < originalDepth) { return; } } return; }
public void ListGroupsResponse( [Values( ErrorCode.NONE, ErrorCode.OFFSET_METADATA_TOO_LARGE )] ErrorCode errorCode, [Values("test", "a groupId")] string groupId, [Range(2, 3)] int count, [Values("consumer")] string protocolType) { var groups = new ListGroupsResponse.Group[count]; for (var g = 0; g < count; g++) { groups[g] = new ListGroupsResponse.Group(groupId + g, protocolType); } var response = new ListGroupsResponse(errorCode, groups); response.AssertCanEncodeDecodeResponse(0); }
public void ListGroupsResponse( [Values( ErrorResponseCode.None, ErrorResponseCode.OffsetMetadataTooLarge )] ErrorResponseCode errorCode, [Values("test", "a groupId")] string groupId, [Range(2, 3)] int count, [Values("consumer")] string protocolType) { var groups = new ListGroupsResponse.Group[count]; for (var g = 0; g < count; g++) { groups[g] = new ListGroupsResponse.Group(groupId + g, protocolType); } var response = new ListGroupsResponse(errorCode, groups); response.AssertCanEncodeDecodeResponse(0); }
static bool ListGroups(string url, Credentials c) { Console.WriteLine("Listing groups..."); ArticulateOnline ao = new ArticulateOnline { Url = url }; ListGroupsRequest request = new ListGroupsRequest { Credentials = c }; ListGroupsResponse response = ao.ListGroups(request); if (response.Success) { foreach (GroupSummary gs in response.Groups) { Console.WriteLine("{0} {1} {2}", gs.GroupID, gs.Name, gs.Description); } } return(response.Success); }
private static void UnmarshallResult(XmlUnmarshallerContext context, ListGroupsResponse response) { int originalDepth = context.CurrentDepth; int targetDepth = originalDepth + 1; if (context.IsStartOfDocument) { targetDepth += 2; } while (context.ReadAtDepth(originalDepth)) { if (context.IsStartElement || context.IsAttribute) { if (context.TestExpression("Groups/member", targetDepth)) { var unmarshaller = GroupUnmarshaller.Instance; var item = unmarshaller.Unmarshall(context); response.Groups.Add(item); continue; } if (context.TestExpression("IsTruncated", targetDepth)) { var unmarshaller = BoolUnmarshaller.Instance; response.IsTruncated = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("Marker", targetDepth)) { var unmarshaller = StringUnmarshaller.Instance; response.Marker = unmarshaller.Unmarshall(context); continue; } } } return; }
public static void DeleteUsersAndGroupsInTestNameSpace(string testPrefix) { AmazonIdentityManagementServiceClient client = UtilityMethods.CreateClient <AmazonIdentityManagementServiceClient>(); var prefix = MakePath(testPrefix); ListGroupsResponse lgRes = client.ListGroupsAsync(new ListGroupsRequest() { PathPrefix = prefix }).Result; foreach (Group g in lgRes.Groups) { GetGroupResponse ggRes = client.GetGroupAsync(new GetGroupRequest() { GroupName = g.GroupName }).Result; foreach (User u in ggRes.Users) { client.RemoveUserFromGroupAsync(new RemoveUserFromGroupRequest() { GroupName = g.GroupName, UserName = u.UserName }).Wait(); } client.DeleteGroupAsync(new DeleteGroupRequest() { GroupName = g.GroupName }).Wait(); } ListUsersResponse luRes = client.ListUsersAsync(new ListUsersRequest() { PathPrefix = prefix }).Result; foreach (User u in luRes.Users) { DeleteTestUsers(client, u.UserName); } }
public override AmazonWebServiceResponse Unmarshall(XmlUnmarshallerContext context) { ListGroupsResponse response = new ListGroupsResponse(); while (context.Read()) { if (context.IsStartElement) { if (context.TestExpression("ListGroupsResult", 2)) { response.ListGroupsResult = ListGroupsResultUnmarshaller.GetInstance().Unmarshall(context); continue; } if (context.TestExpression("ResponseMetadata", 2)) { response.ResponseMetadata = ResponseMetadataUnmarshaller.GetInstance().Unmarshall(context); } } } return(response); }
public static ListGroupsResponse Unmarshall(UnmarshallerContext _ctx) { ListGroupsResponse listGroupsResponse = new ListGroupsResponse(); listGroupsResponse.HttpResponse = _ctx.HttpResponse; listGroupsResponse.RequestId = _ctx.StringValue("ListGroups.RequestId"); listGroupsResponse.ErrorCode = _ctx.StringValue("ListGroups.ErrorCode"); listGroupsResponse.Success = _ctx.BooleanValue("ListGroups.Success"); listGroupsResponse.ErrorMessage = _ctx.StringValue("ListGroups.ErrorMessage"); listGroupsResponse.Total = _ctx.LongValue("ListGroups.Total"); List <ListGroupsResponse.ListGroups_ResultItem> listGroupsResponse_result = new List <ListGroupsResponse.ListGroups_ResultItem>(); for (int i = 0; i < _ctx.Length("ListGroups.Result.Length"); i++) { ListGroupsResponse.ListGroups_ResultItem resultItem = new ListGroupsResponse.ListGroups_ResultItem(); resultItem.Id = _ctx.LongValue("ListGroups.Result[" + i + "].Id"); resultItem.CreatedAt = _ctx.StringValue("ListGroups.Result[" + i + "].CreatedAt"); resultItem.UpdatedAt = _ctx.StringValue("ListGroups.Result[" + i + "].UpdatedAt"); resultItem.AccessLevel = _ctx.IntegerValue("ListGroups.Result[" + i + "].AccessLevel"); resultItem.Description = _ctx.StringValue("ListGroups.Result[" + i + "].Description"); resultItem.Name = _ctx.StringValue("ListGroups.Result[" + i + "].Name"); resultItem.NameWithNamespace = _ctx.StringValue("ListGroups.Result[" + i + "].NameWithNamespace"); resultItem.OwnerId = _ctx.LongValue("ListGroups.Result[" + i + "].OwnerId"); resultItem.ParentId = _ctx.LongValue("ListGroups.Result[" + i + "].ParentId"); resultItem.Path = _ctx.StringValue("ListGroups.Result[" + i + "].Path"); resultItem.PathWithNamespace = _ctx.StringValue("ListGroups.Result[" + i + "].PathWithNamespace"); resultItem.Type = _ctx.StringValue("ListGroups.Result[" + i + "].Type"); resultItem.VisibilityLevel = _ctx.StringValue("ListGroups.Result[" + i + "].VisibilityLevel"); resultItem.WebUrl = _ctx.StringValue("ListGroups.Result[" + i + "].WebUrl"); listGroupsResponse_result.Add(resultItem); } listGroupsResponse.Result = listGroupsResponse_result; return(listGroupsResponse); }
public static void DeleteUsersAndGroupsInTestNameSpace(AmazonIdentityManagementServiceClient client) { ListGroupsResponse lgRes = client.ListGroupsAsync(new ListGroupsRequest() { PathPrefix = TEST_PATH }).Result; foreach (Group g in lgRes.Groups) { GetGroupResponse ggRes = client.GetGroupAsync(new GetGroupRequest() { GroupName = g.GroupName }).Result; foreach (User u in ggRes.Users) { client.RemoveUserFromGroupAsync(new RemoveUserFromGroupRequest() { GroupName = g.GroupName, UserName = u.UserName }).Wait(); } client.DeleteGroupAsync(new DeleteGroupRequest() { GroupName = g.GroupName }).Wait(); } ListUsersResponse luRes = client.ListUsersAsync(new ListUsersRequest() { PathPrefix = TEST_PATH }).Result; foreach (User u in luRes.Users) { DeleteTestUsers(client, u.UserName); } }
private static bool TryEncodeResponse(IKafkaWriter writer, IRequestContext context, ListGroupsResponse response) { if (response == null) { return(false); } writer.Write(response.error_code) .Write(response.groups.Count); foreach (var group in response.groups) { writer.Write(group.group_id) .Write(group.protocol_type); } return(true); }
public async Task <ListGroupsResponse> List(DataTableParameters dataTableParameters) { if (dataTableParameters == null) { //Response.StatusCode = (int)HttpStatusCode.BadRequest; return(new ListGroupsResponse() { success = false, message = "No query provided" }); } using (var db = new ZapContext()) { var search = dataTableParameters.Search; // We need to know the user making the call (if any) so we know if they are a member of the group or not User user = await GetCurrentUser(db).ConfigureAwait(true); int userid = user != null ? user.Id : 0; // Build query var groupsQ = db.Groups .Select(g => new { numPosts = g.Posts.Count, numMembers = g.Members.Count, IsMember = g.Members.Select(m => m.Id).Contains(userid), IsModerator = g.Moderators.Select(m => m.Id).Contains(userid), IsAdmin = g.Administrators.Select(m => m.Id).Contains(userid), g.GroupId, g.GroupName, g.Tags, g.TotalEarned, g.TotalEarnedToDistribute, g.CreationDate, Icon = g.GroupImage == null ? g.Icon : null, // Only if GroupImage doesn't exist g.Tier, IconId = g.GroupImage == null ? 0 : g.GroupImage.ImageId }).AsNoTracking(); if (search != null && search.Value != null) { groupsQ = groupsQ.Where(g => g.GroupName.Contains(search.Value) || g.Tags.Contains(search.Value)); } groupsQ = groupsQ.OrderByDescending(g => g.TotalEarned + g.TotalEarnedToDistribute); var groups = await groupsQ .Skip(dataTableParameters.Start) .Take(dataTableParameters.Length) .ToListAsync().ConfigureAwait(false); var values = groups.Select(g => new GroupInfo() { Id = g.GroupId, CreatedddMMMYYYY = g.CreationDate == null ? "2 Aug 2018" : g.CreationDate.Value.ToString("dd MMM yyyy", CultureInfo.InvariantCulture), Name = g.GroupName, NumMembers = g.numMembers, NumPosts = g.numPosts, Tags = g.Tags != null ? g.Tags.Split(',').ToList() : new List <string>(), Icon = g.Icon != null ? "fa-" + g.Icon : null, // "fa-bolt", // NOTE: this is legacy, and will eventually be replaced. All new groups will have image icons. Level = g.Tier, Progress = GetGroupProgress(g.TotalEarned, g.TotalEarnedToDistribute, g.Tier), IsMember = g.IsMember, IsLoggedIn = user != null, IsMod = g.IsModerator, IsAdmin = g.IsAdmin, }).ToList(); var ret = new ListGroupsResponse() { success = true, draw = dataTableParameters.Draw, recordsTotal = await groupsQ.CountAsync().ConfigureAwait(false), recordsFiltered = await groupsQ.CountAsync().ConfigureAwait(false), data = values }; return(ret); } }
public void TestListGroupWithPaths() { string groupname1 = "group1" + DateTime.Now.Ticks, groupname2 = "group2" + DateTime.Now.Ticks, groupname3 = "group3" + DateTime.Now.Ticks, groupname4 = "group4" + DateTime.Now.Ticks; string pathA = IAMUtil.MakePath("A"), pathB = IAMUtil.MakePath("B"); try { Client.CreateGroup(new CreateGroupRequest() { GroupName = groupname1, Path = pathA }); Client.CreateGroup(new CreateGroupRequest() { GroupName = groupname2, Path = pathA }); Client.CreateGroup(new CreateGroupRequest() { GroupName = groupname3, Path = pathB }); Client.CreateGroup(new CreateGroupRequest() { GroupName = groupname4, Path = pathB }); ListGroupsResponse response = Client.ListGroups(new ListGroupsRequest() { PathPrefix = pathA }); Assert.AreEqual(2, response.Groups.Count()); int matches = 0; foreach (Group g in response.Groups) { if (g.GroupName.Equals(groupname1)) { matches |= 1; } if (g.GroupName.Equals(groupname2)) { matches |= 2; } if (g.GroupName.Equals(groupname3)) { Assert.Fail(); } if (g.GroupName.Equals(groupname4)) { Assert.Fail(); } } response = Client.ListGroups(new ListGroupsRequest() { PathPrefix = pathB }); Assert.AreEqual(2, response.Groups.Count()); foreach (Group g in response.Groups) { if (g.GroupName.Equals(groupname1)) { Assert.Fail(); } if (g.GroupName.Equals(groupname2)) { Assert.Fail(); } if (g.GroupName.Equals(groupname3)) { matches |= 4; } if (g.GroupName.Equals(groupname4)) { matches |= 8; } } Assert.AreEqual(15, matches); } finally { Client.DeleteGroup(new DeleteGroupRequest() { GroupName = groupname1 }); Client.DeleteGroup(new DeleteGroupRequest() { GroupName = groupname2 }); Client.DeleteGroup(new DeleteGroupRequest() { GroupName = groupname3 }); Client.DeleteGroup(new DeleteGroupRequest() { GroupName = groupname4 }); } }
public void TestListGroupsPaging() { string groupname1 = "group1" + DateTime.Now.Ticks, groupname2 = "group2" + DateTime.Now.Ticks, groupname3 = "group3" + DateTime.Now.Ticks, groupname4 = "group4" + DateTime.Now.Ticks; try { Client.CreateGroup(new CreateGroupRequest() { GroupName = groupname1, Path = IAMUtil.TEST_PATH }); Client.CreateGroup(new CreateGroupRequest() { GroupName = groupname2, Path = IAMUtil.TEST_PATH }); Client.CreateGroup(new CreateGroupRequest() { GroupName = groupname3, Path = IAMUtil.TEST_PATH }); Client.CreateGroup(new CreateGroupRequest() { GroupName = groupname4, Path = IAMUtil.TEST_PATH }); ListGroupsResponse response = Client.ListGroups(new ListGroupsRequest()); Assert.IsTrue(response.Groups.Count >= 4); response = Client.ListGroups(new ListGroupsRequest() { MaxItems = 2, PathPrefix = IAMUtil.TEST_PATH }); Assert.AreEqual(2, response.Groups.Count()); Assert.AreEqual(true, response.IsTruncated); string marker = response.Marker; int matches = 0; foreach (Group g in response.Groups) { if (g.GroupName.Equals(groupname1)) { matches |= 1; } if (g.GroupName.Equals(groupname2)) { matches |= 2; } if (g.GroupName.Equals(groupname3)) { matches |= 4; } if (g.GroupName.Equals(groupname4)) { matches |= 8; } } response = Client.ListGroups(new ListGroupsRequest() { Marker = marker, PathPrefix = IAMUtil.TEST_PATH }); Assert.AreEqual(2, response.Groups.Count()); Assert.AreEqual(false, response.IsTruncated); foreach (Group g in response.Groups) { if (g.GroupName.Equals(groupname1)) { matches |= 1; } if (g.GroupName.Equals(groupname2)) { matches |= 2; } if (g.GroupName.Equals(groupname3)) { matches |= 4; } if (g.GroupName.Equals(groupname4)) { matches |= 8; } } Assert.AreEqual(15, matches); } finally { Client.DeleteGroup(new DeleteGroupRequest() { GroupName = groupname1 }); Client.DeleteGroup(new DeleteGroupRequest() { GroupName = groupname2 }); Client.DeleteGroup(new DeleteGroupRequest() { GroupName = groupname3 }); Client.DeleteGroup(new DeleteGroupRequest() { GroupName = groupname4 }); } }