/// <summary>Snippet for TrainAgent</summary> public void TrainAgent_RequestObject() { // Snippet: TrainAgent(TrainAgentRequest,CallSettings) // Create client AgentsClient agentsClient = AgentsClient.Create(); // Initialize request argument(s) TrainAgentRequest request = new TrainAgentRequest { ParentAsProjectName = new ProjectName("[PROJECT]"), }; // Make the request Operation <Empty, Struct> response = agentsClient.TrainAgent(request); // Poll until the returned long-running operation is complete Operation <Empty, Struct> completedResponse = response.PollUntilCompleted(); // The long-running operation is now complete. // 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 <Empty, Struct> retrievedResponse = agentsClient.PollOnceTrainAgent(operationName); // Check if the retrieved long-running operation has completed if (retrievedResponse.IsCompleted) { // The long-running operation is now complete. } // End snippet }
/// <summary>Snippet for TrainAgentAsync</summary> public async Task TrainAgentRequestObjectAsync() { // Snippet: TrainAgentAsync(TrainAgentRequest, CallSettings) // Additional: TrainAgentAsync(TrainAgentRequest, CancellationToken) // Create client AgentsClient agentsClient = await AgentsClient.CreateAsync(); // Initialize request argument(s) TrainAgentRequest request = new TrainAgentRequest { ParentAsProjectName = ProjectName.FromProject("[PROJECT]"), }; // Make the request Operation <Empty, Struct> response = await agentsClient.TrainAgentAsync(request); // Poll until the returned long-running operation is complete Operation <Empty, Struct> completedResponse = await response.PollUntilCompletedAsync(); // Retrieve the operation result Empty 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 <Empty, Struct> retrievedResponse = await agentsClient.PollOnceTrainAgentAsync(operationName); // Check if the retrieved long-running operation has completed if (retrievedResponse.IsCompleted) { // If it has completed, then access the result Empty retrievedResult = retrievedResponse.Result; } // End snippet }