internal DescribeDestinationsResponse DescribeDestinations(DescribeDestinationsRequest request) { var marshaller = new DescribeDestinationsRequestMarshaller(); var unmarshaller = DescribeDestinationsResponseUnmarshaller.Instance; return(Invoke <DescribeDestinationsRequest, DescribeDestinationsResponse>(request, marshaller, unmarshaller)); }
public async Task DescribeDestinationsTest_TwoResponses() { var request = new DescribeDestinationsRequest(); var firstResponse = new DescribeDestinationsResponse() { NextToken = "foo" }; var secondResponse = new DescribeDestinationsResponse() { NextToken = null }; var token = new CancellationToken(); _mockClient.SetupSequence(x => x.DescribeDestinationsAsync(It.IsAny <DescribeDestinationsRequest>(), It.IsAny <CancellationToken>())) .ReturnsAsync(firstResponse) .ReturnsAsync(secondResponse); var numResponses = 0; await foreach (var desination in _mockClient.Object.Paginators.DescribeDestinations(request).Responses.WithCancellation(token)) { numResponses += 1; } Assert.Equal(2, numResponses); }
public override void Invoke(AWSCredentials creds, RegionEndpoint region, int maxItems) { AmazonCloudWatchLogsConfig config = new AmazonCloudWatchLogsConfig(); config.RegionEndpoint = region; ConfigureClient(config); AmazonCloudWatchLogsClient client = new AmazonCloudWatchLogsClient(creds, config); DescribeDestinationsResponse resp = new DescribeDestinationsResponse(); do { DescribeDestinationsRequest req = new DescribeDestinationsRequest { NextToken = resp.NextToken , Limit = maxItems }; resp = client.DescribeDestinations(req); CheckError(resp.HttpStatusCode, "200"); foreach (var obj in resp.Destinations) { AddObject(obj); } }while (!string.IsNullOrEmpty(resp.NextToken)); }
/// <summary> /// Initiates the asynchronous execution of the DescribeDestinations operation. /// </summary> /// /// <param name="request">Container for the necessary parameters to execute the DescribeDestinations operation.</param> /// <param name="cancellationToken"> /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. /// </param> /// <returns>The task object representing the asynchronous operation.</returns> public Task <DescribeDestinationsResponse> DescribeDestinationsAsync(DescribeDestinationsRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken)) { var marshaller = new DescribeDestinationsRequestMarshaller(); var unmarshaller = DescribeDestinationsResponseUnmarshaller.Instance; return(InvokeAsync <DescribeDestinationsRequest, DescribeDestinationsResponse>(request, marshaller, unmarshaller, cancellationToken)); }
public async Task DescribeDestinationsTest__OnlyUsedOnce() { var request = new DescribeDestinationsRequest(); var response = new DescribeDestinationsResponse(); var token = new CancellationToken(); var paginator = _mockClient.Object.Paginators.DescribeDestinations(request); _mockClient.Setup(x => x.DescribeDestinationsAsync(It.IsAny <DescribeDestinationsRequest>(), It.IsAny <CancellationToken>())).ReturnsAsync(response); // Should work the first time await LoopOverDestinations(paginator, token); // Second time should throw an exception await Assert.ThrowsAsync <System.InvalidOperationException>(async() => await LoopOverDestinations(paginator, token)); }
public async Task DescribeDestinationsTest__CancellationToken() { var request = new DescribeDestinationsRequest(); var firstResponse = new DescribeDestinationsResponse() { NextToken = "foo" }; var secondResponse = new DescribeDestinationsResponse() { NextToken = null }; var paginator = _mockClient.Object.Paginators.DescribeDestinations(request); var tokenSource = new CancellationTokenSource(); var token = tokenSource.Token; tokenSource.Cancel(); _mockClient.SetupSequence(x => x.DescribeDestinationsAsync(It.IsAny <DescribeDestinationsRequest>(), It.IsAny <CancellationToken>())) .ReturnsAsync(firstResponse) .ReturnsAsync(secondResponse); await Assert.ThrowsAsync <OperationCanceledException>(async() => await LoopOverDestinations(paginator, token)); }