public void ThrowOnAnyError_MultipleErrors() { var response = new AnnotateVideoResponse { AnnotationResults = { new VideoAnnotationResults { Error = new Rpc.Status { Message = "Boom" } }, new VideoAnnotationResults { ExplicitAnnotation = new ExplicitContentAnnotation() }, new VideoAnnotationResults { Error = new Rpc.Status { Message = "Bang" } } } }; var exception = Assert.Throws <AggregateException>(() => response.ThrowOnAnyError()); var nestedExceptions = exception.InnerExceptions.Cast <AnnotateVideoException>().ToList(); Assert.Equal(2, nestedExceptions.Count); Assert.Equal("Boom", nestedExceptions[0].Message); Assert.Equal("Bang", nestedExceptions[1].Message); Assert.Same(response.AnnotationResults[0], nestedExceptions[0].Response); // response.AnnotationResults[1] is skipped as it had no error. Assert.Same(response.AnnotationResults[2], nestedExceptions[1].Response); }
/// <summary>Snippet for AnnotateVideoAsync</summary> public async Task AnnotateVideoAsync() { // Snippet: AnnotateVideoAsync(string, IEnumerable<Feature>, CallSettings) // Additional: AnnotateVideoAsync(string, IEnumerable<Feature>, CancellationToken) // Create client VideoIntelligenceServiceClient videoIntelligenceServiceClient = await VideoIntelligenceServiceClient.CreateAsync(); // Initialize request argument(s) string inputUri = ""; IEnumerable <Feature> features = new Feature[] { Feature.Unspecified, }; // Make the request Operation <AnnotateVideoResponse, AnnotateVideoProgress> response = await videoIntelligenceServiceClient.AnnotateVideoAsync(inputUri, features); // Poll until the returned long-running operation is complete Operation <AnnotateVideoResponse, AnnotateVideoProgress> completedResponse = await response.PollUntilCompletedAsync(); // Retrieve the operation result AnnotateVideoResponse result = completedResponse.Result; // Or get the name of the operation string operationName = response.Name; // This name can be stored, then the long-running operation retrieved later by name Operation <AnnotateVideoResponse, AnnotateVideoProgress> retrievedResponse = await videoIntelligenceServiceClient.PollOnceAnnotateVideoAsync(operationName); // Check if the retrieved long-running operation has completed if (retrievedResponse.IsCompleted) { // If it has completed, then access the result AnnotateVideoResponse retrievedResult = retrievedResponse.Result; } // End snippet }
/// <summary>Snippet for AnnotateVideo</summary> public void AnnotateVideo() { // Snippet: AnnotateVideo(string,IEnumerable<Feature>,CallSettings) // Create client VideoIntelligenceServiceClient videoIntelligenceServiceClient = VideoIntelligenceServiceClient.Create(); // Initialize request argument(s) string inputUri = "gs://demomaker/cat.mp4"; IEnumerable <Feature> features = new[] { Feature.LabelDetection, }; // Make the request Operation <AnnotateVideoResponse, AnnotateVideoProgress> response = videoIntelligenceServiceClient.AnnotateVideo(inputUri, features); // Poll until the returned long-running operation is complete Operation <AnnotateVideoResponse, AnnotateVideoProgress> completedResponse = response.PollUntilCompleted(); // Retrieve the operation result AnnotateVideoResponse result = completedResponse.Result; // Or get the name of the operation string operationName = response.Name; // This name can be stored, then the long-running operation retrieved later by name Operation <AnnotateVideoResponse, AnnotateVideoProgress> retrievedResponse = videoIntelligenceServiceClient.PollOnceAnnotateVideo(operationName); // Check if the retrieved long-running operation has completed if (retrievedResponse.IsCompleted) { // If it has completed, then access the result AnnotateVideoResponse retrievedResult = retrievedResponse.Result; } // End snippet }
/// <summary>Snippet for AnnotateVideo</summary> public void AnnotateVideo_RequestObject() { // Snippet: AnnotateVideo(AnnotateVideoRequest,CallSettings) // Create client VideoIntelligenceServiceClient videoIntelligenceServiceClient = VideoIntelligenceServiceClient.Create(); // Initialize request argument(s) AnnotateVideoRequest request = new AnnotateVideoRequest(); // Make the request Operation <AnnotateVideoResponse, AnnotateVideoProgress> response = videoIntelligenceServiceClient.AnnotateVideo(request); // Poll until the returned long-running operation is complete Operation <AnnotateVideoResponse, AnnotateVideoProgress> completedResponse = response.PollUntilCompleted(); // Retrieve the operation result AnnotateVideoResponse result = completedResponse.Result; // Or get the name of the operation string operationName = response.Name; // This name can be stored, then the long-running operation retrieved later by name Operation <AnnotateVideoResponse, AnnotateVideoProgress> retrievedResponse = videoIntelligenceServiceClient.PollOnceAnnotateVideo(operationName); // Check if the retrieved long-running operation has completed if (retrievedResponse.IsCompleted) { // If it has completed, then access the result AnnotateVideoResponse retrievedResult = retrievedResponse.Result; } // End snippet }
public void AnnotateVideo() { // Snippet: AnnotateVideo(string,IEnumerable<Feature>,VideoContext,string,string,CallSettings) // Create client VideoIntelligenceServiceClient videoIntelligenceServiceClient = VideoIntelligenceServiceClient.Create(); // Initialize request argument(s) string inputUri = ""; IEnumerable <Feature> features = new List <Feature>(); VideoContext videoContext = new VideoContext(); string outputUri = ""; string locationId = ""; // Make the request Operation <AnnotateVideoResponse> response = videoIntelligenceServiceClient.AnnotateVideo(inputUri, features, videoContext, outputUri, locationId); // Poll until the returned long-running operation is complete Operation <AnnotateVideoResponse> completedResponse = response.PollUntilCompleted(); // Retrieve the operation result AnnotateVideoResponse result = completedResponse.Result; // Or get the name of the operation string operationName = response.Name; // This name can be stored, then the long-running operation retrieved later by name Operation <AnnotateVideoResponse> retrievedResponse = videoIntelligenceServiceClient.PollOnceAnnotateVideo(operationName); // Check if the retrieved long-running operation has completed if (retrievedResponse.IsCompleted) { // If it has completed, then access the result AnnotateVideoResponse retrievedResult = retrievedResponse.Result; } // End snippet }
public void ThrowOnAnyError_NoErrors() { var response = new AnnotateVideoResponse { AnnotationResults = { new VideoAnnotationResults { ExplicitAnnotation = new ExplicitContentAnnotation() }, new VideoAnnotationResults { FaceAnnotations = { new FaceAnnotation()} } } }; Assert.Same(response, response.ThrowOnAnyError()); }
/// <summary>Snippet for AnnotateVideoAsync</summary> public async Task AnnotateVideoRequestObjectAsync() { // Snippet: AnnotateVideoAsync(AnnotateVideoRequest, CallSettings) // Additional: AnnotateVideoAsync(AnnotateVideoRequest, CancellationToken) // Create client VideoIntelligenceServiceClient videoIntelligenceServiceClient = await VideoIntelligenceServiceClient.CreateAsync(); // Initialize request argument(s) AnnotateVideoRequest request = new AnnotateVideoRequest { InputUri = "", Features = { Feature.Unspecified, }, VideoContext = new VideoContext(), OutputUri = "", LocationId = "", InputContent = ByteString.Empty, }; // Make the request Operation <AnnotateVideoResponse, AnnotateVideoProgress> response = await videoIntelligenceServiceClient.AnnotateVideoAsync(request); // Poll until the returned long-running operation is complete Operation <AnnotateVideoResponse, AnnotateVideoProgress> completedResponse = await response.PollUntilCompletedAsync(); // Retrieve the operation result AnnotateVideoResponse result = completedResponse.Result; // Or get the name of the operation string operationName = response.Name; // This name can be stored, then the long-running operation retrieved later by name Operation <AnnotateVideoResponse, AnnotateVideoProgress> retrievedResponse = await videoIntelligenceServiceClient.PollOnceAnnotateVideoAsync(operationName); // Check if the retrieved long-running operation has completed if (retrievedResponse.IsCompleted) { // If it has completed, then access the result AnnotateVideoResponse retrievedResult = retrievedResponse.Result; } // End snippet }
/// <summary>Snippet for AnnotateVideoAsync</summary> public async Task AnnotateVideoAsync_RequestObject() { // Snippet: AnnotateVideoAsync(AnnotateVideoRequest,CallSettings) // Create client VideoIntelligenceServiceClient videoIntelligenceServiceClient = await VideoIntelligenceServiceClient.CreateAsync(); // Initialize request argument(s) AnnotateVideoRequest request = new AnnotateVideoRequest { InputUri = "gs://demomaker/cat.mp4", Features = { Feature.LabelDetection, }, }; // Make the request Operation <AnnotateVideoResponse, AnnotateVideoProgress> response = await videoIntelligenceServiceClient.AnnotateVideoAsync(request); // Poll until the returned long-running operation is complete Operation <AnnotateVideoResponse, AnnotateVideoProgress> completedResponse = await response.PollUntilCompletedAsync(); // Retrieve the operation result AnnotateVideoResponse result = completedResponse.Result; // Or get the name of the operation string operationName = response.Name; // This name can be stored, then the long-running operation retrieved later by name Operation <AnnotateVideoResponse, AnnotateVideoProgress> retrievedResponse = await videoIntelligenceServiceClient.PollOnceAnnotateVideoAsync(operationName); // Check if the retrieved long-running operation has completed if (retrievedResponse.IsCompleted) { // If it has completed, then access the result AnnotateVideoResponse retrievedResult = retrievedResponse.Result; } // End snippet }
public void ThrowOnAnyError_OneError() { var response = new AnnotateVideoResponse { AnnotationResults = { new VideoAnnotationResults { FaceAnnotations = { new FaceAnnotation()} }, new VideoAnnotationResults { Error = new Rpc.Status { Message = "Bang" } } } }; var exception = Assert.Throws <AggregateException>(() => response.ThrowOnAnyError()); var nestedException = (AnnotateVideoException)exception.InnerExceptions[0]; Assert.Equal("Bang", nestedException.Message); Assert.Same(response.AnnotationResults[1], nestedException.Response); }
public async Task AnnotateVideoAsync() { // Snippet: AnnotateVideoAsync(string,IEnumerable<Feature>,ByteString,VideoContext,string,string,CallSettings) // Additional: AnnotateVideoAsync(string,IEnumerable<Feature>,ByteString,VideoContext,string,string,CancellationToken) // Create client VideoIntelligenceServiceClient videoIntelligenceServiceClient = await VideoIntelligenceServiceClient.CreateAsync(); // Initialize request argument(s) string inputUri = ""; IEnumerable <Feature> features = new List <Feature>(); ByteString inputContent = ByteString.CopyFromUtf8(""); VideoContext videoContext = new VideoContext(); string outputUri = ""; string locationId = ""; // Make the request Operation <AnnotateVideoResponse, AnnotateVideoProgress> response = await videoIntelligenceServiceClient.AnnotateVideoAsync(inputUri, features, inputContent, videoContext, outputUri, locationId); // Poll until the returned long-running operation is complete Operation <AnnotateVideoResponse, AnnotateVideoProgress> completedResponse = await response.PollUntilCompletedAsync(); // Retrieve the operation result AnnotateVideoResponse result = completedResponse.Result; // Or get the name of the operation string operationName = response.Name; // This name can be stored, then the long-running operation retrieved later by name Operation <AnnotateVideoResponse, AnnotateVideoProgress> retrievedResponse = await videoIntelligenceServiceClient.PollOnceAnnotateVideoAsync(operationName); // Check if the retrieved long-running operation has completed if (retrievedResponse.IsCompleted) { // If it has completed, then access the result AnnotateVideoResponse retrievedResult = retrievedResponse.Result; } // End snippet }