public async Task <GrantListEntry[]> ListGrantsAsync(string keyId, CancellationToken cancellationToken = default(CancellationToken)) { ListGrantsResponse response = null; var results = new List <GrantListEntry>(); while ((response = await _client.ListGrantsAsync(new ListGrantsRequest() { Marker = response?.NextMarker, Limit = 1000, KeyId = keyId }, cancellationToken).EnsureSuccessAsync()) != null) { if (!response.Grants.IsNullOrEmpty()) { results.AddRange(response.Grants); } if (!response.Truncated) { break; } await Task.Delay(100); } return(results.ToArray()); }
/// <summary> /// Unmarshaller the response from the service to the response class. /// </summary> /// <param name="context"></param> /// <returns></returns> public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context) { ListGrantsResponse response = new ListGrantsResponse(); context.Read(); int targetDepth = context.CurrentDepth; while (context.ReadAtDepth(targetDepth)) { if (context.TestExpression("Grants", targetDepth)) { var unmarshaller = new ListUnmarshaller <GrantListEntry, GrantListEntryUnmarshaller>(GrantListEntryUnmarshaller.Instance); response.Grants = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("NextMarker", targetDepth)) { var unmarshaller = StringUnmarshaller.Instance; response.NextMarker = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("Truncated", targetDepth)) { var unmarshaller = BoolUnmarshaller.Instance; response.Truncated = unmarshaller.Unmarshall(context); continue; } } return(response); }
public static async Task Main() { // The identifier of the AWS KMS key to disable. You can use the // key Id or the Amazon Resource Name (ARN) of the AWS KMS key. var keyId = "1234abcd-12ab-34cd-56ef-1234567890ab"; var client = new AmazonKeyManagementServiceClient(); var request = new ListGrantsRequest { KeyId = keyId, }; var response = new ListGrantsResponse(); do { response = await client.ListGrantsAsync(request); response.Grants.ForEach(grant => { Console.WriteLine($"{grant.GrantId}"); }); request.Marker = response.NextMarker; }while (response.Truncated); }