/// <summary>Snippet for CreateBatch</summary> public void CreateBatchRequestObject() { // Snippet: CreateBatch(CreateBatchRequest, CallSettings) // Create client BatchControllerClient batchControllerClient = BatchControllerClient.Create(); // Initialize request argument(s) CreateBatchRequest request = new CreateBatchRequest { ParentAsLocationName = LocationName.FromProjectLocation("[PROJECT]", "[LOCATION]"), Batch = new Batch(), BatchId = "", RequestId = "", }; // Make the request Operation <Batch, BatchOperationMetadata> response = batchControllerClient.CreateBatch(request); // Poll until the returned long-running operation is complete Operation <Batch, BatchOperationMetadata> completedResponse = response.PollUntilCompleted(); // Retrieve the operation result Batch 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 <Batch, BatchOperationMetadata> retrievedResponse = batchControllerClient.PollOnceCreateBatch(operationName); // Check if the retrieved long-running operation has completed if (retrievedResponse.IsCompleted) { // If it has completed, then access the result Batch retrievedResult = retrievedResponse.Result; } // End snippet }
/// <summary>Snippet for CreateBatch</summary> public void CreateBatch() { // Snippet: CreateBatch(string, Batch, string, CallSettings) // Create client BatchControllerClient batchControllerClient = BatchControllerClient.Create(); // Initialize request argument(s) string parent = "projects/[PROJECT]/locations/[LOCATION]"; Batch batch = new Batch(); string batchId = ""; // Make the request Operation <Batch, BatchOperationMetadata> response = batchControllerClient.CreateBatch(parent, batch, batchId); // Poll until the returned long-running operation is complete Operation <Batch, BatchOperationMetadata> completedResponse = response.PollUntilCompleted(); // Retrieve the operation result Batch 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 <Batch, BatchOperationMetadata> retrievedResponse = batchControllerClient.PollOnceCreateBatch(operationName); // Check if the retrieved long-running operation has completed if (retrievedResponse.IsCompleted) { // If it has completed, then access the result Batch retrievedResult = retrievedResponse.Result; } // End snippet }
/// <summary>Snippet for GetBatch</summary> public void GetBatchResourceNames() { // Snippet: GetBatch(BatchName, CallSettings) // Create client BatchControllerClient batchControllerClient = BatchControllerClient.Create(); // Initialize request argument(s) BatchName name = BatchName.FromProjectLocationBatch("[PROJECT]", "[LOCATION]", "[BATCH]"); // Make the request Batch response = batchControllerClient.GetBatch(name); // End snippet }
/// <summary>Snippet for GetBatch</summary> public void GetBatch() { // Snippet: GetBatch(string, CallSettings) // Create client BatchControllerClient batchControllerClient = BatchControllerClient.Create(); // Initialize request argument(s) string name = "projects/[PROJECT]/locations/[LOCATION]/batches/[BATCH]"; // Make the request Batch response = batchControllerClient.GetBatch(name); // End snippet }
/// <summary>Snippet for GetBatch</summary> public void GetBatchRequestObject() { // Snippet: GetBatch(GetBatchRequest, CallSettings) // Create client BatchControllerClient batchControllerClient = BatchControllerClient.Create(); // Initialize request argument(s) GetBatchRequest request = new GetBatchRequest { BatchName = BatchName.FromProjectLocationBatch("[PROJECT]", "[LOCATION]", "[BATCH]"), }; // Make the request Batch response = batchControllerClient.GetBatch(request); // End snippet }
/// <summary>Snippet for ListBatches</summary> public void ListBatchesRequestObject() { // Snippet: ListBatches(ListBatchesRequest, CallSettings) // Create client BatchControllerClient batchControllerClient = BatchControllerClient.Create(); // Initialize request argument(s) ListBatchesRequest request = new ListBatchesRequest { ParentAsLocationName = LocationName.FromProjectLocation("[PROJECT]", "[LOCATION]"), }; // Make the request PagedEnumerable <ListBatchesResponse, Batch> response = batchControllerClient.ListBatches(request); // Iterate over all response items, lazily performing RPCs as required foreach (Batch item in response) { // Do something with each item Console.WriteLine(item); } // Or iterate over pages (of server-defined size), performing one RPC per page foreach (ListBatchesResponse page in response.AsRawResponses()) { // Do something with each page of items Console.WriteLine("A page of results:"); foreach (Batch item in page) { // Do something with each item Console.WriteLine(item); } } // Or retrieve a single page of known size (unless it's the final page), performing as many RPCs as required int pageSize = 10; Page <Batch> singlePage = response.ReadPage(pageSize); // Do something with the page of items Console.WriteLine($"A page of {pageSize} results (unless it's the final page):"); foreach (Batch item in singlePage) { // Do something with each item Console.WriteLine(item); } // Store the pageToken, for when the next page is required. string nextPageToken = singlePage.NextPageToken; // End snippet }